private void Form1_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Right) { RightMove.Start(); } if (e.KeyCode == Keys.Left) { LeftMove.Start(); } if (e.KeyCode == Keys.Up) { UpMove.Start(); } if (e.KeyCode == Keys.Down) { DownMove.Start(); } if (e.KeyCode == Keys.Space) { if (canFire == true) { lasers[0].Location = new Point(player.Location.X + 20, player.Location.Y - 0); MoveLaser.Start(); } } }
void Update() { if (GameObject.Find(UnityXR.gameObject.name)) { GetComponent <VRTK_UICanvas>().enabled = true; LeftMove.SetActive(false); RightMove.SetActive(false); Plus.SetActive(true); Minus.SetActive(true); for (int i = 0; i < Keyboard.Length; i++) { Keyboard[i].SetActive(true); } } else { GetComponent <VRTK_UICanvas>().enabled = false; LeftMove.SetActive(true); RightMove.SetActive(true); Plus.SetActive(false); Minus.SetActive(false); for (int i = 0; i < Keyboard.Length; i++) { Keyboard[i].SetActive(false); } } }
private void Form1_KeyUp(object sender, KeyEventArgs e) { RightMove.Stop(); LeftMove.Stop(); UpMove.Stop(); DownMove.Stop(); // canFire = false; }
public void MoveRightTest() { IPosition current = new Position(new Coordinate(1, 1), Business.Enums.Direction.North); IPosition expected = new Position(new Coordinate(1, 1), Business.Enums.Direction.East); IMove rightMove = new RightMove(); IPosition output = rightMove.Move(current); Assert.AreEqual(expected.Coordinate.X, output.Coordinate.X); Assert.AreEqual(expected.Coordinate.Y, output.Coordinate.Y); Assert.AreEqual(expected.Direction, output.Direction); }
/// <summary> /// Check keyboard input and fire events according to what was pressed. /// </summary> private void CheckInput() { if (TMBAW_Game.CurrentGameMode == GameMode.None) { return; } if (TMBAW_Game.Dialog.IsActive) { return; } if (StoryTracker.InCutscene || GameWorld.IsInCutsceneMode) { return; } if (DialogueSystem.IsShowingDialogue) { return; } if (TMBAW_Game.CurrentGameMode == GameMode.Edit) { return; } if (IsPunchPressed() && !_attackIsPressed) { PlayerScript.TimeSinceLastPunch.Reset(); } if (!PlayerScript.IsDoingAction) { if (TMBAW_Game.CurrentGameMode == GameMode.Play) { if (IsRewindPressed()) { RewindAction?.Invoke(); } } if (IsMoveLeftPressed()) { LeftMove?.Invoke(); } if (IsMoveRightPressed()) { RightMove?.Invoke(); } if (IsMoveDownPressed()) { if (GameWorld.WorldData.IsTopDown) { DownMove?.Invoke(); } else { DuckAction?.Invoke(); } } else { DuckActionStop?.Invoke(); } if (IsInteractPressed()) { if (GameWorld.WorldData.IsTopDown) { UpMove?.Invoke(); } else { InteractAction?.Invoke(); } } if (!IsMoveDownPressed() && !IsInteractPressed()) { ReleaseUpAndDownAction?.Invoke(); } if (IsPunchPressed()) { if (!_attackIsPressed) { //FireWeaponAction?.Invoke(); _attackIsPressed = true; } } else { _attackIsPressed = false; } if (IsWeaponFirePressed()) { FireWeaponAction?.Invoke(); } if (InputSystem.WasKeyReleased(Keys.Space) && IsJumpButtonPressed()) { JumpAction?.Invoke(); //_jumpButtonIsPressed = true; } //else //{ // _jumpButtonIsPressed = false; //} if (IsSprintButtonPressed()) { FastRunActive?.Invoke(); } else { FastRunInactive?.Invoke(); } } StillUpdate?.Invoke(); if (InputSystem.IsAnyInputPressed()) { NotIdle?.Invoke(); } }