示例#1
0
        /** Unschedules all selectors for a given target.
         *   This also includes the "update" selector.
         *   @since v0.99.3
         */

        public void UnscheduleAllForTarget(ICCSelectorProtocol target)
        {
            // explicit NULL handling
            if (target == null)
            {
                return;
            }

            // custom selectors
            HashTimeEntry element;

            if (m_pHashForTimers.TryGetValue(target, out element))
            {
                if (element.Timers.Contains(element.CurrentTimer))
                {
                    element.CurrentTimerSalvaged = true;
                }
                element.Timers.Clear();

                if (m_pCurrentTarget == element)
                {
                    m_bCurrentTargetSalvaged = true;
                }
                else
                {
                    RemoveHashElement(element);
                }
            }

            // update selector
            UnscheduleUpdateForTarget(target);
        }
        /// <summary>
        ///  creates a menu item from a string and atlas. Use it with MenuItemToggle
        /// </summary>
        public static CCMenuItemAtlasFont ItemFromString(string value, string charMapFile, int itemWidth, int itemHeight, char startCharMap,
		                                                 ICCSelectorProtocol target, Action<object> selector)
        {
            var pRet = new CCMenuItemAtlasFont();
            pRet.InitFromString(value, charMapFile, itemWidth, itemHeight, startCharMap, target, selector);
            return pRet;
        }
示例#3
0
        /** Schedules the 'update' selector for a given target with a given priority.
         *   The 'update' selector will be called every frame.
         *   The lower the priority, the earlier it is called.
         *   @since v0.99.3
         */

        public void ScheduleUpdateForTarget(ICCSelectorProtocol targt, int priority, bool paused)
        {
            HashUpdateEntry element;

            if (m_pHashForUpdates.TryGetValue(targt, out element))
            {
                Debug.Assert(element.Entry.MarkedForDeletion);

                // TODO: check if priority has changed!
                element.Entry.MarkedForDeletion = false;

                return;
            }

            // most of the updates are going to be 0, that's way there
            // is an special list for updates with priority 0
            if (priority == 0)
            {
                AppendIn(m_pUpdates0List, targt, paused);
            }
            else if (priority < 0)
            {
                PriorityIn(m_pUpdatesNegList, targt, priority, paused);
            }
            else
            {
                PriorityIn(m_pUpdatesPosList, targt, priority, paused);
            }
        }
        /// <summary>
        /// initializes a menu item from a string and atlas with a target/selector
        /// </summary>
        public bool InitFromString(string value, string charMapFile, int itemWidth, int itemHeight, char startCharMap, ICCSelectorProtocol target,
		                           Action<object> selector)
        {
            // CCAssert( value != NULL && strlen(value) != 0, "value length must be greater than 0");
            var label = new CCLabelAtlas(value, charMapFile, itemWidth, itemHeight, startCharMap);
            base.InitWithLabel(label, selector);
            return true;
        }
        /// <summary>
        ///  creates a menu item from a string and atlas. Use it with MenuItemToggle
        /// </summary>
        public static CCMenuItemAtlasFont ItemFromString(string value, string charMapFile, int itemWidth, int itemHeight, char startCharMap,
                                                         ICCSelectorProtocol target, Action <CCMenuItem> selector)
        {
            var pRet = new CCMenuItemAtlasFont();

            pRet.InitFromString(value, charMapFile, itemWidth, itemHeight, startCharMap, target, selector);
            return(pRet);
        }
