/// <summary>
 /// Adds a Lua observer.
 /// </summary>
 /// <param name='luaExpression'>
 /// Lua expression to observe.
 /// </param>
 /// <param name='frequency'>
 /// Frequency to check.
 /// </param>
 /// <param name='luaChangedHandler'>
 /// Delegate to call when the expression changes.
 /// </param>
 public void AddObserver(string luaExpression, LuaWatchFrequency frequency, LuaChangedDelegate luaChangedHandler)
 {
     switch (frequency) {
     case LuaWatchFrequency.EveryUpdate:
         everyUpdateList.AddObserver(luaExpression, luaChangedHandler);
         break;
     case LuaWatchFrequency.EveryDialogueEntry:
         everyDialogueEntryList.AddObserver(luaExpression, luaChangedHandler);
         break;
     case LuaWatchFrequency.EndOfConversation:
         endOfConversationList.AddObserver(luaExpression, luaChangedHandler);
         break;
     default:
         Debug.LogError(string.Format("{0}: Internal error - unexpected Lua watch frequency {1}", new System.Object[] { DialogueDebug.Prefix, frequency }));
         break;
     }
 }
Exemple #2
0
        /// <summary>
        /// Adds a Lua observer.
        /// </summary>
        /// <param name='luaExpression'>
        /// Lua expression to observe.
        /// </param>
        /// <param name='frequency'>
        /// Frequency to check.
        /// </param>
        /// <param name='luaChangedHandler'>
        /// Delegate to call when the expression changes.
        /// </param>
        public void AddObserver(string luaExpression, LuaWatchFrequency frequency, LuaChangedDelegate luaChangedHandler)
        {
            switch (frequency)
            {
            case LuaWatchFrequency.EveryUpdate:
                everyUpdateList.AddObserver(luaExpression, luaChangedHandler);
                break;

            case LuaWatchFrequency.EveryDialogueEntry:
                everyDialogueEntryList.AddObserver(luaExpression, luaChangedHandler);
                break;

            case LuaWatchFrequency.EndOfConversation:
                endOfConversationList.AddObserver(luaExpression, luaChangedHandler);
                break;

            default:
                Debug.LogError(string.Format("{0}: Internal error - unexpected Lua watch frequency {1}", new System.Object[] { DialogueDebug.Prefix, frequency }));
                break;
            }
        }
