private void FormMain_KeyDown(object sender, KeyEventArgs e) { //进入菜单 if (_nowgame == gameState.title && (e.KeyCode == Keys.Space || e.KeyCode == Keys.Enter)) { _nowgame = gameState.menu; panelBackground.Invalidate(); } //选择菜单选项 else if (_nowgame == gameState.menu) { //进入游戏 if (e.KeyCode == Keys.Enter) { _nowgame = gameState.open; //panelBackground.Invalidate(); } else if (e.KeyCode == Keys.Down && _playerChoose == menuChoose.New_Run) { _playerChoose = menuChoose.Continue; panelBackground.Invalidate(); } else if (e.KeyCode == Keys.Down && _playerChoose == menuChoose.Continue) { _playerChoose = menuChoose.Test; panelBackground.Invalidate(); } else if (e.KeyCode == Keys.Up && _playerChoose == menuChoose.Test) { _playerChoose = menuChoose.Continue; panelBackground.Invalidate(); } else if (e.KeyCode == Keys.Up && _playerChoose == menuChoose.Continue) { _playerChoose = menuChoose.New_Run; panelBackground.Invalidate(); } else if (e.KeyCode == Keys.Escape) { _nowgame = gameState.title; panelBackground.Invalidate(); } } }
private void FormMain_KeyDown(object sender, KeyEventArgs e) { #region 菜单界面的简单控制 //进入菜单 if (_nowgame == gameState.title && (e.KeyCode == Keys.Space || e.KeyCode == Keys.Enter)) { _nowgame = gameState.menu; _Sound_player.Play(); } //选择菜单选项 else if (_nowgame == gameState.menu) { //进入游戏 if (e.KeyCode == Keys.Enter || e.KeyCode == Keys.Space) { if (_playerChoose == menuChoose.New_Run) { _nowgame = gameState.open; _Sound_player.Play(); _boss_0.creat(); _player.creat(); _player._Speed = 5; _player._Hp_B = 10; _player._Dmg = 1; } else if (_playerChoose == menuChoose.Continue) { _nowgame = gameState.open; _Sound_player.Play(); _boss_0.creat(); _player.creat(); _boss_0._Hp = _boss_0._Hp_B; } } else if (e.KeyCode == Keys.Down && _playerChoose == menuChoose.New_Run) { _playerChoose = menuChoose.Continue; } else if (e.KeyCode == Keys.Down && _playerChoose == menuChoose.Continue) { _playerChoose = menuChoose.Test; } else if (e.KeyCode == Keys.Up && _playerChoose == menuChoose.Test) { _playerChoose = menuChoose.Continue; } else if (e.KeyCode == Keys.Up && _playerChoose == menuChoose.Continue) { _playerChoose = menuChoose.New_Run; } else if (e.KeyCode == Keys.Escape) { _nowgame = gameState.title; } } else if (_nowgame == gameState.open) { timer1.Enabled = true; _playerChoose = menuChoose.Back; if (e.KeyCode == Keys.P) { timer1.Enabled = !timer1.Enabled; } } else if (_nowgame == gameState.win) { if (e.KeyCode == Keys.Right && _playerChoose == menuChoose.Back) { _playerChoose = menuChoose.Continue; } else if (e.KeyCode == Keys.Left && _playerChoose == menuChoose.Continue) { _playerChoose = menuChoose.Back; } else if ((e.KeyCode == Keys.Enter || e.KeyCode == Keys.Space) && _playerChoose == menuChoose.Continue) { _nowgame = gameState.next; _Sound_player.Play(); } else if ((e.KeyCode == Keys.Enter || e.KeyCode == Keys.Space) && _playerChoose == menuChoose.Back) { _nowgame = gameState.menu; _playerChoose = menuChoose.New_Run; _Sound_player.Play(); } } else if (_nowgame == gameState.next) { if (e.KeyCode == Keys.Down && _playerUP == playerUP.DMG) { _playerUP = playerUP.SPEED; } else if (e.KeyCode == Keys.Down && _playerUP == playerUP.SPEED) { _playerUP = playerUP.HP; } else if (e.KeyCode == Keys.Up && _playerUP == playerUP.SPEED) { _playerUP = playerUP.DMG; } else if (e.KeyCode == Keys.Up && _playerUP == playerUP.HP) { _playerUP = playerUP.SPEED; } else if (e.KeyCode == Keys.Space || e.KeyCode == Keys.Enter) { if (_playerUP == playerUP.DMG) { _Sound_Tear.Play(); _player._Dmg *= 2; _tear._Size = _player._Dmg * 2; } else if (_playerUP == playerUP.HP) { _player._Hp_B += 2; _Sound_Hp.Play(); } else if (_playerUP == playerUP.SPEED) { _Sound_Speed.Play(); _player._Speed += 5; _tear._Speed = _player._Speed * 2; } _nowgame = gameState.open; _boss_0.creat(); _player.creat(); _boss_0._Hp_B *= 4; _boss_0._Hp = _boss_0._Hp_B; _player._Hp = _player._Hp_B; _tearList.Clear(); } } else if (_nowgame == gameState.over) { timer1.Enabled = false; if (e.KeyCode == Keys.Space || e.KeyCode == Keys.Enter) { _nowgame = gameState.menu; _Sound_player.Play(); _playerChoose = menuChoose.New_Run; } } #endregion pictureBoxBackground.Invalidate(); }