public IEnumerator DoFight() { // if (this.fighter.isEnemy()) { // this.getEnemyAction(); // } Messenger.Broadcast <FightResult>(Messages.OnFightStart, new FightResult(this.fighter, queuedAction.GetAction())); QueuedAction attackerAction = queuedAction; string attackerName = this.fighter.Name; if (attackerAction == null) { Debug.LogError("Cannot find queued action: " + attackerName); yield break; } ActionBase action = attackerAction.GetAction(); string attackName = action.name; List <FightingEntity> targets = action.GetTargets(this.fighter, attackerAction.GetTargetIds()); if (targets.Count == 1) { Debug.Log(this.fighter.Name + " Execute Action: " + attackName + targets[0].targetId); } List <FightingEntity> focusedFighters = new List <FightingEntity>(); focusedFighters.Add(fighter); List <FightingEntity> focusedTargets = action.GetFocusedTargets(this.fighter, attackerAction.GetTargetIds()); foreach (FightingEntity target in focusedTargets) { focusedFighters.Add(target); } List <FightingEntity> unfocusedFighters = this._field.GetAllFightingEntities().Filter(fighter => !focusedFighters.Contains(fighter)); foreach (FightingEntity focusedFighter in focusedFighters) { this._ui.focusOverlay.AddToFocusLayer(focusedFighter.gameObject, true); } foreach (FightingEntity unfocusedFighter in unfocusedFighters) { this._ui.focusOverlay.AddToFocusLayer(unfocusedFighter.gameObject, false); } yield return(GameManager.Instance.time.GetController().StartCoroutine(action.ExecuteAction(fighter, targets, this))); }
protected override IEnumerator Run() { this._ui.battleOrderUI.SetTurnOrder(fighters); yield return(GameManager.Instance.time.GetController().StartCoroutine(this._ui.battleStartUI.PlayAnimation())); this._ui.targetIconsUI.ClearTargetArrows(); for (int i = 0; i < fighters.Count; i++) { if (fighters[i] == null) { // This can happen if the fighter dies mid-battle this._ui.battleOrderUI.PopFighter(); yield return(GameManager.Instance.time.GetController().WaitForSeconds(1.0f)); continue; } // Apply Status Ailment fighters[i].ailmentController.TickAilmentEffects(this._phase); if (queuedActions[i] == null) { Debug.LogError("ERROR: Queued action was null!"); } QueuedAction attackerAction = queuedActions[i]; // This can happen if target dies mid-battle if (attackerAction._action.TargetsDead(fighters[i], attackerAction.GetTargetIds())) { Debug.Log("Skip attacker's turn: " + fighters[i].Name); this._ui.battleOrderUI.PopFighter(); yield return(GameManager.Instance.time.GetController().WaitForSeconds(1.0f)); continue; } BattleFight fight = new BattleFight(_field, fighters[i], attackerAction, this._ui); this.currentFight = fight; yield return(GameManager.Instance.time.GetController().StartCoroutine(this._ui.focusOverlay.EnableOverlay())); yield return(GameManager.Instance.time.GetController().StartCoroutine(fight.DoFight())); yield return(GameManager.Instance.time.GetController().StartCoroutine(this._ui.focusOverlay.DisableOverlay())); this._ui.battleOrderUI.PopFighter(); } }