示例#1
0
		void MainForm_KeyDown(object sender,KeyEventArgs e)
		{
			if(game.Misjudgement() == false){MessageBox.Show("地图有误,请重试!"); return;}
			if(game.GetCurrentPerson() != null){
				switch(e.KeyCode){
					case Keys.Up:
						game.GetCurrentPerson().MoveInForm(this,Direction.UP,resources);
						break;
					case Keys.Down:
						game.GetCurrentPerson().MoveInForm(this,Direction.DOWN,resources);
						break;
					case Keys.Left:					
						game.GetCurrentPerson().MoveInForm(this,Direction.LEFT,resources);
						break;
					case Keys.Right:					
						game.GetCurrentPerson().MoveInForm(this,Direction.RIGHT,resources);
						break;
				}
			}else{
					switch(e.KeyCode){
					case Keys.Up:
						game.GetCurrentPersonInCage().MoveInForm(this,Direction.UP,resources);
						break;
					case Keys.Down:
						game.GetCurrentPersonInCage().MoveInForm(this,Direction.DOWN,resources);
						break;
					case Keys.Left:					
						game.GetCurrentPersonInCage().MoveInForm(this,Direction.LEFT,resources);
						break;
					case Keys.Right:					
						game.GetCurrentPersonInCage().MoveInForm(this,Direction.RIGHT,resources);
						break;
				}
			}
		}