Пример #1
0
        public override void Execute(float deltaTime, TimeEvent.Name name)
        {
            GameObject pUFO = null;

            switch (this.flag)
            {
            case false:
                pUFO      = new LeftUFO(gameObjectName, spriteName, 800, 600);
                this.flag = true;
                break;

            case true:
                pUFO      = new RightUFO(gameObjectName, spriteName, 100, 600);
                this.flag = false;
                break;

            default:
                // something is wrong
                Debug.Assert(false);
                break;
            }
            this.pTree.Add(pUFO);

            // Attached to Group
            pUFO.ActivateGameSprite(this.pSpriteBatch);
            pUFO.ActivateCollisionSprite(this.pCollisionSpriteBatch);

            Random rnd = new Random();
            int    num = rnd.Next(20, 50);

            TimerMan.Add(name, this, num);
        }
        public void Enqueue(TimeEvent.Name inEventName, Command inCommand, float inTimeDelta)
        {
            QueuedTimeEvent pQueuedTimeEvent = (QueuedTimeEvent)BaseAdd();

            Debug.Assert(pQueuedTimeEvent != null);

            // Initialize QTE
            pQueuedTimeEvent.Set(inEventName, inCommand, inTimeDelta);
        }
Пример #3
0
        public void Set(TimeEvent.Name inEventName, Command inCommand, float inTimeDelta)
        {
            Debug.Assert(inCommand != null);
            Debug.Assert(inTimeDelta > 0);

            this.timeEventName    = inEventName;
            this.pCommand         = inCommand;
            this.commandTimeDelta = inTimeDelta;
        }
Пример #4
0
        //---------------------------------------------------------------------------------------------------------
        // Methods
        //---------------------------------------------------------------------------------------------------------
        public void set(TimeEvent.Name name, Command pCommand, float deltaTimeToTrigger)
        {
            Debug.Assert(pCommand != null);
            this.name      = name;
            this.pCommand  = pCommand;
            this.deltaTime = deltaTimeToTrigger;

            // set trigger time
            this.triggerTime = TimerMan.GetCurrTime() + deltaTimeToTrigger;
        }
Пример #5
0
        public void Set(TimeEvent.Name eventName, Command pCommand, float deltaTimeToTrigger)
        {
            Debug.Assert(pCommand != null);

            this.name      = eventName;
            this.pCommand  = pCommand;
            this.deltaTime = deltaTimeToTrigger;

            this.trigger = TimerMan.GetCurrentTime() + deltaTimeToTrigger;
        }
Пример #6
0
        //----------------------------------------------------------------------------------
        // Methods
        //----------------------------------------------------------------------------------


        public void Set(TimeEvent.Name eventName, Command pCmd, float deltaTimeToTrigger)
        {
            Debug.Assert(pCmd != null);

            this.name      = eventName;
            this.pCommand  = pCmd;
            this.deltaTime = deltaTimeToTrigger;

            // set the trigger time
            this.triggerTime = TimerManager.GetCurrentTime() + deltaTimeToTrigger;
        }
Пример #7
0
        public static TimeEvent Find(TimeEvent.Name name)
        {
            TimerMan pTMan = TimerMan.PrivGetInstance();

            Debug.Assert(pTMan != null);

            pTMan.poNodeCompare.name = name;

            TimeEvent pTEnode = (TimeEvent)pTMan.BaseFind(pTMan.poNodeCompare);

            return(pTEnode);
        }
Пример #8
0
        public static TimeEvent Find(TimeEvent.Name name)
        {
            TimerManager pMan = TimerManager.PrivGetInstance();

            Debug.Assert(pMan != null);
            // So:  Use the Compare Node - as a reference
            //      use in the Compare() function
            pMan.poNodeCompare.name = name;
            TimeEvent pData = (TimeEvent)pMan.BaseFind(pInstance.poNodeCompare);

            return(pData);
        }
