Beispiel #1
0
 /// <summary>
 /// Activates the target game objects and components if the condition is true.
 /// </summary>
 /// <param name='other'>
 /// The collider that entered the trigger.
 /// </param>
 public void OnTriggerEnter(Collider other)
 {
     if (condition.IsTrue(other.transform))
     {
         SetTargets(true);
     }
 }
Beispiel #2
0
 public virtual void Check()
 {
     if (enabled)
     {
         target.SetActive(condition.IsTrue(null));
     }
 }
 /// <summary>
 /// If the condition is true, starts the conversation between the specified actor and the
 /// character that this component is attached to.
 /// </summary>
 /// <param name='actor'>
 /// The actor to converse with.
 /// </param>
 public void TryStartConversation(Transform actor)
 {
     if (!tryingToStart)
     {
         tryingToStart = true;
         try {
             if ((condition == null) || condition.IsTrue(actor))
             {
                 if (string.IsNullOrEmpty(conversation))
                 {
                     if (DialogueDebug.LogErrors)
                     {
                         Debug.LogError(string.Format("{0}: Conversation triggered on {1}, but conversation name is blank.", new System.Object[] { DialogueDebug.Prefix, name }));
                     }
                 }
                 else if (DialogueManager.IsConversationActive)
                 {
                     if (DialogueDebug.LogWarnings)
                     {
                         Debug.LogWarning(string.Format("{0}: Conversation triggered on {1}, but another conversation is already active.", new System.Object[] { DialogueDebug.Prefix, name }));
                     }
                 }
                 else
                 {
                     StartConversation(actor);
                 }
                 DestroyIfOnce();
             }
         } finally {
             tryingToStart = false;
         }
     }
 }
Beispiel #4
0
        public void TryIncrement()
        {
            if (!Application.isPlaying)
            {
                return;
            }
            if (DialogueManager.MasterDatabase == null)
            {
                return;
            }
            if (!(listenForOnDestroy && condition.IsTrue(null)))
            {
                return;
            }
            int oldValue = DialogueLua.GetVariable(ActualVariableName).AsInt;
            int newValue = Mathf.Clamp(oldValue + increment, min, max);

            DialogueLua.SetVariable(ActualVariableName, newValue);
            DialogueManager.SendUpdateTracker();
            if (!(string.IsNullOrEmpty(alertMessage) || DialogueManager.Instance == null))
            {
                if (Mathf.Approximately(0, alertDuration))
                {
                    DialogueManager.ShowAlert(alertMessage);
                }
                else
                {
                    DialogueManager.ShowAlert(alertMessage, alertDuration);
                }
            }
            onIncrement.Invoke();
        }
Beispiel #5
0
 /// <summary>
 /// Show the alert 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(message))
         {
             string actualMessage = message;
             if ((localizedTextTable != null) && localizedTextTable.ContainsField(message))
             {
                 actualMessage = localizedTextTable[message];
             }
             string text = FormattedText.Parse(actualMessage, DialogueManager.masterDatabase.emphasisSettings).text;
             if (Mathf.Approximately(0, duration))
             {
                 DialogueManager.ShowAlert(text);
             }
             else
             {
                 DialogueManager.ShowAlert(text, duration);
             }
             DestroyIfOnce();
         }
     }
     finally
     {
         tryingToStart = false;
     }
 }
Beispiel #6
0
        /// <summary>
        /// Call this method to manually check the condition and fire the action
        /// if it's true.
        /// </summary>
        public void Check()
        {
            var observeTransform = (observeGameObject == null) ? null : observeGameObject.transform;

            if (condition.IsTrue(observeTransform))
            {
                Fire();
            }
        }
Beispiel #7
0
 private void TryAddDatabases(Transform interactor, bool immediate)
 {
     if (!trying)
     {
         trying = true;
         try {
             if ((condition == null) || condition.IsTrue(interactor))
             {
                 AddDatabases(immediate);
                 if (once)
                 {
                     Destroy(this);
                 }
             }
         } finally {
             trying = false;
         }
     }
 }
Beispiel #8
0
 /// <summary>
 /// Sets the quest status 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(questName))
         {
             Fire();
         }
     } finally {
         tryingToStart = false;
     }
 }
Beispiel #9
0
 public virtual void Check()
 {
     if (enabled)
     {
         if (target == null)
         {
             if (DialogueDebug.logWarnings)
             {
                 Debug.LogWarning("Dialogue System: No target is assigned to Persistent Active Data component on " + name + ".", this);
             }
         }
         else
         {
             target.SetActive(condition.IsTrue(null));
         }
     }
 }
 /// <summary>
 /// Starts the sequence if the condition is true.
 /// </summary>
 public void TryStartSequence(Transform actor)
 {
     if (tryingToStart)
     {
         return;
     }
     tryingToStart = true;
     try {
         if (((condition == null) || condition.IsTrue(actor)) && !string.IsNullOrEmpty(sequence))
         {
             DialogueManager.PlaySequence(sequence, Tools.Select(speaker, this.transform), Tools.Select(listener, actor));
             DestroyIfOnce();
         }
     } finally {
         tryingToStart = false;
     }
 }
Beispiel #11
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;
     }
 }
Beispiel #12
0
 /// <summary>
 /// Sets the quest status if the condition is true.
 /// </summary>
 public void TryStart(Transform actor, Transform interactor)
 {
     if (tryingToStart)
     {
         return;
     }
     tryingToStart = true;
     try
     {
         if (((condition == null) || condition.IsTrue(interactor)))
         {
             Fire(actor);
         }
     }
     finally
     {
         tryingToStart = false;
     }
 }
Beispiel #13
0
        public void TryIncrement()
        {
            if (!listenForOnDestroy)
            {
                return;
            }
            if (!condition.IsTrue(null))
            {
                return;
            }
            int oldValue = DialogueLua.GetVariable(ActualVariableName).AsInt;
            int newValue = Mathf.Clamp(oldValue + increment, min, max);

            DialogueLua.SetVariable(ActualVariableName, newValue);
            DialogueManager.SendUpdateTracker();
            if (!(string.IsNullOrEmpty(alertMessage) || DialogueManager.Instance == null))
            {
                DialogueManager.ShowAlert(alertMessage);
            }
        }
Beispiel #14
0
 /// <summary>
 /// Show the alert if the condition is true.
 /// </summary>
 public void TryStart(Transform actor)
 {
     if (tryingToStart)
     {
         return;
     }
     tryingToStart = true;
     try
     {
         if ((condition == null) || condition.IsTrue(actor))
         {
             SetBindings();
             playableDirector.Play();
             DestroyIfOnce();
         }
     }
     finally
     {
         tryingToStart = false;
     }
 }
Beispiel #15
0
 /// <summary>
 /// Listens for an OnApplyPersistentData message from the PersistentDataManager, and sets a target
 /// game object accordingly.
 /// </summary>
 public void OnApplyPersistentData()
 {
     target.SetActive(condition.IsTrue(null));
 }