Esempio n. 1
0
        private void OnTankDestroyed(object sender, EventArgs e)
        {
            var destroyedTank = sender as Tank;

            destroyedTank.RemoveCheckPositionListeners();
            destroyedTank.RemoveShotListeners();
            destroyedTank.RemoveDestroyedListeners();

            foreach (var compTankOnField in TanksOnField)
            {
                if (compTankOnField != destroyedTank)
                {
                    compTankOnField.CheckPosition -= destroyedTank.GetCheckPositionListener();
                }
            }

            foreach (var playerTank in Field.PlayersManager.Tanks)
            {
                playerTank.CheckPosition -= destroyedTank.GetCheckPositionListener();
            }

            foreach (var shell in Field.Shells)
            {
                shell.CheckPosition -= destroyedTank.GetCheckPositionListener();
            }

            TanksOnField.Remove(destroyedTank);

            AliveTanks--;
        }