public void Press(object sender, KeyEventArgs e) { MesageToExit(); if (Control.Contains(e.KeyCode)) { player.Move(e); } if (e.KeyCode == Keys.I) { inventory.Show(); } if (e.KeyCode == Keys.Escape) { Application.Exit(); } if (e.KeyCode == Keys.F && MesageToExit()) { FormCollection fc = Application.OpenForms; bool open = false; foreach (Form frm in fc) { if (frm.Name == "Loading" && frm.Visible == true) { open = true; } } if (!open) { FinalLevel level = new FinalLevel(); level.Show(); this.Hide(); } } if (e.KeyCode == Keys.Space) { player.OnMove = true; player.Direction = "Idle"; player.Status = "Attack"; if (Math.Abs(player.PosX - ghoul.PosX) <= 20 && ghoul.Health >= 0) { ghoul.Health -= 10; } if (ghoul.Health == 0) { Points.point += ghoul.point; Score.Text = "Score " + Points.point.ToString(); } if (Math.Abs(player.PosX - cobra.PosX) <= 20 && cobra.Health >= 0) { cobra.Health -= 10; } if (cobra.Health == 0) { Points.point += cobra.point; Score.Text = "Score " + Points.point.ToString(); } } }