Exemple #3
0
        /// <summary>
        /// Adds a Lua observer.
        /// </summary>
        /// <param name='luaExpression'>
        /// Lua expression to observe.
        /// </param>
        /// <param name='frequency'>
        /// Frequency to check.
        /// </param>
        /// <param name='luaChangedHandler'>
        /// Delegate to call when the expression changes.
        /// </param>
        public void AddObserver(string luaExpression, LuaWatchFrequency frequency, LuaChangedDelegate luaChangedHandler)
        {
            switch (frequency)
            {
            case LuaWatchFrequency.EveryUpdate:
                m_everyUpdateList.AddObserver(luaExpression, luaChangedHandler);
                break;

            case LuaWatchFrequency.EveryDialogueEntry:
                m_everyDialogueEntryList.AddObserver(luaExpression, luaChangedHandler);
                break;

            case LuaWatchFrequency.EndOfConversation:
                m_endOfConversationList.AddObserver(luaExpression, luaChangedHandler);
                break;

            default:
                Debug.LogError("Dialogue System: Internal error - unexpected Lua watch frequency " + frequency);
                break;
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="PixelCrushers.DialogueSystem.WatchItem"/> class.
 /// </summary>
 /// <param name='luaExpression'>
 /// Lua expression to watch.
 /// </param>
 /// <param name='luaChangedHandler'>
 /// Delegate to call when the expression changes.
 /// </param>
 public LuaWatchItem(string luaExpression, LuaChangedDelegate luaChangedHandler)
 {
     this.luaExpression  = LuaExpressionWithReturn(luaExpression);
     this.m_currentValue = Lua.Run(this.luaExpression).asString;
     this.luaChanged     = luaChangedHandler;
 }
 /// <summary>
 /// Removes a watch item from the list.
 /// </summary>
 /// <param name='luaExpression'>
 /// Lua expression.
 /// </param>
 /// <param name='luaChangedHandler'>
 /// Lua changed handler.
 /// </param>
 public void RemoveObserver(string luaExpression, LuaChangedDelegate luaChangedHandler)
 {
     watchList.RemoveAll(watchItem => watchItem.Matches(luaExpression, luaChangedHandler));
 }
 /// <summary>
 /// Adds a watch item to the list.
 /// </summary>
 /// <param name='luaExpression'>
 /// Lua expression to watch.
 /// </param>
 /// <param name='luaChangedHandler'>
 /// Delegate to call when the expression changes.
 /// </param>
 public void AddObserver(string luaExpression, LuaChangedDelegate luaChangedHandler)
 {
     watchList.Add(new LuaWatchItem(luaExpression, luaChangedHandler));
 }
 /// <summary>
 /// Removes a watch item from the list.
 /// </summary>
 /// <param name='luaExpression'>
 /// Lua expression.
 /// </param>
 /// <param name='luaChangedHandler'>
 /// Lua changed handler.
 /// </param>
 public void RemoveObserver(string luaExpression, LuaChangedDelegate luaChangedHandler)
 {
     watchList.RemoveAll(watchItem => watchItem.Matches(luaExpression, luaChangedHandler));
 }
 /// <summary>
 /// Checks if the watch item matches a specified luaExpression and luaChangedHandler.
 /// </summary>
 /// <param name='luaExpression'>
 /// The lua expression.
 /// </param>
 /// <param name='luaChangedHandler'>
 /// The notification delegate.
 /// </param>
 public bool Matches(string luaExpression, LuaChangedDelegate luaChangedHandler)
 {
     return (luaChangedHandler == LuaChanged) && string.Equals(luaExpression, this.LuaExpression);
 }
Exemple #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PixelCrushers.DialogueSystem.WatchItem"/> class.
 /// </summary>
 /// <param name='luaExpression'>
 /// Lua expression to watch.
 /// </param>
 /// <param name='luaChangedHandler'>
 /// Delegate to call when the expression changes.
 /// </param>
 public LuaWatchItem(string luaExpression, LuaChangedDelegate luaChangedHandler)
 {
     this.luaExpression  = luaExpression.StartsWith("return ") ? luaExpression : ("return " + luaExpression);
     this.m_currentValue = Lua.Run(this.luaExpression).asString;
     this.luaChanged     = luaChangedHandler;
 }
 /// <summary>
 /// Removes a Lua expression observer. To be removed, the expression, frequency, and
 /// notification delegate must all match.
 /// </summary>
 /// <param name='luaExpression'>
 /// Lua expression being watched.
 /// </param>
 /// <param name='frequency'>
 /// Frequency that the expression is being watched.
 /// </param>
 /// <param name='luaChangedHandler'>
 /// Delegate that's called when the expression changes.
 /// </param>
 public void RemoveLuaObserver(string luaExpression, LuaWatchFrequency frequency, LuaChangedDelegate luaChangedHandler)
 {
     luaWatchers.RemoveObserver(luaExpression, frequency, luaChangedHandler);
 }
 /// <summary>
 /// Adds a Lua expression observer.
 /// </summary>
 /// <param name='luaExpression'>
 /// Lua expression to watch.
 /// </param>
 /// <param name='frequency'>
 /// Frequency to check the expression.
 /// </param>
 /// <param name='luaChangedHandler'>
 /// Delegate to call when the expression changes. This should be in the form:
 /// <code>void MyDelegate(LuaWatchItem luaWatchItem, Lua.Result newValue) {...}</code>
 /// </param>
 public void AddLuaObserver(string luaExpression, LuaWatchFrequency frequency, LuaChangedDelegate luaChangedHandler)
 {
     StartCoroutine(AddLuaObserverAfterStart(luaExpression, frequency, luaChangedHandler));
 }
 private IEnumerator AddLuaObserverAfterStart(string luaExpression, LuaWatchFrequency frequency, LuaChangedDelegate luaChangedHandler)
 {
     int MaxFramesToWait = 10;
     int framesWaited = 0;
     while (!hasStarted && (framesWaited < MaxFramesToWait)) {
         framesWaited++;
         yield return null;
     }
     yield return null;
     luaWatchers.AddObserver(luaExpression, frequency, luaChangedHandler);
 }
 /// <summary>
 /// Adds a Lua expression observer.
 /// </summary>
 /// <param name='luaExpression'>
 /// Lua expression to watch.
 /// </param>
 /// <param name='frequency'>
 /// Frequency to check the expression.
 /// </param>
 /// <param name='luaChangedHandler'>
 /// Delegate to call when the expression changes. This should be in the form:
 /// <code>void MyDelegate(LuaWatchItem luaWatchItem, Lua.Result newValue) {...}</code>
 /// </param>
 public static void AddLuaObserver(string luaExpression, LuaWatchFrequency frequency, LuaChangedDelegate luaChangedHandler)
 {
     Instance.AddLuaObserver(luaExpression, frequency, luaChangedHandler);
 }
 /// <summary>
 /// Adds a Lua expression observer.
 /// </summary>
 /// <param name='luaExpression'>
 /// Lua expression to watch.
 /// </param>
 /// <param name='frequency'>
 /// Frequency to check the expression.
 /// </param>
 /// <param name='luaChangedHandler'>
 /// Delegate to call when the expression changes. This should be in the form:
 /// <code>void MyDelegate(LuaWatchItem luaWatchItem, Lua.Result newValue) {...}</code>
 /// </param>
 public static void AddLuaObserver(string luaExpression, LuaWatchFrequency frequency, LuaChangedDelegate luaChangedHandler)
 {
     Instance.AddLuaObserver(luaExpression, frequency, luaChangedHandler);
 }
Exemple #15
0
 /// <summary>
 /// Removes a watch item from the list.
 /// </summary>
 /// <param name='luaExpression'>
 /// Lua expression.
 /// </param>
 /// <param name='luaChangedHandler'>
 /// Lua changed handler.
 /// </param>
 public void RemoveObserver(string luaExpression, LuaChangedDelegate luaChangedHandler)
 {
     m_watchList.RemoveAll(watchItem => watchItem.Matches(LuaWatchItem.LuaExpressionWithReturn(luaExpression), luaChangedHandler));
 }
 /// <summary>
 /// Removes a Lua expression observer. To be removed, the expression, frequency, and
 /// notification delegate must all match.
 /// </summary>
 /// <param name='luaExpression'>
 /// Lua expression being watched.
 /// </param>
 /// <param name='frequency'>
 /// Frequency that the expression is being watched.
 /// </param>
 /// <param name='luaChangedHandler'>
 /// Delegate that's called when the expression changes.
 /// </param>
 public static void RemoveLuaObserver(string luaExpression, LuaWatchFrequency frequency, LuaChangedDelegate luaChangedHandler)
 {
     if (!hasInstance)
     {
         return;
     }
     instance.RemoveLuaObserver(luaExpression, frequency, luaChangedHandler);
 }
 /// <summary>
 /// Adds a watch item to the list.
 /// </summary>
 /// <param name='luaExpression'>
 /// Lua expression to watch.
 /// </param>
 /// <param name='luaChangedHandler'>
 /// Delegate to call when the expression changes.
 /// </param>
 public void AddObserver(string luaExpression, LuaChangedDelegate luaChangedHandler)
 {
     watchList.Add(new LuaWatchItem(luaExpression, luaChangedHandler));
 }
Exemple #18
0
 /// <summary>
 /// Checks if the watch item matches a specified luaExpression and luaChangedHandler.
 /// </summary>
 /// <param name='luaExpression'>
 /// The lua expression.
 /// </param>
 /// <param name='luaChangedHandler'>
 /// The notification delegate.
 /// </param>
 public bool Matches(string luaExpression, LuaChangedDelegate luaChangedHandler)
 {
     return((luaChangedHandler == luaChanged) && string.Equals(luaExpression, this.luaExpression));
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="PixelCrushers.DialogueSystem.WatchItem"/> class.
 /// </summary>
 /// <param name='luaExpression'>
 /// Lua expression to watch.
 /// </param>
 /// <param name='luaChangedHandler'>
 /// Delegate to call when the expression changes.
 /// </param>
 public LuaWatchItem(string luaExpression, LuaChangedDelegate luaChangedHandler)
 {
     this.LuaExpression = luaExpression.StartsWith("return ") ? luaExpression : ("return " + luaExpression);
     this.currentValue = Lua.Run(this.LuaExpression).AsString;
     this.LuaChanged = luaChangedHandler;
 }