Beispiel #1
0
    void PlayTutorial()
    {
        WaveInfo waveInfo = new WaveInfo
        {
            minNumberOfBoxes     = 1,
            maxNumberOfBoxes     = 2,
            minNumberOfDecals    = 1,
            maxNumberOfDecals    = 2,
            spawnAfterSeconds    = 0.0f,
            canSpawnGarbage      = false,
            canSpawnCrossedLabel = false
        };

        StartCoroutine(Coroutines.Chain(
                           Coroutines.Wait(2.0f),
                           tutorialCanvas.DisplayText("Hello!", 3.0f),
                           Coroutines.Wait(1.0f),
                           tutorialCanvas.DisplayText("Welcome to \"Rooster Express, Inc.\" We hope that you enjoy this job as much as we enjoy having you here!", 5.5f),
                           Coroutines.Wait(1.0f),
                           tutorialCanvas.DisplayText("Your job here will consist in picking up packages from that place over there and putting them in these conveyor belts...", 5.5f),
                           Coroutines.Wait(1.0f),
                           tutorialCanvas.DisplayText("But you have to make sure they go in the right conveyor, or some clients won't receive their packages in time.", 5.5f),
                           Coroutines.Wait(1.0f),
                           Coroutines.Join(
                               tutorialCanvas.DisplayText("Look, let's try it...", 2.0f),
                               Coroutines.Wrap(() => spawner.SpawnBoxes(waveInfo))),
                           Coroutines.Wait(2.5f),
                           Coroutines.Wrap(() => CreateTutorialBoxSpawnAndDeliver(waveInfo))
                           ));
    }
Beispiel #2
0
 private void CreateTutorialBoxSpawnAndDeliver(WaveInfo waveInfo)
 {
     StartCoroutine(Coroutines.Chain(
                        _CreateTutorialBoxSpawnAndDeliver(waveInfo),
                        Coroutines.Wrap(() =>
     {
         if (!gm.playerCompletedFirstTaskSuccessful)
         {
             gm.playerCompletedFirstTask = false;
             StartCoroutine(Coroutines.Chain(
                                Coroutines.Join(
                                    Coroutines.Wait(2.0f),
                                    tutorialCanvas.DisplayText("... Ok, let's try again.", 2.0f),
                                    Coroutines.Wrap(() => spawner.SpawnBoxes(waveInfo))),
                                Coroutines.Wait(3.0f),
                                Coroutines.Wrap(() => CreateTutorialBoxSpawnAndDeliver(waveInfo))
                                ));
             return;
         }
         else
         {
             StartCoroutine(Coroutines.Chain(
                                tutorialCanvas.DisplayText("Good job!", 2.0f),
                                Coroutines.Wrap(() => CreateTutorialDifferentDisplayGarbage())
                                ));
         }
     })));
 }
Beispiel #3
0
 public IEnumerator DisplayCommand(string text)
 {
     return(Coroutines.Chain(
                Coroutines.Join(
                    Coroutines.Wrap(() => commandtext.text = text),
                    Coroutines.FadeAlpha01(commandtext, textFadeTime)
                    )));
 }
 IEnumerator CoroutineEndFail()
 {
     return(Coroutines.Chain(
                Coroutines.Wait(2.0f),
                DisplayText("Well... that was a disaster. You are fired.", 4.0f),
                Coroutines.Wait(1.0f),
                Coroutines.Wrap(() => statisticsCanvas.gameObject.SetActive(true))));
 }
