예제 #1
0
    public void Execute(Player player)
    {
        if (player.onGround == true)
        {
            // transition to ducking
            StandingPlayerState standingState = new StandingPlayerState();

            Rigidbody rbPlayer = player.GetComponent <Rigidbody>();
            rbPlayer.transform.localScale = new Vector3(1, 1f, 1);

            standingState.Enter(player);
        }

        if (Input.GetKey(KeyCode.LeftShift))
        {
            DivingPlayerState divingState = new DivingPlayerState();
            divingState.Enter(player);
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            DoubleJumpPlayerState doubleJumpState = new DoubleJumpPlayerState();
            doubleJumpState.Enter(player);
        }
    }
 public void Execute(Player player)
 {
     if (Physics.Raycast(player.transform.position, Vector3.down, 0.55f))
     {
         StandingPlayerState standingState = new StandingPlayerState();
         standingState.Enter(player);
     }
     if (Input.GetKeyDown(KeyCode.S))
     {
         DivingPlayerState divingState = new DivingPlayerState();
         divingState.Enter(player);
     }
 }
    public void Execute(Player player)
    {
        // If hit the ground
        if (Physics.Raycast(player.transform.position, Vector3.down, 0.55f))
        {
            StandingPlayerState standingState = new StandingPlayerState();
            standingState.Enter(player);
        }

        // If presses S to dive
        if (Input.GetKeyDown(KeyCode.S))
        {
            // transition to diving
            DivingPlayerState divingState = new DivingPlayerState();
            divingState.Enter(player);
        }
    }
예제 #4
0
    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);
    }