//------------------------------------------------------------------------- /// <summary> /// KeyDown input event handler function. /// </summary> /// <param name="e">KeyEvent arguments.</param> /// <returns>True if handled.</returns> public override bool injectKeyDown(KeyEventArgs e) { switch (e.Key) { case Keys.W: MoveDirection += GameLevelManager.directionVectorFromView(Direction.DIR_N); break; case Keys.A: MoveDirection += GameLevelManager.directionVectorFromView(Direction.DIR_W); break; case Keys.S: MoveDirection += GameLevelManager.directionVectorFromView(Direction.DIR_S); break; case Keys.D: MoveDirection += GameLevelManager.directionVectorFromView(Direction.DIR_E); break; case Keys.Space: _character.jump(); break; } return(base.injectKeyDown(e)); }
/// <summary> /// KeyUp input event handler function. /// </summary> /// <param name="e">KeyEvent arguments.</param> /// <returns>True if handled.</returns> public override bool injectKeyUp(KeyEventArgs e) { switch (e.Key) { case Keys.W: MoveDirection -= GameLevelManager.directionVectorFromView(Direction.DIR_N); break; case Keys.A: MoveDirection -= GameLevelManager.directionVectorFromView(Direction.DIR_W); break; case Keys.S: MoveDirection -= GameLevelManager.directionVectorFromView(Direction.DIR_S); break; case Keys.D: MoveDirection -= GameLevelManager.directionVectorFromView(Direction.DIR_E); break; } return(base.injectKeyUp(e)); }