Beispiel #1
0
        private IEnumerator Invoke(StageBuilder stageBuilder)
        {
            if (stageBuilder.newcomer != null)
            {
                if (FindActor(stageBuilder.newcomer.name) != null)
                {
                    throw new UnityException(
                              "There already exists an actor in the scene with name: "
                              + stageBuilder.newcomer.name);
                }

                yield return(AddActor(stageBuilder.newcomer, stageBuilder.newcomer.side));
            }

            if (stageBuilder.message != null)
            {
                CutsceneSide side = CutsceneSide.None;

                if (!string.IsNullOrEmpty(stageBuilder.speaker))
                {
                    side = FindActor(stageBuilder.speaker).side;

                    foreach (Actor actor in actors)
                    {
                        if (actor.side != side)
                        {
                            actor.IsDark = true;
                        }
                    }
                }

                textbox.AddText(side, stageBuilder.speaker, stageBuilder.message);
                yield return(new WaitForSeconds(5));

                foreach (Actor actor in actors)
                {
                    actor.IsDark = false;
                }
            }

            if (!string.IsNullOrEmpty(stageBuilder.leaverName))
            {
                Actor foundActor = FindActor(stageBuilder.leaverName);

                if (foundActor == null)
                {
                    throw new UnityException(
                              "There exists no actor in the scene with name: "
                              + stageBuilder.leaverName
                              );
                }
                yield return(RemoveActor(foundActor));
            }

            yield break;
        }
Beispiel #2
0
        private IEnumerator Invoke(StageBuilder stageBuilder)
        {
            if (stageBuilder.stopAudio)
            {
                Audio.stopAudio(false);
            }

            if (stageBuilder.pauseBattleTheme)
            {
                Audio.pauseAudio(true);
            }

            if (stageBuilder.newcomer != null)
            {
                if (FindActor(stageBuilder.newcomer.name) != null)
                {
                    throw new UnityException(
                              "There already exists an actor in the scene with name: "
                              + stageBuilder.newcomer.name);
                }

                yield return(AddActor(stageBuilder.newcomer, stageBuilder.newcomer.side));
            }

            if (stageBuilder.expression != null)
            {
                Actor foundActor = FindActor(stageBuilder.speaker);

                if (foundActor == null)
                {
                    throw new UnityException(
                              "There exists no actor in the scene with name: "
                              + stageBuilder.speaker
                              );
                }

                foundActor.image.sprite = stageBuilder.expression;
            }

            if (stageBuilder.sfx != null)
            {
                Audio.playSfx(stageBuilder.sfx);
            }

            if (stageBuilder.background != null)
            {
                Sprite foundSprite = (Resources.Load <Sprite>("Sprites/" + stageBuilder.background));

                if (foundSprite == null)
                {
                    throw new UnityException(
                              "There exists no background " + stageBuilder.background + " in the Resources/Sprites folder, or it has not been imported as a Sprite."
                              );
                }

                yield return(changeBackground(foundSprite));
            }

            if (stageBuilder.message != null)
            {
                CutsceneSide side = CutsceneSide.None;

                if (!string.IsNullOrEmpty(stageBuilder.speaker))
                {
                    Actor foundActor = FindActor(stageBuilder.speaker);

                    if (foundActor == null)
                    {
                        throw new UnityException(
                                  "There exists no actor in the scene with name: "
                                  + stageBuilder.speaker
                                  );
                    }

                    side = foundActor.side;

                    foreach (Actor actor in actors)
                    {
                        if (actor.side != side)
                        {
                            actor.IsDark = true;
                        }
                    }
                }

                textbox.AddText(side, stageBuilder.speaker, stageBuilder.message);

                //I approximate it to take ~0.03 seconds per letter, but we do more so players can actually read
                float playTimeGuess = (float)(stageBuilder.message.Length * 0.06 + 1.5);
                currentDialogLine = this.StartStoppableCoroutine(waitForSeconds(playTimeGuess));
                yield return(currentDialogLine.WaitFor());

                foreach (Actor actor in actors)
                {
                    actor.IsDark = false;
                }
            }

            if (!string.IsNullOrEmpty(stageBuilder.leaverName))
            {
                Actor foundActor = FindActor(stageBuilder.leaverName);

                if (foundActor == null)
                {
                    throw new UnityException(
                              "There exists no actor in the scene with name: "
                              + stageBuilder.leaverName
                              );
                }
                yield return(RemoveActor(foundActor));
            }

            yield break;
        }