public override void Execute() { // Resiter the change with the Level Level.KilledUFO(); // if this brick removed the last child in the column, then remove column // Debug.WriteLine(" alien {0} parent {1}", this.pAlien, this.pAlien.pParent); GameObject pA = (GameObject)this.pAlien; GameObject pB = (GameObject)Iterator.GetParent(pA); pB.bMarkForDeath = true; pA.Remove(); Debug.WriteLine("---- Hiding : Missile Destroyed"); TimerManager.Add(TimeEvent.Name.HideUFO, new HideUFO((AlienGrid)pB), ((AlienGrid)pB).movementTimeInterval); }
public override void Execute() { GameObject goBrick = (GameObject)this.pBrick; GameObject goParent = (GameObject)goBrick.pParent; goBrick.Remove(); if (goParent.pChild == null) { GameObject goTmp = (GameObject)goParent.pParent; goParent.Remove(); if (goTmp.pChild == null) { goTmp.Remove(); } } }
public override void Remove() { // Since the Root object is being drawn // 1st set its size to zero this.poColObj.poColRect.Set(0, 0, 0, 0); base.Update(); //// Update the parent (missile root) GameObject pParent = (GameObject)this.pParent; //remove missile from composite... missile only has one parent..need to find root for others? pParent.Remove(this); pParent.Update(); // Now remove it base.Remove(); }
public override void Execute() { // Let the gameObject deal with this... //this.pAlien.Remove(); GameObject pA = (GameObject)this.pAlien; GameObject pB = (GameObject)Iterator.GetParent(pA); 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(); // Recreate Grid on last alien delete AlienGrid pGrid = (AlienGrid)pC; pGrid.GenerateAlien(GameObjectMan.GetActive()); pGrid.ResetSpeed(); this.scenePlay.AddLife(); } } // TODO: update score - may need a better way (maybe an observer) SceneContext sc = SceneContext.GetInstance(); sc.GetState().UpdateScore(this.pAlien.scoreValue); // TODO: Splat Alien - needs a better way this.pSplat = new Splat(GameObject.Name.Splat, GameSprite.Name.SplatAlien, pAlien.x, pAlien.y); pSplat.ActivateCollisionSprite(this.pSB_Boxes); pSplat.ActivateGameSprite(this.pSB_Aliens); GameObject pSplatbRoot = GameObjectMan.Find(GameObject.Name.SplatRoot); Debug.Assert(pSplatbRoot != null); pSplatbRoot.Add(pSplat); TimerMan.Add(TimeEvent.Name.SplatRemoveAlien, new SplatRemoveEvent(this.pSplat), 0.5f); }
public override void ExecuteDelayed() { // Let the gameObjects deal with this... GameObject pCoreCannon = GameStateManager.GetGame().GetStateGameObjectManager().Find(GameObject.Name.CoreCannon); // Remove from composite Composite pCoreCannonGroup = GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.CoreCannonGroup); pCoreCannonGroup.Remove(pCoreCannon); if (pCoreCannon != null) { pCoreCannon.Remove(SpriteBatch.Name.CoreCannon, SpriteBatch.Name.CollisionBox); } // Add Timer Event to restore CoreCannon TimerManager.Add(TimeEvent.Name.ResetCoreCannon, new ResetCoreCannonCommand(), 1.0f); }
public override void Execute() { // Let the gameObject deal with this... GameObject pA = (GameObject)this.pAlien; GameObject pB = (GameObject)Iterator.GetParent(pA); pA.Remove(); // TODO: Need a better way... if (PrivCheckParent(pB) == true) { GameObject pC = (GameObject)Iterator.GetParent(pB); pB.Remove(); if (PrivCheckParent(pC) == true) { SceneMan.ChangeSceneInternal(pC); } } }
public override void Update() { //Debug.WriteLine("RemoveShipObserver: {0} {1}", this.pSubject.goA, this.pSubject.goB); GameObject ship = ShipManager.GetShip(); if (ship != null) { ship.Remove(); GameObject pShipRoot = GameObjectManager.Find(GameObjectName.ShipRoot); pShipRoot.Remove(); } Alien pExplosion = new Explosion(GameObjectName.Explosion, SpriteBaseName.Explosion, AlienType.Explosion, ship, ColorName.Green, 0); SpriteBatch sbAliens = SpriteBatchManager.Find(SpriteBatchName.Aliens); SpriteBatch sbBoxes = SpriteBatchManager.Find(SpriteBatchName.Boxes); pExplosion.ActivateGameSprite(sbAliens); pExplosion.ActivateCollisionSprite(sbBoxes); GameObjectManager.AttachTree(pExplosion); Game pGame = GameManager.GetGame(); //pGame.Pause(); int lives = ScoreManager.UpdateLives(); if (lives == 0) { pGame.roundNum = 1; TimerManager.ClearTimerManager(); pExplosion.Remove(); pGame.Die(); TimerManager.Add(TimerEventName.GameStart, TimerManager.GetCurrentTime() + 10.0f, 10.0f, new GameStartEvent(pGame)); } else { TimerManager.Add(TimerEventName.RemoveGameObject, TimerManager.GetCurrentTime(), TimerManager.GetCurrentTime(), new RemoveGameObjectCommand(pExplosion)); PCSTree pRootTree = GameObjectManager.GetRootTree(); //ShipRoot pShipRoot = (ShipRoot)GameObjectManager.Find(GameObjectName.ShipRoot); //pShipRoot.ActivateCollisionSprite(sbBoxes); //pShipRoot.ActivateGameSprite(sbAliens); ShipManager.Create(GameManager.GetCollisionBoxes()); } }
public override void Execute() { // if this brick removed the last child in the column, then remove column // Debug.WriteLine(" brick {0} parent {1}", this.pBrick, this.pBrick.pParent); GameObject pA = (GameObject)this.pBrick; GameObject pB = (GameObject)Iterator.GetParent(pA); 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(); } } }
public override void Execute() { GameObject pA = (GameObject)this.pBrick; GameObject pB = (GameObject)Iterator.GetParent(pA); pA.Remove(); if (!(this.pObjA is AlienGrid)) { SoundMan.PlaySound(Sound.Name.Explode); } if (privCheckParent(pB) == true) { GameObject pC = (GameObject)Iterator.GetParent(pB); pB.Remove(); if (privCheckParent(pC) == true) { //pC.Remove(); } } }
public virtual void Remove() { // Grab a reference to the object's parent // We may need to remove it as well if it has no children after this is removed GameObject pParent = (GameObject)this.GetParent(); // Remove from SpriteBatch // Find the SBNode Debug.Assert(this.pProxySprite != null); SpriteBaseNode pSBNode = this.pProxySprite.GetSBNode(); // Remove it from the manager Debug.Assert(pSBNode != null); SpriteBatchManager.Remove(pSBNode); // Remove collision sprite from spriteBatch Debug.Assert(this.poColObj != null); Debug.Assert(this.poColObj.pColSprite != null); pSBNode = this.poColObj.pColSprite.GetSBNode(); Debug.Assert(pSBNode != null); SpriteBatchManager.Remove(pSBNode); // Remove from GameObjectMan GameObjectManager.Remove(this); // check to see if the parent has any more children if (pParent != null && pParent.GetFirstChild() == null) { // We just removed the last of the parent's children // so it is time to remove the parent as well pParent.Remove(); } // TODO Add to ghost manager }
public override void Execute() { GameObject pBrickObject = (GameObject)this.pBrick; GameObject pColumn = (GameObject)Iterator.GetParent(pBrickObject); SpaceInvaders pGame = GameMan.GetGame(); //always remove the brick pBrickObject.Remove(); //check if Column has bricks left //true means we have no more children, and safe to remove column if (PrivCheckParent(pColumn) == true) { GameObject pGroup = (GameObject)Iterator.GetParent(pColumn); pColumn.Remove(); //Check if Shield has any columns left if (PrivCheckParent(pGroup) == true) { pGroup.Remove(); } } }
public override void Execute() { // Resiter the change with the Level Level.KilledAlien(); // if this brick removed the last child in the column, then remove column // Debug.WriteLine(" alien {0} parent {1}", this.pAlien, this.pAlien.pParent); GameObject pA = (GameObject)this.pAlien; GameObject pB = (GameObject)Iterator.GetParent(pA); 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(); } } }
public static void Remove(GameObject pNode) { // Keenan(delete.E) Debug.Assert(pNode != null); GameObjectManager pMan = GameObjectManager.pActiveManager; Debug.Assert(pMan != null); GameObject pSafetyNode = pNode; // OK so we have a linked list of trees (Remember that) // 1) find the tree root (we already know its the most parent) GameObject pTmp = pNode; GameObject pRoot = null; while (pTmp != null) { pRoot = pTmp; pTmp = (GameObject)Iterator.GetParent(pTmp); } // 2) pRoot is the tree we are looking for // now walk the active list looking for pRoot GameObjectNode pTree = (GameObjectNode)pMan.baseGetActive(); while (pTree != null) { if (pTree.poGameObj == pRoot) { // found it break; } // Goto Next tree pTree = (GameObjectNode)pTree.pNext; } // 3) pTree is the tree that holds pNode // Now remove the node from that tree Debug.Assert(pTree != null); Debug.Assert(pTree.poGameObj != null); // Is pTree.poGameObj same as the node we are trying to delete? // Answer: should be no... since we always have a group (that was a good idea) Debug.Assert(pTree.poGameObj != pNode); GameObject pParent = (GameObject)Iterator.GetParent(pNode); Debug.Assert(pParent != null); // Make sure there is no child before the delete GameObject pChild = (GameObject)Iterator.GetChild(pNode); Debug.Assert(pChild == null); // remove the node pParent.Remove(pNode); // FOUND the bug!!!! pParent.Update(); // TODO - Recycle pNode }
//execute the Alien Removal - and potentially the removal of a column and the alien grid object public override void Execute() { //if the alien that was removed was the last one in the column, delete the column it was assigned to! //Debug.WriteLine("alien {0} parentColumn {1}", this.pAlien, this.pAlien.pParent); GameObject targetAlien = (GameObject)this.pAlienObj; GameObject parentColumn = (GameObject)targetAlien.pParent; //make sure the parent is a column; Debug.Assert(parentColumn.GetName() == GameObject.Name.Column); Debug.WriteLine("removing alien {0} at x:{1}, y: {2}, sx: {3}, sy: {4}", targetAlien.pProxySprite.pSprite.GetName(), targetAlien.pProxySprite.x, targetAlien.pProxySprite.y, targetAlien.pProxySprite.sx, targetAlien.pProxySprite.sy ); //hold the x, y coordinates of the target alien; //float target_X = targetAlien.pProxySprite.x; //float target_Y = targetAlien.pProxySprite.y; //remove the alien targetAlien.Remove(); //gameobject and proxysprite gone; //after alien removal, place an explosion sprite in the last location of its proxy sprite; //GameSprite pExplodeSprite = GameSpriteManager.Find(GameSprite.Name.AlienExplosion); //pExplodeSprite.x = target_X; //pExplodeSprite.y = target_Y; //pExplodeSprite.sx = 1.0f; //pExplodeSprite.sy = 1.0f; //pExplodeSprite.Update(); //pExplodeSprite.Draw(); ////find the AlienGrid game object to increase the march speed; //GameObject pAlienGridObj = GameObjectManager.Find() //alienGrid.IncreaseAlienMarchSpeed(); //Debug.WriteLine("Increased Alien Grid March Speed"); //Debug.WriteLine("Current MarchSpeed: {0}", AlienGrid.marchSpeed); //Grid.liveAlienCount--; //Grid.deadAlienCount++; //Debug.WriteLine("Live AlienCount: {0}", AlienGrid.liveAlienCount); //Debug.WriteLine("Dead AlienCount: {0}", AlienGrid.deadAlienCount); //TODO: Need a better way to check if this is last alien in column/last column in grid; //check if last alien in the column if (privIsLastChildOf(parentColumn) == true) { //if so, remove the parent column; //get the grid pointer before removing the column (in case this is the last column) GameObject parentAlienGrid = (GameObject)parentColumn.pParent; parentColumn.Remove(); //double check that parentAlienGrid is actually an alien grid Debug.Assert(parentAlienGrid.GetName() == GameObject.Name.Grid); //cast to a grid object and decrement the number of columns; Grid alienGrid = (Grid)parentAlienGrid; alienGrid.DecrementColumnCount(); //check if the last column in the grid if (privIsLastChildOf(parentAlienGrid) == true) { //todo - place a next level reload or reward for beating the level here!!! //if so, remove the grid and trigger a reaction parentAlienGrid.Remove(); } } }
public static void Remove(GameObject pNode, SpriteBatchMan pSpriteBatchMan) { Debug.Assert(pNode != null); GameObjectMan pMan = GameObjectMan.PrivGetInstance(); GameObject pSafetyNode = pNode; // OK so we have a linked list of trees (Remember that) // 1) find the tree root (we already know its the most parent) GameObject pTmp = pNode; GameObject pRoot = null; while (pTmp != null) { pRoot = pTmp; pTmp = (GameObject)Iterator.GetParent(pTmp); } // 2) pRoot is the tree we are looking for // now walk the active list looking for pRoot GameObjectNode pTree = (GameObjectNode)pMan.BaseGetActive(); while (pTree != null) { if (pTree.poGameObj == pRoot) { // found it break; } // Goto Next tree pTree = (GameObjectNode)pTree.pNext; } // 3) pTree is the tree that holds pNode // Now remove the node from that tree Debug.Assert(pTree != null); Debug.Assert(pTree.poGameObj != null); // Is pTree.poGameObj same as the node we are trying to delete? // Answer: should be no... since we always have a group (that was a good idea) Debug.Assert(pTree.poGameObj != pNode); GameObject pParent = (GameObject)Iterator.GetParent(pNode); Debug.Assert(pParent != null); GameObject pChild = (GameObject)Iterator.GetChild(pNode); //Debug.Assert(pChild == null); if (pChild == null) { // remove the node pParent.Remove(pNode); } else { GameObject pSibling = (GameObject)Iterator.GetSibling(pChild); while (pSibling != null) { pChild.Remove(pSpriteBatchMan); pChild = pSibling; pSibling = (GameObject)Iterator.GetSibling(pChild); } pChild.Remove(pSpriteBatchMan); pParent.Remove(pNode); } // TODO - Recycle pNode }
public static void KillAll() { GraveyardMan pGraveyard = GraveyardMan.PrivGetInstance(); Debug.Assert(pGraveyard != null); // trying to gather leftover Aliens GameObject pAlienGroup = GONodeMan.Find(GameObject.Name.AlienGrid); //Start with the columns GameObject pColumn = (GameObject)pAlienGroup.GetFirstChild(); while (pColumn != null) { //store the next column GameObject pNextColumn = (GameObject)pColumn.pNext; //remove aliens from the column GameObject pAlien = (GameObject)pColumn.GetFirstChild(); while (pAlien != null) { GameObject pNextAlien = (GameObject)pAlien.pNext; pAlien.Remove(); pAlien = pNextAlien; } //once your out do a check to see if its null Debug.Assert(pColumn.GetFirstChild() == null); //remove the column pColumn.Remove(); pColumn = pNextColumn; } // trying to gather leftover Shieldbricks GameObject pShieldRoot = GONodeMan.Find(GameObject.Name.ShieldRoot); //start with shields (4 of them if all there) GameObject pShield = (GameObject)pShieldRoot.GetFirstChild(); while (pShield != null) { //store the next shield GameObject pNextShield = (GameObject)pShield.pNext; //go to the shield columns GameObject pShieldColumn = (GameObject)pShield.GetFirstChild(); while (pShieldColumn != null) { GameObject pNextColumn = (GameObject)pShieldColumn.pNext; //finally at the bricks GameObject pBrick = (GameObject)pShieldColumn.GetFirstChild(); while (pBrick != null) { GameObject pNextBrick = (GameObject)pBrick.pNext; pBrick.Remove(); pBrick = pNextBrick; } //once your out do a check to see if its null Debug.Assert(pShieldColumn.GetFirstChild() == null); //remove the column from shield pShieldColumn.Remove(); pShieldColumn = pNextColumn; } //once your out do a check to see if its null Debug.Assert(pShield.GetFirstChild() == null); //remove the shield from root pShield.Remove(); pShield = pNextShield; } }
public override void Update() { //first time through set a time to change states if (this.bStateToggle == true) { //inititally used the game to get time //Testing timer man //could use Timer Man for current time float curTime = TimerMan.GetCurrentTime(); this.ChangeStateTime = curTime + 10; this.bStateToggle = false; } else { SpaceInvaders pGame = GameMan.GetGame(); //time has elapsed start over if (this.ChangeStateTime <= pGame.GetTime()) { this.bStateToggle = true; SpriteBatch pSB_Intro = SpriteBatchMan.Find(SpriteBatch.Name.IntroScreen); pSB_Intro.bToggle = true; SpriteBatch pGameOverScreen = SpriteBatchMan.Find(SpriteBatch.Name.GameOver); pGameOverScreen.bToggle = false; //SpriteBatch pSB_Splats = SpriteBatchMan.Find(SpriteBatch.Name.Splats); //pSB_Splats.bToggle = false; //---------------------------------------------------------------------------------------------------- //Things we need to reset for the Next game? //---------------------------------------------------------------------------------------------------- // need to remove ship from its root GameObject pShipRoot = GONodeMan.Find(GameObject.Name.ShipRoot); GameObject pShip = (GameObject)pShipRoot.GetFirstChild(); if (pShip != null) { pShip.Remove(); } ShipMan.Destroy(); GraveyardMan.KillAll(); //GraveyardMan.DumpNodes(); GraveyardMan.Destroy(); TimerMan.ClearActiveList(); TimerMan.DumpTimeEvents(); AlienGroup pAlienGroup = (AlienGroup)GONodeMan.Find(GameObject.Name.AlienGrid); pAlienGroup.SetDeltaMove(15.0f); SpriteBatch pSB_Projectiles = SpriteBatchMan.Find(SpriteBatch.Name.Projectiles); pSB_Projectiles.bToggle = false; //---------------------------------------------------------------------------------------------------- pGame.SetGameState(GameMan.State.Intro); pGame.GetCurrentState().Update(); } } }
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); } }