コード例 #1
0
    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);
        }
    }
コード例 #2
0
    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);
        }
    }
コード例 #3
0
    public void Execute(Player player)
    {
        if (Input.GetKey(KeyCode.Space))
        {
            JumpingPlayerState jumpingState = new JumpingPlayerState();
            jumpingState.Enter(player);
        }

        if (Input.GetKey(KeyCode.D))
        {
            KickingPlayerState kickingState = new KickingPlayerState();
            kickingState.Enter(player);
        }

        if (Input.GetKey(KeyCode.E))
        {
            PunchingPlayerState punchingState = new PunchingPlayerState();
            punchingState.Enter(player);
        }

        if (Input.GetKey(KeyCode.C))
        {
            FallingPlayerState fallingState = new FallingPlayerState();
            fallingState.Enter(player);
        }
    }
コード例 #4
0
    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);
        }
    }
コード例 #5
0
    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);
        }
    }
コード例 #6
0
 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);
     }
 }
コード例 #7
0
    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);
        }
    }
コード例 #8
0
    public void Execute(Player player)
    {
        if (!Input.GetKey(KeyCode.LeftShift))
        {
            // 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.Space))
        {
            JumpingPlayerState jumpingState = new JumpingPlayerState();

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

            jumpingState.Enter(player);
        }
    }
コード例 #9
0
    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);
    }
コード例 #10
0
    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);
        }
    }