Пример #1
0
    private void Update()
    {
        // freeze player when playing dialogue
        if (InkDialogueManager.GetInstance().dialogueIsPlaying)
        {
            actionFreeze = true;
            animator.SetBool("isWalking", false);
        }
        else
        {
            actionFreeze = false;
        }

        if (!actionFreeze)
        {
            horizontalInput = Input.GetAxisRaw("Horizontal");
            if (animator != null)
            {
                if (Mathf.Abs(horizontalInput) > 0.01f)
                {
                    animator.SetBool("isWalking", true);
                }
                else
                {
                    animator.SetBool("isWalking", false);
                }
            }

            if (horizontalInput < 0 && !sprite.flipX)
            {
                sprite.flipX = true;
            }
            if (horizontalInput > 0 && sprite.flipX)
            {
                sprite.flipX = false;
            }


            if (Input.GetKeyDown(KeyCode.I))
            {
                showInventory = !showInventory;
                uiInventory.gameObject.SetActive(showInventory);
            }
            if (enterInteractable && !InkDialogueManager.GetInstance().dialogueIsPlaying)
            {
                if (Input.GetKeyDown(KeyCode.E))
                {
                    if (interactItem)
                    {
                        interactItem.TriggerDialogue();

                        if (interactItem.destroyOnInteract)
                        {
                            interactItem.DestroySelf();
                        }
                        //interactItem.SetInteractable(false);// disable object after interation
                        interactItem      = null;
                        enterInteractable = false;
                    }

                    uiManager.HideInteractPrompt();
                }
            }
        }
    }