示例#6
0
        /** The scheduled method will be called every 'interval' seconds.
         * If paused is YES, then it won't be called until it is resumed.
         * If 'interval' is 0, it will be called every frame, but if so, it's recommended to use 'scheduleUpdateForTarget:' instead.
         * If the selector is already scheduled, then only the interval parameter will be updated without re-scheduling it again.
         * repeat let the action be repeated repeat + 1 times, use kCCRepeatForever to let the action run continuously
         * delay is the amount of time the action will wait before it'll start
         *
         * @since v0.99.3, repeat and delay added in v1.1
         */

        public void ScheduleSelector(Action <float> selector, ICCSelectorProtocol target, float interval, uint repeat,
                                     float delay, bool paused)
        {
            Debug.Assert(selector != null);
            Debug.Assert(target != null);

            HashTimeEntry element;

            lock (m_pHashForTimers)
            {
                if (!m_pHashForTimers.TryGetValue(target, out element))
                {
                    element = new HashTimeEntry {
                        Target = target
                    };
                    m_pHashForTimers[target] = element;

                    // Is this the 1st element ? Then set the pause level to all the selectors of this target
                    element.Paused = paused;
                }
                else
                {
                    if (element != null)
                    {
                        Debug.Assert(element.Paused == paused);
                    }
                }
                if (element != null)
                {
                    if (element.Timers == null)
                    {
                        element.Timers = new List <CCTimer>();
                    }
                    else
                    {
                        CCTimer[] timers = element.Timers.ToArray();
                        foreach (var timer in timers)
                        {
                            if (timer == null)
                            {
                                continue;
                            }
                            if (selector == timer.Selector)
                            {
                                CCLog.Log(
                                    "CCSheduler#scheduleSelector. Selector already scheduled. Updating interval from: {0} to {1}",
                                    timer.Interval, interval);
                                timer.Interval = interval;
                                return;
                            }
                        }
                    }

                    element.Timers.Add(new CCTimer(this, target, selector, interval, repeat, delay));
                }
            }
        }
示例#7
0
 public CCTimer(CCScheduler scheduler, ICCSelectorProtocol target, Action<float> selector, float seconds, uint repeat, float delay)
 {
     _scheduler = scheduler;
     Target = target;
     Selector = selector;
     Elapsed = -1;
     OriginalInterval = seconds;
     Interval = seconds;
     m_fDelay = delay;
     m_bUseDelay = delay > 0f;
     m_nRepeat = repeat;
     m_bRunForever = m_nRepeat == uint.MaxValue;
 }
示例#8
0
 public CCTimer(CCScheduler scheduler, ICCSelectorProtocol target, Action <float> selector, float seconds, uint repeat, float delay)
 {
     _scheduler       = scheduler;
     Target           = target;
     Selector         = selector;
     Elapsed          = -1;
     OriginalInterval = seconds;
     Interval         = seconds;
     m_fDelay         = delay;
     m_bUseDelay      = delay > 0f;
     m_nRepeat        = repeat;
     m_bRunForever    = m_nRepeat == uint.MaxValue;
 }
示例#9
0
        /** Unschedule a selector for a given target.
         *   If you want to unschedule the "update", use unscheudleUpdateForTarget.
         *   @since v0.99.3
         */

        public void UnscheduleSelector(Action <float> selector, ICCSelectorProtocol target)
        {
            // explicity handle nil arguments when removing an object
            if (selector == null || target == null)
            {
                return;
            }

            HashTimeEntry element;

            if (m_pHashForTimers.TryGetValue(target, out element))
            {
                for (int i = 0; i < element.Timers.Count; i++)
                {
                    var timer = element.Timers[i];
                    if (timer == null)
                    {
                        continue;
                    }
                    if (selector == timer.Selector)
                    {
                        if (timer == element.CurrentTimer && (!element.CurrentTimerSalvaged))
                        {
                            element.CurrentTimerSalvaged = true;
                        }

                        element.Timers.RemoveAt(i);

                        // update timerIndex in case we are in tick:, looping over the actions
                        if (element.TimerIndex >= i)
                        {
                            element.TimerIndex--;
                        }

                        if (element.Timers.Count == 0)
                        {
                            if (m_pCurrentTarget == element)
                            {
                                m_bCurrentTargetSalvaged = true;
                            }
                            else
                            {
                                RemoveHashElement(element);
                            }
                        }

                        return;
                    }
                }
            }
        }
示例#10
0
        public bool IsTargetPaused(ICCSelectorProtocol target)
        {
            Debug.Assert(target != null, "target must be non nil");

            // Custom selectors
            HashSelectorEntry element;

            if (m_pHashForSelectors.TryGetValue(target, out element))
            {
                return(element.Paused);
            }

            return(false); // should never get here
        }
示例#11
0
 public CCTimer(CCScheduler scheduler, ICCSelectorProtocol target, Action<float> selector, float seconds,
                uint repeat, float delay)
 {
     _scheduler = scheduler;
     m_pTarget = target;
     Selector = selector;
     m_fElapsed = -1;
     OriginalInterval = seconds;
     Interval = seconds;
     m_fDelay = delay;
     m_bUseDelay = delay > 0f;
     m_uRepeat = repeat;
     m_bRunForever = (m_uRepeat == CCScheduler.kCCRepeatForever);
 }
