Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        //management of interruptable actions (mostly walk to a new place while walking towards another destination)
        if (canMove)
        {
            checkForMoveCommand();

            //if the player is trying to use an item on something else, we control where the raycast hits
            if (selectedItem != null)
            {
                //checkForUseObject();

                checkForSecondaryAction();
            }
        }
        //management of actions not interruptable by walking
        else
        {
            //if the player is trying to use an item on something else, we control where the raycast hits
            if (selectedItem != null)
            {
                //checkForUseObject();

                checkForSecondaryAction();
            }
        }

        //if we have to move to target
        if (move)
        {
            goToTarget();
        }

        //ANIMATOR CODE
        if (move)
        {
            if (target.x > transform.position.x)
            {
                animator.SetBool("isMovingLeft", false);
            }
            else
            {
                animator.SetBool("isMovingLeft", true);
            }

            animator.SetBool("isMoving", true);
        }
        else
        {
            animator.SetBool("isMoving", false);
        }

        //EXIT PROMPT
        if (Input.GetKeyUp(KeyCode.Escape))
        {
            exitGui.Activate();
        }
    }