Example #1
0
 public void unscheduleSelector(SEL_SCHEDULE selector, SelectorProtocol target)
 {
     if (((selector != null) && (target != null)) && this.m_pHashForSelectors.ContainsKey(target))
     {
         tHashSelectorEntry element = this.m_pHashForSelectors[target];
         for (int i = 0; i < element.timers.Count; i++)
         {
             CCTimer timer = element.timers[i];
             if (selector == timer.m_pfnSelector)
             {
                 if ((timer == element.currentTimer) && !element.currentTimerSalvaged)
                 {
                     element.currentTimerSalvaged = true;
                 }
                 element.timers.RemoveAt(i);
                 if (element.timerIndex >= i)
                 {
                     element.timerIndex--;
                 }
                 if (element.timers.Count == 0)
                 {
                     if (this.m_pCurrentTarget == element)
                     {
                         this.m_bCurrentTargetSalvaged = true;
                         return;
                     }
                     this.removeHashElement(element);
                 }
                 return;
             }
         }
     }
 }
Example #2
0
        public void Schedule(SEL_SCHEDULE selector, float interval, uint repeat, float delay)
        {
            Debug.Assert(selector != null, "Argument must be non-nil");
            Debug.Assert(interval >= 0, "Argument must be positive");

            m_pScheduler.ScheduleSelector(selector, this, interval, !m_bIsRunning, repeat, delay);
        }
Example #3
0
 public void unschedule(SEL_SCHEDULE selector)
 {
     if (selector != null)
     {
         CCScheduler.sharedScheduler().unscheduleSelector(selector, this);
     }
 }
Example #4
0
 public bool initWithTarget(object target, SEL_SCHEDULE selector, float fSeconds)
 {
     this.m_pTarget     = target;
     this.m_pfnSelector = selector;
     this.m_fElapsed    = -1f;
     this.m_fInterval   = fSeconds;
     return(true);
 }
Example #5
0
 /// <summary>
 /// unschedules a custom selector.
 /// </summary>
 public void unschedule(SEL_SCHEDULE selector)
 {
     // explicit nil handling
     if (selector != null)
     {
         CCScheduler.sharedScheduler().unscheduleSelector(selector, this);
     }
 }
Example #6
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 bool initWithTarget(object target, SEL_SCHEDULE selector, float fSeconds)
        {
            m_pTarget = target;
            m_pfnSelector = selector;
            m_fElapsed = -1;
            m_fInterval = fSeconds;

            return true;
        }
Example #7
0
        public void Unschedule(SEL_SCHEDULE selector)
        {
            // explicit nil handling
            if (selector == null)
            {
                return;
            }

            m_pScheduler.UnscheduleSelector(selector, this);
        }
Example #8
0
 public CCTimer(CCScheduler scheduler, SelectorProtocol target, SEL_SCHEDULE 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;
 }
Example #9
0
 public CCTimer(CCScheduler scheduler, SelectorProtocol target, SEL_SCHEDULE 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;
 }
Example #10
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);
        }
Example #11
0
        /** Unschedule a selector for a given target.
         *   If you want to unschedule the "update", use unscheudleUpdateForTarget.
         *   @since v0.99.3
         */
        public void unscheduleSelector(SEL_SCHEDULE selector, SelectorProtocol target)
        {
            // explicity handle nil arguments when removing an object
            if (selector == null || target == null)
            {
                return;
            }

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

                for (int i = 0; i < element.timers.Count; i++)
                {
                    CCTimer timer = element.timers[i];

                    if (selector == timer.m_pfnSelector)
                    {
                        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;
                    }
                }
            }
        }
Example #12
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);
        }
Example #13
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(SEL_SCHEDULE selector, SelectorProtocol target, float interval, bool paused,
                                 uint repeat,
                                 float delay)
    {
        Debug.Assert(selector != null);
        Debug.Assert(target != null);

        HashSelectorEntry element;

        if (!m_pHashForSelectors.TryGetValue(target, out element))
        {
            element = new HashSelectorEntry {
                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 = 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));
    }
Example #14
0
 /// <summary>
 /// schedules a selector.
 /// The scheduled selector will be ticked every frame
 /// </summary>
 /// <param name="selector"></param>
 public void schedule(SEL_SCHEDULE selector)
 {
     this.schedule(selector, 0);
 }
 /// <summary>
 /// unschedules a custom selector.
 /// </summary>
 public void unschedule(SEL_SCHEDULE selector)
 {
     // explicit nil handling
     if (selector != null)
     {
         CCScheduler.sharedScheduler().unscheduleSelector(selector, this);
     }
 }
