public void MoveGridHorizontal() { ForwardIterator pFor = new ForwardIterator(this); Component pNode = pFor.First(); while (!pFor.IsDone()) { GameObject pGameObj = (GameObject)pNode; pGameObj.x += this.delta; pNode = pFor.Next(); } }
public void MoveGridVertical(float _delta) { ForwardIterator pFor = new ForwardIterator(this); Component pNode = pFor.First(); while (!pFor.IsDone()) { GameObject pGameObj = (GameObject)pNode; pGameObj.y += _delta; pNode = pFor.Next(); } }
static public GameObject GetSiblingGameObject(GameObject pNode) { GameObject pGameObj = null; Component pComponent = ForwardIterator.GetSibling(pNode); if (pComponent != null) { pGameObj = (GameObject)pComponent; } return(pGameObj); }
public void MoveDown() { ForwardIterator pForIter = new ForwardIterator(this); Component pNode = pForIter.First(); while (!pForIter.IsDone()) { GameObject pGameObject = (GameObject)pNode; pGameObject.y -= this.deltaStep; pNode = pForIter.Next(); } }
public override void MoveDownGrid() { ForwardIterator pFor = new ForwardIterator(this); Component pNode = pFor.First(); while (!pFor.IsDone()) { GameObject pGameObj = (GameObject)pNode; pGameObj.y -= 30f; pNode = pFor.Next(); } }
public void RemoveLife(int count) { ForwardIterator pFor = new ForwardIterator(this); Component pNode = pFor.First(); GameObject pGameObj; for (int i = 0; i < count; i++) { pGameObj = (GameObject)pNode; pGameObj.pProxySprite.Set(GameSprite.Name.NullObject); pNode = pFor.Next(); } }
static public GameObject GetChildGameObject(GameObject pNode) { GameObject pGameObj = null; // TRICKY... Component pComponent = pNode; if (pComponent != null) { pComponent = ForwardIterator.GetChild(pComponent); pGameObj = (GameObject)pComponent; } return(pGameObj); }
public void DropGrid() { ForwardIterator pForward = new ForwardIterator(this); Component pNode = pForward.First(); while (!pForward.IsDone()) { GameObject pGameObj = (GameObject)pNode; pGameObj.y -= this.dropLength; // go to next pNode = pForward.Next(); } }
public void ResetLives() { ForwardIterator pFor = new ForwardIterator(this); Component pNode = pFor.First(); GameObject pGameObj; while (!pFor.IsDone()) { pGameObj = (GameObject)pNode; pGameObj.pProxySprite.Set(GameSprite.Name.Ship); pNode = pFor.Next(); } }
public void MoveGrid() { this.isDropping = false; ForwardIterator pFor = new ForwardIterator(this); Component pNode = pFor.First(); while (!pFor.IsDone()) { GameObject pGameObj = (GameObject)pNode; pGameObj.x += this.delta; pNode = pFor.Next(); } }
protected void BaseUpdateBoundingBox() { GameObject pNode = (GameObject)ForwardIterator.GetChild(this); CollisionRect pBigRect = this.pColObject.pColRect; if (pNode != null) { pBigRect.Set(pNode.pColObject.pColRect); } while (pNode != null) { pBigRect.Union(pNode.pColObject.pColRect); pNode = (GameObject)ForwardIterator.GetSibling(pNode); } this.x = this.pColObject.pColRect.x; this.y = this.pColObject.pColRect.y; }
public void MoveGrid() { //iterates through composite and moves by delta ForwardIterator pFor = new ForwardIterator(this); Component pNode = pFor.First(); while (!pFor.IsDone()) { GameObject pGameObj = (GameObject)pNode; pGameObj.x += this.delta; pGameObj.y += this.Y_Delta; pNode = pFor.Next(); } this.SetYDelta(0.0f); }
public AlienCategory GetRandomAlien() { AlienCategory pAlien = null; ForwardIterator pFor = new ForwardIterator(this); Component pNode = pFor.First(); int pCount = pRandom.Next(1, this.nTotalAliens - 1); int x = 0; while (!pFor.IsDone()) { GameObject pGameObj = (GameObject)pNode; if (!pGameObj.bMarkForDeath && x >= pCount && pGameObj is AlienCategory) { pAlien = (AlienCategory)pGameObj; break; } pNode = pFor.Next(); x++; } return(pAlien); }
public void MoveGrid() { // Everybody MOVE! ForwardIterator pForward = new ForwardIterator(this); Component pNode = pForward.First(); while (!pForward.IsDone()) { GameObject pGameObj = (GameObject)pNode; pGameObj.x += this.movementJump * this.delta; // go to next pNode = pForward.Next(); } // Bombs Away?! if (bCanDropBombs == true) { this.DropBomb(); } }
public void DropGrid() { if (!this.isDropping) { this.isDropping = true; ForwardIterator pFor = new ForwardIterator(this); Component pNode = pFor.First(); while (!pFor.IsDone()) { GameObject pGameObj = (GameObject)pNode; pGameObj.y -= 10.0f; pNode = pFor.Next(); } this.SetDelta(-1.0f); this.MoveGrid(); } }
public ReverseIterator(Component Start) { ForwardIterator ForwardIt = new ForwardIterator(Start); Root = Start; Curr = Start; Prev = null; Component PrevComponent = Root; Component component = ForwardIt.First(); while (!ForwardIt.IsDone()) { PrevComponent = component; component = ForwardIt.Next(); if (component != null) { component.Reverse = PrevComponent; } } Root.Reverse = PrevComponent; }
public AlienNumObserver(IrrKlang.ISoundEngine pEng) { int count = 0; GameObject pGameObj = GameObjectMan.Find(GameObject.Name.AlienGroup); AlienGroup pAlienGroup = (AlienGroup)pGameObj; ForwardIterator pFor = new ForwardIterator(pAlienGroup); Component pNode = pFor.First(); while (!pFor.IsDone()) { if (pNode.holder == Component.Container.LEAF) { count++; } pNode = pFor.Next(); } this.num = count; this.initial = count; this.sndEngine = pEng; }
// TODO Clean this up public override void Notify() { //Debug.WriteLine("RemoveShieldBrickObserver: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB); // This cast will throw an exception if wrong this.pShieldBrick = (ShieldBrick)this.pSubject.pObjA; this.pColComposite = null; this.pShieldComposite = null; // Remove Shield from composite Composite pShieldGrid = GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.ShieldGroup); ForwardIterator pFwdIter = new ForwardIterator(pShieldGrid); Component pNode = pFwdIter.First(); while (!pFwdIter.IsDone()) { if (pNode.containerType == Component.Container.LEAF) { // If Component is target shield brick if (pNode.GetHashCode() == this.pShieldBrick.GetHashCode()) { // Remove shield brick from column pNode.pParent.Remove(pNode); // Get references to parent composites Component pShieldColComposite = pNode.pParent; Component pShieldComposite = null; if (pShieldColComposite != null) { pShieldComposite = pShieldColComposite.pParent; } // If column is now empty, delete column if (pShieldColComposite.GetFirstChild() == null) { // Delete empty column from parent composite if (pShieldColComposite.pParent != null) { pShieldColComposite.pParent.Remove(pShieldColComposite); } // Mark empty column for death if (!((GameObject)pShieldColComposite).IsMarkedForDeath()) { this.pColComposite = (GameObject)pShieldColComposite; this.pColComposite.MarkForDeath(); } } // If Shield is now empty, delete column if (pShieldComposite.GetFirstChild() == null) { // Delete empty shield from parent composite if (pShieldComposite.pParent != null) { pShieldComposite.pParent.Remove(pShieldComposite); } // Mark empty shield for death if (!((GameObject)pShieldComposite).IsMarkedForDeath()) { this.pShieldComposite = (GameObject)pShieldComposite; this.pShieldComposite.MarkForDeath(); } } break; } } pNode = pFwdIter.Next(); } if (!pShieldBrick.IsMarkedForDeath()) { pShieldBrick.MarkForDeath(); // Delay - remove object later RemoveShieldBrickObserver pObserver = new RemoveShieldBrickObserver(this); GameStateManager.GetGame().GetStateDelayedObjectManager().Attach(pObserver); } }
public override void Execute(float deltaTime, TimeEvent.Name name) { //if (Component.right > 896 || Component.left < 0.0f) //{ // Component.speed *= -1.0f; // grid.MoveDown(); //} //Component.right += Component.speed; //Component.left += Component.speed; grid.MoveGrid(); IrrKlang.ISoundEngine pSndEngine = SpaceInvaders.GetInstance().sndEngine; pSndEngine.SoundVolume = 0.2f; if (counting % 4 == 0) { pSndEngine.Play2D("fastinvader1.wav"); } else if (counting % 4 == 1) { pSndEngine.Play2D("fastinvader2.wav"); } else if (counting % 4 == 2) { pSndEngine.Play2D("fastinvader3.wav"); } else if (counting % 4 == 3) { pSndEngine.Play2D("fastinvader4.wav"); } counting++; //1, using ForwardIterator ForwardIterator pIterator = new ForwardIterator(grid); Random rnd = new Random(); int num = rnd.Next(0, 11); Debug.WriteLine(" random number generated: {0}", num); Component pColumn = null; bool flag = false; for (int i = 0; i <= num; i++) { if (pColumn == null && flag == true) { break; } pColumn = pIterator.Next(); flag = true; if (pColumn == null) { break; } while (pColumn.holder != Component.Container.COMPOSITE) { pColumn = pIterator.Next(); if (pColumn == null) { break; } } } //2, using Iterator //Component pColumn = Iterator.GetChild(grid); //pColumn = Iterator.GetSibling(pColumn); if (pColumn != null) { //Debug.WriteLine(" 3, child type: {0}", pColumn); Bomb pBomb = ((AlienColumn)pColumn).ActivateBomb(rnd); pBomb.ActivateGameSprite(this.pSpriteBatch); pBomb.ActivateCollisionSprite(this.pCollisionSpriteBatch); pTree.Add(pBomb); } // Add itself back to timer TimerMan.Add(name, this, deltaTime - 0.003f); }
// strategy() override public void LoadContent() { AlienGroup.ResetDirection(); TextureMan.Create(2, 1); ImageMan.Create(5, 2); GameSpriteMan.Create(4, 2); BoxSpriteMan.Create(3, 1); SpriteBatchMan.Create(3, 1); TimerMan.Create(3, 1); ProxySpriteMan.Create(10, 1); GameObjectMan.Create(3, 1); ColPairMan.Create(1, 1); Simulation.Create(); GlyphMan.Create(3, 1); FontMan.Create(1, 1); //GhostSpriteBatchMan.Create(2, 1); //--------------------------------------------------------------------------------------------------------- // Sound Experiment //--------------------------------------------------------------------------------------------------------- // start up the engine sndEngine = new IrrKlang.ISoundEngine(); //--------------------------------------------------------------------------------------------------------- // Load the Textures //--------------------------------------------------------------------------------------------------------- TextureMan.Add(Texture.Name.Aliens, "newaliens.tga"); TextureMan.Add(Texture.Name.Shields, "birds_N_shield.tga"); Texture pTexture = TextureMan.Add(Texture.Name.Consolas20pt, "Consolas20pt.tga"); FontMan.AddXml(Glyph.Name.Consolas20pt, "Consolas20pt.xml", Texture.Name.Consolas20pt); //--------------------------------------------------------------------------------------------------------- // Load the Images //--------------------------------------------------------------------------------------------------------- ImageMan.Add(Image.Name.SquidA, Texture.Name.Aliens, 547, 15, 250, 135); ImageMan.Add(Image.Name.CrabA, Texture.Name.Aliens, 281, 15, 250, 135); ImageMan.Add(Image.Name.OctopusA, Texture.Name.Aliens, 15, 15, 250, 135); ImageMan.Add(Image.Name.SquidB, Texture.Name.Aliens, 547, 170, 250, 135); ImageMan.Add(Image.Name.CrabB, Texture.Name.Aliens, 281, 170, 250, 135); ImageMan.Add(Image.Name.OctopusB, Texture.Name.Aliens, 15, 170, 250, 135); ImageMan.Add(Image.Name.MissileBombCol, Texture.Name.Aliens, 395, 480, 130, 130); ImageMan.Add(Image.Name.AlienDies, Texture.Name.Aliens, 550, 480, 220, 130); ImageMan.Add(Image.Name.UFO, Texture.Name.Aliens, 80, 500, 230, 100); ImageMan.Add(Image.Name.UFODies, Texture.Name.Aliens, 15, 630, 355, 140); ImageMan.Add(Image.Name.Missile, Texture.Name.Aliens, 370, 795, 30, 105); ImageMan.Add(Image.Name.MissileBombDies, Texture.Name.Aliens, 685, 790, 110, 130); ImageMan.Add(Image.Name.Ship, Texture.Name.Aliens, 50, 325, 190, 125); ImageMan.Add(Image.Name.ShipDiesA, Texture.Name.Aliens, 280, 325, 245, 130); ImageMan.Add(Image.Name.ShipDiesB, Texture.Name.Aliens, 545, 325, 245, 130); ImageMan.Add(Image.Name.BombRoll, Texture.Name.Aliens, 445, 795, 50, 105); ImageMan.Add(Image.Name.BombZigZag, Texture.Name.Aliens, 560, 630, 70, 140); ImageMan.Add(Image.Name.BombCross, Texture.Name.Aliens, 110, 790, 50, 100); ImageMan.Add(Image.Name.BombFork, Texture.Name.Aliens, 520, 790, 50, 100); ImageMan.Add(Image.Name.BombStraight, Texture.Name.Aliens, 370, 795, 30, 105); ImageMan.Add(Image.Name.Brick, Texture.Name.Shields, 20, 210, 10, 5); ImageMan.Add(Image.Name.BrickLeft_Top0, Texture.Name.Shields, 15, 180, 10, 5); ImageMan.Add(Image.Name.BrickLeft_Top1, Texture.Name.Shields, 15, 185, 10, 5); ImageMan.Add(Image.Name.BrickLeft_Bottom, Texture.Name.Shields, 35, 215, 10, 5); ImageMan.Add(Image.Name.BrickRight_Top0, Texture.Name.Shields, 75, 180, 10, 5); ImageMan.Add(Image.Name.BrickRight_Top1, Texture.Name.Shields, 75, 185, 10, 5); ImageMan.Add(Image.Name.BrickRight_Bottom, Texture.Name.Shields, 55, 215, 10, 5); //--------------------------------------------------------------------------------------------------------- // Create Sprites //--------------------------------------------------------------------------------------------------------- GameSpriteMan.Add(GameSprite.Name.Squid, Image.Name.SquidA, 100, 600, 35, 30, 255, 255, 255, 1); GameSpriteMan.Add(GameSprite.Name.Crab, Image.Name.CrabA, 100, 550, 35, 30, 255, 255, 255, 1); GameSpriteMan.Add(GameSprite.Name.Octopus, Image.Name.OctopusA, 100, 500, 35, 30, 255, 255, 255, 1); GameSpriteMan.Add(GameSprite.Name.AlienDies, Image.Name.AlienDies, 0, 0, 35, 30, 255, 255, 255, 1); GameSpriteMan.Add(GameSprite.Name.UFO, Image.Name.UFO, 100, 500, 35, 30, 255, 0, 0, 1); GameSpriteMan.Add(GameSprite.Name.UFODies, Image.Name.UFODies, 0, 0, 35, 30, 255, 0, 0, 1); GameSpriteMan.Add(GameSprite.Name.Missile, Image.Name.Missile, 100, 200, 10, 20, 255, 255, 0, 1); GameSpriteMan.Add(GameSprite.Name.MissileDies, Image.Name.MissileBombDies, 0, 0, 10, 20, 255, 255, 0, 1); GameSpriteMan.Add(GameSprite.Name.MissileBombCol, Image.Name.MissileBombCol, 0, 0, 10, 20, 255, 255, 255, 1); GameSpriteMan.Add(GameSprite.Name.Ship, Image.Name.Ship, 300, 30, 40, 20, 255, 255, 0, 1); GameSpriteMan.Add(GameSprite.Name.ShipDies, Image.Name.ShipDiesA, 0, 0, 50, 25, 255, 255, 0, 1); GameSpriteMan.Add(GameSprite.Name.BombZigZag, Image.Name.BombZigZag, 0, 0, 10, 20, 255, 0, 0, 1); GameSpriteMan.Add(GameSprite.Name.BombRolling, Image.Name.BombRoll, 0, 0, 10, 20, 255, 0, 0, 1); GameSpriteMan.Add(GameSprite.Name.BombDagger, Image.Name.BombCross, 0, 0, 10, 20, 255, 0, 0, 1); GameSpriteMan.Add(GameSprite.Name.BombStraight, Image.Name.BombStraight, 0, 0, 10, 20, 255, 0, 0, 1); GameSpriteMan.Add(GameSprite.Name.BombFork, Image.Name.BombFork, 0, 0, 12, 24, 255, 0, 0, 1); GameSpriteMan.Add(GameSprite.Name.BombDies, Image.Name.MissileBombDies, 0, 0, 10, 20, 255, 0, 0, 1); GameSpriteMan.Add(GameSprite.Name.Brick, Image.Name.Brick, 50, 25, 10, 5, 0, 255, 0, 1); GameSpriteMan.Add(GameSprite.Name.Brick_LeftTop0, Image.Name.BrickLeft_Top0, 50, 25, 10, 5, 0, 255, 0, 1); GameSpriteMan.Add(GameSprite.Name.Brick_LeftTop1, Image.Name.BrickLeft_Top1, 50, 25, 10, 5, 0, 255, 0, 1); GameSpriteMan.Add(GameSprite.Name.Brick_LeftBottom, Image.Name.BrickLeft_Bottom, 50, 25, 10, 5, 0, 255, 0, 1); GameSpriteMan.Add(GameSprite.Name.Brick_RightTop0, Image.Name.BrickRight_Top0, 50, 25, 10, 5, 0, 255, 0, 1); GameSpriteMan.Add(GameSprite.Name.Brick_RightTop1, Image.Name.BrickRight_Top1, 50, 25, 10, 5, 0, 255, 0, 1); GameSpriteMan.Add(GameSprite.Name.Brick_RightBottom, Image.Name.BrickRight_Bottom, 50, 25, 10, 5, 0, 255, 0, 1); SpriteBatch pSB_Aliens = SpriteBatchMan.Add(SpriteBatch.Name.Aliens); SpriteBatch pSB_Box = SpriteBatchMan.Add(SpriteBatch.Name.Boxes); SpriteBatch pSB_Shields = SpriteBatchMan.Add(SpriteBatch.Name.Shields); SpriteBatch pSB_Texts = SpriteBatchMan.Add(SpriteBatch.Name.Texts); //SpriteBatch pSB_GhostAliens = GhostSpriteBatchMan.Add(SpriteBatch.Name.Aliens); //SpriteBatch pSB_GhostBox = GhostSpriteBatchMan.Add(SpriteBatch.Name.Boxes); //SpriteBatch pSB_GhostShields = GhostSpriteBatchMan.Add(SpriteBatch.Name.Shields); //--------------------------------------------------------------------------------------------------------- // GameObject //--------------------------------------------------------------------------------------------------------- AnimationSprite pAnimSpriteSquid = new AnimationSprite(GameSprite.Name.Squid); AnimationSprite pAnimSpriteCrab = new AnimationSprite(GameSprite.Name.Crab); AnimationSprite pAnimSpriteOctopus = new AnimationSprite(GameSprite.Name.Octopus); pAnimSpriteSquid.Attach(Image.Name.SquidB); pAnimSpriteSquid.Attach(Image.Name.SquidA); pAnimSpriteCrab.Attach(Image.Name.CrabB); pAnimSpriteCrab.Attach(Image.Name.CrabA); pAnimSpriteOctopus.Attach(Image.Name.OctopusB); pAnimSpriteOctopus.Attach(Image.Name.OctopusA); TimerMan.Add(TimerEvent.Name.SquidAnimation, pAnimSpriteSquid, pMoveRate); TimerMan.Add(TimerEvent.Name.CrabAnimation, pAnimSpriteCrab, pMoveRate); TimerMan.Add(TimerEvent.Name.OctopusAnimation, pAnimSpriteOctopus, pMoveRate); //--------------------------------------------------------------------------------------------------------- // Create Walls //--------------------------------------------------------------------------------------------------------- WallGroup pWallGroup = new WallGroup(GameObject.Name.WallGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pWallGroup.ActivateGameSprite(pSB_Aliens); pWallGroup.ActivateCollisionSprite(pSB_Box); WallBottom pWallBottom = new WallBottom(GameObject.Name.WallBottom, GameSprite.Name.NullObject, 336, 35, 750, 10); pWallBottom.ActivateCollisionSprite(pSB_Box); pWallGroup.Add(pWallBottom); WallRight pWallRight = new WallRight(GameObject.Name.WallRight, GameSprite.Name.NullObject, 722, 384, 120, 765); pWallRight.ActivateCollisionSprite(pSB_Box); pWallGroup.Add(pWallRight); WallLeft pWallLeft = new WallLeft(GameObject.Name.WallLeft, GameSprite.Name.NullObject, -45, 384, 120, 765); pWallLeft.ActivateCollisionSprite(pSB_Box); pWallGroup.Add(pWallLeft); WallTop pWallTop = new WallTop(GameObject.Name.WallTop, GameSprite.Name.NullObject, 336, 685, 750, 10); pWallTop.ActivateCollisionSprite(pSB_Box); pWallGroup.Add(pWallTop); GameObjectMan.Attach(pWallGroup); //--------------------------------------------------------------------------------------------------------- // Create Bumper //--------------------------------------------------------------------------------------------------------- BumperGroup pBumperGroup = new BumperGroup(GameObject.Name.BumperGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pBumperGroup.ActivateGameSprite(pSB_Aliens); pBumperGroup.ActivateCollisionSprite(pSB_Box); BumperRight pBumperRight = new BumperRight(GameObject.Name.BumperRight, GameSprite.Name.NullObject, 650, 55, 15, 20); pBumperRight.ActivateCollisionSprite(pSB_Box); pBumperGroup.Add(pBumperRight); BumperLeft pBumperLeft = new BumperLeft(GameObject.Name.BumperLeft, GameSprite.Name.NullObject, 20, 55, 15, 20); pBumperLeft.ActivateCollisionSprite(pSB_Box); pBumperGroup.Add(pBumperLeft); GameObjectMan.Attach(pBumperGroup); //--------------------------------------------------------------------------------------------------------- // Create Ship //--------------------------------------------------------------------------------------------------------- ShipRoot pShipRoot = new ShipRoot(GameObject.Name.ShipRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); pShipRoot.ActivateCollisionSprite(pSB_Box); GameObjectMan.Attach(pShipRoot); ShipMan.Create(new SndObserver(sndEngine, SndObserver.Name.ShootMissile)); Ship pShip = new Ship(GameObject.Name.Ship, GameSprite.Name.Ship, 50, 20, null); pShip.ActivateCollisionSprite(pSB_Box); pShip.ActivateGameSprite(pSB_Aliens); pShipRoot.Add(pShip); //--------------------------------------------------------------------------------------------------------- // Bomb //--------------------------------------------------------------------------------------------------------- BombRoot pBombRoot = new BombRoot(GameObject.Name.BombRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); pBombRoot.ActivateCollisionSprite(pSB_Box); GameObjectMan.Attach(pBombRoot); //--------------------------------------------------------------------------------------------------------- // Explosion //--------------------------------------------------------------------------------------------------------- ExplosionFactory explosionFactory = new ExplosionFactory(SpriteBatch.Name.Aliens, SpriteBatch.Name.Boxes); ExplosionGroup pExplosionGroup = (ExplosionGroup)explosionFactory.Create(GameObject.Name.ExplosionGroup, GameSprite.Name.NullObject); GameObjectMan.Attach(pExplosionGroup); //--------------------------------------------------------------------------------------------------------- // Create Missile //--------------------------------------------------------------------------------------------------------- MissileGroup pMissileGroup = new MissileGroup(GameObject.Name.MissileGroup, GameSprite.Name.NullObject, 0, 0.0f, 0.0f); pMissileGroup.ActivateGameSprite(pSB_Aliens); pMissileGroup.ActivateCollisionSprite(pSB_Box); GameObjectMan.Attach(pMissileGroup); //--------------------------------------------------------------------------------------------------------- // Create Aliens //--------------------------------------------------------------------------------------------------------- AlienGroup pAlienGroup; if (SceneStateGame.loadGhost == false) { GameObject pGameObj; AlienMan.Create(); AlienFactory alienFactory = new AlienFactory(SpriteBatch.Name.Aliens, SpriteBatch.Name.Boxes); pAlienGroup = (AlienGroup)alienFactory.Create(GameObject.Name.AlienGroup, AlienCategory.Type.Group); for (int i = 0; i < 11; i++) { float x = 100.0f + 35 * (i % 11); GameObject pGameObjCol = alienFactory.Create(GameObject.Name.AlienColumn, AlienCategory.Type.Column, pAlienGroup); pGameObj = alienFactory.Create(GameObject.Name.Squid, AlienCategory.Type.Squid, pGameObjCol, x, baseY); pGameObj = alienFactory.Create(GameObject.Name.Crab, AlienCategory.Type.Crab, pGameObjCol, x, baseY - 30); pGameObj = alienFactory.Create(GameObject.Name.Crab, AlienCategory.Type.Crab, pGameObjCol, x, baseY - 30 * 2); pGameObj = alienFactory.Create(GameObject.Name.Octopus, AlienCategory.Type.Octopus, pGameObjCol, x, baseY - 30 * 3); pGameObj = alienFactory.Create(GameObject.Name.Octopus, AlienCategory.Type.Octopus, pGameObjCol, x, baseY - 30 * 4); } } else { GameObjectNode pGhostGameObjNode = GhostGameObjectMan.Find(GameObject.Name.AlienGroup); pAlienGroup = (AlienGroup)pGhostGameObjNode.pGameObj; ForwardIterator pFor = new ForwardIterator(pAlienGroup); Component pNode = pFor.First(); while (!pFor.IsDone()) { GameObject pGameObj = (GameObject)pNode; pGameObj.ActivateGameSprite(pSB_Aliens); pGameObj.ActivateCollisionSprite(pSB_Box); pNode = pFor.Next(); } GhostGameObjectMan.Remove(pGhostGameObjNode); } GameObjectMan.Attach(pAlienGroup); MovementSprite pMvSprite = new MovementSprite(pAlienGroup); pMvSprite.Attach(10.0f, 20.0f, new SndObserver(sndEngine, SndObserver.Name.AlienMove4, 0.5f)); pMvSprite.Attach(10.0f, 20.0f, new SndObserver(sndEngine, SndObserver.Name.AlienMove3, 0.5f)); pMvSprite.Attach(10.0f, 20.0f, new SndObserver(sndEngine, SndObserver.Name.AlienMove2, 0.5f)); pMvSprite.Attach(10.0f, 20.0f, new SndObserver(sndEngine, SndObserver.Name.AlienMove1, 0.5f)); TimerMan.Add(TimerEvent.Name.AlienMovement, pMvSprite, pMoveRate); //--------------------------------------------------------------------------------------------------------- // UFO //--------------------------------------------------------------------------------------------------------- UFORoot pUFORoot = new UFORoot(GameObject.Name.UFORoot, GameSprite.Name.NullObject, 0.0f, 0.0f); pUFORoot.ActivateCollisionSprite(pSB_Box); GameObjectMan.Attach(pUFORoot); UFOMan.Create(new SndObserver(sndEngine, SndObserver.Name.UFOFlyHigh, 0.2f, true)); //--------------------------------------------------------------------------------------------------------- // Shield //--------------------------------------------------------------------------------------------------------- ShieldFactory shieldFactory = new ShieldFactory(SpriteBatch.Name.Shields, SpriteBatch.Name.Boxes); ShieldRoot pShieldRoot = (ShieldRoot)shieldFactory.Create(ShieldCategory.Type.Root, GameObject.Name.NullObject); GameObjectMan.Attach(pShieldRoot); // load by column for (int i = 0; i < 4; i++) { int j = 0; float start_x = 86.0f + i * 146; float start_y = 100.0f; float off_x = 0; float brickWidth = 10.0f; float brickHeight = 5.0f; ShieldGrid pShieldGrid = (ShieldGrid)shieldFactory.Create(ShieldCategory.Type.Grid, GameObject.Name.NullObject, pShieldRoot); GameObject pColumn; pColumn = shieldFactory.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++, pShieldGrid); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x, start_y); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x, start_y + brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x, start_y + 2 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x, start_y + 3 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x, start_y + 4 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x, start_y + 5 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x, start_y + 6 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x, start_y + 7 * brickHeight); shieldFactory.Create(ShieldCategory.Type.LeftTop1, GameObject.Name.ShieldBrick, pColumn, start_x, start_y + 8 * brickHeight); shieldFactory.Create(ShieldCategory.Type.LeftTop0, GameObject.Name.ShieldBrick, pColumn, start_x, start_y + 9 * brickHeight); pColumn = shieldFactory.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++, pShieldGrid); off_x += brickWidth; shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 2 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 3 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 4 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 5 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 6 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 7 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 8 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 9 * brickHeight); pColumn = shieldFactory.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++, pShieldGrid); off_x += brickWidth; shieldFactory.Create(ShieldCategory.Type.LeftBottom, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 2 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 3 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 4 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 5 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 6 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 7 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 8 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 9 * brickHeight); pColumn = shieldFactory.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++, pShieldGrid); off_x += brickWidth; shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 3 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 4 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 5 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 6 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 7 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 8 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 9 * brickHeight); pColumn = shieldFactory.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++, pShieldGrid); off_x += brickWidth; shieldFactory.Create(ShieldCategory.Type.RightBottom, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 2 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 3 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 4 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 5 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 6 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 7 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 8 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 9 * brickHeight); pColumn = shieldFactory.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++, pShieldGrid); off_x += brickWidth; shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 0 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 1 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 2 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 3 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 4 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 5 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 6 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 7 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 8 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 9 * brickHeight); pColumn = shieldFactory.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++, pShieldGrid); off_x += brickWidth; shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 0 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 1 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 2 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 3 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 4 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 5 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 6 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 7 * brickHeight); shieldFactory.Create(ShieldCategory.Type.RightTop1, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 8 * brickHeight); shieldFactory.Create(ShieldCategory.Type.RightTop0, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 9 * brickHeight); } //--------------------------------------------------------------------------------------------------------- // ColPair //--------------------------------------------------------------------------------------------------------- // associate in a collision pair ColPair pColPair = ColPairMan.Add(ColPair.Name.Alien_Wall, pAlienGroup, pWallGroup); Debug.Assert(pColPair != null); pColPair.Attach(new GridObserver()); //pColPair.Attach(new SndObserver(sndEngine, SndObserver.Name.Alien_Wall)); // Missile vs Wall pColPair = ColPairMan.Add(ColPair.Name.Missile_Wall, pMissileGroup, pWallGroup); Debug.Assert(pColPair != null); pColPair.Attach(new ShipReadyObserver()); pColPair.Attach(new RemoveMissileObserver()); pColPair.Attach(new ExplosionObserver(explosionFactory, GameObject.Name.MissileDies, GameSprite.Name.MissileDies, pExplosionGroup, 1)); // Bomb vs Bottom pColPair = ColPairMan.Add(ColPair.Name.Bomb_Wall, pBombRoot, pWallGroup); pColPair.Attach(new BombObserver(1)); pColPair.Attach(new RemoveBombObserver()); pColPair.Attach(new ExplosionObserver(explosionFactory, GameObject.Name.BombDies, GameSprite.Name.BombDies, pExplosionGroup, 1)); // UFO vs Wall pColPair = ColPairMan.Add(ColPair.Name.UFO_Wall, pUFORoot, pWallGroup); Debug.Assert(pColPair != null); pColPair.Attach(new RemoveUFOObserver()); pColPair.Attach(new UFOReadyObserver(sndEngine)); // Missle vs UFO pColPair = ColPairMan.Add(ColPair.Name.Missile_UFO, pMissileGroup, pUFORoot); Debug.Assert(pColPair != null); pColPair.Attach(new SndObserver(sndEngine, SndObserver.Name.Missile_Shield)); pColPair.Attach(new RemoveUFOObserver2()); pColPair.Attach(new RemoveMissileObserver()); pColPair.Attach(new UFOReadyObserver(sndEngine)); pColPair.Attach(new ScoreObserver()); pColPair.Attach(new ShipReadyObserver()); pColPair.Attach(new ExplosionObserver(explosionFactory, GameObject.Name.UFODies, GameSprite.Name.UFODies, pExplosionGroup, 2)); // missile vs alien pColPair = ColPairMan.Add(ColPair.Name.Alien_Missile, pMissileGroup, pAlienGroup); pColPair.Attach(new ShipReadyObserver()); pColPair.Attach(new RemoveMissileObserver()); pColPair.Attach(new ScoreObserver()); pColPair.Attach(new ExplosionObserver(explosionFactory, GameObject.Name.AlienDies, GameSprite.Name.AlienDies, pExplosionGroup, 2)); pColPair.Attach(new GridRemoveAlienObserver()); pColPair.Attach(new SndObserver(sndEngine, SndObserver.Name.Missile_Alien)); pColPair.Attach(new AlienNumObserver(sndEngine)); // Missile vs Shield pColPair = ColPairMan.Add(ColPair.Name.Misslie_Shield, pMissileGroup, pShieldRoot); pColPair.Attach(new SndObserver(sndEngine, SndObserver.Name.Missile_Shield)); pColPair.Attach(new RemoveMissileObserver()); pColPair.Attach(new RemoveBrickObserver()); pColPair.Attach(new ShipReadyObserver()); pColPair.Attach(new ExplosionObserver(explosionFactory, GameObject.Name.MissileDies, GameSprite.Name.MissileDies, pExplosionGroup, 1)); // Bomb vs Shield pColPair = ColPairMan.Add(ColPair.Name.Bomb_Shield, pBombRoot, pShieldRoot); pColPair.Attach(new SndObserver(sndEngine, SndObserver.Name.Bomb_Shield)); pColPair.Attach(new BombObserver(1)); pColPair.Attach(new RemoveBrickObserver()); pColPair.Attach(new RemoveBombObserver()); pColPair.Attach(new ExplosionObserver(explosionFactory, GameObject.Name.BombDies, GameSprite.Name.BombDies, pExplosionGroup, 1)); // Bomb vs Ship pay attention to the order pColPair = ColPairMan.Add(ColPair.Name.Bomb_Ship, pBombRoot, pShipRoot); pColPair.Attach(new SndObserver(sndEngine, SndObserver.Name.Bomb_Ship)); pColPair.Attach(new BombObserver(1)); pColPair.Attach(new RemoveBombObserver()); pColPair.Attach(new RemoveShipObserver()); pColPair.Attach(new LifeObserver()); pColPair.Attach(new AnimExplosionObserver(explosionFactory, GameObject.Name.ShipDies, GameSprite.Name.ShipDies, pExplosionGroup, 2)); pColPair.Attach(new CreateShipObserver(sndEngine)); // Ship vs Bumper pColPair = ColPairMan.Add(ColPair.Name.Ship_Bumper, pShipRoot, pBumperGroup); pColPair.Attach(new ShipMoveObserver()); // Missle vs Bomb pColPair = ColPairMan.Add(ColPair.Name.Missile_Bomb, pMissileGroup, pBombRoot); Debug.Assert(pColPair != null); pColPair.Attach(new BombObserver(2)); pColPair.Attach(new RemoveMissileObserver()); pColPair.Attach(new RemoveBomb2Observer()); pColPair.Attach(new ShipReadyObserver()); pColPair.Attach(new ExplosionObserver(explosionFactory, GameObject.Name.MissileBombCol, GameSprite.Name.MissileBombCol, pExplosionGroup, 1)); //--------------------------------------------------------------------------------------------------------- // Input //--------------------------------------------------------------------------------------------------------- InputSubject pInputSubject; pInputSubject = InputMan.GetArrowRightSubject(); pInputSubject.Attach(new MoveRightObserver()); pInputSubject = InputMan.GetArrowLeftSubject(); pInputSubject.Attach(new MoveLeftObserver()); pInputSubject = InputMan.GetSpaceSubject(); pInputSubject.Attach(new ShootObserver()); pInputSubject = InputMan.GetTSubject(); pInputSubject.Attach(new ToggleObserver()); pInputSubject = InputMan.GetRSubject(); pInputSubject.Attach(new ToggleShieldObserver()); Simulation.SetState(Simulation.State.Realtime); //--------------------------------------------------------------------------------------------------------- // Font //--------------------------------------------------------------------------------------------------------- FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, "SCORE<1>", Glyph.Name.Consolas20pt, 100, 730); FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, "HI-SCORE", Glyph.Name.Consolas20pt, 300, 730); FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, "SCORE<2>", Glyph.Name.Consolas20pt, 500, 730); FontMan.Add(Font.Name.Score1, SpriteBatch.Name.Texts, score1, Glyph.Name.Consolas20pt, 100, 700); FontMan.Add(Font.Name.ScoreHigh, SpriteBatch.Name.Texts, scoreHigh, Glyph.Name.Consolas20pt, 300, 700); FontMan.Add(Font.Name.Score2, SpriteBatch.Name.Texts, score2, Glyph.Name.Consolas20pt, 500, 700); FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, "X", Glyph.Name.Consolas20pt, 80, 17); FontMan.Add(Font.Name.Life, SpriteBatch.Name.Texts, GetPlayerLife(GetCurrPlayer()).ToString(), Glyph.Name.Consolas20pt, 100, 17); FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, "Player " + currPlayer.ToString(), Glyph.Name.Consolas20pt, 480, 17); FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, currPlayer == 1 ? "Level " + player1Level.ToString() : "Level " + player2Level.ToString(), Glyph.Name.Consolas20pt, 570, 17); //--------------------------------------------------------------------------------------------------------- // State settings //--------------------------------------------------------------------------------------------------------- SceneStateGame.SetLoadGhost(false); }
public void LoadAll(GameObject pAlienGrid) { GameObject pC0 = Create(GameObject.Name.C0, AlienCategory.Type.Column); pAlienGrid.Add(pC0); GameObject pC1 = Create(GameObject.Name.C1, AlienCategory.Type.Column); pAlienGrid.Add(pC1); GameObject pC2 = Create(GameObject.Name.C2, AlienCategory.Type.Column); pAlienGrid.Add(pC2); GameObject pC3 = Create(GameObject.Name.C3, AlienCategory.Type.Column); pAlienGrid.Add(pC3); GameObject pC4 = Create(GameObject.Name.C4, AlienCategory.Type.Column); pAlienGrid.Add(pC4); GameObject pC5 = Create(GameObject.Name.C5, AlienCategory.Type.Column); pAlienGrid.Add(pC5); GameObject pC6 = Create(GameObject.Name.C6, AlienCategory.Type.Column); pAlienGrid.Add(pC6); GameObject pC7 = Create(GameObject.Name.C7, AlienCategory.Type.Column); pAlienGrid.Add(pC7); GameObject pC8 = Create(GameObject.Name.C8, AlienCategory.Type.Column); pAlienGrid.Add(pC8); GameObject pC9 = Create(GameObject.Name.C9, AlienCategory.Type.Column); pAlienGrid.Add(pC9); GameObject pC10 = Create(GameObject.Name.C10, AlienCategory.Type.Column); pAlienGrid.Add(pC10); GameObject pGameObj = null; pGameObj = Create(GameObject.Name.R0C0, AlienCategory.Type.Squid, 60.0f + 40.0f * 0, 500.0f - 30.0f * 0); pC0.Add(pGameObj); pGameObj = Create(GameObject.Name.R1C0, AlienCategory.Type.Squid, 60f + 40.0f * 0, 500.0f - 30.0f * 1); pC0.Add(pGameObj); pGameObj = Create(GameObject.Name.R2C0, AlienCategory.Type.Crab, 60.0f + 40.0f * 0, 500.0f - 30.0f * 2); pC0.Add(pGameObj); pGameObj = Create(GameObject.Name.R3C0, AlienCategory.Type.Crab, 60.0f + 40.0f * 0, 500.0f - 30.0f * 3); pC0.Add(pGameObj); pGameObj = Create(GameObject.Name.R4C0, AlienCategory.Type.Octopus, 60.0f + 40.0f * 0, 500.0f - 30.0f * 4); pC0.Add(pGameObj); pGameObj = Create(GameObject.Name.R0C1, AlienCategory.Type.Squid, 60.0f + 40.0f * 1, 500.0f - 30.0f * 0); pC1.Add(pGameObj); pGameObj = Create(GameObject.Name.R1C1, AlienCategory.Type.Squid, 60.0f + 40.0f * 1, 500.0f - 30.0f * 1); pC1.Add(pGameObj); pGameObj = Create(GameObject.Name.R2C1, AlienCategory.Type.Crab, 60.0f + 40.0f * 1, 500.0f - 30.0f * 2); pC1.Add(pGameObj); pGameObj = Create(GameObject.Name.R3C1, AlienCategory.Type.Crab, 60.0f + 40.0f * 1, 500.0f - 30.0f * 3); pC1.Add(pGameObj); pGameObj = Create(GameObject.Name.R4C1, AlienCategory.Type.Octopus, 60.0f + 40.0f * 1, 500.0f - 30.0f * 4); pC1.Add(pGameObj); pGameObj = Create(GameObject.Name.R0C2, AlienCategory.Type.Squid, 60.0f + 40.0f * 2, 500.0f - 30.0f * 0); pC2.Add(pGameObj); pGameObj = Create(GameObject.Name.R1C2, AlienCategory.Type.Squid, 60.0f + 40.0f * 2, 500.0f - 30.0f * 1); pC2.Add(pGameObj); pGameObj = Create(GameObject.Name.R2C2, AlienCategory.Type.Crab, 60.0f + 40.0f * 2, 500.0f - 30.0f * 2); pC2.Add(pGameObj); pGameObj = Create(GameObject.Name.R3C2, AlienCategory.Type.Crab, 60.0f + 40.0f * 2, 500.0f - 30.0f * 3); pC2.Add(pGameObj); pGameObj = Create(GameObject.Name.R4C2, AlienCategory.Type.Octopus, 60.0f + 40.0f * 2, 500.0f - 30.0f * 4); pC2.Add(pGameObj); pGameObj = Create(GameObject.Name.R0C3, AlienCategory.Type.Squid, 60.0f + 40.0f * 3, 500.0f - 30.0f * 0); pC3.Add(pGameObj); pGameObj = Create(GameObject.Name.R1C3, AlienCategory.Type.Squid, 60.0f + 40.0f * 3, 500.0f - 30.0f * 1); pC3.Add(pGameObj); pGameObj = Create(GameObject.Name.R2C3, AlienCategory.Type.Crab, 60.0f + 40.0f * 3, 500.0f - 30.0f * 2); pC3.Add(pGameObj); pGameObj = Create(GameObject.Name.R3C3, AlienCategory.Type.Crab, 60.0f + 40.0f * 3, 500.0f - 30.0f * 3); pC3.Add(pGameObj); pGameObj = Create(GameObject.Name.R4C3, AlienCategory.Type.Octopus, 60.0f + 40.0f * 3, 500.0f - 30.0f * 4); pC3.Add(pGameObj); pGameObj = Create(GameObject.Name.R0C4, AlienCategory.Type.Squid, 60.0f + 40.0f * 4, 500.0f - 30.0f * 0); pC4.Add(pGameObj); pGameObj = Create(GameObject.Name.R1C4, AlienCategory.Type.Squid, 60.0f + 40.0f * 4, 500.0f - 30.0f * 1); pC4.Add(pGameObj); pGameObj = Create(GameObject.Name.R2C4, AlienCategory.Type.Crab, 60.0f + 40.0f * 4, 500.0f - 30.0f * 2); pC4.Add(pGameObj); pGameObj = Create(GameObject.Name.R3C4, AlienCategory.Type.Crab, 60.0f + 40.0f * 4, 500.0f - 30.0f * 3); pC4.Add(pGameObj); pGameObj = Create(GameObject.Name.R4C4, AlienCategory.Type.Octopus, 60.0f + 40.0f * 4, 500.0f - 30.0f * 4); pC4.Add(pGameObj); pGameObj = Create(GameObject.Name.R0C5, AlienCategory.Type.Squid, 60.0f + 40.0f * 5, 500.0f - 30.0f * 0); pC5.Add(pGameObj); pGameObj = Create(GameObject.Name.R1C5, AlienCategory.Type.Squid, 60.0f + 40.0f * 5, 500.0f - 30.0f * 1); pC5.Add(pGameObj); pGameObj = Create(GameObject.Name.R2C5, AlienCategory.Type.Crab, 60.0f + 40.0f * 5, 500.0f - 30.0f * 2); pC5.Add(pGameObj); pGameObj = Create(GameObject.Name.R3C5, AlienCategory.Type.Crab, 60.0f + 40.0f * 5, 500.0f - 30.0f * 3); pC5.Add(pGameObj); pGameObj = Create(GameObject.Name.R4C5, AlienCategory.Type.Octopus, 60.0f + 40.0f * 5, 500.0f - 30.0f * 4); pC5.Add(pGameObj); pGameObj = Create(GameObject.Name.R0C6, AlienCategory.Type.Squid, 60.0f + 40.0f * 6, 500.0f - 30.0f * 0); pC6.Add(pGameObj); pGameObj = Create(GameObject.Name.R1C6, AlienCategory.Type.Squid, 60.0f + 40.0f * 6, 500.0f - 30.0f * 1); pC6.Add(pGameObj); pGameObj = Create(GameObject.Name.R2C6, AlienCategory.Type.Crab, 60.0f + 40.0f * 6, 500.0f - 30.0f * 2); pC6.Add(pGameObj); pGameObj = Create(GameObject.Name.R3C6, AlienCategory.Type.Crab, 60.0f + 40.0f * 6, 500.0f - 30.0f * 3); pC6.Add(pGameObj); pGameObj = Create(GameObject.Name.R4C6, AlienCategory.Type.Octopus, 60.0f + 40.0f * 6, 500.0f - 30.0f * 4); pC6.Add(pGameObj); pGameObj = Create(GameObject.Name.R0C7, AlienCategory.Type.Squid, 60.0f + 40.0f * 7, 500.0f - 30.0f * 0); pC7.Add(pGameObj); pGameObj = Create(GameObject.Name.R1C7, AlienCategory.Type.Squid, 60.0f + 40.0f * 7, 500.0f - 30.0f * 1); pC7.Add(pGameObj); pGameObj = Create(GameObject.Name.R2C7, AlienCategory.Type.Crab, 60.0f + 40.0f * 7, 500.0f - 30.0f * 2); pC7.Add(pGameObj); pGameObj = Create(GameObject.Name.R3C7, AlienCategory.Type.Crab, 60.0f + 40.0f * 7, 500.0f - 30.0f * 3); pC7.Add(pGameObj); pGameObj = Create(GameObject.Name.R4C7, AlienCategory.Type.Octopus, 60.0f + 40.0f * 7, 500.0f - 30.0f * 4); pC7.Add(pGameObj); pGameObj = Create(GameObject.Name.R0C8, AlienCategory.Type.Squid, 60.0f + 40.0f * 8, 500.0f - 30.0f * 0); pC8.Add(pGameObj); pGameObj = Create(GameObject.Name.R1C8, AlienCategory.Type.Squid, 60.0f + 40.0f * 8, 500.0f - 30.0f * 1); pC8.Add(pGameObj); pGameObj = Create(GameObject.Name.R2C8, AlienCategory.Type.Crab, 60.0f + 40.0f * 8, 500.0f - 30.0f * 2); pC8.Add(pGameObj); pGameObj = Create(GameObject.Name.R3C8, AlienCategory.Type.Crab, 60.0f + 40.0f * 8, 500.0f - 30.0f * 3); pC8.Add(pGameObj); pGameObj = Create(GameObject.Name.R4C8, AlienCategory.Type.Octopus, 60.0f + 40.0f * 8, 500.0f - 30.0f * 4); pC8.Add(pGameObj); pGameObj = Create(GameObject.Name.R0C9, AlienCategory.Type.Squid, 60.0f + 40.0f * 9, 500.0f - 30.0f * 0); pC9.Add(pGameObj); pGameObj = Create(GameObject.Name.R1C9, AlienCategory.Type.Squid, 60.0f + 40.0f * 9, 500.0f - 30.0f * 1); pC9.Add(pGameObj); pGameObj = Create(GameObject.Name.R2C9, AlienCategory.Type.Crab, 60.0f + 40.0f * 9, 500.0f - 30.0f * 2); pC9.Add(pGameObj); pGameObj = Create(GameObject.Name.R3C9, AlienCategory.Type.Crab, 60.0f + 40.0f * 9, 500.0f - 30.0f * 3); pC9.Add(pGameObj); pGameObj = Create(GameObject.Name.R4C9, AlienCategory.Type.Octopus, 60.0f + 40.0f * 9, 500.0f - 30.0f * 4); pC9.Add(pGameObj); pGameObj = Create(GameObject.Name.R0C10, AlienCategory.Type.Squid, 60.0f + 40.0f * 10, 500.0f - 30.0f * 0); pC10.Add(pGameObj); pGameObj = Create(GameObject.Name.R1C10, AlienCategory.Type.Squid, 60.0f + 40.0f * 10, 500.0f - 30.0f * 1); pC10.Add(pGameObj); pGameObj = Create(GameObject.Name.R2C10, AlienCategory.Type.Crab, 60.0f + 40.0f * 10, 500.0f - 30.0f * 2); pC10.Add(pGameObj); pGameObj = Create(GameObject.Name.R3C10, AlienCategory.Type.Crab, 60.0f + 40.0f * 10, 500.0f - 30.0f * 3); pC10.Add(pGameObj); pGameObj = Create(GameObject.Name.R4C10, AlienCategory.Type.Octopus, 60.0f + 40.0f * 10, 500.0f - 30.0f * 4); pC10.Add(pGameObj); pAlienGrid.Print(); Debug.WriteLine("\n"); Debug.WriteLine("Iterator...\n"); ForwardIterator pIt = new ForwardIterator(pAlienGrid); Component pNode = pIt.First(); while (!pIt.IsDone()) { pNode.Dump(); pNode = pIt.Next(); } }
public override void Notify() { // Delete missile //Debug.WriteLine("RemoveAlienObserver: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB); // This cast will throw an exception if wrong this.pAlien = (Alien)this.pSubject.pObjA; this.pComposite = null; // Remove Alien from composite Composite pAlienGrid = GameStateManager.GetGame().GetStateCompositeManager().Find(Composite.CompositeName.AlienGrid); ForwardIterator pFwdIter = new ForwardIterator(pAlienGrid); Component pNode = pFwdIter.First(); while (!pFwdIter.IsDone()) { if (pNode.containerType == Component.Container.LEAF) { // If Component is target alien if (pNode.GetHashCode() == this.pAlien.GetHashCode()) { // Remove Alien from column pNode.pParent.Remove(pNode); Component parentComposite = pNode.pParent; // If column is now empty, delete column if (parentComposite.GetFirstChild() == null) { // Delete empty column from parent composite if (parentComposite.pParent != null) { parentComposite.pParent.Remove(parentComposite); } if (!((GameObject)parentComposite).IsMarkedForDeath()) { // Delay - remove object later this.pComposite = (GameObject)parentComposite; this.pComposite.MarkForDeath(); } } break; } } pNode = pFwdIter.Next(); } if (!pAlien.IsMarkedForDeath()) { pAlien.MarkForDeath(); // Delay - remove object later RemoveAlienObserver pObserver = new RemoveAlienObserver(this); GameStateManager.GetGame().GetStateDelayedObjectManager().Attach(pObserver); } // Faster grid speed (shorter delta) float newSpeed = GameStateManager.GetGame().GetStateAlienGridSpeed() - 0.013f; if (newSpeed > 0.0f) { // Increase Alien Grid Speed GameStateManager.GetGame().SetStateAlienGridSpeed(newSpeed); } }