Esempio n. 1
0
    // Use this for initialization
    IEnumerator Start()
    {
        // Cache the character script
        _character = GameObject.Find("character").GetComponent <CharacterLogic>();

        // Put the character near to the bed
        _character.transform.position = characterSpawnObject.position;
        _character.transform.rotation = characterSpawnObject.rotation;

        // Play the thud noise
        _character.audio.PlayOneShot(thudClip);

        // Set the looking camera to the current camera
        _character.lookingCamera = GameObject.Find("Main Camera").GetComponent <Camera>();

        // Give the character the bed game object
        _character.bed = GameObject.Find("Bed");

        // Disable the top light
        _character.topLight.enabled = false;

        // Change the character state
        _character.currentState = CharacterLogic.States.GettingUpFromGround;

        // Disable character input
        _character.inputEnabled = false;

        // Wait for the getting up animation to end
        yield return(StartCoroutine(WaitForState(_character, CharacterLogic.States.Idle)));

        // Wait before going to bed
        yield return(new WaitForSeconds(delayBeforeGoingToBed));

        // Make the character going to bed
        _character.currentState = CharacterLogic.States.GoingToBed;

        // Wait for the going to bed animation to end
        yield return(StartCoroutine(WaitForState(_character, CharacterLogic.States.InBed)));

        // Switch the the secondary camera
        mainCamera.SetActive(false);
        secondaryCamera.SetActive(true);

        // Wait some time before closing eyes
        yield return(new WaitForSeconds(eyeCloseDelay));

        // Make the character eyes closed
        _character.CloseEyes();
    }