示例#12
0
 public CCTimer(CCScheduler scheduler, ICCSelectorProtocol target, Action <float> selector, float seconds,
                uint repeat, float delay)
 {
     _scheduler       = scheduler;
     m_pTarget        = target;
     Selector         = selector;
     m_fElapsed       = -1;
     OriginalInterval = seconds;
     Interval         = seconds;
     m_fDelay         = delay;
     m_bUseDelay      = delay > 0f;
     m_uRepeat        = repeat;
     m_bRunForever    = (m_uRepeat == CCScheduler.kCCRepeatForever);
 }
示例#13
0
        private void UpdateTarget(ICCSelectorProtocol target, float dt)
        {
            if (OnUnhandledException == null)
            {
                target.Update(dt);
                return;
            }

            try
            {
                target.Update(dt);
            }
            catch (Exception exception)
            {
                OnUnhandledException(exception);
            }
        }
示例#14
0
        private void PriorityIn(LinkedList <ListEntry> list, ICCSelectorProtocol target, int priority, bool paused)
        {
            var listElement = new ListEntry
            {
                Target            = target,
                Priority          = priority,
                Paused            = paused,
                MarkedForDeletion = false
            };

            if (list.First == null)
            {
                list.AddFirst(listElement);
            }
            else
            {
                bool added = false;
                for (LinkedListNode <ListEntry> node = list.First; node != null; node = node.Next)
                {
                    if (priority < node.Value.Priority)
                    {
                        list.AddBefore(node, listElement);
                        added = true;
                        break;
                    }
                }

                if (!added)
                {
                    list.AddLast(listElement);
                }
            }

            // update hash entry for quick access
            var hashElement = new HashUpdateEntry
            {
                Target = target,
                List   = list,
                Entry  = listElement
            };

            m_pHashForUpdates.Add(target, hashElement);
        }
示例#15
0
        public void ResumeTarget(ICCSelectorProtocol target)
        {
            Debug.Assert(target != null);

            // custom selectors
            HashTimeEntry element;

            if (m_pHashForTimers.TryGetValue(target, out element))
            {
                element.Paused = false;
            }

            // Update selector
            HashUpdateEntry elementUpdate;

            if (m_pHashForUpdates.TryGetValue(target, out elementUpdate))
            {
                elementUpdate.Entry.Paused = false;
            }
        }
示例#16
0
        public void PauseTarget(ICCSelectorProtocol target)
        {
            Debug.Assert(target != null);

            // custom selectors
            HashTimeEntry entry;

            if (m_pHashForTimers.TryGetValue(target, out entry))
            {
                entry.Paused = true;
            }

            // Update selector
            HashUpdateEntry updateEntry;

            if (m_pHashForUpdates.TryGetValue(target, out updateEntry))
            {
                updateEntry.Entry.Paused = true;
            }
        }
示例#17
0
        /*
         * unsigned int CCScheduler::scheduleScriptFunc(unsigned int nHandler, float fInterval, bool bPaused)
         * {
         *  CCSchedulerScriptHandlerEntry* pEntry = CCSchedulerScriptHandlerEntry::create(nHandler, fInterval, bPaused);
         *  if (!m_pScriptHandlerEntries)
         *  {
         *      m_pScriptHandlerEntries = CCArray::create(20);
         *      m_pScriptHandlerEntries->retain();
         *  }
         *  m_pScriptHandlerEntries->addObject(pEntry);
         *  return pEntry->getEntryId();
         * }
         *
         * void CCScheduler::unscheduleScriptEntry(unsigned int uScheduleScriptEntryID)
         * {
         *  for (int i = m_pScriptHandlerEntries->count() - 1; i >= 0; i--)
         *  {
         *      CCSchedulerScriptHandlerEntry* pEntry = static_cast<CCSchedulerScriptHandlerEntry*>(m_pScriptHandlerEntries->objectAtIndex(i));
         *      if (pEntry->getEntryId() == uScheduleScriptEntryID)
         *      {
         *          pEntry->markedForDeletion();
         *          break;
         *      }
         *  }
         * }
         */

        public void UnscheduleUpdateForTarget(ICCSelectorProtocol target)
        {
            if (target == null)
            {
                return;
            }

            HashUpdateEntry element;

            if (m_pHashForUpdates.TryGetValue(target, out element))
            {
                if (m_bUpdateHashLocked)
                {
                    element.Entry.MarkedForDeletion = true;
                }
                else
                {
                    RemoveUpdateFromHash(element.Entry);
                }
            }
        }
