Ejemplo n.º 1
0
        public override void OnEnter()
        {
            if (!showAlways && executionCount >= showCount)
            {
                Continue();
                return;
            }

            executionCount++;

            // Override the active say dialog if needed
            if (character != null && character.SetSayDialog != null)
            {
                SayDialog.activeSayDialog = character.SetSayDialog;
            }

            if (setSayDialog != null)
            {
                SayDialog.activeSayDialog = setSayDialog;
            }

            ISayDialog sayDialog = SayDialog.GetSayDialog();

            if (sayDialog == null)
            {
                Continue();
                return;
            }

            var flowchart = GetFlowchart();

            sayDialog.SetActive(true);

            sayDialog.SetCharacter(character, flowchart);
            sayDialog.SetCharacterImage(portrait);

            string displayText = storyText;

            foreach (CustomTag ct in CustomTag.activeCustomTags)
            {
                displayText = displayText.Replace(ct.TagStartSymbol, ct.ReplaceTagStartWith);
                if (ct.TagEndSymbol != "" && ct.ReplaceTagEndWith != "")
                {
                    displayText = displayText.Replace(ct.TagEndSymbol, ct.ReplaceTagEndWith);
                }
            }

            string subbedText = flowchart.SubstituteVariables(displayText);

            sayDialog.Say(subbedText, !extendPrevious, waitForClick, fadeWhenDone, stopVoiceover, voiceOverClip, delegate {
                Continue();
            });
        }
Ejemplo n.º 2
0
        public IEnumerator DoConversation(string conv)
        {
            if (string.IsNullOrEmpty(conv))
            {
                yield break;
            }

            var conversationItems = Parse(conv);

            if (conversationItems.Count == 0)
            {
                yield break;
            }

            // Track the current and previous parameter values
            Character     currentCharacter  = null;
            Sprite        currentPortrait   = null;
            RectTransform currentPosition   = null;
            Character     previousCharacter = null;

            // Play the conversation
            for (int i = 0; i < conversationItems.Count; ++i)
            {
                ConversationItem item = conversationItems[i];

                if (item.Character != null)
                {
                    currentCharacter = item.Character;
                }

                currentPortrait = item.Portrait;
                currentPosition = item.Position;

                ISayDialog sayDialog = GetSayDialog(currentCharacter);

                if (sayDialog == null)
                {
                    // Should never happen
                    yield break;
                }

                sayDialog.SetActive(true);

                if (currentCharacter != null &&
                    currentCharacter != previousCharacter)
                {
                    sayDialog.SetCharacter(currentCharacter);
                }

                var stage = Stage.GetActiveStage();

                if (stage != null && currentCharacter != null &&
                    (currentPortrait != currentCharacter.State.portrait ||
                     currentPosition != currentCharacter.State.position))
                {
                    var portraitOptions = new PortraitOptions(true);
                    portraitOptions.display      = item.Hide ? DisplayType.Hide : DisplayType.Show;
                    portraitOptions.character    = currentCharacter;
                    portraitOptions.fromPosition = currentCharacter.State.position;
                    portraitOptions.toPosition   = currentPosition;
                    portraitOptions.portrait     = currentPortrait;

                    //Flip option - Flip the opposite direction the character is currently facing
                    if (item.Flip)
                    {
                        portraitOptions.facing = item.FacingDirection;
                    }

                    // Do a move tween if the character is already on screen and not yet at the specified position
                    if (currentCharacter.State.onScreen &&
                        currentPosition != currentCharacter.State.position)
                    {
                        portraitOptions.move = true;
                    }

                    if (item.Hide)
                    {
                        stage.Hide(portraitOptions);
                    }
                    else
                    {
                        stage.Show(portraitOptions);
                    }
                }

                if (stage == null &&
                    currentPortrait != null)
                {
                    sayDialog.SetCharacterImage(currentPortrait);
                }

                previousCharacter = currentCharacter;

                if (!string.IsNullOrEmpty(item.Text))
                {
                    exitSayWait = false;
                    sayDialog.Say(item.Text, true, true, true, false, null, () => {
                        exitSayWait = true;
                    });

                    while (!exitSayWait)
                    {
                        yield return(null);
                    }
                    exitSayWait = false;
                }
            }
        }