public static void ResetAllAlienGrid() { AlienManager pMan = AlienManager.PrivGetInstance(); Debug.Assert(pMan != null); AlienNode pCurr = (AlienNode)pMan.BaseGetActive(); AlienNode pNext; GameObject pParent; GameObject pObj; AlienCategory pAlien; while (pCurr != null) { pNext = (AlienNode)pCurr.pNext; // Get Alien object and its parent. The parent will be AlienGroup or AlienColumn. pObj = pCurr.GetAlienObject(); pParent = (GameObject)pCurr.GetAlienObject().pParent; pObj.isDead = false; pObj.pPrev = null; pObj.pNext = null; pParent.Add(pObj); if (pObj.type == Component.Container.LEAF) { pAlien = (AlienCategory)pObj; pObj.x = pAlien.originX; pObj.y = pAlien.originY; SpriteBatch pSB_GameSprite = SpriteBatchManager.Find(SpriteBatch.Name.GameSprites); Debug.Assert(pSB_GameSprite != null); pSB_GameSprite.Attach(pObj.pProxySprite); // pMan.pSB_GameSprite.Attach(pObj.pProxySprite); } SpriteBatch pSB_Collsion = SpriteBatchManager.Find(SpriteBatch.Name.BoxSprites); pSB_Collsion.Attach(pObj.pColObject.pBoxSprite); // pMan.pSB_CollisionSprite.Attach(pObj.pColObject.pBoxSprite); AlienManager.Remove(pCurr); DLink p = pMan.BaseGetActive(); pCurr = pNext; } // Checked new Alien Hierarchy is good // pMan.pSB_GameSprite.Dump(); // pMan.pSB_CollisionSprite.Dump(); }
public void RemoveComposite() { if (this.poHead != null && this.poLast != null) { return; } if (this is AlienColumn) { AlienManager.Add(this); } if (this is ShieldColumn) { ShieldNodeManager.Add(this); } Composite pParent = (Composite)this.pParent; if (this.pPrev == null && this.pNext == null) { pParent.poLast = null; pParent.poHead = null; } else if (this.pPrev == null) { pParent.poHead = this.pNext; this.pNext.pPrev = null; } else if (this.pNext == null) { pParent.poLast = this.pPrev; this.pPrev.pNext = null; } else { this.pPrev.pNext = this.pNext; this.pNext.pPrev = this.pPrev; } this.RemoveFromSpriteBatch(); this.pPrev = null; this.pNext = null; this.Remove(this); if (pParent.poHead == null && pParent.poLast == null && pParent.pNext == null && pParent.pPrev == null) { pParent.Remove(this); if (pParent is AlienGroup) { GameScene.Handle(); } //AlienManager.PrintMe(); //AlienManager.ResetAllAlienGrid(); //pParent.RemoveFromSpriteBatch(); } }
//--------------------------------------------------------------------------------- // Static Methods //--------------------------------------------------------------------------------- public static void Create(int reserveNum = 66, int reserveGrow = 10) { Debug.Assert(reserveNum > 0); Debug.Assert(reserveGrow > 0); // Initialize the singleton here Debug.Assert(pInstance == null); // Do the initialization if (pInstance == null) { pInstance = new AlienManager(reserveNum, reserveGrow); } }
public static void PrintMe() { AlienManager pMan = AlienManager.PrivGetInstance(); Debug.Assert(pMan != null); AlienNode pNode = (AlienNode)pMan.BaseGetActive(); while (pNode != null) { pNode.PrintMe(); pNode = (AlienNode)pNode.pNext; } }
public override void Execute(float deltaTime) { Debug.Assert(this.pGridHead != null); if (PlayerManager.GetPlayerDeadOrAlive()) { switch (soundIdx) { case 0: SoundManager.Play(Sound.Name.AlienMove1); break; case 1: SoundManager.Play(Sound.Name.AlienMove2); break; case 2: SoundManager.Play(Sound.Name.AlienMove3); break; case 3: SoundManager.Play(Sound.Name.AlienMove4); break; default: Debug.Assert(false); break; } soundIdx++; if (soundIdx > 3) { soundIdx = 0; } this.pGridHead.MoveAllAliens(); } AlienManager.CheckDeltaTime(); TimerManager.Add(TimeEvent.Name.MovementSprite, this, TimerManager.GetAlienDeltatTime()); }
public override void Execute() { AlienManager.Add(this.pAlien); this.pAlien.GotHitMissile(); }
//----------------------------------------------------------------------------- // Game::LoadContent() // Allows you to load all content needed for your engine, // such as objects, graphics, etc. //----------------------------------------------------------------------------- public override void LoadContent() { //--------------------------------------------------------------------------------------------------------- // Manager initialization //--------------------------------------------------------------------------------------------------------- TextureManager.Create(1, 1); ImageManager.Create(5, 2); GameSpriteManager.Create(4, 2); BoxSpriteManager.Create(3, 1); SpriteBatchManager.Create(3, 1); ProxySpriteManager.Create(10, 1); TimerManager.Create(3, 1); GameObjectManager.Create(3, 1); CollisionPairManager.Create(3, 1); InputManager.Create(); SoundManager.Create(); GlyphManager.Create(3, 1); FontManager.Create(3, 1); ScoreManager.Create(); //--------------------------------------------------------------------------------------------------------- // Load the Textures //--------------------------------------------------------------------------------------------------------- TextureManager.Add(Texture.Name.Aliens, "aliens14x14.tga"); TextureManager.Add(Texture.Name.Shield, "birds_N_shield.tga"); TextureManager.Add(Texture.Name.Consolas36pt, "consolas36pt.tga"); FontManager.AddXml(Glyph.Name.Consolas36pt, "Consolas36pt.xml", Texture.Name.Consolas36pt); //--------------------------------------------------------------------------------------------------------- // Create Images //--------------------------------------------------------------------------------------------------------- ImageManager.Add(Image.Name.Octopus0, Texture.Name.Aliens, 56, 28, 168, 112); ImageManager.Add(Image.Name.Octopus1, Texture.Name.Aliens, 56, 182, 168, 112); ImageManager.Add(Image.Name.Crab1, Texture.Name.Aliens, 322, 182, 154, 112); ImageManager.Add(Image.Name.Crab0, Texture.Name.Aliens, 322, 28, 154, 112); ImageManager.Add(Image.Name.Squid0, Texture.Name.Aliens, 616, 28, 112, 112); ImageManager.Add(Image.Name.Squid1, Texture.Name.Aliens, 616, 182, 112, 112); ImageManager.Add(Image.Name.UFO, Texture.Name.Aliens, 84, 504, 224, 98); ImageManager.Add(Image.Name.Missile, Texture.Name.Aliens, 378, 798, 14, 98); ImageManager.Add(Image.Name.Player, Texture.Name.Aliens, 57, 336, 182, 112); ImageManager.Add(Image.Name.BombCross, Texture.Name.Aliens, 196, 798, 42, 84); ImageManager.Add(Image.Name.BombStraight, Texture.Name.Aliens, 630, 798, 14, 98); ImageManager.Add(Image.Name.BombZigZag, Texture.Name.Aliens, 574, 644, 42, 98); ImageManager.Add(Image.Name.UFO_Explosion, Texture.Name.Aliens, 42, 643, 294, 112); ImageManager.Add(Image.Name.Player_Explosion1, Texture.Name.Aliens, 308, 336, 210, 112); ImageManager.Add(Image.Name.Player_Explosion2, Texture.Name.Aliens, 560, 336, 224, 112); ImageManager.Add(Image.Name.Missile_Explosion, Texture.Name.Aliens, 406, 490, 112, 112); ImageManager.Add(Image.Name.Alien_Explosion2, Texture.Name.Aliens, 574, 490, 182, 112); ImageManager.Add(Image.Name.Bomb_Explosion, Texture.Name.Aliens, 700, 798, 84, 112); ImageManager.Add(Image.Name.Brick, Texture.Name.Shield, 20, 210, 10, 5); ImageManager.Add(Image.Name.BrickLeft_Top0, Texture.Name.Shield, 15, 180, 10, 5); ImageManager.Add(Image.Name.BrickLeft_Top1, Texture.Name.Shield, 15, 185, 10, 5); ImageManager.Add(Image.Name.BrickLeft_Bottom, Texture.Name.Shield, 35, 215, 10, 5); ImageManager.Add(Image.Name.BrickRight_Top0, Texture.Name.Shield, 75, 180, 10, 5); ImageManager.Add(Image.Name.BrickRight_Top1, Texture.Name.Shield, 75, 185, 10, 5); ImageManager.Add(Image.Name.BrickRight_Bottom, Texture.Name.Shield, 55, 215, 10, 5); //--------------------------------------------------------------------------------------------------------- // Create Sprites //--------------------------------------------------------------------------------------------------------- GameSpriteManager.Add(GameSprite.Name.Squid, Image.Name.Squid0, 400, 200, Constant.ALIEN_WIDTH - 10, Constant.ALIEN_HEIGHT); GameSpriteManager.Add(GameSprite.Name.Octopus, Image.Name.Octopus0, 50, 500, Constant.ALIEN_WIDTH, Constant.ALIEN_HEIGHT); GameSpriteManager.Add(GameSprite.Name.Crab, Image.Name.Crab0, 100, 300, Constant.ALIEN_WIDTH, Constant.ALIEN_HEIGHT); GameSpriteManager.Add(GameSprite.Name.Missile, Image.Name.Missile, Constant.WINDOW_WIDTH / 2, 0, 4, 20); GameSpriteManager.Add(GameSprite.Name.Player, Image.Name.Player, Constant.WINDOW_WIDTH / 2, 30, 40.0f, 25.0f); GameSpriteManager.Add(GameSprite.Name.BombStraight, Image.Name.BombStraight, Constant.WINDOW_WIDTH / 2, Constant.WINDOW_HEIGHT, 6, 25.0f); GameSpriteManager.Add(GameSprite.Name.BombCross, Image.Name.BombCross, Constant.WINDOW_WIDTH / 2, Constant.WINDOW_HEIGHT, 6, 25.0f); GameSpriteManager.Add(GameSprite.Name.BombZigZag, Image.Name.BombZigZag, Constant.WINDOW_WIDTH / 2, Constant.WINDOW_HEIGHT, 6, 25.0f); GameSpriteManager.Add(GameSprite.Name.UFO, Image.Name.UFO, Constant.WINDOW_WIDTH / 2, Constant.WINDOW_HEIGHT, 40, 20); GameSpriteManager.Add(GameSprite.Name.Missile_Explosion, Image.Name.Missile_Explosion, 0, 0, 10, 10); GameSpriteManager.Add(GameSprite.Name.UFO_Explosion, Image.Name.UFO_Explosion, Constant.WINDOW_WIDTH / 2, Constant.WINDOW_HEIGHT, 40, 20); GameSpriteManager.Add(GameSprite.Name.Player_Explosion, Image.Name.Player_Explosion1, Constant.WINDOW_WIDTH / 2, Constant.WINDOW_HEIGHT, 40, 25.0f); GameSpriteManager.Add(GameSprite.Name.Bomb_Explosion, Image.Name.Bomb_Explosion, Constant.WINDOW_WIDTH / 2, Constant.WINDOW_HEIGHT, 10, 10); GameSpriteManager.Add(GameSprite.Name.Alien_Explosion, Image.Name.Alien_Explosion2, Constant.WINDOW_WIDTH / 2, Constant.WINDOW_HEIGHT, Constant.ALIEN_WIDTH, Constant.ALIEN_HEIGHT); GameSpriteManager.Add(GameSprite.Name.Brick, Image.Name.Brick, 50, 25, Constant.SHIELD_BRICK_WIDTH, Constant.SHIELD_BRICK_HEIGHT); GameSpriteManager.Add(GameSprite.Name.BrickLeft_Top0, Image.Name.BrickLeft_Top0, 50, 25, Constant.SHIELD_BRICK_WIDTH, Constant.SHIELD_BRICK_HEIGHT); GameSpriteManager.Add(GameSprite.Name.BrickLeft_Top1, Image.Name.BrickLeft_Top1, 50, 25, Constant.SHIELD_BRICK_WIDTH, Constant.SHIELD_BRICK_HEIGHT); GameSpriteManager.Add(GameSprite.Name.BrickLeft_Bottom, Image.Name.BrickLeft_Bottom, 50, 25, Constant.SHIELD_BRICK_WIDTH, Constant.SHIELD_BRICK_HEIGHT); GameSpriteManager.Add(GameSprite.Name.BrickRight_Top0, Image.Name.BrickRight_Top0, 50, 25, Constant.SHIELD_BRICK_WIDTH, Constant.SHIELD_BRICK_HEIGHT); GameSpriteManager.Add(GameSprite.Name.BrickRight_Top1, Image.Name.BrickRight_Top1, 50, 25, Constant.SHIELD_BRICK_WIDTH, Constant.SHIELD_BRICK_HEIGHT); GameSpriteManager.Add(GameSprite.Name.BrickRight_Bottom, Image.Name.BrickRight_Bottom, 50, 25, Constant.SHIELD_BRICK_WIDTH, Constant.SHIELD_BRICK_HEIGHT); //--------------------------------------------------------------------------------------------------------- // Create SpriteBatch //--------------------------------------------------------------------------------------------------------- SpriteBatch pSB_Aliens = SpriteBatchManager.Add(SpriteBatch.Name.GameSprites); SpriteBatch pSB_Boxes = SpriteBatchManager.Add(SpriteBatch.Name.BoxSprites); SpriteBatch pSB_Shields = SpriteBatchManager.Add(SpriteBatch.Name.ShieldSprites); SpriteBatch pSB_Bombs = SpriteBatchManager.Add(SpriteBatch.Name.BombSprites); SpriteBatch pSB_Texts = SpriteBatchManager.Add(SpriteBatch.Name.TextSprite); SpriteBatch pSB_Effect = SpriteBatchManager.Add(SpriteBatch.Name.ExplosionEffectSprite); pSB_Boxes.GetSBNodeManager().ToggleDraw(); AlienGroup pAlienGroup = new AlienGroup(GameObject.Name.AlienGroup, GameSprite.Name.NullObject, -1, 0.0f, 0.0f); pSB_Boxes.Attach(pAlienGroup.pColObject.pBoxSprite); GameObjectManager.Attach(pAlienGroup); ShieldGroup pShieldGroup = new ShieldGroup(GameObject.Name.ShieldRoot, GameSprite.Name.NullObject, -1, 0.0f, 0.0f); pSB_Boxes.Attach(pShieldGroup.pColObject.pBoxSprite); GameObjectManager.Attach(pShieldGroup); AlienManager.Create(); ShieldNodeManager.Create(); GameSceneManager.Create(); GameScene.Create(); GameScene.SetGameScene(GameState.SceneName.Select); }