示例#18
0
        private void AppendIn(LinkedList <ListEntry> list, ICCSelectorProtocol target, bool paused)
        {
            var listElement = new ListEntry
            {
                Target            = target,
                Paused            = paused,
                MarkedForDeletion = false
            };

            list.AddLast(listElement);

            // update hash entry for quicker access
            var hashElement = new HashUpdateEntry
            {
                Target = target,
                List   = list,
                Entry  = listElement
            };

            m_pHashForUpdates.Add(target, hashElement);
        }
示例#19
0
        public bool IsTargetPaused(ICCSelectorProtocol target)
        {
            Debug.Assert(target != null, "target must be non nil");

            // Custom selectors
            HashTimeEntry element;

            if (m_pHashForTimers.TryGetValue(target, out element))
            {
                return(element.Paused);
            }

            // We should check update selectors if target does not have custom selectors
            HashUpdateEntry elementUpdate;

            if (m_pHashForUpdates.TryGetValue(target, out elementUpdate))
            {
                return(elementUpdate.Entry.Paused);
            }

            return(false); // should never get here
        }
示例#20
0
        /// <summary>
        /// initializes a menu item from a string and atlas with a target/selector
        /// </summary>
        public bool InitFromString(string value, string charMapFile, int itemWidth, int itemHeight, char startCharMap, ICCSelectorProtocol target,
                                   Action <CCMenuItem> selector)
        {
            // CCAssert( value != NULL && strlen(value) != 0, "value length must be greater than 0");
            var label = new CCLabelAtlas(value, charMapFile, itemWidth, itemHeight, startCharMap);

            base.InitWithLabel(label, selector);
            return(true);
        }
示例#21
0
        private void AppendIn(LinkedList<ListEntry> list, ICCSelectorProtocol target, bool paused)
        {
            var listElement = new ListEntry
                {
                    Target = target,
                    Paused = paused,
                    MarkedForDeletion = false
                };

            list.AddLast(listElement);

            // update hash entry for quicker access
            var hashElement = new HashUpdateEntry
                {
                    Target = target,
                    List = list,
                    Entry = listElement
                };

            m_pHashForUpdates.Add(target, hashElement);
        }
示例#22
0
        public bool IsTargetPaused(ICCSelectorProtocol target)
        {
            Debug.Assert(target != null, "target must be non nil");

            // Custom selectors
            HashSelectorEntry element;
            if (m_pHashForSelectors.TryGetValue(target, out element))
            {
                return element.Paused;
            }

            return false; // should never get here
        }
示例#23
0
        public bool IsTargetPaused(ICCSelectorProtocol target)
        {
            Debug.Assert(target != null, "target must be non nil");

            // Custom selectors
            HashTimeEntry element;
            if (m_pHashForTimers.TryGetValue(target, out element))
            {
                return element.Paused;
            }

            // We should check update selectors if target does not have custom selectors
            HashUpdateEntry elementUpdate;
            if (m_pHashForUpdates.TryGetValue(target, out elementUpdate))
            {
                return elementUpdate.Entry.Paused;
            }

            return false; // should never get here
        }
示例#24
0
        private void PriorityIn(LinkedList<ListEntry> list, ICCSelectorProtocol target, int priority, bool paused)
        {
            var listElement = new ListEntry
                {
                    Target = target,
                    Priority = priority,
                    Paused = paused,
                    MarkedForDeletion = false
                };

            if (list.First == null)
            {
                list.AddFirst(listElement);
            }
            else
            {
                bool added = false;
                for (LinkedListNode<ListEntry> node = list.First; node != null; node = node.Next)
                {
                    if (priority < node.Value.Priority)
                    {
                        list.AddBefore(node, listElement);
                        added = true;
                        break;
                    }
                }

                if (!added)
                {
                    list.AddLast(listElement);
                }
            }

            // update hash entry for quick access
            var hashElement = new HashUpdateEntry
                {
                    Target = target,
                    List = list,
                    Entry = listElement
                };

            m_pHashForUpdates.Add(target, hashElement);
        }
