Exemplo n.º 1
0
        /// <summary>
        /// Call this method to manually run the action.
        /// </summary>
        public void Fire()
        {
            // Quest:
            if (!string.IsNullOrEmpty(questName))
            {
                QuestLog.SetQuestState(questName, questState);
            }

            // Lua:
            if (!string.IsNullOrEmpty(luaCode))
            {
                Lua.Run(luaCode, DialogueDebug.logInfo);
                DialogueManager.CheckAlerts();
            }

            // Sequence:
            if (!string.IsNullOrEmpty(sequence))
            {
                DialogueManager.PlaySequence(sequence);
            }

            // Alert:
            if (!string.IsNullOrEmpty(alertMessage))
            {
                string localizedAlertMessage;
                if ((textTable != null) && textTable.HasFieldTextForLanguage(alertMessage, Localization.GetCurrentLanguageID(textTable)))
                {
                    localizedAlertMessage = textTable.GetFieldTextForLanguage(alertMessage, Localization.GetCurrentLanguageID(textTable));
                }
                else
                {
                    localizedAlertMessage = DialogueManager.GetLocalizedText(alertMessage);
                }
                DialogueManager.ShowAlert(localizedAlertMessage);
            }

            // Send Messages:
            foreach (var sma in sendMessages)
            {
                if (sma.gameObject != null && !string.IsNullOrEmpty(sma.message))
                {
                    sma.gameObject.SendMessage(sma.message, sma.parameter, SendMessageOptions.DontRequireReceiver);
                }
            }

            DialogueManager.SendUpdateTracker();

            if (once)
            {
                StopObserving();
                enabled = false;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Runs the Lua code if the condition is true.
 /// </summary>
 public void TryStart(Transform actor)
 {
     if (tryingToStart)
     {
         return;
     }
     tryingToStart = true;
     try {
         if (((condition == null) || condition.IsTrue(actor)) && !string.IsNullOrEmpty(luaCode))
         {
             Lua.Run(luaCode, DialogueDebug.LogInfo);
             DialogueManager.CheckAlerts();
             DestroyIfOnce();
         }
     } finally {
         tryingToStart = false;
     }
 }