public Field(GUIForm guiForm, Rectangle rect, GameForm gameForm) : base(guiForm, rect) { _gameForm = gameForm; Obstacles = new List <Obstacle>(); PlayersManager = new PlayersManager(guiForm, this); CompsManager = new CompsManager(guiForm, this); BonusManager = new BonusManager(guiForm, this); Shells = new List <Shell>(); _showelDelayTimer = new Timer(); _showelDelayTimer.Interval = 20 * 1000; _showelDelayTimer.Tick += OnShowelDelayTimerTick; _watchDelayTimer = new Timer(); _watchDelayTimer.Interval = 10 * 1000; _watchDelayTimer.Tick += OnWatchDelayTimerTick; }
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; }
public override void Subscribe() { GUIForm.Paint += OnPaint; SubscribeObstacles(Obstacles); PlayersManager.Subscribe(); PlayersManager.TankShot += OnShot; PlayersManager.TanksDestroyed += OnPlayerTanksOrHQDestroyed; CompsManager.Subscribe(); CompsManager.TankShot += OnShot; CompsManager.TanksDestroyed += OnCompTanksDestroyed; BonusManager.Subscribe(); BonusManager.PlayerTookBomb += OnPlayerTookBomb; BonusManager.CompTookBomb += OnCompTookBomb; BonusManager.PlayerTookWatch += OnPlayerTookWatch; BonusManager.CompTookWatch += OnCompTookWatch; BonusManager.PlayerTookShowel += OnPlayerTookShowel; BonusManager.CompTookShowel += OnCompTookShowel; }
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); }
public void StartNewGame(int players) { _stage = 0; PlayersManager.SetNewGameTanksParameters(players); CompsManager.SetNewGameTanksParameters(players); }