Beispiel #5
0
 public void PlayAgain()
 {
     StartCoroutine(
         Coroutines.Chain(
             Coroutines.Join(
                 Coroutines.FadeVolume(bgMusic, 1.0f, 0.0f),
                 Coroutines.FadeAlpha01(fadePanel, 1.0f)),
             Coroutines.Wrap(() => SceneManager.LoadScene("MapScene"))));
 }
 IEnumerator CoroutineEndOk()
 {
     return(Coroutines.Chain(
                Coroutines.Join(
                    Coroutines.Wrap(() => spawner.SpawnBoxes(500, 0.01f)),
                    DisplayText("You think you are good at your job? Let's see how you handle THIS...", 4.0f)),
                Coroutines.Wait(2.0f),
                DisplayText("... Oh, wait, your turn is over. Don't worry, someone else will pick this up. See you tomorrow...", 6.0f),
                Coroutines.Wait(1.0f),
                Coroutines.Wrap(() => statisticsCanvas.gameObject.SetActive(true))));
 }
    public void TurnRed(Light threadmillLight)
    {
        // GLOBAL LIGHTS

        if (globalLightsCoroutine != null)
        {
            StopCoroutine(globalLightsCoroutine);
        }

        List <IEnumerator> fadeToRedCoroutines       = new List <IEnumerator>();
        List <IEnumerator> fadeBackFromRedCoroutines = new List <IEnumerator>();

        fadeToRedCoroutines.Add(
            Coroutines.FadeColor(directionalLight, 0.5f, directionalLight.color, Color.red));

        fadeBackFromRedCoroutines.Add(
            Coroutines.FadeColor(directionalLight, 0.5f, Color.red, GetDefaultColor(directionalLight)));

        for (int i = 0; i < pointLights.Length; i++)
        {
            fadeToRedCoroutines.Add(
                Coroutines.FadeColor(pointLights[i], 0.5f, pointLights[i].color, Color.red));

            fadeBackFromRedCoroutines.Add(
                Coroutines.FadeColor(pointLights[i], 0.5f, Color.red, GetDefaultColor(pointLights[i])));
        }

        globalLightsCoroutine = CoroutineSingleton.Instance.StartCoroutine(Coroutines.Chain(
                                                                               Coroutines.Join(fadeToRedCoroutines.ToArray()),
                                                                               Coroutines.Wait(1.0f),
                                                                               Coroutines.Join(fadeBackFromRedCoroutines.ToArray())));

        // TREADMILL LIGHT

        if (treadmillLightsCoroutine.ContainsKey(threadmillLight) && treadmillLightsCoroutine[threadmillLight] != null)
        {
            StopCoroutine(treadmillLightsCoroutine[threadmillLight]);
        }

        Renderer r = threadmillLight.transform.parent.GetComponent <Renderer>();

        treadmillLightsCoroutine[threadmillLight] = StartCoroutine(Coroutines.Chain(
                                                                       Coroutines.Join(
                                                                           Coroutines.FadeColor(threadmillLight, 0.5f, threadmillLight.color, Color.red),
                                                                           // Coroutines.FadeColor(r.material, "_Color", 0.5f, Color.white, new Color(255, 89, 89) / 255.0f),
                                                                           Coroutines.FadeColor(r.material, "_EmissionColor", 0.5f, Color.black, Color.red)),
                                                                       Coroutines.Wait(1.0f),
                                                                       Coroutines.Join(
                                                                           Coroutines.FadeColor(threadmillLight, 0.5f, Color.red, GetDefaultColor(threadmillLight)),
                                                                           // Coroutines.FadeColor(r.material, "_Color", 0.5f, new Color(255, 89, 89) / 255.0f, Color.white),
                                                                           Coroutines.FadeColor(r.material, "_EmissionColor", 0.5f, Color.red, Color.black))));
    }
Beispiel #8
0
 public IEnumerator DisplayText(string text, float length)
 {
     return(Coroutines.Chain(
                Coroutines.Join(
                    Coroutines.Wrap(() => screen.Talk()),
                    Coroutines.Wrap(() => tutorialText.text = text),
                    Coroutines.FadeAlpha01(tutorialText, textFadeTime)
                    ),
                Coroutines.Wait(length),
                Coroutines.Join(
                    Coroutines.FadeAlpha10(tutorialText, textFadeTime),
                    Coroutines.Wrap(() => screen.Relaxed()))
                ));
 }
 IEnumerator DisplayText(string text, float length)
 {
     return(Coroutines.Chain(
                Coroutines.Join(
                    Coroutines.Wrap(() => bossScreen.Talk()),
                    Coroutines.Wrap(() => bossText.text = text),
                    Coroutines.FadeAlpha01(bossText, 0.5f)
                    ),
                Coroutines.Wait(length),
                Coroutines.Join(
                    Coroutines.FadeAlpha10(bossText, 0.5f),
                    Coroutines.Wrap(() => bossScreen.Relaxed()))
                ));
 }
