コード例 #1
0
    public void Execute(Player player)
    {
        Rigidbody rb = player.GetComponent <Rigidbody>();

        rb.velocity = new Vector3(player.speed, 0, 0);
        // Put all key checks into State functions - this gets run every frame the state is active - no need for switch
        if (Input.GetKeyUp(KeyCode.W))
        {
            Standing standing = new Standing();
            standing.Enter(player);
        }
        if (Input.GetKeyDown(KeyCode.Space))
        {
            LongJump lJump = new LongJump();
            lJump.Enter(player);
        }
        if (Input.GetKeyDown(KeyCode.S))
        {
            Sliding slide = new Sliding();
            slide.Enter(player);
        }
    }