public static void Update(float totalTime) { // Get the instance TimerManager pMan = TimerManager.PrivGetInstance(); Debug.Assert(pMan != null); // squirrel away pMan.mCurrTime = totalTime; // walk the list TimeEvent pEvent = (TimeEvent)pMan.BaseGetActive(); TimeEvent pNextEvent = null; // Walk the list until there is no more list OR currTime is greater than timeEvent // List needs to be sorted by trigger time while (pEvent != null && (pMan.mCurrTime >= pEvent.triggerTime)) { // Difficult to walk a list and remove itself from the list // so squirrel away the next event now, use it at bottom of while pNextEvent = (TimeEvent)pEvent.GetNext(); if (pMan.mCurrTime >= pEvent.triggerTime) { // call it pEvent.Process(); // remove from list pMan.BaseRemove(pEvent); } // advance the pointer pEvent = pNextEvent; } }
public static void Update(float totalTime) { // Get the instance TimerManager pInstance = TimerManager.PrivGetInstance(); Debug.Assert(pInstance != null); // "Latch" the current time pInstance.currTime = totalTime; TimeEvent pEvent = (TimeEvent)pInstance.BaseGetActive(); TimeEvent pNextEvent = null; // Walk the list to end OR currTime is greater than timeEvent while (pEvent != null && (pInstance.currTime >= pEvent.GetTriggerTime())) { pNextEvent = (TimeEvent)pEvent.GetNext(); if (pInstance.currTime >= pEvent.GetTriggerTime()) { // Process event pEvent.Process(); // Remove from list pInstance.BaseRemove(pEvent); } // Advance the pointer pEvent = pNextEvent; } }
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 TimerManager pMan = TimerManager.pActiveMan; Debug.Assert(pMan != null); // squirrel away pMan.mCurrTime = totalTime; // walk the list TimeEvent pEvent = (TimeEvent)pMan.BaseGetActive(); TimeEvent pNextEvent = null; // Walk the list until there is no more list OR currTime is greater than timeEvent // ToDo Fix: List needs to be sorted while (pEvent != null)// && (pMan.mCurrTime >= pEvent.triggerTime)) { // Difficult to walk a list and remove itself from the list // so squirrel away the next event now, use it at bottom of while pNextEvent = (TimeEvent)pEvent.pNext; if (pMan.mCurrTime >= pEvent.triggerTime) { pEvent.Process(); pMan.BaseRemove(pEvent); } pEvent = pNextEvent; } }
public static void Remove(DLink node) { if (node != null) { TimerManager timerMan = TimerManager.GetInstance(); timerMan.BaseRemove(node); } }
public static void Remove(TimeEvent pNode) { TimerManager pMan = TimerManager.PrivGetInstance(); Debug.Assert(pMan != null); Debug.Assert(pNode != null); pMan.BaseRemove(pNode); }
public static void Remove(TimeEvent pNode) { TimerManager pMan = TimerManager.pActiveMan; Debug.Assert(pMan != null); Debug.Assert(pNode != null); pMan.BaseRemove(pNode); }
public static TimeEvent Pop() { TimerManager pInstance = TimerManager.PrivGetInstance(); Debug.Assert(pInstance != null); DLink pNode = pInstance.pActive; if (pNode != null) { pInstance.BaseRemove(pNode); } return((TimeEvent)pNode); }
public static void Update(float totalTime) { TimerManager pMan = TimerManager.PrivGetInstance(); Debug.Assert(pMan != null); // squirrel away pMan.currentTime = totalTime; // walk the list TimeEvent pEvent = (TimeEvent)pMan.BaseGetActive(); TimeEvent pNextEvent = null; // Walk the list until there is no more list OR currTime is greater than timeEvent while (pEvent != null && pMan.currentTime >= pEvent.triggerTime) { pNextEvent = (TimeEvent)pEvent.pNext; pEvent.Process(); pMan.BaseRemove(pEvent); // advance the pointer pEvent = pNextEvent; } }