Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.P))
        {
            if (pauseScreenOn)
            {
                pauseScreen.disableObject();
                Time.timeScale   = 1;
                Cursor.lockState = CursorLockMode.Locked;
                Cursor.visible   = false;
                pauseScreenOn    = false;
            }
            // pause the game
            else
            {
                pauseScreen.enableHiddenObject();
                //Time.timeScale = 0;
                Cursor.lockState = CursorLockMode.None;
                Cursor.visible   = true;
                pauseScreenOn    = true;
            }
        }

        // Movement is disallowed when we are talking to something
        if (!VD.isActive)
        {
            crosshair.enabled = true;
            movePlayer();
        }
        else
        {
            crosshair.enabled = false;
            walkingAudioClip.Stop();
        }

        // Deal with interactables
        // The current interactable will be stored in a variable "focus"

        findInteractable();
        if (!sceneManager.transitioning && Input.GetKeyDown(KeyCode.E))
        {
            interactWithFocus();
        }

        // Ch 2: make the UI disappear when reading the letter
        // and reappear when the letter is closed
        if (readable != null)
        {
            if (readable.isPlayerInteracting)
            {
                dialogueManager.SetPagesFoundUI(false);
            }
            else
            {
                dialogueManager.SetPagesFoundUI(true);
            }
        }

        // To continue dialogue, press return
        if (Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.Space))
        {
            //Debug.Log("next");
            if (VD.isActive)
            {
                VD.Next();
            }
        }

        if (Input.GetKeyDown(KeyCode.C))
        {
            setCrouch();
        }

        if (bIsCrouching)
        {
            smoothCrouching(-crouchOffset);
        }
        else
        {
            smoothCrouching(cameraHeight);
        }

        // For Chapter 3 (quick & dirty fix)
        // Initiate the dialogue right after we stopped interacting with the textbook
        // The dialogue will be attached to the Player for Chapter 3
        if (readable != null &&
            readable.Ch3_stoppedInteracting)
        {
            if (!VD.isActive)
            {
                VIDE_Assign dialogue = gameObject.GetComponent <VIDE_Assign>();
                dialogueManager.StartDialogue(dialogue);
                readable.Ch3_stoppedInteracting = false;
            }
        }

        if (diariesRead >= 5)
        {
            dialogueManager.SetPagesFoundUI(false);
        }
    }