public void Execute(Player player) { if (Input.GetKeyDown(KeyCode.S)) { //transition to ducking DuckingPlayerState duckingState = new DuckingPlayerState(); duckingState.Enter(player); } if (Input.GetKeyDown(KeyCode.Space)) { JumpingPlayerState jumpingState = new JumpingPlayerState(); jumpingState.Enter(player); } if (Input.GetKeyDown(KeyCode.R)) { RedPlayerState redState = new RedPlayerState(); redState.Enter(player); } if (Input.GetKeyDown(KeyCode.B)) { BluePlayerState blueState = new BluePlayerState(); blueState.Enter(player); } }
public void Execute(Player player) { // If player presses s, transition to ducking if (Input.GetKeyDown(KeyCode.S)) { // transition to ducking DuckingPlayerState duckingState = new DuckingPlayerState(); duckingState.Enter(player); } // If player presses x, transition to Stone state if (Input.GetKeyDown(KeyCode.X)) { // transition to Stone StonePlayerState stoneState = new StonePlayerState(); stoneState.Enter(player); } // If presses space from standing, jump if (Input.GetKeyDown(KeyCode.Space)) { JumpingPlayerState jumpingState = new JumpingPlayerState(); jumpingState.Enter(player); } }
public void Execute(Player player) { //Debug.Log("Executing State: Standing"); if (Input.GetKeyDown(KeyCode.Space)) { // transition to jump JumpingPlayerState jumpingState = new JumpingPlayerState(); jumpingState.Enter(player); } if (Input.GetKeyDown(KeyCode.S)) { // transition to duck DuckingPlayerState duckingState = new DuckingPlayerState(); duckingState.Enter(player); } if (Input.GetKeyDown(KeyCode.D)) { DodgeRightPlayerState dodgeState = new DodgeRightPlayerState(); dodgeState.Enter(player); } if (Input.GetKeyDown(KeyCode.A)) { DodgeLeftPlayerState dodgeState = new DodgeLeftPlayerState(); dodgeState.Enter(player); } if (Input.GetKeyDown(KeyCode.X)) { DipPlayerState dipState = new DipPlayerState(); dipState.Enter(player); } }
public void Execute(Player player) { Rigidbody rbPlayer = player.GetComponent <Rigidbody>(); rbPlayer.AddForce(10, 0, 0); if (!Input.GetKey(KeyCode.D)) { StandingPlayerState standingState = new StandingPlayerState(); standingState.Enter(player); } if (Input.GetKey(KeyCode.D) && Input.GetKey(KeyCode.W)) { MoveDiagonalRightForwardPlayerState movingForwardRight = new MoveDiagonalRightForwardPlayerState(); movingForwardRight.Enter(player); } if (Input.GetKey(KeyCode.D) && Input.GetKey(KeyCode.S)) { MoveDiagonalRightBackwardsPlayerState movingBackwardsRight = new MoveDiagonalRightBackwardsPlayerState(); movingBackwardsRight.Enter(player); } if (Input.GetKey(KeyCode.LeftShift)) { // transition to ducking DuckingPlayerState duckingState = new DuckingPlayerState(); duckingState.Enter(player); } if (Input.GetKey(KeyCode.Space) && player.onGround == true) { JumpingPlayerState jumpingState = new JumpingPlayerState(); jumpingState.Enter(player); } }
public void Execute(Player player) { if (Physics.Raycast(rbPlayer.transform.position, Vector3.down, 0.55f)) { StandingPlayerState standingState = new StandingPlayerState(); standingState.Enter(player); } else if (Input.GetKeyDown(KeyCode.S)) { DuckingPlayerState duckState = new DuckingPlayerState(); rbPlayer.AddForce(0, -400 * Time.deltaTime, 0, ForceMode.VelocityChange); duckState.Enter(player); } }
public void Execute(Player player) { if (player.onGround == true) { if (Input.GetKeyDown(KeyCode.LeftShift)) { DuckingPlayerState duckingState = new DuckingPlayerState(); duckingState.Enter(player); } else { StandingPlayerState standingState = new StandingPlayerState(); standingState.Enter(player); } } }
public void Execute(Client player) { if (Input.GetMouseButton(0)) { DuckingPlayerState DuckingState = new DuckingPlayerState(); DuckingState.Enter(player); } if (Input.GetKey(KeyCode.Space)) { JumpingPlayerState jumpingState = new JumpingPlayerState(); jumpingState.Enter(player); } if (Input.GetKey(KeyCode.A) || Input.GetKey(KeyCode.D) || Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.S)) { MovingPlayerState movingState = new MovingPlayerState(); movingState.Enter(player); } }
public void Execute(Player player) { if (Input.GetKey(KeyCode.LeftShift)) { // transition to ducking DuckingPlayerState duckingState = new DuckingPlayerState(); duckingState.Enter(player); } if (Input.GetKey(KeyCode.W)) { MoveForwardPlayerState movingForward = new MoveForwardPlayerState(); movingForward.Enter(player); } if (Input.GetKey(KeyCode.S)) { MoveBackwardsPlayerState movingBackwards = new MoveBackwardsPlayerState(); movingBackwards.Enter(player); } if (Input.GetKey(KeyCode.D)) { MoveRightPlayerState movingRight = new MoveRightPlayerState(); movingRight.Enter(player); } if (Input.GetKey(KeyCode.A)) { MoveLeftPlayerState movingLeft = new MoveLeftPlayerState(); movingLeft.Enter(player); } if (Input.GetKey(KeyCode.Space) && player.onGround == true) { //player.onGround = false; JumpingPlayerState jumpingState = new JumpingPlayerState(); jumpingState.Enter(player); } }
public void Execute(Client player) { if (!Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.D) && !Input.GetKey(KeyCode.W) && !Input.GetKey(KeyCode.S)) { StandingPlayerState standingState = new StandingPlayerState(); standingState.Enter(player); } if (Input.GetMouseButton(0)) { DuckingPlayerState DuckingState = new DuckingPlayerState(); DuckingState.Enter(player); } if (Input.GetKey(KeyCode.Space)) { JumpingPlayerState jumpingState = new JumpingPlayerState(); jumpingState.Enter(player); } float horizontal = Input.GetAxisRaw("Horizontal"); float vertical = Input.GetAxisRaw("Vertical"); Vector3 direction = new Vector3(horizontal, 0, vertical); player.transform.Translate(direction.normalized * Time.deltaTime * mforce, Space.World); }
public void Execute(Client player) { if (Physics.Raycast(player.transform.position, Vector3.down, 0.55f)) { StandingPlayerState standingState = new StandingPlayerState(); standingState.Enter(player); } else if (Input.GetMouseButtonDown(1)) { DivingPlayerState DivingState = new DivingPlayerState(); DivingState.Enter(player); } else if (Input.GetMouseButton(0)) { DuckingPlayerState DuckingState = new DuckingPlayerState(); DuckingState.Enter(player); } float horizontal = Input.GetAxisRaw("Horizontal"); float vertical = Input.GetAxisRaw("Vertical"); Vector3 direction = new Vector3(horizontal, 0, vertical); player.transform.Translate(direction.normalized * Time.deltaTime * mforce, Space.World); }
public void Execute(Player player) { Rigidbody rbPlayer = player.GetComponent <Rigidbody>(); rbPlayer.AddForce(-10, 0, 10); if (!Input.GetKey(KeyCode.A) && Input.GetKey(KeyCode.W)) { MoveForwardPlayerState movingForward = new MoveForwardPlayerState(); movingForward.Enter(player); } if (!Input.GetKey(KeyCode.W) && Input.GetKey(KeyCode.A)) { MoveLeftPlayerState movingLeft = new MoveLeftPlayerState(); movingLeft.Enter(player); } if (!Input.GetKey(KeyCode.W) && !Input.GetKey(KeyCode.A)) { StandingPlayerState standingState = new StandingPlayerState(); standingState.Enter(player); } if (Input.GetKey(KeyCode.LeftShift)) { // transition to ducking DuckingPlayerState duckingState = new DuckingPlayerState(); duckingState.Enter(player); } if (Input.GetKey(KeyCode.Space) && player.onGround == true) { JumpingPlayerState jumpingState = new JumpingPlayerState(); jumpingState.Enter(player); } }