示例#25
0
        public void PauseTarget(ICCSelectorProtocol target)
        {
            Debug.Assert(target != null);

            // custom selectors
            HashTimeEntry entry;
            if (m_pHashForTimers.TryGetValue(target, out entry))
            {
                entry.Paused = true;
            }

            // Update selector
            HashUpdateEntry updateEntry;
            if (m_pHashForUpdates.TryGetValue(target, out updateEntry))
            {
                updateEntry.Entry.Paused = true;
            }
        }
示例#26
0
        public void ResumeTarget(ICCSelectorProtocol target)
        {
            Debug.Assert(target != null);

            // custom selectors
            HashTimeEntry element;
            if (m_pHashForTimers.TryGetValue(target, out element))
            {
                element.Paused = false;
            }

            // Update selector
            HashUpdateEntry elementUpdate;
            if (m_pHashForUpdates.TryGetValue(target, out elementUpdate))
            {
                elementUpdate.Entry.Paused = false;
            }
        }
示例#27
0
        /** Unschedules all selectors for a given target.
    	     This also includes the "update" selector.
    	     @since v0.99.3
    	     */

        public void UnscheduleAllForTarget(ICCSelectorProtocol target)
        {
            // explicit NULL handling
            if (target == null)
            {
                return;
            }

            // custom selectors           
            HashTimeEntry element;

            if (m_pHashForTimers.TryGetValue(target, out element))
            {
                if (element.Timers.Contains(element.CurrentTimer))
                {
                    element.CurrentTimerSalvaged = true;
                }
                element.Timers.Clear();

                if (m_pCurrentTarget == element)
                {
                    m_bCurrentTargetSalvaged = true;
                }
                else
                {
                    RemoveHashElement(element);
                }
            }

            // update selector
            UnscheduleUpdateForTarget(target);
        }
示例#28
0
        /*
        unsigned int CCScheduler::scheduleScriptFunc(unsigned int nHandler, float fInterval, bool bPaused)
        {
            CCSchedulerScriptHandlerEntry* pEntry = CCSchedulerScriptHandlerEntry::create(nHandler, fInterval, bPaused);
            if (!m_pScriptHandlerEntries)
            {
                m_pScriptHandlerEntries = CCArray::create(20);
                m_pScriptHandlerEntries->retain();
            }
            m_pScriptHandlerEntries->addObject(pEntry);
            return pEntry->getEntryId();
        }

        void CCScheduler::unscheduleScriptEntry(unsigned int uScheduleScriptEntryID)
        {
            for (int i = m_pScriptHandlerEntries->count() - 1; i >= 0; i--)
            {
                CCSchedulerScriptHandlerEntry* pEntry = static_cast<CCSchedulerScriptHandlerEntry*>(m_pScriptHandlerEntries->objectAtIndex(i));
                if (pEntry->getEntryId() == uScheduleScriptEntryID)
                {
                    pEntry->markedForDeletion();
                    break;
                }
            }
        }
        */

        public void UnscheduleUpdateForTarget(ICCSelectorProtocol target)
        {
            if (target == null)
            {
                return;
            }

            HashUpdateEntry element;
            if (m_pHashForUpdates.TryGetValue(target, out element))
            {
                if (m_bUpdateHashLocked)
                {
                    element.Entry.MarkedForDeletion = true;
                }
                else
                {
                    RemoveUpdateFromHash(element.Entry);
                }
            }
        }
示例#29
0
        /** Unschedule a selector for a given target.
    	     If you want to unschedule the "update", use unscheudleUpdateForTarget.
    	     @since v0.99.3
    	     */

        public void UnscheduleSelector(Action<float> selector, ICCSelectorProtocol target)
        {
            // explicity handle nil arguments when removing an object
            if (selector == null || target == null)
            {
                return;
            }

            HashTimeEntry element;
            if (m_pHashForTimers.TryGetValue(target, out element))
            {
                for (int i = 0; i < element.Timers.Count; i++)
                {
                    var timer = element.Timers[i];

                    if (selector == timer.Selector)
                    {
                        if (timer == element.CurrentTimer && (!element.CurrentTimerSalvaged))
                        {
                            element.CurrentTimerSalvaged = true;
                        }

                        element.Timers.RemoveAt(i);

                        // update timerIndex in case we are in tick:, looping over the actions
                        if (element.TimerIndex >= i)
                        {
                            element.TimerIndex--;
                        }

                        if (element.Timers.Count == 0)
                        {
                            if (m_pCurrentTarget == element)
                            {
                                m_bCurrentTargetSalvaged = true;
                            }
                            else
                            {
                                RemoveHashElement(element);
                            }
                        }

                        return;
                    }
                }
            }
        }
