IEnumerator RunAfterTurn(BattleUnit source) { if (state == BattleState.BattleOver) { yield break; } yield return(new WaitUntil(() => state == BattleState.RunningTurn)); // damage check for Status source.teras.OnAfterTurn(); yield return(ShowStatusChanges(source.teras)); yield return(source.Hud.UpdateHP()); if (source.teras.Health <= 0) { yield return(dialogBox.TypeDialog($"{source.teras._baseTeras.Name} fainted!")); source.FaintAnim(); yield return(new WaitForSeconds(2f)); CheckBattleOver(source); } }
IEnumerator SwitchTeras(TerasCalcs nextTeras) { if (playerUnit.teras.Health > 0) { yield return(dialogBox.TypeDialog($"Return {playerUnit.teras._baseTeras.Name}")); playerUnit.FaintAnim(); yield return(new WaitForSeconds(2f)); } // setup player playerUnit.Setup(nextTeras); // set skills of player dialogBox.SetSkillNames(nextTeras.Skills); yield return(StartCoroutine(dialogBox.TypeDialog($"Fight {nextTeras._baseTeras.Name}!"))); state = BattleState.RunningTurn; }
IEnumerator RunSkill(BattleUnit source, BattleUnit target, SkillCalc skill) { bool canMove = source.teras.OnBeforeMove(); if (!canMove) { yield return(ShowStatusChanges(source.teras)); yield return(source.Hud.UpdateHP()); yield break; } skill.UseLeft--; yield return(dialogBox.TypeDialog($"{source.teras._baseTeras.Name} used {skill.baseSkill.Name}!")); if (CheckAccHit(skill, source.teras, target.teras) == true) { source.AttackAnim(); yield return(new WaitForSeconds(1f)); target.GetHitAnim(); // Check for status condition if (skill.baseSkill.Category == SkillCategory.Status) { yield return(RunSkillEffects(skill.baseSkill.Effects, source.teras, target.teras, skill.baseSkill.SkillTarget)); } // if its not a damaging move deal damage if (skill.baseSkill.Category.CompareTo(SkillCategory.Status) <= 0) { var damageDetails = target.teras.TakeDamage(skill, source.teras); yield return(target.Hud.UpdateHP()); yield return(ShowDamageDetails(damageDetails)); } if (skill.baseSkill.SecondaryEffects != null && skill.baseSkill.SecondaryEffects.Count > 0 && target.teras.Health > 0) { foreach (var secondary in skill.baseSkill.SecondaryEffects) { var random = UnityEngine.Random.Range(1, 101); if (random <= secondary.Chance) { yield return(RunSkillEffects(secondary, source.teras, target.teras, secondary.Target)); } } } // if the opposing teras fainted make battle over event true to end battle if (target.teras.Health <= 0) { yield return(dialogBox.TypeDialog($"{target.teras._baseTeras.Name} fainted!")); target.FaintAnim(); yield return(new WaitForSeconds(2f)); CheckBattleOver(target); } } else { yield return(dialogBox.TypeDialog($"{source.teras._baseTeras.Name} missed its attack!")); } }