Beispiel #10
0
    private IEnumerator _CreateTutorialBoxSpawnAndDeliver(WaveInfo waveInfo)
    {
        return(Coroutines.Chain(

                   Coroutines.IfCondition(

                       x => !gm.playerGrabbedFirstBox,

                       Coroutines.Chain(
                           tutorialCanvas.DisplayCommand("Pick up that box to continue [LeftMouseClick or the \"A\" button]."),
                           Coroutines.WaitFor(x => gm.playerGrabbedFirstBox),
                           Coroutines.Join(
                               tutorialCanvas.HideCommand(),
                               tutorialCanvas.DisplayText("Good job!", 3.0f)))),

                   Coroutines.IfCondition(

                       x => !gm.playerInspectedFirstBox,

                       Coroutines.Chain(
                           tutorialCanvas.DisplayText("As you know, out city is distributed in districts. Each one of these conveyors...", 4.0f),
                           tutorialCanvas.DisplayText("... delivers to a specific district. The district info can be found in the package labels.", 5.0f),
                           tutorialCanvas.DisplayText("Now please, pay attention to the box.", 2.0f),
                           tutorialCanvas.DisplayCommand(
                               "Inspect the box to continue [RightMouseClick or the \"B\" button]."),

                           Coroutines.WaitFor(x => gm.playerInspectedFirstBox || gm.playerCompletedFirstTask),
                           Coroutines.IfCondition(
                               x => !gm.playerCompletedFirstTask,

                               Coroutines.Join(
                                   Coroutines.Chain(
                                       tutorialCanvas.HideCommand(),
                                       tutorialCanvas.DisplayCommand("Zoom in / out [MouseScrollWheel or the Left/right triggers].")),

                                   Coroutines.Chain(
                                       tutorialCanvas.DisplayText("Good job!", 2.0f),
                                       tutorialCanvas.DisplayText("But be careful, because sometimes the packages are redirected and have to go through another district.", 5.0f)))))),

                   Coroutines.IfCondition(

                       x => !gm.playerCompletedFirstTask,

                       Coroutines.Chain(
                           Coroutines.Wait(0.5f),
                           tutorialCanvas.DisplayCommand("Drop it in the correct conveyor"),
                           Coroutines.WaitFor(x => gm.playerCompletedFirstTask),
                           tutorialCanvas.HideCommand()))));
    }
Beispiel #11
0
    private IEnumerator _CreateTutorialDifferentDisplayGarbage()
    {
        return(Coroutines.Chain(
                   Coroutines.IfCondition(
                       x => !gm.tutorialDifferentDisplaysExplained,

                       Coroutines.Chain(
                           tutorialCanvas.DisplayText("Sometimes we also deliver based on priorities. Look at the screens above the conveyors...", 5.0f),
                           Coroutines.Wrap(() => gm.SwapDisplays()),
                           Coroutines.Wait(5.0f),
                           Coroutines.Wrap(() => gm.tutorialDifferentDisplaysExplained = true))),

                   tutorialCanvas.DisplayCommand("Drop it in the correct conveyor [LeftMouseClick or the \"A\" button]."),
                   Coroutines.WaitFor(x => gm.playerCompletedSecondtask),
                   tutorialCanvas.HideCommand()));
    }
 public void SwapDisplay(int index)
 {
     StartCoroutine(Coroutines.Chain(
                        Coroutines.BlinkFastFast(screen.material, "_Color", 4.0f, 0.5f, 0.01f),
                        Coroutines.Wrap(() =>
     {
         this.index = index;
         if (displayingDistrict)
         {
             screen.material = matPriority[index];
         }
         else
         {
             screen.material = matDistrict[index];
         }
         displayingDistrict = !displayingDistrict;
     }
                                        )));
 }
    public void TurnGreen(Light threadmillLight)
    {
        Renderer r = threadmillLight.transform.parent.GetComponent <Renderer>();

        if (treadmillLightsCoroutine.ContainsKey(threadmillLight) && treadmillLightsCoroutine[threadmillLight] != null)
        {
            StopCoroutine(treadmillLightsCoroutine[threadmillLight]);
        }

        treadmillLightsCoroutine[threadmillLight] = StartCoroutine(Coroutines.Chain(
                                                                       Coroutines.Join(
                                                                           Coroutines.FadeColor(threadmillLight, 0.5f, threadmillLight.color, Color.green),
                                                                           // Coroutines.FadeColor(r.material, "_Color", 0.5f, Color.white, new Color(255, 89, 89) / 255.0f),
                                                                           Coroutines.FadeColor(r.material, "_EmissionColor", 0.5f, r.material.GetColor("_EmissionColor"), Color.green)),
                                                                       Coroutines.Wait(1.0f),
                                                                       Coroutines.Join(
                                                                           Coroutines.FadeColor(threadmillLight, 0.5f, Color.green, GetDefaultColor(threadmillLight)),
                                                                           // Coroutines.FadeColor(r.material, "_Color", 0.5f, new Color(255, 89, 89) / 255.0f, Color.white),
                                                                           Coroutines.FadeColor(r.material, "_EmissionColor", 0.5f, Color.green, Color.black))));
    }
