| | |
| | | private Dictionary<int, BattleObject> redCampDict = new Dictionary<int, BattleObject>(); |
| | | private Dictionary<int, BattleObject> blueCampDict = new Dictionary<int, BattleObject>(); |
| | | |
| | | protected Dictionary<int, BattleObject> allBattleObjDict = new Dictionary<int, BattleObject>(); |
| | | public Dictionary<int, BattleObject> allBattleObjDict = new Dictionary<int, BattleObject>(); |
| | | |
| | | protected BattleField battleField; |
| | | |
| | | public void Init(BattleField _battleField, TeamBase _redTeam, TeamBase _blueTeam) |
| | | { |
| | | Release(); |
| | | battleField = _battleField; |
| | | ReloadTeam(_redTeam, BattleCamp.Red); |
| | | ReloadTeam(_blueTeam, BattleCamp.Blue); |
| | | ReloadTeam(_blueTeam, BattleCamp.Blue, false); |
| | | } |
| | | |
| | | public void ReloadTeam(TeamBase teamBase, BattleCamp _camp) |
| | | public void ReloadTeam(TeamBase teamBase, BattleCamp _camp, bool active = true) |
| | | { |
| | | var posNodeList = _camp == BattleCamp.Red ? battleField.battleRootNode.redTeamNodeList : battleField.battleRootNode.blueTeamNodeList; |
| | | var campDict = _camp == BattleCamp.Red ? redCampDict : blueCampDict; |
| | | CreateTeam(posNodeList, campDict, teamBase, _camp); |
| | | CreateTeam(posNodeList, campDict, teamBase, _camp, active); |
| | | } |
| | | |
| | | protected void CreateTeam(List<GameObject> posNodeList, Dictionary<int, BattleObject> campDict, TeamBase teamBase, BattleCamp _Camp) |
| | | protected void CreateTeam(List<GameObject> posNodeList, Dictionary<int, BattleObject> campDict, TeamBase teamBase, BattleCamp _Camp, bool active) |
| | | { |
| | | DestroyTeam(campDict); |
| | | if (teamBase == null) |
| | |
| | | if (teamHero != null) |
| | | { |
| | | BattleObject battleObj = BattleObjectFactory.CreateBattleObject(battleField, posNodeList, teamHero, _Camp); |
| | | battleObj.heroGo.SetActive(active); |
| | | allBattleObjDict.Add(battleObj.ObjID, battleObj); |
| | | campDict.Add(teamHero.positionNum, battleObj); |
| | | battleObj.SetSpeedRatio(battleField.speedRatio); |
| | | } |
| | | } |
| | | } |
| | |
| | | { |
| | | if (allBattleObjDict.TryGetValue((int)objID, out BattleObject battleObj)) |
| | | { |
| | | if (battleObj.Camp == BattleCamp.Red) |
| | | { |
| | | redCampDict.Remove(battleObj.teamHero.positionNum); |
| | | } |
| | | else |
| | | { |
| | | blueCampDict.Remove(battleObj.teamHero.positionNum); |
| | | } |
| | | allBattleObjDict.Remove((int)objID); |
| | | redCampDict.Remove((int)objID); |
| | | blueCampDict.Remove((int)objID); |
| | | BattleObjectFactory.DestroyBattleObject((int)objID, battleObj); |
| | | } |
| | | } |
| | |
| | | foreach (var item in campDict) |
| | | { |
| | | BattleObject battleObj = item.Value; |
| | | var positionNum = item.Key; |
| | | if (battleObj != null) |
| | | { |
| | | allBattleObjDict.Remove(battleObj.ObjID); |
| | | BattleObjectFactory.DestroyBattleObject(item.Key, battleObj); |
| | | BattleObjectFactory.DestroyBattleObject(battleObj.ObjID, battleObj); |
| | | } |
| | | } |
| | | campDict.Clear(); |
| | |
| | | } |
| | | } |
| | | |
| | | public void SetSpeedRatio(float ratio) |
| | | { |
| | | foreach (var obj in allBattleObjDict.Values) |
| | | { |
| | | obj.SetSpeedRatio(ratio); |
| | | } |
| | | } |
| | | |
| | | #if UNITY_EDITOR_STOP_USING |
| | | public void ReviveAll() |
| | | { |