private void SpawnUFO() { int random = UFOManager.GetRandom().Next(7, 10); this.pUFO = UFOManager.ActivateUFO(GameManager.GetCollisionBoxes()); TimerManager.Add(TimerEventName.PlayUFOSound, TimerManager.GetCurrentTime() + 0.2f, 0.2f, new StartUFOSoundCommand()); TimerManager.Add(TimerEventName.UFOSpawnBomb, TimerManager.GetCurrentTime() + (float)UFOManager.GetRandom().Next(1, 6), TimerManager.GetCurrentTime() + (float)UFOManager.GetRandom().Next(1, 6), new UFOBombSpawnEvent()); }
public void ActivateCollisionSprite(SpriteBatch pSpriteBatch) { if (GameManager.GetCollisionBoxes()) { Debug.Assert(pSpriteBatch != null); pSpriteBatch.Attach(this.pCollisionObject.pCollisionSpriteBox); } }
public static void ClearGameScreen() { // Remove Bombs GameObject bombRoot = GameObjectManager.Find(GameObjectName.BombRoot); PCSTreeReverseIterator iterBomb = new PCSTreeReverseIterator(bombRoot); GameObject pGoBomb = (GameObject)iterBomb.First(); while (!iterBomb.IsDone()) { pGoBomb.Remove(); pGoBomb = (GameObject)iterBomb.Next(); } Missile pMissile = ShipManager.GetMissile(); if (pMissile != null && pMissile.enabled) { pMissile.Remove(); } // Remove Shields for (int i = 1; i < 5; ++i) { GameObject shieldRoot = GameObjectManager.Find(GameObjectName.ShieldRoot, i); PCSTreeReverseIterator iter = new PCSTreeReverseIterator(shieldRoot); GameObject pGO = (GameObject)iter.First(); while (!iter.IsDone()) { pGO.Remove(); pGO = (GameObject)iter.Next(); } } // Remove Alien Grid GameObject grid = GameObjectManager.Find(GameObjectName.Grid); PCSTreeReverseIterator iterGrid = new PCSTreeReverseIterator(grid); GameObject pGameObj = (GameObject)iterGrid.First(); while (!iterGrid.IsDone()) { pGameObj.Remove(); pGameObj = (GameObject)iterGrid.Next(); } // Remove CollisionBoxes if (GameManager.GetCollisionBoxes()) { GameObject pWallRoot = GameObjectManager.Find(GameObjectName.WallRoot); PCSTreeReverseIterator iterWall = new PCSTreeReverseIterator(pWallRoot); GameObject pGO = (GameObject)iterWall.First(); while (!iterWall.IsDone()) { pGO.Remove(); pGO = (GameObject)iterWall.Next(); } } }
public virtual void Remove() { Debug.Assert(this.pProxySprite != null); SpriteBatchNode sbNode = this.pProxySprite.GetSpriteBatchNode(); Debug.Assert(sbNode != null); SpriteBatchManager.Remove(sbNode); if (GameManager.GetCollisionBoxes()) { if (this.pCollisionObject.pCollisionSpriteBox.pSpriteBatchNode != null) { sbNode = this.pCollisionObject.pCollisionSpriteBox.GetSpriteBatchNode(); Debug.Assert(sbNode != null); SpriteBatchManager.Remove(sbNode); } } GameObjectManager.Remove(this); }
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 ShieldCategory Create(ShieldType type, GameObjectName goName, float x = 0.0f, float y = 0.0f, int idx = 0) { ShieldCategory pShield = null; switch (type) { case ShieldType.Brick: pShield = new ShieldBrick(goName, SpriteBaseName.Brick, x, y, idx); break; case ShieldType.LeftTop0: pShield = new ShieldBrick(goName, SpriteBaseName.BrickLeftTop0, x, y, idx); break; case ShieldType.LeftTop1: pShield = new ShieldBrick(goName, SpriteBaseName.BrickLeftTop1, x, y, idx); break; case ShieldType.LeftBottom: pShield = new ShieldBrick(goName, SpriteBaseName.BrickLeftBottom, x, y, idx); break; case ShieldType.RightTop0: pShield = new ShieldBrick(goName, SpriteBaseName.BrickRightTop0, x, y, idx); break; case ShieldType.RightTop1: pShield = new ShieldBrick(goName, SpriteBaseName.BrickRightTop1, x, y, idx); break; case ShieldType.RightBottom: pShield = new ShieldBrick(goName, SpriteBaseName.BrickRightBottom, x, y, idx); break; case ShieldType.Root: pShield = new ShieldRoot(goName, SpriteBaseName.Null, x, y, idx); pShield.pCollisionObject.pCollisionSpriteBox.pLineColor = ColorFactory.Create(ColorName.Blue).pAzulColor; Debug.Assert(false); break; case ShieldType.Grid: pShield = new ShieldGrid(goName, SpriteBaseName.Null, x, y, idx); pShield.pCollisionObject.pCollisionSpriteBox.pLineColor = ColorFactory.Create(ColorName.Blue).pAzulColor; break; case ShieldType.Column: pShield = new ShieldColumn(goName, SpriteBaseName.Null, x, y, idx); pShield.pCollisionObject.pCollisionSpriteBox.pLineColor = ColorFactory.Create(ColorName.Red).pAzulColor; break; default: Debug.Assert(false); break; } this.pTree.Insert(pShield, this.pParent); pShield.ActivateGameSprite(this.pSpriteBatch); if (GameManager.GetCollisionBoxes()) { pShield.ActivateCollisionSprite(this.pCollisionSpriteBatch); } return(pShield); }