// Damages a random unit in the party public void TakeDamage(PartyMember attacker, bool damagesFocus = false) { List <int> validTargets = new List <int>(); for (int i = 0; i < party.Count; ++i) { if (PartyMember.Interacts(attacker, party[i])) { validTargets.Add(i); } } if (validTargets.Count == 0) { return; } int targetedUnit = validTargets[Random.Range(0, validTargets.Count)]; if (damagesFocus) { party[targetedUnit].focus -= 1; } else { party[targetedUnit].health -= 1; // This needs to be much more complicated if (OneDown() && GetComponent <PlayerMover>()) { Instantiate(corpse, transform.position, Quaternion.identity); GetComponentInChildren <SpriteRenderer>().enabled = false; enabled = false; TransitionFader.instance.Transition(""); } if (AllDown() && GetComponent <AutoMover>()) { Instantiate(corpse, transform.position, Quaternion.identity); DestroyImmediate(gameObject); } } // indicator.SetColor(health); }