Ejemplo n.º 1
0
 // Show a sentence
 protected virtual IEnumerator showSentence(TextModifications textMod) => null;
Ejemplo n.º 2
0
        // If you're UI supports tags, use this to execute all tags at a given position in the sentence
        // I don't like this here. But unfortunately, the default and background conversations are too different (in my example implementation) to put it in a parent class.
        // Please note, not all tags are used here
        protected IEnumerator processTagsForPosition(TextModifications textMod, int index)
        {
            var mods = textMod.GetAnyTextModsForPosition(index);

            // Check for custom modifications
            foreach (var mod in mods)
            {
                // Commands
                if (mod.ModType == TextModifications.Modifications.CLOSE_BG_CONVERSATIONS)
                {
                    BackgroundDialogueController.Instance?.CloseConversations();
                }

                // Simple modifications e.g. <command=value>
                if (mod.ModType == TextModifications.Modifications.SPEED)
                {
                    _speedMultiplyer = (mod as SimpleModification).GetValue <float>();
                }
                else if (mod.ModType == TextModifications.Modifications.REMOVE_VARAIBLE)
                {
                    VariableRepo.Instance?.Remove((mod as SimpleModification).GetValue <string>());
                }
                else if (mod.ModType == TextModifications.Modifications.WAIT)
                {
                    yield return(new WaitForSeconds((mod as SimpleModification).GetValue <float>()));
                }
                else if (mod.ModType == TextModifications.Modifications.ACTION)
                {
                    performAction((mod as SimpleModification).GetValue <string>());
                }
                else if (mod.ModType == TextModifications.Modifications.LOG)
                {
                    DialogueLogger.Log((mod as SimpleModification).GetValue <string>());
                }
                else if (mod.ModType == TextModifications.Modifications.LOG_WARNING)
                {
                    DialogueLogger.LogWarning((mod as SimpleModification).GetValue <string>());
                }
                else if (mod.ModType == TextModifications.Modifications.LOG_ERROR)
                {
                    DialogueLogger.LogError((mod as SimpleModification).GetValue <string>());
                }
                else if (mod.ModType == TextModifications.Modifications.BG_CONVERSATION)
                {
                    BackgroundDialogueController.Instance?.StartConversation((mod as SimpleModification).GetValue <string>());
                }

                // Complex modifications e.g. <command=value>content</command>
                else if (mod.ModType == TextModifications.Modifications.SEND_MESSAGE)
                {
                    var revievingObject = GameObject.Find((mod as SimpleModification).GetValue <string>());
                    if (revievingObject == null)
                    {
                        DialogueLogger.LogError($"Trying to execute a send message command, but GameObject {(mod as SimpleModification).GetValue<string>()} was not found");
                        continue;
                    }

                    revievingObject.SendMessage((mod as ComplexModification).GetContent <string>(), SendMessageOptions.DontRequireReceiver);
                }
                else if (mod.ModType == TextModifications.Modifications.ACTION_WITH_MESSAGE)
                {
                    performActionWithMessage((mod as SimpleModification).GetValue <string>(), (mod as ComplexModification).GetContent <string>());
                }
                else if (mod.ModType == TextModifications.Modifications.ACTION_WITH_TARGET)
                {
                    performActionWithTarget((mod as SimpleModification).GetValue <string>(), (mod as ComplexModification).GetContent <string>());
                }
            }
        }
Ejemplo n.º 3
0
 // Prepare then show sentence
 public void ShowSentence(string speaker, TextModifications textMods, Sprite characterSprite, bool sameSpeakerAsLastDialogue = true, bool autoProceed = false)
 {
     _speedMultiplyer = 1;
     _currentTextMod  = textMods;
     StartCoroutine(showSentence(speaker, characterSprite, sameSpeakerAsLastDialogue, autoProceed));
 }