private IEnumerator DoDamage() { // Get all cards currently in play. Card[] allCardsInPlay = GameObject.FindObjectsOfType <Card>(); // This while loop will run FOREVER until this coroutine is stopped. while (true) { // Wait so many seconds before this character attacks (again) yield return(new WaitForSeconds(this.stats.timeBetweenAttacks)); // Tell other card(s) to take damage from this card. for (int i = 0; i < allCardsInPlay.Length; i++) { CharacterCard characterCard = allCardsInPlay[i] as CharacterCard; // If characterCard is null then is a non-character so don't tell it to take damage. if (characterCard == null) { continue; } // Don't damage self! if (characterCard == this) { continue; } // Tell other character that this character wants to damage it. characterCard.TakeDamage(this); } } }