void Update() { testVel = Velocity; // abstract out input float inputX = Input.GetAxisRaw("Horizontal"); if (inputX != 0) { SwitchState(State.Run); if (inputX < 0) { SwitchDir(Direction.Left); } else { SwitchDir(Direction.Right); } moveByXCommand.execute(this); } else { SwitchState(State.Idle); } if (Input.GetKeyDown(KeyCode.Space)) { JumpCommand j = new JumpCommand(); j.execute(this); } }
private void Jump() { JumpCommand jumpCommand = new JumpCommand(PlayerSettings.JumpForce, _heightAtJump); jumpCommand.execute(null, _player); _jumpCommands.Enqueue(jumpCommand); _player.PlaySound("jump"); }
private void Fall() { JumpCommand fallCommand = new JumpCommand(_currentFallForce, _heightAtJump); fallCommand.execute(null, _player); _jumpCommands.Enqueue(fallCommand); _currentFallForce += PlayerSettings.DefaultFallAcceleration; _currentTimer--; if (_player.IsGrounded() && _currentTimer <= 0 && !_undoActive) { _player.EnterState(new DefaultPlayerState()); } }
void Update() { testVel = Velocity; // abstract out input float inputX = Input.GetAxisRaw("Horizontal"); if (inputX != 0) { SwitchState(State.Run); if (inputX < 0) SwitchDir(Direction.Left); else SwitchDir(Direction.Right); moveByXCommand.execute(this); } else { SwitchState(State.Idle); } if (Input.GetKeyDown(KeyCode.Space)) { JumpCommand j = new JumpCommand(); j.execute(this); } }