public override IEnumerator Turn() { InitTurn(); Debug.Log("(Player) " + UnitName + " turn"); CombatUIManager.RefreshUI(); CombatUIManager.SetActiveAllButtons(true, AttributesSheet.GetAttribute(AttributeType.MovementPoint)); CombatUIManager.UpdateSkillsButtons(); while (ActionState != ActionState.EndTurn && IsAlive) { switch (ActionState) { case ActionState.LookingForMovement: if (AttributesSheet.GetAttribute(AttributeType.MovementPoint) != 0) { if (ProjectionManager.SelectionState != SelectionState.AvailableMovement) { ProjectionManager.SelectAvailableMovement(CurrentCell, AttributesSheet.GetAttribute(AttributeType.MovementPoint), SelectionState.AvailableMovement); } } else { Debug.Log("Can't move, no movementPoint available"); ActionState = ActionState.Waiting; } break; case ActionState.Waiting: if (ProjectionManager.SelectionState != SelectionState.CurrentCell && ProjectionManager.SelectionState != SelectionState.OtherAvailableMovement) { ProjectionManager.SelectCurrentCell(CurrentCell, Team); } break; default: break; } yield return(new WaitForFixedUpdate()); } AttributesSheet.RemoveCosts(); ProjectionManager.ClearProjections(); SelfProjection.gameObject.SetActive(true); IsPlaying = false; yield return(null); }
public override IEnumerator Turn() { InitTurn(); Debug.Log("(Enemy) " + UnitName + " turn"); CombatUIManager.RefreshUI(); CombatUIManager.UpdateSkillsButtons(); CombatUIManager.SetActiveAllButtons(false, 0); ProjectionManager.SelectCurrentCell(CurrentCell, Team); // GET MOST EFFICIENT TURN CombatUIManager.ToggleThinkingAI(true); yield return(GetTurn()); CombatUIManager.ToggleThinkingAI(false); // PLAY TURN if (AITurn != null && AITurn.Actions != null) { foreach (AIAction action in AITurn.Actions) { if (action is AIActionMovement) { AIActionMovement movementAction = action as AIActionMovement; Cell cellDestination = MapInfos.Map[(int)movementAction.Destination.x, (int)movementAction.Destination.y]; Debug.Log("Move from [" + CurrentCell.X + ", " + CurrentCell.Z + "] to [" + cellDestination.X + ", " + cellDestination.Z + "]"); // ProjectionManager.SelectAvailableMovement(); // yield return new WaitForSeconds(0.5f); Move(cellDestination, true, Utils.GetDistanceBetweenCells(CurrentCell, cellDestination)); while (ActionState == ActionState.Moving) { yield return(new WaitForEndOfFrame()); } } else if (action is AIActionUseSkill) { AIActionUseSkill useSkillAction = action as AIActionUseSkill; Debug.Log("Use " + useSkillAction.SpellId + " at [" + useSkillAction.SpellTarget.X + ", " + useSkillAction.SpellTarget.Z + "]"); SkillDisplayRange(useSkillAction.SpellId); yield return(new WaitForSeconds(0.5f)); SkillDisplayAoe(useSkillAction.SpellTarget); yield return(new WaitForSeconds(0.5f)); SkillUse(useSkillAction.SpellTarget); while (ActionState == ActionState.PlayingAnimation) { yield return(new WaitForEndOfFrame()); } } } } // END TURN AttributesSheet.RemoveCosts(); ProjectionManager.ClearProjections(); SelfProjection.gameObject.SetActive(true); IsPlaying = false; yield return(null); }