示例#30
0
        /** Initializes a timer with a target, a selector and an interval in seconds. 
         *  Target is not needed in c#, it is just for compatibility.
         */

        public CCTimer(CCScheduler scheduler, ICCSelectorProtocol target, Action<float> selector, float seconds)
            : this(scheduler, target, selector, seconds, 0, 0)
        {
        }
示例#31
0
        /** Schedules the 'update' selector for a given target with a given priority.
    	     The 'update' selector will be called every frame.
    	     The lower the priority, the earlier it is called.
    	     @since v0.99.3
    	     */

        public void ScheduleUpdateForTarget(ICCSelectorProtocol targt, int priority, bool paused)
        {
            HashUpdateEntry element;

            if (m_pHashForUpdates.TryGetValue(targt, out element))
            {
                Debug.Assert(element.Entry.MarkedForDeletion);

                // TODO: check if priority has changed!
                element.Entry.MarkedForDeletion = false;

                return;
            }

            // most of the updates are going to be 0, that's way there
            // is an special list for updates with priority 0
            if (priority == 0)
            {
                AppendIn(m_pUpdates0List, targt, paused);
            }
            else if (priority < 0)
            {
                PriorityIn(m_pUpdatesNegList, targt, priority, paused);
            }
            else
            {
                PriorityIn(m_pUpdatesPosList, targt, priority, paused);
            }
        }
示例#32
0
        /** The scheduled method will be called every 'interval' seconds.
         If paused is YES, then it won't be called until it is resumed.
         If 'interval' is 0, it will be called every frame, but if so, it's recommended to use 'scheduleUpdateForTarget:' instead.
         If the selector is already scheduled, then only the interval parameter will be updated without re-scheduling it again.
         repeat let the action be repeated repeat + 1 times, use kCCRepeatForever to let the action run continuously
         delay is the amount of time the action will wait before it'll start

         @since v0.99.3, repeat and delay added in v1.1
         */

        public void ScheduleSelector(Action<float> selector, ICCSelectorProtocol target, float interval, uint repeat,
                                     float delay, bool paused)
        {
            Debug.Assert(selector != null);
            Debug.Assert(target != null);

            HashTimeEntry element;

            if (!m_pHashForTimers.TryGetValue(target, out element))
            {
                element = new HashTimeEntry {Target = target};
                m_pHashForTimers[target] = element;

                // Is this the 1st element ? Then set the pause level to all the selectors of this target
                element.Paused = paused;
            }
            else
            {
                Debug.Assert(element.Paused == paused);
            }

            if (element.Timers == null)
            {
                element.Timers = new List<CCTimer>();
            }
            else
            {
                foreach (var timer in element.Timers)
                {
                    if (selector == timer.Selector)
                    {
                        Debug.WriteLine(
                            "CCSheduler#scheduleSelector. Selector already scheduled. Updating interval from: {0} to {1}",
                            timer.Interval, interval);
                        timer.Interval = interval;
                        return;
                    }
                }
            }

            element.Timers.Add(new CCTimer(this, target, selector, interval, repeat, delay));
        }
示例#33
0
        private void UpdateTarget(ICCSelectorProtocol target, float dt)
        {
            if (OnUnhandledException == null)
            {
                target.Update(dt);
                return;
            }

            try
            {
                target.Update(dt);
            }
            catch (Exception exception)
            {
                OnUnhandledException(exception);
            }
        }