Example #16
0
 /// <summary>
 /// schedules a custom selector with an interval time in seconds.
 ///If time is 0 it will be ticked every frame.
 ///If time is 0, it is recommended to use 'scheduleUpdate' instead.
 ///If the selector is already scheduled, then the interval parameter
 ///will be updated without scheduling it again.
 /// </summary>
 public void schedule(SEL_SCHEDULE selector, float interval)
 {
     CCScheduler.sharedScheduler().scheduleSelector(selector, this, interval, !IsRunning);
 }
Example #17
0
 public void Schedule(SEL_SCHEDULE selector)
 {
     Schedule(selector, 0.0f, CCScheduler.kCCRepeatForever, 0.0f);
 }
Example #18
0
 public void ScheduleOnce(SEL_SCHEDULE selector, float delay)
 {
     Schedule(selector, 0.0f, 0, delay);
 }
Example #19
0
 public void Schedule(SEL_SCHEDULE selector, float interval)
 {
     Schedule(selector, interval, CCScheduler.kCCRepeatForever, 0.0f);
 }
Example #20
0
 /// <summary>
 /// schedules a selector.
 /// The scheduled selector will be ticked every frame
 /// </summary>
 /// <param name="selector"></param>
 public void schedule(SEL_SCHEDULE selector)
 {
     this.schedule(selector, 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);
        }
Example #22
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, SelectorProtocol target, SEL_SCHEDULE selector, float seconds)
            : this(scheduler, target, selector, seconds, 0, 0)
        {
        }
Example #23
0
 /** Initializes a timer with a target and a selector.
  */
 public bool initWithTarget(object target, SEL_SCHEDULE selector)
 {
     return(initWithTarget(target, selector, 0));
 }
Example #24
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);
        }
Example #25
0
 public void ScheduleOnce(SEL_SCHEDULE selector, float delay)
 {
     Schedule(selector, 0.0f, 0, delay);
 }
Example #26
0
 /// <summary>
 /// schedules a custom selector with an interval time in seconds.
 ///If time is 0 it will be ticked every frame.
 ///If time is 0, it is recommended to use 'scheduleUpdate' instead.
 ///If the selector is already scheduled, then the interval parameter 
 ///will be updated without scheduling it again.
 /// </summary>
 public void schedule(SEL_SCHEDULE selector, float interval)
 {
     CCScheduler.sharedScheduler().scheduleSelector(selector, this, interval, !m_bIsRunning);
 }
 /** Initializes a timer with a target and a selector.
  */
 public bool initWithTarget(object target, SEL_SCHEDULE selector)
 {
     return initWithTarget(target, selector, 0);
 }
Example #28
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(SEL_SCHEDULE selector, SelectorProtocol target, float interval, bool paused,
                                        uint repeat,
                                        float delay)
    {
        Debug.Assert(selector != null);
        Debug.Assert(target != null);

        HashSelectorEntry element;

        if (!m_pHashForSelectors.TryGetValue(target, out element))
        {
            element = new HashSelectorEntry { 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 = 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));
    }
Example #29
0
 public void Schedule(SEL_SCHEDULE selector)
 {
     Schedule(selector, 0.0f, CCScheduler.kCCRepeatForever, 0.0f);
 }
Example #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, SelectorProtocol target, SEL_SCHEDULE selector, float seconds)
     : this(scheduler, target, selector, seconds, 0, 0)
 {
 }
Example #31
0
        public void Schedule(SEL_SCHEDULE selector, float interval, uint repeat, float delay)
        {
            Debug.Assert(selector != null, "Argument must be non-nil");
            Debug.Assert(interval >= 0, "Argument must be positive");

            m_pScheduler.ScheduleSelector(selector, this, interval, !m_bIsRunning, repeat, delay);
        }
Example #32
0
    /** Unschedule a selector for a given target.
         If you want to unschedule the "update", use unscheudleUpdateForTarget.
         @since v0.99.3
         */
    public void UnscheduleSelector(SEL_SCHEDULE selector, SelectorProtocol target)
    {
        // explicity handle nil arguments when removing an object
        if (selector == null || target == null)
        {
            return;
        }

        HashSelectorEntry element;
        if (m_pHashForSelectors.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;
                }
            }
        }
    }
Example #33
0
        public void Unschedule(SEL_SCHEDULE selector)
        {
            // explicit nil handling
            if (selector == null)
                return;

            m_pScheduler.UnscheduleSelector(selector, this);
        }
Example #34
0
 public void Schedule(SEL_SCHEDULE selector, float interval)
 {
     Schedule(selector, interval, CCScheduler.kCCRepeatForever, 0.0f);
 }