Пример #9
0
        public static TimeEvent Find(TimeEvent.Name name)
        {
            TimerManager pMan = TimerManager.PrivGetInstance();

            Debug.Assert(pMan != null);

            pMan.poNodeCompare.name = name;

            TimeEvent pData = (TimeEvent)pMan.BaseFind(pMan.poNodeCompare);

            Debug.Assert(pData != null);
            return(pData);
        }
Пример #10
0
        public static TimeEvent Find(TimeEvent.Name name)
        {
            TimerMan pMan = TimerMan.privGetInstance();

            Debug.Assert(pMan != null);

            Debug.Assert(pMan.poNodeCompare != null);
            pMan.poNodeCompare.Wash();
            pMan.poNodeCompare.SetName(name);

            TimeEvent pData = (TimeEvent)pMan.baseFind(pMan.poNodeCompare);

            return(pData);
        }
Пример #11
0
        public static TimeEvent Find(TimeEvent.Name name)
        {
            // ensure call Create() first
            TimerMan pMan = TimerMan.GetInstance();

            Debug.Assert(pMan != null);

            Debug.Assert(pMan.poNodeForCompare != null);
            pMan.poNodeForCompare.setName(name);

            TimeEvent pData = (TimeEvent)pMan.baseFind(pMan.poNodeForCompare);

            return(pData);
        }
Пример #12
0
        public static TimeEvent Find(TimeEvent.Name theName)
        {
            TimerManager pTimerMan = TimerManager.privGetInstance();

            Debug.Assert(pTimerMan != null);

            Debug.Assert(pTimerMan.poNodeCompare != null);
            pTimerMan.poNodeCompare.Wash();
            pTimerMan.poNodeCompare.SetName(theName);

            TimeEvent pTimeEvent = (TimeEvent)pTimerMan.baseFind(pTimerMan.poNodeCompare);

            return(pTimeEvent);
        }
Пример #13
0
        public static TimeEvent Add(TimeEvent.Name timeName, Command pCmd, float timeToTrigger)
        {
            TimerManager pMan = TimerManager.privGetInstance();

            Debug.Assert(pMan != null);

            TimeEvent pNode = (TimeEvent)pMan.baseAdd();

            Debug.Assert(pNode != null);
            Debug.Assert(pCmd != null);
            Debug.Assert(timeToTrigger >= 0.0f);

            pNode.Set(timeName, pCmd, timeToTrigger);
            return(pNode);
        }
Пример #14
0
        public static TimeEvent Find(TimeEvent.Name name)
        {
            TimerManager pInstance = TimerManager.PrivGetInstance();

            Debug.Assert(pInstance != null);

            // Use compare node to compare to search nodes
            Debug.Assert(pInstance.pTimeEventCompare != null);
            pInstance.pTimeEventCompare.Clean();
            pInstance.pTimeEventCompare.SetName(name);

            TimeEvent pData = (TimeEvent)pInstance.BaseFind(pInstance.pTimeEventCompare);

            return(pData);
        }
Пример #15
0
        public static TimeEvent Add(TimeEvent.Name timeName, Command pCommand, float deltaTimeToTrigger)
        {
            TimerMan pMan = TimerMan.PrivGetInstance();

            Debug.Assert(pMan != null);

            TimeEvent pNode = (TimeEvent)pMan.baseAddSorted(deltaTimeToTrigger + GetCurrTime());

            Debug.Assert(pNode != null);

            Debug.Assert(pCommand != null);
            Debug.Assert(deltaTimeToTrigger >= 0.0f);

            pNode.Set(timeName, pCommand, deltaTimeToTrigger);
            return(pNode);
        }
