public IEnumerator RunCombat() { while (attackQueue.Length() > 0) { CombatResponse attack = attackQueue.Next(); Debug.DrawLine(attack.Self.transform.position, player.transform.position); switch (attack.AttackType) { case "Slash": AddIndicator(attack.Self, Color.red); break; case "Parry": AddIndicator(attack.Self, Color.yellow); break; case "Feint": AddIndicator(attack.Self, Color.blue); break; } yield return(new WaitForSeconds(1)); FillAnimQueue(attack); } if (!Animating) { StartCoroutine(ExecuteCombat()); } }
public void FillAnimQueue(CombatResponse attack) { if (defenseQueue.Length() > 0) { CombatResponse defense = defenseQueue.Next(); bool victor = attack.Battle(defense); if (victor == WIN) { animQueue.Add(new AnimationBean(attack.AttackType, defense.AttackType, WIN, attack.Self.GetComponent <EnemyLogic>())); } else { animQueue.Add(new AnimationBean(attack.AttackType, defense.AttackType, LOSE, attack.Self.GetComponent <EnemyLogic>())); } } else { animQueue.Add(new AnimationBean(attack.AttackType, "nothing", LOSE, attack.Self.GetComponent <EnemyLogic>())); } }