void UpdateLastState() { lastX = x; lastY = y; lastLeftState = leftState; lastRightState = rightState; }
/// <summary> /// Initializes a new instance of the NumberRendererData class /// </summary> public NumberRendererData() { this.upState = UpDownState.Normal; this.downState = UpDownState.Normal; this.clickX = -1; this.clickY = -1; }
// Update is called once per frame void OnGUI() { Color tmpColor = transform.GetComponent <SpriteRenderer>().color; if (criticalState == CriticalState.CRITICAL) { if (upDownState == UpDownState.UP && tmpColor.a < limAlpha) { tmpColor.a += 0.01f; } else if (upDownState == UpDownState.DOWN && tmpColor.a > 0) { tmpColor.a -= 0.01f; } else if (upDownState == UpDownState.DOWN) { upDownState = UpDownState.UP; } else if (upDownState == UpDownState.UP) { upDownState = UpDownState.DOWN; } transform.GetComponent <SpriteRenderer>().color = tmpColor; } else { tmpColor.a = 0; transform.GetComponent <SpriteRenderer>().color = tmpColor; } }
public void Update(MouseEventArgs e, MouseEventType t) { UpdateLastState(); position.Set(e.X, e.Y); x = e.X; y = e.Y; switch (t) { case MouseEventType.LeftButtonUp: leftState = UpDownState.Up; leftUpPos = new Point(e.X, e.Y); break; case MouseEventType.LeftButtonDown: leftState = UpDownState.Down; leftDownPos = new Point(e.X, e.Y); break; case MouseEventType.RightButtonUp: rightState = UpDownState.Up; rightUpPos = new Point(e.X, e.Y); break; case MouseEventType.RightButtonDown: rightState = UpDownState.Down; rightDownPos = new Point(e.X, e.Y); break; case MouseEventType.Move: break; default: break; } }
// Update is called once per frame void OnGUI() { Color tmpColor = transform.GetComponent<SpriteRenderer>().color; if(criticalState == CriticalState.CRITICAL) { if(upDownState == UpDownState.UP && tmpColor.a < limAlpha) { tmpColor.a += 0.01f; } else if(upDownState == UpDownState.DOWN && tmpColor.a > 0) { tmpColor.a -= 0.01f; } else if(upDownState == UpDownState.DOWN) upDownState = UpDownState.UP; else if(upDownState == UpDownState.UP) upDownState = UpDownState.DOWN; transform.GetComponent<SpriteRenderer>().color = tmpColor; } else { tmpColor.a = 0; transform.GetComponent<SpriteRenderer>().color = tmpColor; } }
private void UpdateKbControl(KeyboardControlKeys key, UpDownState state) { int keyIndex = (int)key; KeyboardControl kbc = kbControlList[keyIndex]; kbc.State = state; kbControlList[keyIndex] = kbc; }
public void UpdateKeyboardEventArgs(System.Windows.Forms.KeyEventArgs ke, UpDownState state) { if (state == UpDownState.Down) { gameControl.UpdateKeyDown(ke); } if (state == UpDownState.Up) { gameControl.UpdateKeyUp(ke); } }
/// <summary> /// Converts the specified UpDownState value to a ButtonState value /// </summary> /// <param name="state">The UpDownState value to be converted</param> /// <returns>A ButtonState value that represents the specified UpDownState /// value</returns> private static ButtonState ConvertUpDownStateToButtonState(UpDownState state) { switch (state) { case UpDownState.Pressed: { return(ButtonState.Pushed); } case UpDownState.Disabled: { return(ButtonState.Inactive); } } return(ButtonState.Normal); }
/// <summary> /// Raises the PaintBackground event /// </summary> /// <param name="e">A PaintCellEventArgs that contains the event data</param> protected override void OnPaintBackground(PaintCellEventArgs e) { base.OnPaintBackground(e); // don't bother going any further if the Cell is null if (e.Cell == null) { return; } if (this.ShowUpDownButtons) { UpDownState upButtonState = this.GetNumberRendererData(e.Cell).UpButtonState; UpDownState downButtonState = this.GetNumberRendererData(e.Cell).DownButtonState; if (!e.Enabled) { upButtonState = UpDownState.Disabled; downButtonState = UpDownState.Disabled; } ThemeManager.DrawUpDownButtons(e.Graphics, this.GetUpButtonBounds(), upButtonState, this.GetDownButtonBounds(), downButtonState); } }
/// <summary> /// Converts the specified UpDownState value to a ButtonState value /// </summary> /// <param name="state">The UpDownState value to be converted</param> /// <returns>A ButtonState value that represents the specified UpDownState /// value</returns> private static ButtonState ConvertUpDownStateToButtonState(UpDownState state) { switch (state) { case UpDownState.Pressed: { return ButtonState.Pushed; } case UpDownState.Disabled: { return ButtonState.Inactive; } } return ButtonState.Normal; }
/// <summary> /// Draws an UpDown's up and down buttons in the specified state, on the specified /// graphics surface, and within the specified bounds /// </summary> /// <param name="g">The Graphics to draw on</param> /// <param name="upButtonRect">The Rectangle that represents the dimensions /// of the up button</param> /// <param name="upButtonClipRect">The Rectangle that represents the clipping area /// for the up button</param> /// <param name="upButtonState">An UpDownState value that specifies the /// state to draw the up button in</param> /// <param name="downButtonRect">The Rectangle that represents the dimensions /// of the down button</param> /// <param name="downButtonClipRect">The Rectangle that represents the clipping area /// for the down button</param> /// <param name="downButtonState">An UpDownState value that specifies the /// state to draw the down button in</param> public static void DrawUpDownButtons(Graphics g, Rectangle upButtonRect, Rectangle upButtonClipRect, UpDownState upButtonState, Rectangle downButtonRect, Rectangle downButtonClipRect, UpDownState downButtonState) { if (g == null) { return; } if (upButtonRect.Width > 0 && upButtonRect.Height > 0 && upButtonClipRect.Width > 0 && upButtonClipRect.Height > 0) { if (ThemeManager.VisualStylesEnabled) { //ThemeManager.DrawThemeBackground(g, ThemeClasses.UpDown, (int) UpDownParts.Up, (int) upButtonState, upButtonRect, upButtonClipRect); VisualStyleRenderer renderer; switch (upButtonState) { case UpDownState.Disabled: renderer = new VisualStyleRenderer(VisualStyleElement.Spin.Up.Disabled); break; case UpDownState.Hot: renderer = new VisualStyleRenderer(VisualStyleElement.Spin.Up.Hot); break; case UpDownState.Pressed: renderer = new VisualStyleRenderer(VisualStyleElement.Spin.Up.Pressed); break; case UpDownState.Normal: default: renderer = new VisualStyleRenderer(VisualStyleElement.Spin.Up.Normal); break; } renderer.DrawBackground(g, upButtonRect, upButtonClipRect); } else { ControlPaint.DrawScrollButton(g, upButtonRect, ScrollButton.Up, ThemeManager.ConvertUpDownStateToButtonState(upButtonState)); } } if (downButtonRect.Width > 0 && downButtonRect.Height > 0 && downButtonClipRect.Width > 0 && downButtonClipRect.Height > 0) { if (ThemeManager.VisualStylesEnabled) { //ThemeManager.DrawThemeBackground(g, ThemeClasses.UpDown, (int) UpDownParts.Down, (int) downButtonState, downButtonRect, downButtonClipRect); VisualStyleRenderer renderer; switch (downButtonState) { case UpDownState.Disabled: renderer = new VisualStyleRenderer(VisualStyleElement.Spin.Down.Disabled); break; case UpDownState.Hot: renderer = new VisualStyleRenderer(VisualStyleElement.Spin.Down.Hot); break; case UpDownState.Pressed: renderer = new VisualStyleRenderer(VisualStyleElement.Spin.Down.Pressed); break; case UpDownState.Normal: default: renderer = new VisualStyleRenderer(VisualStyleElement.Spin.Down.Normal); break; } renderer.DrawBackground(g, downButtonRect, downButtonClipRect); } else { ControlPaint.DrawScrollButton(g, downButtonRect, ScrollButton.Down, ThemeManager.ConvertUpDownStateToButtonState(downButtonState)); } } }
/// <summary> /// Draws an UpDown's up and down buttons in the specified state, on the specified /// graphics surface, and within the specified bounds /// </summary> /// <param name="g">The Graphics to draw on</param> /// <param name="upButtonRect">The Rectangle that represents the dimensions /// of the up button</param> /// <param name="upButtonState">An UpDownState value that specifies the /// state to draw the up button in</param> /// <param name="downButtonRect">The Rectangle that represents the dimensions /// of the down button</param> /// <param name="downButtonState">An UpDownState value that specifies the /// state to draw the down button in</param> public static void DrawUpDownButtons(Graphics g, Rectangle upButtonRect, UpDownState upButtonState, Rectangle downButtonRect, UpDownState downButtonState) { ThemeManager.DrawUpDownButtons(g, upButtonRect, upButtonRect, upButtonState, downButtonRect, downButtonRect, downButtonState); }
// Use this for initialization void Start() { criticalState = CriticalState.NORMAL; upDownState = UpDownState.UP; }
// Update is called once per frame void Update() { transform.position = new Vector3(transform.position.x, 0.9f, transform.position.z); //always make sure the players height sounds the same //PLAYER MOVEMENT if (gameStateManager.isGamePaused == false && gameStateManager.currentGameState != GameStateManager.GameState.levelDialogue) //can only move if the game isn't paused { if (Input.GetKey(KeyCode.A) == true && Input.GetKey(KeyCode.D) != true) { currentLeftRightState = LeftRightState.left; lastLeftRightState = LeftRightState.left; } else if (Input.GetKey(KeyCode.A) != true && Input.GetKey(KeyCode.D) == true) { currentLeftRightState = LeftRightState.right; lastLeftRightState = LeftRightState.right; } else if (Input.GetKey(KeyCode.A) == true && Input.GetKey(KeyCode.D) == true) { currentLeftRightState = LeftRightState.idle; } else { currentLeftRightState = LeftRightState.idle; if (playerSpeedHorizontal > playerSpeedMin) { playerSpeedHorizontal = playerSpeedHorizontal * movingDecceleration; } } if (Input.GetKey(KeyCode.W) == true && Input.GetKey(KeyCode.S) != true) { currentUpDownState = UpDownState.up; lastUpDownState = UpDownState.up; } else if (Input.GetKey(KeyCode.W) != true && Input.GetKey(KeyCode.S) == true) { currentUpDownState = UpDownState.down; lastUpDownState = UpDownState.down; } else if (Input.GetKey(KeyCode.W) == true && Input.GetKey(KeyCode.S) == true) { currentUpDownState = UpDownState.idle; } else { currentUpDownState = UpDownState.idle; if (playerSpeedVertical > playerSpeedMin) { playerSpeedVertical = playerSpeedVertical * movingDecceleration; } } } else { currentLeftRightState = LeftRightState.idle; currentUpDownState = UpDownState.idle; if (playerSpeedVertical > playerSpeedMin) { playerSpeedVertical = playerSpeedVertical * movingDecceleration; } if (playerSpeedHorizontal > playerSpeedMin) { playerSpeedHorizontal = playerSpeedHorizontal * movingDecceleration; } } //making the player move if (currentLeftRightState == LeftRightState.left) { if (audioLock == false) { playerAudioSource.loop = true; playerAudioSource.Play(); audioLock = true; } if (playerSpeedHorizontal < playerSpeedMax) { playerSpeedHorizontal = playerSpeedHorizontal * (movingAcceleration); } moveVelocity = new Vector3(-playerSpeedHorizontal, moveVelocity.y, moveVelocity.z); } else if (currentLeftRightState == LeftRightState.right) { if (audioLock == false) { playerAudioSource.loop = true; playerAudioSource.Play(); audioLock = true; } if (playerSpeedHorizontal < playerSpeedMax) { playerSpeedHorizontal = playerSpeedHorizontal * (movingAcceleration); } moveVelocity = new Vector3(playerSpeedHorizontal, moveVelocity.y, moveVelocity.z); } else if (currentLeftRightState == LeftRightState.idle) { if (playerSpeedHorizontal > playerSpeedMin) { if (lastLeftRightState == LeftRightState.left) { moveVelocity = new Vector3(-playerSpeedHorizontal, moveVelocity.y, moveVelocity.z); } else if (lastLeftRightState == LeftRightState.right) { moveVelocity = new Vector3(playerSpeedHorizontal, moveVelocity.y, moveVelocity.z); } } else { moveVelocity = new Vector3(0, moveVelocity.y, moveVelocity.z); } } if (currentUpDownState == UpDownState.up) { if (audioLock == false) { playerAudioSource.loop = true; playerAudioSource.Play(); audioLock = true; } if (playerSpeedVertical < playerSpeedMax) { playerSpeedVertical = playerSpeedVertical * (movingAcceleration); } moveVelocity = new Vector3(moveVelocity.x, moveVelocity.y, playerSpeedVertical); } else if (currentUpDownState == UpDownState.down) { if (audioLock == false) { playerAudioSource.loop = true; playerAudioSource.Play(); audioLock = true; } if (playerSpeedVertical < playerSpeedMax) { playerSpeedVertical = playerSpeedVertical * (movingAcceleration); } moveVelocity = new Vector3(moveVelocity.x, moveVelocity.y, -playerSpeedVertical); } else if (currentUpDownState == UpDownState.idle) { if (playerSpeedVertical > playerSpeedMin) { if (lastUpDownState == UpDownState.up) { moveVelocity = new Vector3(moveVelocity.x, moveVelocity.y, playerSpeedVertical); } else if (lastUpDownState == UpDownState.down) { moveVelocity = new Vector3(moveVelocity.x, moveVelocity.y, -playerSpeedVertical); } } else { moveVelocity = new Vector3(moveVelocity.x, moveVelocity.y, 0); } } }
public void Update(float delta) { switch (State) { case OutriggersState.Undeploying: { if (VerticalState == UpDownState.None) // wait for the legs to go up { float moveDist = data.ExtensionMoveSpeed * delta; Vector3 translation = -extensionDirection * moveDist; currentExtendDistance -= Math.Abs(moveDist); extensionBone.Translate(translation); if (currentExtendDistance <= 0.0f) { State = OutriggersState.Undeployed; } } } break; case OutriggersState.Deploying: { float moveDist = data.ExtensionMoveSpeed * delta; Vector3 translation = extensionDirection * moveDist; currentExtendDistance += Math.Abs(moveDist); extensionBone.Translate(translation); if (currentExtendDistance >= data.ExtensionDistance) { State = OutriggersState.Deployed; VerticalState = UpDownState.Down; } } break; } switch (VerticalState) { case UpDownState.Up: { float moveDist = data.SupportMoveSpeed * delta; Vector3 translation = -supportDirection * moveDist; currentSupportDistance -= Math.Abs(moveDist); supportBone.Translate(translation); if (currentSupportDistance <= 0.0f) { VerticalState = UpDownState.None; } } break; case UpDownState.Down: { float moveDist = data.SupportMoveSpeed * delta; Vector3 translation = supportDirection * moveDist; currentSupportDistance += Math.Abs(moveDist); supportBone.Translate(translation); if (currentSupportDistance >= data.SupportDistance) { VerticalState = UpDownState.None; } } break; } }