Пример #16
0
 public override void Execute(float deltaTime, TimeEvent.Name name)
 {
     if (this.pGameObject.bMarkForDeath == false)
     {
         this.pGameObject.bMarkForDeath = true;
         //   Delay
         //switch (this.pGameObject.name)
         //{
         //    case GameObject.Name.Ship:
         //        ShipMan.DettachShip();
         //        break;
         //}
         RemoveAlienObserver pObserver = new RemoveAlienObserver(pSpriteBatchMan);
         pObserver.SetGameObject(this.pGameObject);
         DelayedObjectMan.Attach(pObserver);
     }
 }
        public static TimeEvent Add(TimeEvent.Name timeName, Command pCommand, float deltaTimeToTrigger)
        {
            TimerManager pMan = TimerManager.pActiveMan;

            Debug.Assert(pMan != null);

            //TimeEvent pNode = (TimeEvent)pMan.BaseAdd();
            TimeEvent pNode = (TimeEvent)pMan.BaseSortedAdd(deltaTimeToTrigger);

            Debug.Assert(pNode != null);

            Debug.Assert(pCommand != null);
            Debug.Assert(deltaTimeToTrigger >= 0.0f);

            pNode.Set(timeName, pCommand, deltaTimeToTrigger);
            return(pNode);
        }
Пример #18
0
        public static TimeEvent Add(TimeEvent.Name timeName, Command pCommand, float deltaTimeToTrigger)
        {
            //TimerMan pMan = TimerMan.privGetInstance();
            TimerMan pMan = TimerMan.pActiveTmMan;

            Debug.Assert(pMan != null);

            TimeEvent pNode = TimerMan.privSortedAdd(deltaTimeToTrigger);

            Debug.Assert(pNode != null);

            Debug.Assert(pCommand != null);
            Debug.Assert(deltaTimeToTrigger >= 0.0f);

            pNode.Set(timeName, pCommand, deltaTimeToTrigger);
            return(pNode);
        }
        public static TimeEvent Find(TimeEvent.Name name)
        {
            TimerManager pMan = TimerManager.pActiveMan;

            Debug.Assert(pMan != null);

            // Compare functions only compares two Nodes

            // So:  Use the Compare Node - as a reference
            //      use in the Compare() function
            //Debug.Assert(pMan.poNodeCompare != null);
            TimerManager.poNodeCompare.Wash();
            TimerManager.poNodeCompare.SetName(name);

            TimeEvent pData = (TimeEvent)pMan.BaseFind(TimerManager.poNodeCompare);

            return(pData);
        }
Пример #20
0
        public static TimeEvent Add(TimeEvent.Name name, Command pCommand, float deltaTimeToTrigger)
        {
            // ensure call Create() first
            TimerMan pMan = TimerMan.GetInstance();

            Debug.Assert(pMan != null);

            TimeEvent pTimeEvent = (TimeEvent)pMan.getNewNode();

            Debug.Assert(pTimeEvent != null);

            Debug.Assert(pCommand != null);
            Debug.Assert(deltaTimeToTrigger >= 0.0f);

            pTimeEvent.set(name, pCommand, deltaTimeToTrigger);
            pMan.sortTimeEventList(pTimeEvent);
            return(pTimeEvent);
        }
Пример #21
0
        public static TimeEvent Find(TimeEvent.Name name)
        {
            //TimerMan pMan = TimerMan.privGetInstance();
            TimerMan pMan = TimerMan.pActiveTmMan;

            Debug.Assert(pMan != null);

            // Compare functions only compares two Nodes

            // So:  Use the Compare Node - as a reference
            //      use in the Compare() function
            Debug.Assert(pMan.poNodeCompare != null);
            pMan.poNodeCompare.Wash();
            pMan.poNodeCompare.name = name;

            TimeEvent pData = (TimeEvent)pMan.baseFind(pMan.poNodeCompare);

            return(pData);
        }
