//public void ResetAtThis() //{ // StartCoroutine(ResetTiles()); //} public override void OnUnitSelected(UnitProxy obj) { if (!UnitMoving) { if (currentUnit == null) { toAttack = null; UnHighlightTiles(); currentUnit = obj; //The maximum range in which a player has actions allTiles = BoardProxy.instance.GetAllVisitableNodes(obj, obj.GetMoveSpeed() > obj.GetAttackRange() ? obj.GetMoveSpeed() : obj.GetAttackRange(), true); //The attackable tiles attackableTiles = BoardProxy.instance.GetAllVisitableNodes(obj, obj.GetAttackRange(), true); //The visitable tiles visitableTiles = BoardProxy.instance.GetAllVisitableNodes(obj, obj.GetMoveSpeed()); HighlightTiles(obj); PanelControllerNew.SwitchChar(obj); if (currentUnit.GetData().GetTeam() == TurnController.instance.currentTeam) { currentUnit.SaySomething(Skill.Actions.None); } CheckFocusAI(); } else { if (toAttack != obj && currentUnit != obj) { if (TurnController.instance.currentTeam == BoardProxy.PLAYER_TEAM && currentUnit.GetData().GetTeam() == BoardProxy.ENEMY_TEAM) { currentUnit = null; OnUnitSelected(obj); } else { toAttack = obj; UnitProxy player = currentUnit.GetData().GetTeam() == BoardProxy.PLAYER_TEAM ? currentUnit : toAttack; UnitProxy enemy = currentUnit.GetData().GetTeam() == BoardProxy.ENEMY_TEAM ? currentUnit : toAttack; PanelControllerNew.SwitchChar(player, enemy); } } else { if (obj.GetData().GetTeam() != currentUnit.GetData().GetTeam() && attackableTiles.Contains(BoardProxy.instance.GetTileAtPosition(obj.GetPosition())) && currentUnit.GetData().GetTurnActions().CanAttack() && !obj.GetData().IsDead()) { CheckFocusAI(); toAttack = null; bool charDead = obj.IsAttacked(currentUnit); if (currentUnit != null) { currentUnit.AcceptAction(Skill.Actions.DidAttack, obj); } if (charDead) { UnitProxy victor = BoardProxy.instance.GetTileAtPosition(currentUnit.GetPosition()).GetUnit(); victor.SaySomething(Skill.Actions.DidKill); obj.DelayedKill(obj, victor); StartCoroutine(ResetTiles()); } else { currentUnit.SaySomething(Skill.Actions.DidAttack); obj.SaySomething(Skill.Actions.DidDefend); } OnDisable(); PanelControllerNew.SwitchChar(currentUnit); } } } } }