Example #1
0
        private IEnumerator CheckForDeath()
        {
            foreach (Character c in GetAll())
            {
                HashSet <Character> graveyard = null;

                bool isLeftGrave = false;

                if (Left.Contains(c))
                {
                    graveyard   = leftGraveyard;
                    isLeftGrave = true;
                }
                else
                {
                    graveyard   = rightGraveyard;
                    isLeftGrave = false;
                }
                bool characterIsInGraveyard = graveyard.Contains(c);

                // Display death effect
                if (c.Stats.State == State.DEAD && !characterIsInGraveyard)
                {
                    IList <Buff> dispellableOnDeath = c.Buffs.Where(b => b.IsDispellable).ToList();
                    foreach (Buff removableBuff in dispellableOnDeath)
                    {
                        c.Buffs.RemoveBuff(RemovalType.DISPEL, removableBuff);
                    }
                    Main.Instance.Sound.PlaySound("synthetic_explosion_1");
                    yield return(SFX.DoDeathEffect(c, 1f));

                    AddText(string.Format(CHARACTER_DEATH, c.Look.Name));

                    graveyard.Add(c);
                    if (!c.HasFlag(Characters.Flag.PERSISTS_AFTER_DEFEAT))
                    {
                        Left.Remove(c);
                        Right.Remove(c);
                    }
                }

                // Bring them back! (for revivals)
                if (c.Stats.State == State.ALIVE && characterIsInGraveyard)
                {
                    graveyard.Remove(c);
                    if (isLeftGrave)
                    {
                        Left.Add(c);
                    }
                    else
                    {
                        Right.Add(c);
                    }
                }
            }
        }