Example #1
0
    //tutorial: tells player what to do, waits for action of player (moving, shooting, teleporting, switching orbs)
    private IEnumerator Introduction()
    {
        float delay = 1.0f;

        yield return(new WaitForSeconds(5.0f));

        companion.StartSpeaking(audioClips[0]);
        yield return(new WaitForSeconds(audioClips[0].length + delay));

        InvokeRepeating("CompanionSayImHere", 5.0f, 5.0f);

        while (!companion.IsVisibleByAnyCamera())
        {
            yield return(null);
        }

        CancelInvoke("CompanionSayImHere");

        yield return(new WaitForSeconds(1.0f));

        companion.StartSpeaking(audioClips[2]);
        yield return(new WaitForSeconds(audioClips[2].length + delay));

        Vector3 lastCameraPosition = Camera.main.transform.position;

        do
        {
            yield return(new WaitForSeconds(1.0f));
        } while (lastCameraPosition == Camera.main.transform.position);

        companion.StartSpeaking(audioClips[3]);
        yield return(new WaitForSeconds(audioClips[3].length + delay));

        Vector3 orbPosition = companion.transform.position + companion.transform.forward;

        orbPosition.y = 1.5f;
        paintOrb.transform.position = orbPosition;
        paintOrb.SetActive(true);
        while (!paintOrb.taken)
        {
            yield return(new WaitForSeconds(1.0f));
        }

        companion.StartSpeaking(audioClips[4]);
        yield return(new WaitForSeconds(audioClips[4].length + delay));

        VRPlayerController vrPlayerController = player.GetComponent <VRPlayerController>();

        if (vrPlayerController != null)
        {
            vrPlayerController.SetTriggerHintActive(true);
        }

        do
        {
            yield return(new WaitForSeconds(1.0f));
        } while (!paintOrbWasShot);

        if (vrPlayerController != null)
        {
            vrPlayerController.SetTriggerHintActive(false);
        }

        companion.StartSpeaking(audioClips[5]);
        yield return(new WaitForSeconds(audioClips[5].length + delay));

        orbPosition   = companion.transform.position + companion.transform.forward;
        orbPosition.y = 1.5f;
        teleportOrb.transform.position = orbPosition;
        teleportOrb.SetActive(true);
        while (!teleportOrb.taken)
        {
            yield return(new WaitForSeconds(1.0f));
        }

        yield return(new WaitForSeconds(1.0f));

        firstDoor.OpenDoor();
        yield return(new WaitForSeconds(1.0f));

        companion.StartSpeaking(audioClips[6]);
        yield return(new WaitForSeconds(audioClips[6].length + delay));

        companion.SetAutoFollow(true);

        do
        {
            yield return(new WaitForSeconds(1.0f));
        } while (!teleportOrbWasShot);

        yield return(new WaitForSeconds(1.0f));

        companion.StartSpeaking(audioClips[7]);
        yield return(new WaitForSeconds(audioClips[7].length + delay));

        orbChanged = false;

        if (vrPlayerController != null)
        {
            vrPlayerController.SetTouchpadHintActive(true);
        }

        do
        {
            yield return(new WaitForSeconds(1.0f));
        } while (!orbChanged);

        if (vrPlayerController != null)
        {
            vrPlayerController.SetTouchpadHintActive(false);
        }

        companion.StartSpeaking(audioClips[8]);
        yield return(new WaitForSeconds(audioClips[8].length + delay));

        yield return(new WaitForSeconds(1.0f));

        secondDoor.OpenDoor();
        yield return(new WaitForSeconds(1.0f));

        companion.StartSpeaking(audioClips[9]);
        yield return(new WaitForSeconds(audioClips[9].length));

        companion.SetIdle(true);
        yield return(null);
    }