Beispiel #14
0
    public void StartGame()
    {
        playerCompletedFirstTask  = true;
        playerCompletedSecondtask = true;
        playerCompletedThirdTask  = true;

        for (int i = 0; i < deliveriesWithoutGarbage.Length; i++)
        {
            deliveriesWithoutGarbage[i].District(i);
        }

        waveSpawner.gameObject.SetActive(true);
        gameCanvas.gameObject.SetActive(true);

        bgMusic.Play();

        waveSpawner.BeginWaves();

        StartCoroutine(Coroutines.Chain(
                           Coroutines.Wait(0.1f),
                           Coroutines.Wrap(() => gameStarted = true)));
    }
Beispiel #15
0
    private void CreateTutorialDifferentDisplayGarbage()
    {
        gm.playerCompletedFirstTask = true;

        WaveInfo waveInfo = new WaveInfo
        {
            minNumberOfBoxes     = 1,
            maxNumberOfBoxes     = 2,
            minNumberOfDecals    = 1,
            maxNumberOfDecals    = 2,
            spawnAfterSeconds    = 0.0f,
            canSpawnGarbage      = false,
            canSpawnCrossedLabel = false,
            districtCode         = "B"
        };

        WaveInfo garbage = new WaveInfo
        {
            minNumberOfBoxes     = 1,
            maxNumberOfBoxes     = 2,
            minNumberOfDecals    = 1,
            maxNumberOfDecals    = 2,
            spawnAfterSeconds    = 0.0f,
            canSpawnGarbage      = true,
            canSpawnCrossedLabel = false,
            districtCode         = "E"
        };

        StartCoroutine(Coroutines.Chain(
                           Coroutines.Wrap(() => spawner.SpawnBoxes(waveInfo)),
                           _CreateTutorialDifferentDisplayGarbage(),
                           Coroutines.Wrap(() =>
        {
            if (!gm.playerCompletedSecondTaskSuccessful)
            {
                gm.playerCompletedSecondtask = false;
                StartCoroutine(Coroutines.Chain(
                                   Coroutines.Wait(2.0f),
                                   tutorialCanvas.DisplayText("... Ok, let's try again.", 2.0f),
                                   Coroutines.Wait(1.0f),
                                   Coroutines.Wrap(() => CreateTutorialDifferentDisplayGarbage())
                                   ));
                return;
            }
            else
            {
                StartCoroutine(Coroutines.Chain(
                                   Coroutines.Join(
                                       Coroutines.Wrap(() => spawner.SpawnBoxes(garbage)),
                                       tutorialCanvas.DisplayText("Good job!", 3.5f)),

                                   tutorialCanvas.DisplayText("Now...", 3.0f),

                                   tutorialCanvas.DisplayText("... How did that got here? Please, get rid of any goods you find that are not properly labeled.", 5.0f),

                                   Coroutines.WaitFor(x => gm.playerCompletedThirdTask),

                                   Coroutines.IfCondition(
                                       x => !gm.playerCompletedThirdTaskSuccessful,
                                       tutorialCanvas.DisplayText("Oh god...", 2.0f)),

                                   tutorialCanvas.DisplayText("Congratulations! You've passed the trial period with great results.", 4.0f),
                                   tutorialCanvas.DisplayText("And because of that, we are going to heat the things up a little bit.", 4.0f),
                                   tutorialCanvas.DisplayText("Oh, and by the way - I don't like messes. So keep this place in order or you are fired.", 5.0f),
                                   Coroutines.Wrap(() => EndTutorial())));
            }
        })));
    }
