public void HandleKeyUp(object sender, KeyEventArgs e) { eThrottleStick throttleStickState = eThrottleStick.None; eDirectionStick directionStickState = eDirectionStick.None; switch (e.KeyCode) { case Keys.W: wKeyPressed = false; throttleStickState = eThrottleStick.Ascend; break; case Keys.S: sKeyPressed = false; throttleStickState = eThrottleStick.Descend; break; case Keys.D: dKeyPressed = false; throttleStickState = eThrottleStick.Right; break; case Keys.A: aKeyPressed = false; throttleStickState = eThrottleStick.Left; break; case Keys.Up: upKeyPressed = false; directionStickState = eDirectionStick.Forward; break; case Keys.Down: downKeyPressed = false; directionStickState = eDirectionStick.Backward; break; case Keys.Right: rightKeyPressed = false; directionStickState = eDirectionStick.Right; break; case Keys.Left: leftKeyPressed = false; directionStickState = eDirectionStick.Left; break; } if (throttleStickState != eThrottleStick.None) { m_scene.ThrottleStickDeactivate(throttleStickState); } if (directionStickState != eDirectionStick.None) { m_scene.DirectionStickDeactivate(directionStickState); } }
private void checkOneDirection(eDirectionStick state, ref float value, float maxValue) { if (DirectionStickState.HasFlag(state)) { if (value < maxValue) { value += m_rollingSpeed; } } else { if (value > 0) { value -= m_rollingSpeed; } } }
public void HandleKeyDown(object sender, KeyEventArgs e) { eThrottleStick throttleStickState = eThrottleStick.None; eDirectionStick directionStickState = eDirectionStick.None; switch (e.KeyCode) { case Keys.W: if (!wKeyPressed) { throttleStickState = eThrottleStick.Ascend; wKeyPressed = true; } break; case Keys.S: if (!sKeyPressed) { throttleStickState = eThrottleStick.Descend; sKeyPressed = true; } break; case Keys.D: if (!dKeyPressed) { throttleStickState = eThrottleStick.Right; dKeyPressed = true; } break; case Keys.A: if (!aKeyPressed) { throttleStickState = eThrottleStick.Left; aKeyPressed = true; } break; case Keys.Up: if (!upKeyPressed) { directionStickState = eDirectionStick.Forward; upKeyPressed = true; } break; case Keys.Down: if (!downKeyPressed) { directionStickState = eDirectionStick.Backward; downKeyPressed = true; } break; case Keys.Right: if (!rightKeyPressed) { directionStickState = eDirectionStick.Right; rightKeyPressed = true; } break; case Keys.Left: if (!leftKeyPressed) { directionStickState = eDirectionStick.Left; leftKeyPressed = true; } break; } if (throttleStickState != eThrottleStick.None) { m_scene.ThrottleStickActivate(throttleStickState); } if (directionStickState != eDirectionStick.None) { m_scene.DirectionStickActivate(directionStickState); } }
public void DirectionStickDeactivate(eDirectionStick directionStickState) { m_helicopter.DirectionStickState &= ~directionStickState; m_directionStickState &= ~directionStickState; }
public void DirectionStickActivate(eDirectionStick directionStickState) { m_helicopter.DirectionStickState |= directionStickState; m_directionStickState |= directionStickState; }