private void timer3_Tick(object sender, EventArgs e) { if (isBoss2) { for (int j = 0; j < 4; j++) { enemy en = new enemy((boss2.Left + 300 < this.Width) ? (boss2.Left + j * 60) : boss2.Left - j * 60, boss2.Top + boss2.Height - 55, 3, 2, 4); enemies.Add(en); this.Controls.Add(en); en.BringToFront(); } } }
private void Form1_KeyDown(object sender, KeyEventArgs e) { if (!gameOver && !(HPs == 0)) { if (e.KeyCode == Keys.S) { isSdown = true; } if (e.KeyCode == Keys.ControlKey) { isCtrldown = true; } if (e.KeyCode == Keys.Y) { isYdown = true; } if (!isPaused) { if (e.KeyCode == Keys.Right) { right = true; } if (e.KeyCode == Keys.Left) { left = true; } if (e.KeyCode == Keys.Space && !isLaunched) { bullet b = new bullet(true, Hero.Left, Hero.Width, Hero.Top, Hero.Height, Hero.attackSpeed, Color.Red, Hero.shotWidth); bullets.Add(b); this.Controls.Add(b); b.BringToFront(); isLaunched = true; } if (e.KeyCode == Keys.Tab) { if (Hero.heroChosen == 1) { Hero.BackgroundImage = Properties.Resources.hero2; Hero.speed = 7; Hero.attackSpeed = 5; Hero.shotWidth = 2; } if (Hero.heroChosen == 2) { Hero.BackgroundImage = Properties.Resources.hero3; Hero.speed = 3; Hero.attackSpeed = 2; Hero.shotWidth = 13; } if (Hero.heroChosen == 3) { Hero.BackgroundImage = Properties.Resources.hero1; Hero.speed = 5; Hero.attackSpeed = 4; Hero.shotWidth = 4; } if (Hero.heroChosen != 3) { Hero.heroChosen += 1; } else { Hero.heroChosen = 1; } } if (isReady) { if (e.KeyCode == Keys.Z) { difficulty++; labelToStart.Visible = false; lvlabel.Text = "LVL" + difficulty; isReady = false; switch (difficulty) { case 10: boss1 = new boss1(this.Width / 2, -80, 2, 100, 0); isBoss1 = true; this.Controls.Add(boss1); timer2.Enabled = true; boss1.BringToFront(); break; case 20: boss2 = new boss2(this.Width / 2, -80, 2, 200, 0); isBoss2 = true; this.Controls.Add(boss2); timer3.Enabled = true; boss2.BringToFront(); break; default: for (int i = 0; i < 2; i++) { for (int j = 0; j < 8; j++) { int chance; if (difficulty < 10) { chance = rand.Next(100 - difficulty * 10); } else { chance = 0; } enemy en = new enemy(this.Width - 60 * j - 80 - i * 10, i * 60, 2 + difficulty / 6, (chance == 0) ? 2 : 1, difficulty > 20?4:(!(chance == 0)?1:2)); enemies.Add(en); this.Controls.Add(en); en.BringToFront(); } } break; } } } } if (e.KeyCode == Keys.Escape) { if (isPaused) { timer1.Enabled = true; timer2.Enabled = true; timer3.Enabled = true; pause.Enabled = false; pause.Visible = false; } else { timer1.Enabled = false; timer2.Enabled = false; timer3.Enabled = false; pause.Enabled = true; pause.Visible = true; pause.BackColor = Color.Transparent; pause.Dock = DockStyle.Fill; } isPaused = !isPaused; } } }