Beispiel #16
0
    public static void FadeScreen(FadingScreenParams screenParams, FadingAudioParams audioParams = null)
    {
        if (audioParams == null)
        {
            audioParams = new FadingAudioParams();
        }

        Image fadePanel = FadeCanvasSingleton.Instance.FadePanel;

        List <IEnumerator> actions = new List <IEnumerator>();

        // --- ENABLE FADE PANEL ---

        actions.Add(Coroutines.Wrap(() => fadePanel.gameObject.SetActive(true)));

        // --- FADING OUT ---

        float screenFadeOutTime = screenParams.fadeOutTime;

        IEnumerator fadeOutScreen = Coroutines.FadeAlpha01(fadePanel, screenFadeOutTime);

        if (audioParams.fadeOut)
        {
            float audioFadeOutTime = audioParams.fadeOutTime;

            if (screenFadeOutTime < 0.0f)
            {
                Debug.LogWarning("Negative screenFadeOutTime. Will default to 1.0f");
                screenFadeOutTime = 1.0f;
            }

            if (audioFadeOutTime < 0.0f)
            {
                Debug.Log("Negative audioFadeOutTime. Will default to screenFadeOutTime (" + screenFadeOutTime + ")");
                audioFadeOutTime = screenFadeOutTime;
            }

            /*
             * IEnumerator fadeOutBgMusic = Coroutines.FadeVolume(
             *  AudioManagerSingleton.Instance.BackgroundMusicSource,
             *  audioFadeOutTime,
             *  0.0f);
             *
             * IEnumerator stopBgMusic = Coroutines.Wrap(() => AudioManagerSingleton.Instance.BackgroundMusicSource.Stop());
             *
             * // When joining coroutines the longest one should be the last one
             * if (audioFadeOutTime > screenFadeOutTime)
             * {
             *  actions.Add(Coroutines.Join(fadeOutScreen, Coroutines.Chain(fadeOutBgMusic, stopBgMusic)));
             * }
             * else
             * {
             *  actions.Add(Coroutines.Join(Coroutines.Chain(fadeOutBgMusic, stopBgMusic), fadeOutScreen));
             * }
             */
        }
        else
        {
            actions.Add(fadeOutScreen);
        }

        // --- BEFORE WAIT TIME CALLBACK ---

        if (screenParams.beforeWaitCallback != null)
        {
            actions.Add(Coroutines.Wrap(screenParams.beforeWaitCallback));
        }

        // --- WAIT TIME ---

        if (screenParams.waitTime != 0.0f)
        {
            actions.Add(Coroutines.Wait(screenParams.waitTime));
        }

        // --- AFTER WAIT TIME CALLBACK ---

        if (screenParams.afterWaitCallback != null)
        {
            actions.Add(Coroutines.Wrap(screenParams.afterWaitCallback));
        }

        // --- SWAP CLIP BEFORE FADING IN, IF NEEDED ---

        if (audioParams.newClip != null)
        {
            //  actions.Add(Coroutines.Wrap(() => AudioManagerSingleton.Instance.BackgroundMusicSource.clip = audioParams.newClip));
        }

        // --- FADE IN ---

        float screenFadeInTime = screenParams.fadeInTime;

        IEnumerator fadeInScreen = Coroutines.FadeAlpha10(fadePanel, screenFadeInTime);

        if (audioParams.fadeIn)
        {
            float audioFadeInTime = audioParams.fadeInTime;
            if (screenFadeInTime < 0.0f)
            {
                Debug.LogWarning("Negative screenFadeInTime. Will default to 1.0f");
                screenFadeInTime = 1.0f;
            }

            if (audioFadeInTime < 0.0f)
            {
                Debug.Log("Negative audioFadeInTime. Will default to screenFadeInTime (" + screenFadeInTime + ")");
                audioFadeInTime = screenFadeOutTime;
            }


            /*
             * /IEnumerator fadeInBgMusic = Coroutines.FadeVolume(
             *  AudioManagerSingleton.Instance.BackgroundMusicSource,
             *  audioFadeInTime,
             *  AudioManagerSingleton.Instance.BackgroundMusicMaxVolume);
             *
             * // When joining coroutines the longest one should be the last one
             * if (audioFadeInTime > screenFadeInTime)
             * {
             *  actions.Add(Coroutines.Join(fadeInScreen, fadeInBgMusic));
             * }
             * else
             * {
             *  actions.Add(Coroutines.Join(fadeInBgMusic, fadeInScreen));
             * }
             */
        }
        else
        {
            actions.Add(fadeInScreen);
        }

        // --- END CALLBACK

        if (screenParams.endCallback != null)
        {
            actions.Add(Coroutines.Wrap(screenParams.endCallback));
        }

        // --- DISABLE FADE PANEL ---

        actions.Add(Coroutines.Wrap(() => fadePanel.gameObject.SetActive(false)));

        // Chain and run

        Coroutines.Chain(actions.ToArray()).Run();
    }