Exemplo n.º 1
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 recommened to use 'scheduleUpdateForTarget:' instead.
         *   If the selector is already scheduled, then only the interval parameter will be updated without re-scheduling it again.
         *
         *   @since v0.99.3
         */
        public void scheduleSelector(SEL_SCHEDULE selector, SelectorProtocol target, float fInterval, bool bPaused)
        {
            if (selector == null)
            {
                throw (new ArgumentNullException("selector", "Schedule selector can not be null"));
            }
            if (target == null)
            {
                throw (new ArgumentNullException("target", "Schedule target must be set."));
            }

            tHashSelectorEntry element = null;

            if (!m_pHashForSelectors.ContainsKey(target))
            {
                element        = new tHashSelectorEntry();
                element.target = target;
                m_pHashForSelectors[target] = element;

                // Is this the 1st element ? Then set the pause level to all the selectors of this target
                element.paused = bPaused;
            }
            else
            {
                element = m_pHashForSelectors[target];

                Debug.Assert(element.paused == bPaused);
            }

            if (element.timers == null)
            {
                element.timers = new List <CCTimer>();
            }
            else
            {
                foreach (CCTimer timer in element.timers)
                {
                    if (selector == timer.m_pfnSelector)
                    {
                        System.Diagnostics.Debug.WriteLine("CCSheduler#scheduleSelector. Selector already scheduled.");
                        timer.m_fInterval = fInterval;
                        return;
                    }
                }
            }

            CCTimer timer2 = new CCTimer();

            timer2.initWithTarget(target, selector, fInterval);
            element.timers.Add(timer2);
        }
Exemplo n.º 2
0
        public void scheduleSelector(SEL_SCHEDULE selector, SelectorProtocol target, float fInterval, bool bPaused)
        {
            if (selector == null)
            {
                throw new ArgumentNullException("selector", "Schedule selector can not be null");
            }
            if (target == null)
            {
                throw new ArgumentNullException("target", "Schedule target must be set.");
            }
            tHashSelectorEntry entry = null;

            if (!this.m_pHashForSelectors.ContainsKey(target))
            {
                entry = new tHashSelectorEntry
                {
                    target = target
                };
                this.m_pHashForSelectors[target] = entry;
                entry.paused = bPaused;
            }
            else
            {
                entry = this.m_pHashForSelectors[target];
            }
            if (entry.timers == null)
            {
                entry.timers = new List <CCTimer>();
            }
            else
            {
                foreach (CCTimer timer in entry.timers)
                {
                    if (selector == timer.m_pfnSelector)
                    {
                        CCLog.Log("CCSheduler#scheduleSelector. Selector already scheduled.");
                        timer.m_fInterval = fInterval;
                        return;
                    }
                }
            }
            CCTimer item = new CCTimer();

            item.initWithTarget(target, selector, fInterval);
            entry.timers.Add(item);
        }
Exemplo n.º 3
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 recommened to use 'scheduleUpdateForTarget:' instead.
         If the selector is already scheduled, then only the interval parameter will be updated without re-scheduling it again.

         @since v0.99.3
         */
        public void scheduleSelector(SEL_SCHEDULE selector, SelectorProtocol target, float fInterval, bool bPaused)
        {
            Debug.Assert(selector != null);
            Debug.Assert(target != null);

            tHashSelectorEntry element = null;
            if (!m_pHashForSelectors.ContainsKey(target))
            {
                element = new tHashSelectorEntry();
                element.target = target;
                m_pHashForSelectors[target] = element;

                // Is this the 1st element ? Then set the pause level to all the selectors of this target
                element.paused = bPaused;
            }
            else
            {
                element = m_pHashForSelectors[target];

                Debug.Assert(element.paused == bPaused);
            }

            if (element.timers == null)
            {
                element.timers = new List<CCTimer>();
            }
            else
            {
                foreach (CCTimer timer in element.timers)
                {
                    if (selector == timer.m_pfnSelector)
                    {
                        Debug.WriteLine("CCSheduler#scheduleSelector. Selector already scheduled.");
                        timer.m_fInterval = fInterval;
                        return;
                    }
                }
            }

            CCTimer timer2 = new CCTimer();
            timer2.initWithTarget(target, selector, fInterval);
            element.timers.Add(timer2);
        }
Exemplo n.º 4
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 recommened to use 'scheduleUpdateForTarget:' instead.
	     If the selector is already scheduled, then only the interval parameter will be updated without re-scheduling it again.

	     @since v0.99.3
	     */
        public void scheduleSelector(SEL_SCHEDULE selector, SelectorProtocol target, float fInterval, bool bPaused)
        {
            if (selector == null)
            {
                throw (new ArgumentNullException("selector", "Schedule selector can not be null"));
            }
            if (target == null)
        {
                throw (new ArgumentNullException("target", "Schedule target must be set."));
            }

            tHashSelectorEntry element = null;
            if (!m_pHashForSelectors.ContainsKey(target))
            {
                element = new tHashSelectorEntry();
                element.target = target;
                m_pHashForSelectors[target] = element;

                // Is this the 1st element ? Then set the pause level to all the selectors of this target
                element.paused = bPaused;
            }
            else
            {
                element = m_pHashForSelectors[target];

                Debug.Assert(element.paused == bPaused);
            }

            if (element.timers == null)
            {
                element.timers = new List<CCTimer>();
            }
            else
            {
                foreach (CCTimer timer in element.timers)
                {
                    if (selector == timer.m_pfnSelector)
                    {
                        CCLog.Log("CCSheduler#scheduleSelector. Selector already scheduled.");
                        timer.m_fInterval = fInterval;
                        return;
                    }
                }
            }

            CCTimer timer2 = new CCTimer();
            timer2.initWithTarget(target, selector, fInterval);
            element.timers.Add(timer2);
        }