Example #1
0
        public override void Unsubscribe()
        {
            GUIForm.Paint -= OnPaint;

            UnsubscribeObstacles(Obstacles);

            PlayersManager.Unsubscribe();
            PlayersManager.TankShot       -= OnShot;
            PlayersManager.TanksDestroyed -= OnPlayerTanksOrHQDestroyed;

            CompsManager.Unsubscribe();
            CompsManager.TankShot       -= OnShot;
            CompsManager.TanksDestroyed -= OnCompTanksDestroyed;

            BonusManager.Unsubscribe();
            BonusManager.PlayerTookBomb   -= OnPlayerTookBomb;
            BonusManager.CompTookBomb     -= OnCompTookBomb;
            BonusManager.PlayerTookWatch  -= OnPlayerTookWatch;
            BonusManager.CompTookWatch    -= OnCompTookWatch;
            BonusManager.PlayerTookShowel -= OnPlayerTookShowel;
            BonusManager.CompTookShowel   -= OnCompTookShowel;
        }
Example #2
0
        private void OnPlayerTanksOrHQDestroyed(object sender, EventArgs e)
        {
            int points1 = PlayersManager.P1Tank.Points;
            int points2 = PlayersManager.P2Tank.Points;

            if (points1 > 0)
            {
                _gameForm.FormsManager.Records.AddRecord(Properties.Settings.Default.P1Name, PlayersManager.P1Tank.Points);
            }
            if (points2 > 0)
            {
                _gameForm.FormsManager.Records.AddRecord(Properties.Settings.Default.P2Name, PlayersManager.P2Tank.Points);
            }

            //Очистка уровня
            foreach (var obstacle in Obstacles)
            {
                foreach (var playerTank in PlayersManager.Tanks)
                {
                    playerTank.CheckPosition -= obstacle.GetCheckPositionListener();
                }

                foreach (var compTank in CompsManager.Tanks)
                {
                    compTank.CheckPosition -= obstacle.GetCheckPositionListener();
                }
            }

            PlayersManager.Unsubscribe();
            CompsManager.Unsubscribe();

            Obstacles.Clear();
            _showelDelayTimer.Stop();
            _watchDelayTimer.Stop();

            GameOver?.Invoke(sender, e);
        }