IEnumerator CourtThePlayer()
    {
        //CourtThePlayer starts by setting the variable bCanTakeInput within
        //the CharacterController to false.
        cc.bCanTakeInput = false;
        //Then we update the rotation to look at the enemy using the
        //UpdateTheRot method within the CharacterController.
        cc.UpdateTheRot(gameObject.transform);

        //Next we delay the method for 5 seconds.
        yield return(new WaitForSeconds(5.0f));

        //And finally we load the end game screen. using the
        //LoadEndGame method from the Options Manager.
        om.LoadEndGame();
    }
Exemplo n.º 2
0
    void Update()
    {
        if (bCanTakeInput == true)
        {
            float Z = Input.GetAxis("Vertical") * movementSpeed;
            float X = Input.GetAxis("Horizontal") * movementSpeed;

            //in order to move at a smooth rate we need to multiply them by the time.deltatime.
            Z *= Time.deltaTime;
            X *= Time.deltaTime;

            //finally update the transform of the character.
            transform.Translate(X, 0, Z);


            //If we press Escape we need to reactivate the cursor.
            if (Input.GetKeyDown("escape"))
            {
                pauseMenu.SetActive(true);
                Cursor.lockState = CursorLockMode.None;
                Cursor.visible   = true;
                Time.timeScale   = 0.0f;
                bCanTakeInput    = false;
            }

            if (Input.GetKeyDown("e") && bCanSeePage == true)
            {
                pagesCollected++;
                page.GetComponent <sPages>().PickUpPage();
                enemy = GameObject.FindGameObjectWithTag("Enemy").GetComponent <sEnemyController>();
                enemy.SetWalkingSpeed(0.5f);
                page        = null;
                bCanSeePage = false;
            }

            if (Input.GetKey(KeyCode.LeftShift) && (Input.GetAxis("Vertical") != 0 || Input.GetAxis("Horizontal") != 0))
            {
                if (exausted != true)
                {
                    movementSpeed = 20.0f;
                    StartCoroutine(ChangeStamina(1, -1));
                    regen = false;
                    print(exausted);
                }
                else
                {
                }
            }
            if (Input.GetAxis("Vertical") == 0 && Input.GetAxis("Horizontal") == 0)
            {
                StartCoroutine(PlayWisper());
            }
            else
            {
                OtherSource.Stop();
            }


            if (Input.GetKeyUp(KeyCode.LeftShift) && exausted != true)
            {
                movementSpeed = 10.0f;
                regen         = true;
            }

            if (stamina <= 0)
            {
                exausted      = true;
                regen         = true;
                movementSpeed = 5.0f;
            }

            if (regen)
            {
                if (stamina < 10)
                {
                    StartCoroutine(PlayHeartbeat());
                    StartCoroutine(ChangeStamina(0.5f, 1));
                }
                else
                {
                    exausted      = false;
                    regen         = false;
                    movementSpeed = 10.0f;
                }
            }

            if (pagesCollected >= 10)
            {
                om.LoadEndGame();
            }
        }

        txtPages.text = ("" + pagesCollected);
    }