Пример #22
0
        public static TimeEvent Add(TimeEvent.Name EventName, Command pCommand, float deltaTime)
        {
            Debug.Assert(pCommand != null);
            Debug.Assert(deltaTime > 0.0f);

            TimerManager pMan = TimerManager.PrivGetInstance();

            Debug.Assert(pMan != null);

            // Take a node out from Reserve list.
            // This node is washed in BasePopNode().
            TimeEvent pNode = (TimeEvent)pMan.BasePopNode();

            Debug.Assert(pNode != null);

            pNode.Set(EventName, pCommand, deltaTime);
            pMan.BaseSortedAdd(pNode);
            return(pNode);
        }
Пример #23
0
        public static TimeEvent Add(TimeEvent.Name timeName, Command pCommand, float deltaTimeToTrigger)
        {
            Debug.Assert(pCommand != null);
            Debug.Assert(deltaTimeToTrigger >= 0.0f);

            // store these parameters to be used when BaseSpecializedAdd calls DerivedInitializeNode
            TimerManager.pTmpTimeName           = timeName;
            TimerManager.pTmpCommand            = pCommand;
            TimerManager.pTmpDeltaTimeToTrigger = deltaTimeToTrigger;

            TimerManager pMan = TimerManager.PrivGetInstance();

            Debug.Assert(pMan != null);

            TimeEvent pNode = (TimeEvent)pMan.BaseSpecializedAdd();

            Debug.Assert(pNode != null);

            return(pNode);
        }
        public override void Execute(float deltaTime, TimeEvent.Name name)
        {
            // advance to next image
            ImageHolder pImageHolder = (ImageHolder)this.pCurrImage.pSNext;

            // if at end of list, set to first
            if (pImageHolder == null)
            {
                pImageHolder = (ImageHolder)poFirstImage;
            }

            // squirrel away for next timer event
            this.pCurrImage = pImageHolder;

            // change image
            this.pSprite.SwapImage(pImageHolder.pImage);

            // Add itself back to timer

            TimerMan.Add(name, this, deltaTime - 0.003f);
        }
Пример #25
0
        public static TimeEvent Add(TimeEvent.Name eventName, Command pCommand, float deltaTimeToTrigger)
        {
            TimerManager pInstance = TimerManager.PrivGetInstance();

            Debug.Assert(pInstance != null);

            // Retrieve a node from Reserve list
            TimeEvent pNewNode = (TimeEvent)pInstance.BaseGetNodeFromReserve();

            Debug.Assert(pNewNode != null);

            Debug.Assert(pCommand != null);
            Debug.Assert(deltaTimeToTrigger >= 0.0f);

            // Set TimerEvent attributes
            pNewNode.Set(eventName, pCommand, deltaTimeToTrigger);

            // Add to Active List in sorted order
            AddToActiveListInSortedOrder(pInstance, pNewNode);

            return(pNewNode);
        }
Пример #26
0
        //needs to insert as a priority queue
        public static TimeEvent Add(TimeEvent.Name name, Command pCommand, float deltaTime)
        {
            Debug.Assert(pCommand != null);

            //real-time systems  must be causal
            //cant have an event occur before current time
            Debug.Assert(deltaTime >= 0.0f);

            TimerMan pTMan = TimerMan.PrivGetInstance();

            Debug.Assert(pTMan != null);

            TimeEvent pTEnode = (TimeEvent)pTMan.GrabNode();

            Debug.Assert(pTEnode != null);

            //the TimeEvent class does the updated trigger time
            pTEnode.Set(name, pCommand, deltaTime);


            Insert(pTEnode);
            return(pTEnode);
        }
Пример #27
0
 public QueuedTimeEvent()
 {
     timeEventName    = TimeEvent.Name.Uninitialized;
     pCommand         = null;
     commandTimeDelta = -1.0f;
 }
Пример #28
0
 public void SetName(TimeEvent.Name theName)
 {
     this.name = theName;
 }
Пример #29
0
 public void setName(TimeEvent.Name name)
 {
     this.name = name;
 }
Пример #30
0
 // define this in concrete
 abstract public void Execute(float deltaTime, TimeEvent.Name name);