//Создаёт босса зомби внизу карты private void MakeZombieBoss(object sender, EventArgs e) { ZombieLogic.ZombieBossHP = 5; PictureBox zombieBoss = new PictureBox(); zombieBoss.Tag = "zombieBoss"; zombieBoss.Image = Properties.Resources.zdownboss; zombieBoss.Left = 450; zombieBoss.Top = 1340; zombieBoss.SizeMode = PictureBoxSizeMode.AutoSize; Controls.Add(zombieBoss); zombieBoss.BringToFront(); TimerToZombieBoss.Stop(); }
//Основной метод формы, связанный с главным таймером public void GameEngine(object sender, EventArgs e) { if (PlayerLogic.PlayerHealth > 0) { HealthBar.Value = Convert.ToInt32(PlayerLogic.PlayerHealth); } else {//Конец игры PlayerLogic.Dead(player); Timer.Stop(); TimerToHeal.Stop(); GameOver = true; GameSounds.Music.Stop(); End end = new End(); end.label(Score); end.ShowDialog(); } LabelAmmo.Text = " Ammo: " + PlayerLogic.Ammo; LabelScore.Text = " Score: " + Score; //Движение игрока и перерисовка спрайта PlayerLogic.Move(player); //Контакт между объектами foreach (Control x in Controls) { if (x is PictureBox) { switch (x.Tag.ToString()) { case "ammo": PlayerLogic.TakeAmmo((PictureBox)x, this, player); break; case "heart": PlayerLogic.TakeHealPoint((PictureBox)x, this, player); break; case "bullet": PlayerLogic.RemoveBulletOutOfMap((PictureBox)x, this); break; case "zombie": ZombieLogic.ZombieMove((PictureBox)x, this, PlayerLogic, player); break; case "zombieBoss": ZombieLogic.ZombieBossMove((PictureBox)x, PlayerLogic, player); break; default: break; } } foreach (Control j in Controls) { if (j is PictureBox && j.Tag.ToString() == "bullet") { if (x is PictureBox && x.Tag.ToString() == "zombie") { if (x.Bounds.IntersectsWith(j.Bounds)) { Score++; GameSounds.MusicCounter++; if (GameSounds.MusicCounter > 60) { GameSounds.MusicCounter -= 60; } GameSounds.ZombieKillMusic(GameSounds.MusicCounter); Controls.Remove(j); j.Dispose(); Controls.Remove(x); x.Dispose(); ZombieLogic.MakeZombie(player, this); } } else if (x is PictureBox && x.Tag.ToString() == "zombieBoss") { if (x.Bounds.IntersectsWith(j.Bounds)) { Controls.Remove(j); j.Dispose(); ZombieLogic.ZombieBossHP -= 1; if (ZombieLogic.ZombieBossHP == 0) { GameSounds.ZombieBossKillMusic(); Score += 5; GameSounds.MusicCounter += 5; if (GameSounds.MusicCounter > 60) { GameSounds.MusicCounter -= 60; } Controls.Remove(x); x.Dispose(); TimerToZombieBoss.Start(); ZombieLogic.MakeZombie(player, this); } } } } } } Invalidate(); }