Ejemplo n.º 1
0
        public static void Update(float TotalTime)
        {
            TimerMan pTMan = TimerMan.PrivGetInstance();

            Debug.Assert(pTMan != null);

            //wasn't sure how we started the timer until i saw its use in the game.cs
            pTMan.mCurrentTime = TotalTime;

            TimeEvent pEvent = (TimeEvent)pTMan.BaseGetActive();

            //set the next to walk the list
            TimeEvent pNextEvent = null;

            while (pTMan.mCurrentTime >= pEvent.trigger)
            {
                //trigger event
                if (pTMan.mCurrentTime >= pEvent.trigger)
                {
                    pEvent.Process();

                    //intially i instantiated this outside of the loop "as-is" and it caused issues
                    pNextEvent = (TimeEvent)pEvent.pNext;

                    pTMan.BaseRemove(pEvent);
                }



                pEvent = pNextEvent;
            }
        }
Ejemplo n.º 2
0
        public static void Update(float totalTime)
        {
            // Get the instance
            TimerMan pMan = TimerMan.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
            // 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)
                {
                    // call it
                    pEvent.Process();

                    // remove from list
                    pMan.BaseRemove(pEvent);
                }

                // advance the pointer
                pEvent = pNextEvent;
            }
        }
Ejemplo n.º 3
0
        private TimeEvent GetActiveList()
        {
            TimerMan pTMan = TimerMan.PrivGetInstance();

            Debug.Assert(pTMan != null);

            TimeEvent pEvent = (TimeEvent)pTMan.BaseGetActive();

            return(pEvent);
        }
Ejemplo n.º 4
0
        public static void UpdateMovementRange(int delta)
        {
            TimerMan pTimerMan = TimerMan.PrivGetInstance();

            Debug.Assert(pTimerMan != null);
            TimerEvent pTimerEvent = (TimerEvent)pTimerMan.BaseGetActive();

            while (pTimerEvent != null)
            {
                pTimerEvent.GetCommand().UpdateRange(delta);
                pTimerEvent = (TimerEvent)pTimerEvent.pNext;
            }
        }
Ejemplo n.º 5
0
        public static void UpdateEvent(float deltaTimeToTrigger)
        {
            TimerMan pTimerMan = TimerMan.PrivGetInstance();

            Debug.Assert(pTimerMan != null);
            TimerEvent pTimerEvent = (TimerEvent)pTimerMan.BaseGetActive();

            while (pTimerEvent != null)
            {
                pTimerEvent.SetDeltaTime(deltaTimeToTrigger * pTimerEvent.GetDeltaTime());
                pTimerEvent = (TimerEvent)pTimerEvent.pNext;
            }
        }
Ejemplo n.º 6
0
        private static TimerEvent PrivLocateNode(float triggerTime)
        {
            TimerMan pTimerMan = TimerMan.PrivGetInstance();

            Debug.Assert(pTimerMan != null);
            TimerEvent pNode     = (TimerEvent)pTimerMan.BaseGetActive();
            TimerEvent pPrevNode = null;

            while (pNode != null && pNode.GetTriggerTime() < triggerTime)
            {
                pPrevNode = pNode;
                pNode     = (TimerEvent)pNode.pNext;
            }

            return(pPrevNode);
        }
Ejemplo n.º 7
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;
            }
        }
Ejemplo n.º 8
0
        //i definitely think the insert() needs to be cleaned up
        // i had alot of reference issues
        private static void Insert(TimeEvent pTEnode)
        {
            Debug.Assert(pTEnode != null);

            TimerMan pTMan = TimerMan.PrivGetInstance();

            Debug.Assert(pTMan != null);

            TimeEvent pEvent     = (TimeEvent)pTMan.BaseGetActive();
            TimeEvent pNextEvent = null;
            TimeEvent pPrevEvent = null;


            //very first node
            if (pEvent == null)
            {
                pTEnode.pPrev = null;
                pTEnode.pNext = null;
                DLink pTemp = (DLink)pTEnode;

                pEvent = (TimeEvent)pTMan.SetActive(ref pTemp);
            }

            //insert before the first node
            if (pTEnode.trigger < pEvent.trigger)
            {
                pTEnode.pNext = pEvent;
                pEvent.pPrev  = pTEnode;
                pTEnode.pPrev = null;


                DLink pTemp = (DLink)pTEnode;
                pEvent = (TimeEvent)pTMan.SetActive(ref pTemp);
            }

            while (pTEnode.trigger >= pEvent.trigger && pTEnode.GetHashCode() != pEvent.GetHashCode())
            {
                pNextEvent = (TimeEvent)pEvent.pNext;

                //then something is there
                if (pNextEvent != null)
                {
                    //insert into middle of list
                    if (pTEnode.trigger <= pNextEvent.trigger)
                    {
                        pPrevEvent = (TimeEvent)pEvent;

                        pTEnode.pNext = pNextEvent;
                        pTEnode.pPrev = pPrevEvent;

                        pPrevEvent.pNext = pTEnode;

                        pNextEvent.pPrev = pTEnode;

                        break;
                    }
                }

                //insert at the end of the list
                else
                {
                    pTEnode.pPrev = pEvent;
                    pEvent.pNext  = pTEnode;
                    pTEnode.pNext = null;

                    break;
                }
                pEvent = pNextEvent;
            }
        }