コード例 #1
0
    void Update()
    {
        if (singleton == null)
        {
            singleton = offscreen.singleton;
        }

        if (!beginTimer && singleton.currentTake.name == "end")
        {
            beginTimer = true;
        }
        if (beginTimer)
        {
            if (timer > animStartTime)
            {
                if (!lerpStarted && !lerpFinished)
                {
                    portraitGradePoint  = singleton.takes[1].gazeZones[0].time / 120f;
                    landscapeGradePoint = singleton.takes[1].gazeZones[1].time / 120f;

                    if (portraitGradePoint < 0.5f)
                    {
                        portraitGradeMat.SetTexture("_MainTex", f);
                    }
                    else if (portraitGradePoint >= 0.5f && portraitGradePoint < 0.6f)
                    {
                        portraitGradeMat.SetTexture("_MainTex", d);
                    }
                    else if (portraitGradePoint >= 0.6f && portraitGradePoint < 0.7f)
                    {
                        portraitGradeMat.SetTexture("_MainTex", c);
                    }
                    else if (portraitGradePoint >= 0.7f && portraitGradePoint < 0.8f)
                    {
                        portraitGradeMat.SetTexture("_MainTex", b);
                    }

                    landscapeGrade.transform.localPosition += Vector3.Scale(Random.insideUnitSphere, new Vector3(0.01f, 0.01f, 0f));
                    portraitGrade.transform.localPosition  += Vector3.Scale(Random.insideUnitSphere, new Vector3(0.01f, 0.01f, 0f));

                    landscapeGrade.transform.localScale = landscapeGrade.transform.localScale * Random.Range(0.95f, 1.05f);
                    portraitGrade.transform.localScale  = landscapeGrade.transform.localScale * Random.Range(0.95f, 1.05f);

                    landscapeGrade.transform.Rotate(Vector3.forward * Random.Range(-10f, 10f));
                    portraitGrade.transform.Rotate(Vector3.forward * Random.Range(-10f, 10f));

                    card.SetActive(true);
                    lerpStarted = true;
                }

                else
                {
                    card.transform.localPosition = Vector3.Slerp(cardOffset, Vector3.zero, lerpTimer / lerpInterval);
                    lerpTimer += Time.deltaTime;

                    if (lerpTimer > lerpInterval)
                    {
                        lerpFinished = true;
                    }
                }
            }

            timer += Time.deltaTime;
        }

        if (lerpFinished && timer > 25f)
        {
            UnityEngine.SceneManagement.SceneManager.LoadScene(0);
        }
    }
