// in battle system class IEnumerator RunSkill(BattleUnit source, BattleUnit target, SkillCalc skill) { bool canMove = source.teras.OnBeforeMove(); if(!canMove) { yield return ShowStatusChanges(source.teras); yield break; } skill.UseLeft--; yield return dialogBox.TypeDialog($"{source.teras._baseTeras.Name} used {skill.baseSkill.Name}"); source.AttackAnim(); yield return new WaitForSeconds(1f); target.GetHitAnim(); // Check for status condition if (skill.baseSkill.Category == SkillCategory.Status) { StartCoroutine(RunSkillEffects(skill, source.teras, target.teras)); } // 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 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); } // damage check for poison source.teras.OnAfterTurn(); yield return ShowStatusChanges(source.teras); yield return source.Hud.UpdateHP(); if (source.teras.Health <= 0) { yield return dialogBox.TypeDialog($"{target.teras._baseTeras.Name} fainted"); target.FaintAnim(); yield return new WaitForSeconds(2f); CheckBattleOver(target); } } // in battle system sends and types mesage in TypeDialog coroutine IEnumerator ShowStatusChanges(TerasCalcs teras) { while(teras.StatusChanges.Count > 0) { var message = teras.StatusChanges.Dequeue(); yield return dialogBox.TypeDialog(message); } } // Coroutine to type the dialog slowly in dialogBox class public IEnumerator TypeDialog(string dialog) { dialogText.text = ""; // for loop to write dialog string slowly foreach(var letter in dialog.ToCharArray()) { dialogText.text += letter; yield return new WaitForSeconds(1f / lettersPerSecond); } yield return new WaitForSeconds(1f); }