示例#34
0
        internal void update(float dt)
        {
            m_bUpdateHashLocked = true;

            try
            {
                if (TimeScale != 1.0f)
                {
                    dt *= TimeScale;
                }

                LinkedListNode <ListEntry> next;

                // updates with priority < 0
                //foreach (ListEntry entry in _updatesNegList)
                for (LinkedListNode <ListEntry> node = m_pUpdatesNegList.First; node != null; node = next)
                {
                    next = node.Next;
                    if (!node.Value.Paused && !node.Value.MarkedForDeletion)
                    {
                        UpdateTarget(node.Value.Target, dt);
                    }
                }

                // updates with priority == 0
                //foreach (ListEntry entry in _updates0List)
                for (LinkedListNode <ListEntry> node = m_pUpdates0List.First; node != null; node = next)
                {
                    next = node.Next;
                    if (!node.Value.Paused && !node.Value.MarkedForDeletion)
                    {
                        UpdateTarget(node.Value.Target, dt);
                    }
                }

                // updates with priority > 0
                for (LinkedListNode <ListEntry> node = m_pUpdatesPosList.First; node != null; node = next)
                {
                    next = node.Next;
                    if (!node.Value.Paused && !node.Value.MarkedForDeletion)
                    {
                        UpdateTarget(node.Value.Target, dt);
                    }
                }

                // Iterate over all the custom selectors
                var count = m_pHashForTimers.Keys.Count;
                if (s_pTmpSelectorArray.Length < count)
                {
                    s_pTmpSelectorArray = new ICCSelectorProtocol[s_pTmpSelectorArray.Length * 2];
                }
                m_pHashForTimers.Keys.CopyTo(s_pTmpSelectorArray, 0);

                for (int i = 0; i < count; i++)
                {
                    ICCSelectorProtocol key = s_pTmpSelectorArray[i];
                    if (key == null || !m_pHashForTimers.ContainsKey(key))
                    {
                        continue;
                    }
                    HashTimeEntry elt = m_pHashForTimers[key];

                    m_pCurrentTarget         = elt;
                    m_bCurrentTargetSalvaged = false;

                    if (elt != null && !m_pCurrentTarget.Paused)
                    {
                        // The 'timers' array may change while inside this loop
                        for (elt.TimerIndex = 0; elt.TimerIndex < elt.Timers.Count; ++elt.TimerIndex)
                        {
                            elt.CurrentTimer = elt.Timers[elt.TimerIndex];
                            if (elt.CurrentTimer != null)
                            {
                                elt.CurrentTimerSalvaged = false;
                                UpdateTarget(elt.CurrentTimer, dt);
                                elt.CurrentTimer = null;
                            }
                        }
                    }

                    // only delete currentTarget if no actions were scheduled during the cycle (issue #481)
                    if (m_bCurrentTargetSalvaged && m_pCurrentTarget.Timers.Count == 0)
                    {
                        RemoveHashElement(m_pCurrentTarget);
                    }
                }

                /*
                 * // Iterate over all the script callbacks
                 * if (m_pScriptHandlerEntries)
                 * {
                 *  for (int i = m_pScriptHandlerEntries->count() - 1; i >= 0; i--)
                 *  {
                 *      CCSchedulerScriptHandlerEntry* pEntry = static_cast<CCSchedulerScriptHandlerEntry*>(m_pScriptHandlerEntries->objectAtIndex(i));
                 *      if (pEntry->isMarkedForDeletion())
                 *      {
                 *          m_pScriptHandlerEntries->removeObjectAtIndex(i);
                 *      }
                 *      else if (!pEntry->isPaused())
                 *      {
                 *          pEntry->getTimer()->update(dt);
                 *      }
                 *  }
                 * }
                 */

                // delete all updates that are marked for deletion
                // updates with priority < 0
                for (LinkedListNode <ListEntry> node = m_pUpdatesNegList.First; node != null; node = next)
                {
                    next = node.Next;
                    if (node.Value.MarkedForDeletion)
                    {
                        m_pUpdatesNegList.Remove(node);
                        RemoveUpdateFromHash(node.Value);
                    }
                }

                // updates with priority == 0
                for (LinkedListNode <ListEntry> node = m_pUpdates0List.First; node != null; node = next)
                {
                    next = node.Next;
                    if (node.Value.MarkedForDeletion)
                    {
                        m_pUpdates0List.Remove(node);
                        RemoveUpdateFromHash(node.Value);
                    }
                }

                // updates with priority > 0
                for (LinkedListNode <ListEntry> node = m_pUpdatesPosList.First; node != null; node = next)
                {
                    next = node.Next;
                    if (node.Value.MarkedForDeletion)
                    {
                        m_pUpdatesPosList.Remove(node);
                        RemoveUpdateFromHash(node.Value);
                    }
                }
            }
            finally
            {
                // Always do this just in case there is a problem

                m_bUpdateHashLocked = false;
                m_pCurrentTarget    = null;
            }
        }
示例#35
0
        /** Initializes a timer with a target, a selector and an interval in seconds.
         *  Target is not needed in c#, it is just for compatibility.
         */

        public CCTimer(CCScheduler scheduler, ICCSelectorProtocol target, Action <float> selector, float seconds)
            : this(scheduler, target, selector, seconds, 0, 0)
        {
        }