Exemple #1
0
    private void HandleInput(UserInput button, InputState state)
    {
        if (state == InputState.Ingame)
        {
            //Check for human control before executing any action
            if (SwitchControl.ControlledCharacter.identification == Entity.Human)
            {
                switch (button)
                {
                case UserInput.R2:
                    //Switch the currently equipped item one to the right
                    if (!currentlyChanging)
                    {
                        StartCoroutine(ChangeGadget(Direction.Right));
                    }
                    break;

                case UserInput.L2:
                    //Switch the currently equipped item one to the left
                    if (!currentlyChanging)
                    {
                        StartCoroutine(ChangeGadget(Direction.Left));
                    }
                    break;

                case UserInput.B:
                    //Execute the current item's action
                    storedGadgets[currentlyEquippedGadgetIndex].Execute();
                    break;
                }
            }
            else if (SwitchControl.ControlledCharacter.identification == Entity.Dog)
            {
                //If the controlled character is the dog, the only action the player can take is using the dog's jaw
                switch (button)
                {
                case UserInput.B:
                    //We play the animation of the dog picking up something only if there was a successful invocation
                    if (jaw.Execute())
                    {
                        Animator dogAnim = GameInstance.GetInstance().Player_Components.dog.GetComponent <Animator>();
                        if (dogAnim.GetCurrentAnimatorStateInfo(0).IsTag("GroundedState"))
                        {
                            dogAnim.SetTrigger("PickUp");
                        }
                    }
                    break;
                }
            }
        }
    }