示例#1
0
        public static void Update(float currentTime)
        {
            TimerManager timerMan = TimerManager.GetInstance();

            timerMan.currentTime = currentTime;
            DLink      curr = timerMan.pActive;
            TimerEvent te   = (TimerEvent)curr;

            while (curr != null)
            {
                if (timerMan.currentTime >= te.triggerTime)
                {
                    //Debug.WriteLine("Processing TimerEvent {0} @ {1}", te.name, currentTime);
                    te.Process(currentTime);
                    timerMan.BaseRemove(te);
                    if (te.name != TimerEventName.RemoveGameObject && te.name != TimerEventName.SetGameState &&
                        te.name != TimerEventName.InitiateTimerEvents && te.name != TimerEventName.GameStart &&
                        te.name != TimerEventName.RemoveUFO && te.name != TimerEventName.StopUFOSound)
                    {
                        if (te.name == TimerEventName.UFOSpawn)
                        {
                            float random = UFOManager.GetRandom().Next(5, 10);
                            Debug.WriteLine("UFO Spawn in {0} secs", random);
                            te.deltaTime = random;
                        }
                        Add(te.name, te.triggerTime + te.deltaTime, te.deltaTime, te.command);
                    }
                }
                curr = curr.pDNext;
            }
        }
        public static void Update(float totalTime)
        {
            // Get the instance
            TimerEventManager pTimerEventManager = TimerEventManager.privGetInstance();

            // store the current time
            pTimerEventManager.currTime = totalTime;

            // walk the event list
            TimerEvent pEvent    = (TimerEvent)pTimerEventManager.baseGetActive();
            TimerEvent nextEvent = null;

            // Walk the list until currTime is greater than timeEvent triggerTime
            while (pEvent != null)
            {
                // get the next event early in case this event executes and is removed
                nextEvent = (TimerEvent)pEvent.pMNext;

                if (pTimerEventManager.currTime >= pEvent.triggerTime)
                {
                    //Debug.WriteLine("{0} Event Triggered!", pEvent.GetName());
                    //Debug.WriteLine("Trigger Time:{0}", pTimerEventManager.currTime);
                    // execute the event
                    pEvent.Process();

                    // remove event from list after execution
                    pTimerEventManager.baseRemoveNode(pEvent);
                }
                else
                {
                    // early out, since the list is sorted
                    break;
                }

                // advance the pointer
                pEvent = nextEvent;
            }
        }
示例#3
0
        public static void Update(float totalTime)
        {
            TimerMan pTimerMan = TimerMan.PrivGetInstance();

            Debug.Assert(pTimerMan != null);

            pTimerMan.mCurrTime = totalTime;

            TimerEvent pEvent     = (TimerEvent)pTimerMan.BaseGetActive();
            TimerEvent pNextEvent = null;

            while (pEvent != null && (pTimerMan.mCurrTime >= pEvent.GetTriggerTime()))
            {
                pNextEvent = (TimerEvent)pEvent.pNext;
                if (pTimerMan.mCurrTime >= pEvent.GetTriggerTime())
                {
                    pEvent.Process();
                    pTimerMan.BaseRemove(pEvent);
                }

                pEvent = pNextEvent;
            }
        }