public static void add(float time, Command cObj, TimeEvent.EventType name = TimeEvent.EventType.Animation, Index index = Index.Index_Null) { TimeEvent node = (TimeEvent)Instance.detachReserveHead(); node.set(Instance.currTime, time, cObj, name, index); Instance.addActivePriority(node); }
public override void Execute(float deltaTime) { SpaceInvaders pGame = GameStateManager.GetGame(); pGame.SetResetLevelFlag(false); // Ghost any remaining Shields ShieldGroup pShieldGroup = (ShieldGroup)GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.ShieldGroup); ShieldFactory.DestroyShields(pShieldGroup); // Ghost any remaining Aliens (Only necessary for Game reset) AlienGrid pAlienGrid = (AlienGrid)GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.AlienGrid); AlienFactory.DestroyAlienGrid(pAlienGrid); // Clear TimeEvents TimeEvent tEvent = TimerManager.Pop(); while (tEvent != null) { // Kill any remaining TimerEvents tEvent = TimerManager.Pop(); } // Recreate shields GameObject pShield; pShield = ShieldFactory.RecreateShield(110, 150); pShieldGroup.Add(pShield); pShield = ShieldFactory.RecreateShield(310, 150); pShieldGroup.Add(pShield); pShield = ShieldFactory.RecreateShield(510, 150); pShieldGroup.Add(pShield); pShield = ShieldFactory.RecreateShield(710, 150); pShieldGroup.Add(pShield); // Adjust Starting Speed float newStartingSpeed = pGame.GetStateLevelInitialAlienGridSpeed() - 0.05f; pGame.SetStateLevelInitialAlienGridSpeed(newStartingSpeed); pGame.SetStateAlienGridSpeed(newStartingSpeed); // Adjust Starting Position float newStartingYPosition = pGame.GetStateLevelInitialAlienGridYPosition() - 40.0f; pGame.SetStateLevelInitialAlienGridYPosition(newStartingYPosition); // Recreate AlienGrid AlienFactory.RecreateAlienGrid(pAlienGrid, newStartingSpeed, GameStateManager.GetGame().GetGameInitialGridXPosition(), newStartingYPosition); pGame.GetStateGameObjectManager().Print(); pGame.GetStateSpriteBatchManager().Print(); // Queue up Time Events QueuedTimeEventManager qtem = pGame.GetStateQueuedTimeEventManager(); qtem.Enqueue(TimeEvent.Name.AlienGridMovementSound, new AlienGridMovementSound(), newStartingSpeed); qtem.Enqueue(TimeEvent.Name.SpriteAnimation, SpriteAnimationManager.Find(SpriteAnimation.Name.SquidAlien), newStartingSpeed); qtem.Enqueue(TimeEvent.Name.SpriteAnimation, SpriteAnimationManager.Find(SpriteAnimation.Name.CrabAlien), newStartingSpeed); qtem.Enqueue(TimeEvent.Name.SpriteAnimation, SpriteAnimationManager.Find(SpriteAnimation.Name.JellyfishAlien), newStartingSpeed); // Load Time Events into TimerManager QueuedTimeEvent qte = pGame.GetStateQueuedTimeEventManager().Dequeue(); while (qte != null) { TimerManager.Add(qte.GetTimeEventName(), qte.GetCommand(), qte.GetTimeEventDelta()); qte = pGame.GetStateQueuedTimeEventManager().Dequeue(); } }
public static void add(Command addedObj, TimeEvent.EventType type = TimeEvent.EventType.Not_Initialized, Index index = Index.Index_Null) { CommandNode node = (CommandNode)Instance.baseAdd(); node.set(addedObj, type, index); }
private void createReserve(int numNodes) { this.stats.currNumNodes += numNodes; this.stats.currReserveNodes += numNodes; if (stats.currNumNodes > stats.peakNumNodes) { stats.peakNumNodes = stats.currNumNodes; } ManNode node; for (int i = 0; i < numNodes; i++) { // Derived class implements this // returns the correct object node = new TimeEvent(); addReserve(node); } }
public void set(Command cObj, TimeEvent.EventType type = TimeEvent.EventType.Not_Initialized, Index index = Index.Index_Null) { this.obj = cObj; this.evType = type; this.index = index; }
private void addActivePriority(TimeEvent node) { TimeEvent curr = (TimeEvent)this.activeHead; if (activeHead == null) { activeHead = node; } else { while (curr.next != null && ((TimeEvent)curr).time < ((TimeEvent)node).time) { if (((TimeEvent)curr.next).time > ((TimeEvent)node).time) { break; } curr = (TimeEvent)curr.next; } if (this.activeHead == curr) { node.next = curr; node.prev = curr.prev; curr.prev = node; this.activeHead = node; } else { node.next = curr.next; curr.next = node; node.prev = curr; if (node.next != null) { node.next.prev = node; } } } }
protected override void DerivedDumpNode(DLink pDLink) { TimeEvent pTEnode = (TimeEvent)pDLink; pTEnode.DumpTimeEvent(); }
public override void Execute() { GameObject pA = (GameObject)this.pAlien; GameObject pB = (GameObject)Iterator.GetParent(pA); float x = this.pAlien.x; float y = this.pAlien.y; AlienGrid pGrid = (AlienGrid)this.pAlien.pParent.pParent; pGrid.nNumActive--; pA.Remove(); // TODO: Need a better way... if (privCheckParent(pB) == true) { GameObject pC = (GameObject)Iterator.GetParent(pB); pB.Remove(); if (privCheckParent(pC) == true) { pC.Remove(); } } Missile pMissile = (Missile)this.pGameObj; Player pPlayer = pMissile.pPlayer; // Font.Name pFontName = Font.Name.Uninitialized; if (this.pGameObj is MissileCategory) { pPlayer.nPoints += this.pAlien.GetPoints(); Font pScore = null; if (pPlayer.n == 1) { pScore = FontMan.Find(Font.Name.Score1Value); pFontName = Font.Name.Score1Value; } if (pPlayer.n == 2) { pScore = FontMan.Find(Font.Name.Score2Value); pFontName = Font.Name.Score2Value; } pScore.Set(pFontName, pPlayer.nPoints.ToString(), Glyph.Name.Consolas20pt, pScore.pFontSprite.x, pScore.pFontSprite.y); } //--------------------------------------------------------------------------------------------------------- // Sound //--------------------------------------------------------------------------------------------------------- SoundMan.PlaySound(Sound.Name.InvaderKilled); TimeEvent pTimeEvent = TimerMan.Find(TimeEvent.Name.ScenePlaySound); pTimeEvent.deltaTime -= 0.01f; //--------------------------------------------------------------------------------------------------------- // Explosion //--------------------------------------------------------------------------------------------------------- Explosion explosion = new Explosion(GameObject.Name.Explosion, GameSprite.Name.Explosion, x, y); SpriteBatch pSB_Aliens = SpriteBatchMan.Find(SpriteBatch.Name.Aliens); explosion.ActivateGameSprite(pSB_Aliens); GameObjectMan.Attach(explosion); TimerMan.Add(TimeEvent.Name.RemoveExplosion, new RemoveExplosionCommand(explosion), 0.25f); //--------------------------------------------------------------------------------------------------------- // Scene Transition //--------------------------------------------------------------------------------------------------------- if (pGrid.nNumActive == 0 && pPlayer.nCurrLevel == 1) { PlayerMan.WriteHighScores(); pPlayer.nCurrLevel++; SceneContext.GetState().Initialize(); if (SceneContext.bMultiplayer) { SceneContext.SetState(SceneContext.Scene.MultiPlay); } else { SceneContext.SetState(SceneContext.Scene.SinglePlay); } } else if (pGrid.nNumActive == 0 && pPlayer.nCurrLevel == 2) { PlayerMan.WriteHighScores(); SceneContext.SetState(SceneContext.Scene.Credits); } }
public void set(float totalTime, float deltaTime, Command cObj, TimeEvent.EventType name, Index index = Index.Index_Null) { this.comEvent = cObj; this.trigger = totalTime + deltaTime; this.changeInTime = deltaTime; this.name = name; this.index = index; canUpdate = true; }
//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; } }
private TimerManager(int numNodes = 3, int growthSize = 1) : base(numNodes, growthSize) { poNodeCompare = new TimeEvent(); Debug.Assert(poNodeCompare != null); }
private void sortTimeEventList(TimeEvent pTimeEvent) { // ensure call Create() first TimerMan pMan = TimerMan.GetInstance(); Debug.Assert(pMan != null); TimeEvent pActiveList = (TimeEvent)pMan.baseGetActiveList(); TimeEvent pCurrTimeEvent = pActiveList; if (pCurrTimeEvent == null) { pMan.baseSetActiveHead(pTimeEvent); return; } if (pCurrTimeEvent.pNext == null && pCurrTimeEvent.pPrev == null) { if (pCurrTimeEvent.getTriggerTime() > pTimeEvent.getTriggerTime()) { pCurrTimeEvent.pPrev = pTimeEvent; pTimeEvent.pNext = pCurrTimeEvent; pTimeEvent.pPrev = null; pMan.baseSetActiveHead(pTimeEvent); return; } else { pCurrTimeEvent.pNext = pTimeEvent; pTimeEvent.pPrev = pCurrTimeEvent; pTimeEvent.pNext = null; return; } } while (pCurrTimeEvent != null) { if (pCurrTimeEvent.getTriggerTime() >= pTimeEvent.getTriggerTime()) { if (pCurrTimeEvent.pPrev == null) { pCurrTimeEvent.pPrev = pTimeEvent; pTimeEvent.pNext = pCurrTimeEvent; pTimeEvent.pPrev = null; pMan.baseSetActiveHead(pTimeEvent); return; } else { pTimeEvent.pPrev = pCurrTimeEvent.pPrev; pTimeEvent.pNext = pCurrTimeEvent; pCurrTimeEvent.pPrev.pNext = pTimeEvent; pCurrTimeEvent.pPrev = pTimeEvent; return; } } if (pCurrTimeEvent.pNext == null) { pCurrTimeEvent.pNext = pTimeEvent; pTimeEvent.pPrev = pCurrTimeEvent; pTimeEvent.pNext = null; return; } pCurrTimeEvent = (TimeEvent)pCurrTimeEvent.pNext; } }
protected override void DerivedDumpNode(DLink pLink) { Debug.Assert(pLink != null); TimeEvent pData = (TimeEvent)pLink; //pData.Dump(); }
//---------------------------------------------------------------------- // Constructor / Destructor //---------------------------------------------------------------------- private TimerManager(int reserveNum = 3, int reserveGrow = 1) : base(reserveNum, reserveGrow) { this.pTimeEventCompare = new TimeEvent(); }
protected override void DerivedWash(DLink pDLink) { TimeEvent pTEnode = (TimeEvent)pDLink; pTEnode.Wash(); }
protected override void DerivedDestroyNode(DLink pLink) { TimeEvent pTimeEvent = (TimeEvent)pLink; pTimeEvent.SetCommand(null); }
public override void LoadContent() { //make the next wave more difficult //change grid movement speed and add more bombs GraveyardMan.RaiseDead(); //can be finicky might need to replace //GraveyardMan.RebuildShields(); //------------------------------------------------------------------------------------------------------- //create factory //-------------------------------------------------------------------------------------------------------- Composite pAlienGroup = (Composite)GONodeMan.Find(GameObject.Name.AlienGrid); //AlienFactory AF = new AlienFactory(SpriteBatch.Name.Aliens, SpriteBatch.Name.Boxes, pAlienGroup); //GameObject pGameObj; //AF.SetParent(pAlienGroup); //GameObject pCol = AF.Create(GameObject.Name.Column_1, AlienCategory.Type.Column, 0.0f, 0.0f); //AF.SetParent(pCol); //pGameObj = AF.Create(GameObject.Name.Octopus, AlienCategory.Type.Octopus, 70.0f, 600); //Column Creation 1 - 11 //for (int i = 0; i < 1; i++) //{ // AF.SetParent(pAlienGroup); // GameObject pCol = AF.Create(GameObject.Name.Column_1 + i, AlienCategory.Type.Column, 0.0f, 0.0f, i); // AF.SetParent(pCol); // pGameObj = AF.Create(GameObject.Name.Octopus, AlienCategory.Type.Octopus, 70.0f + i * 43.0f, 660); // pGameObj = AF.Create(GameObject.Name.Crab, AlienCategory.Type.Crab, 70.0f + i * 43.0f, 620); // pGameObj = AF.Create(GameObject.Name.Crab, AlienCategory.Type.Crab, 70.0f + i * 43.0f, 580); // pGameObj = AF.Create(GameObject.Name.Squid, AlienCategory.Type.Squid, 70.0f + i * 43.0f, 540); // pGameObj = AF.Create(GameObject.Name.Squid, AlienCategory.Type.Squid, 70.0f + i * 43.0f, 500); //} //Debug.WriteLine("-------------------"); //pAlienGroup.Print(); //--------------------------------------------------------------------------------------------------------- // Shields //--------------------------------------------------------------------------------------------------------- //float posX = 80; //float posY = 120; //for (int i = 0; i < 1; i++) //{ // ShieldFactory.ShieldCreator(posX, posY, GameObject.Name.ShieldGrid_1 + i); // posX += 130; //} //Debug.WriteLine("-------------------"); //GameObject pShieldRoot = GONodeMan.Find(GameObject.Name.ShieldRoot); //pShieldRoot.Print(); //--------------------------------------------------------------------------------- //Event/Difficulty Modifiers //---------------------------------------------------------------------------------- TimeEvent pE1 = TimerMan.Find(TimeEvent.Name.AnimateSquid); TimeEvent pE2 = TimerMan.Find(TimeEvent.Name.AnimateOcto); TimeEvent pE3 = TimerMan.Find(TimeEvent.Name.AnimateCrab); TimeEvent pE4 = TimerMan.Find(TimeEvent.Name.MoveGrid); pE1.SetTriggerTime(0.50f); pE2.SetTriggerTime(0.50f); pE3.SetTriggerTime(0.50f); pE4.SetTriggerTime(0.50f); //pAlienGroup.SetDeltaMove(18.0f); BombDrop pBombDrop1 = new BombDrop((AlienGroup)pAlienGroup); BombDrop pBombDrop2 = new BombDrop((AlienGroup)pAlienGroup); BombDrop pBombDrop3 = new BombDrop((AlienGroup)pAlienGroup); TimerMan.Add(TimeEvent.Name.ColumnShoot, pBombDrop1, 1.0f); TimerMan.Add(TimeEvent.Name.ColumnShoot, pBombDrop2, 3.0f); TimerMan.Add(TimeEvent.Name.ColumnShoot, pBombDrop3, 5.0f); }