コード例 #2
0
    void Update()
    {
        if (singleton == null)
        {
            singleton = offscreen.singleton;
        }
        else
        {
            if (landscapeMainSource == null)
            {
                landscapeMainSource      = singleton.currentTake.actors[0].mainAudioSource;
                landscapeSecondarySource = singleton.currentTake.actors[0].secondaryAudioSource;
                landscapeJabs            = singleton.currentTake.actors[0].secondaryAudioClips;

                portraitMainSource      = singleton.currentTake.actors[1].mainAudioSource;
                portraitSecondarySource = singleton.currentTake.actors[1].secondaryAudioSource;
                portraitJabs            = singleton.currentTake.actors[1].secondaryAudioClips;
            }
            else
            {
                if (lessonStarted && lessonTimeElapsed < lessonEndTime)
                {
                    if (landscapePlayingJab && !landscapeSecondarySource.isPlaying)                             //#TODO: This
                    {
                        landscapePlayingJab = false; rampLandscapeDown = false; rampLandscapeUp = true;
                    }

                    if (portraitPlayingJab && !portraitSecondarySource.isPlaying)
                    {
                        portraitPlayingJab = false; rampPortraitDown = false; rampPortraitUp = true;
                    }

                    if (rampLandscapeDown)
                    {
                        landscapeMainSource.volume = Mathf.Lerp(1f, 0f, lsDownFloat / rampTime);
                        lsDownFloat += Time.deltaTime;

                        if (lsDownFloat > rampTime)
                        {
                            rampLandscapeDown = false; lsDownFloat = 0f;
                        }
                    }

                    if (rampLandscapeUp)
                    {
                        landscapeMainSource.volume = Mathf.Lerp(0f, 1f, lsUpFloat / rampTime);
                        lsUpFloat += Time.deltaTime;

                        if (lsUpFloat > rampTime)
                        {
                            rampLandscapeUp = false; lsUpFloat = 0f;
                        }
                    }

                    if (rampPortraitDown)
                    {
                        portraitMainSource.volume = Mathf.Lerp(1f, 0f, ptDownFloat / rampTime);
                        ptDownFloat += Time.deltaTime;

                        if (ptDownFloat > rampTime)
                        {
                            rampPortraitDown = false; ptDownFloat = 0f;
                        }
                    }

                    if (rampPortraitUp)
                    {
                        portraitMainSource.volume = Mathf.Lerp(0f, 1f, ptUpFloat / rampTime);
                        ptUpFloat += Time.deltaTime;

                        if (ptUpFloat > rampTime)
                        {
                            rampPortraitUp = false; ptUpFloat = 0f;
                        }
                    }

                    if (!singleton.gazeZones[1].active && timeSinceLastJab > minimumTimeBetweenJabs && Random.value > 0.99f)
                    {
                        Debug.Log("make jab: landscape making jab");

                        landscapeMainSource.volume = 0f;

                        int currentJabIndex;
                        do
                        {
                            currentJabIndex = Random.Range(0, landscapeJabs.Length - 1);
                        }while (currentJabIndex == lastLandscapeJabIndex);

                        lastLandscapeJabIndex = currentJabIndex;

                        landscapeSecondarySource.clip = landscapeJabs[currentJabIndex];
                        landscapeSecondarySource.Play();

                        landscapePlayingJab = true; rampLandscapeDown = true;
                        timeSinceLastJab    = 0f;
                    }

                    else if (!singleton.gazeZones[0].active && timeSinceLastJab > minimumTimeBetweenJabs && Random.value > 0.99f)
                    {
                        Debug.Log("make jab: portrait making jab");

                        portraitMainSource.volume = 0f;

                        int currentJabIndex;
                        do
                        {
                            currentJabIndex = Random.Range(0, portraitJabs.Length - 1);
                        }while (currentJabIndex == lastPortraitJabIndex);

                        lastPortraitJabIndex = currentJabIndex;

                        portraitSecondarySource.clip = portraitJabs[currentJabIndex];
                        portraitSecondarySource.Play();

                        portraitPlayingJab = true; rampPortraitDown = true;
                        timeSinceLastJab   = 0f;
                    }

                    timeSinceLastJab  += Time.deltaTime;
                    lessonTimeElapsed += Time.deltaTime;
                }

                else
                {
                    if (!lessonStarted && singleton.currentTakeIndex == 1)
                    {
                        lessonStarted = true;
                    }
                    if (lessonStarted && !lessonConcluded)
                    {
                        portraitMainSource.volume = landscapeMainSource.volume = 1f; lessonConcluded = true;
                    }
                }
            }
        }
    }
コード例 #3
0
    void Start()
    {
        if (offscreen.singleton == null)
        {
            offscreen.singleton = this;
        }                                                                          //Define this instance as the singleton variable
        else
        {
            GameObject.Destroy(this);
        }

        /*
         * Scene property setup
         */

        takes = new take[sequence.Length];         //Set up the takes

        for (int i = 0; i < sequence.Length; i++)
        {
            int fixedIndex =             //Make sure the take index actually fits the take pool's array boundaries
                             Mathf.Max(0, Mathf.Min(sequence[i].selectedTakeIndex, sequence[i].takes.Length - 1));

            takes[i]      = sequence[i].takes[fixedIndex]; //Set each take in the take array as the one chosen from the take pool ('sequence' variable)
            takes[i].skip = sequence[i].skip;              //Transfer properties
            takes[i].name = sequence[i].name;

            if (debug)
            {
                Debug.Log("take manager: " + takes[i].name + " skip value " + takes[fixedIndex].skip);
            }
        }

        while (takes[currentTakeIndex].skip)
        {
            currentTakeIndex++;
        }                                                                       //Set the current take as the first in the take array that doesn't have a skip flag
        currentTake = takes[currentTakeIndex];

        /*
         * Scene object setup
         */

        actorsDummy      = new GameObject();    //Just to keep the Inspector hierachy organized
        actorsDummy.name = "actors";

        player.playOnAwake       = false;
        player.loopPointReached += advanceTake;         //Move on to the next take when the video clip ends

        gazeZones   = currentTake.gazeZones;
        player.clip = currentTake.video;
        player.Prepare();

        //Animation setup

        for (int i = 0; i < currentTake.actors.Length; i++)
        {
            if (currentTake.actors[i].animation.Length > 0)
            {
                currentTake.actors[i].keyframeStartPosition = currentTake.actors[i].position;
                currentTake.actors[i].currentKeyframe       = currentTake.actors[i].animation[0];           //Load the first keyframe
                currentTake.actors[i].frameDuration         = currentTake.actors[i].currentKeyframe.time;   //Since we're at 0s, duration = time
            }
        }
    }