// game methods public override void load() { //--------------------------------------------------------------------------------------------------------- // Create sprite batch //--------------------------------------------------------------------------------------------------------- SpriteBatchManager.getInstance().AddSpriteBatch(SpriteBatch.Name.Player2, 2); //--------------------------------------------------------------------------------------------------------- // Create game sprites //--------------------------------------------------------------------------------------------------------- GameObject alienGrid = GameSpriteFactory.CreateAlienGrid(SpriteBatch.Name.Player2, 50f, 800f); TimerManager.getInstance().Add(new TimerEvent(TimerEvent.Name.ReleaseUFOCommand, new ReleaseUFOCommand(), 0.5f)); // PA6 Create shield ShieldFactory shieldFactory = new ShieldFactory(); GameObject shieldGrid_1 = shieldFactory.CreateShield(SpriteBatch.Name.Player2, 150f, 300f, 15f, 7.5f); GameObject shieldGrid_2 = shieldFactory.CreateShield(SpriteBatch.Name.Player2, 350f, 300f, 15f, 7.5f); GameObject shieldGrid_3 = shieldFactory.CreateShield(SpriteBatch.Name.Player2, 550f, 300f, 15f, 7.5f); GameObject shieldGrid_4 = shieldFactory.CreateShield(SpriteBatch.Name.Player2, 750f, 300f, 15f, 7.5f); // Collision Pair setup ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.WallAlien, ProjectileTracker.pLeftWall, alienGrid); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.WallAlien, ProjectileTracker.pRightWall, alienGrid); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.WallMissile, ProjectileTracker.pTopWall, ProjectileTracker.pMissile); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.AlienMissile, alienGrid, ProjectileTracker.pMissile); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldMissile, shieldGrid_1, ProjectileTracker.pMissile); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldMissile, shieldGrid_2, ProjectileTracker.pMissile); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldMissile, shieldGrid_3, ProjectileTracker.pMissile); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldMissile, shieldGrid_4, ProjectileTracker.pMissile); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldBomb, shieldGrid_1, ProjectileTracker.pDaggerBomb); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldBomb, shieldGrid_1, ProjectileTracker.pZigZagBomb); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldBomb, shieldGrid_1, ProjectileTracker.pRollingBomb); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldBomb, shieldGrid_2, ProjectileTracker.pDaggerBomb); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldBomb, shieldGrid_2, ProjectileTracker.pZigZagBomb); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldBomb, shieldGrid_2, ProjectileTracker.pRollingBomb); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldBomb, shieldGrid_3, ProjectileTracker.pDaggerBomb); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldBomb, shieldGrid_3, ProjectileTracker.pZigZagBomb); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldBomb, shieldGrid_3, ProjectileTracker.pRollingBomb); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldBomb, shieldGrid_4, ProjectileTracker.pDaggerBomb); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldBomb, shieldGrid_4, ProjectileTracker.pZigZagBomb); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShieldBomb, shieldGrid_4, ProjectileTracker.pRollingBomb); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.WallBomb, ProjectileTracker.pBottomWall, ProjectileTracker.pDaggerBomb); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.WallBomb, ProjectileTracker.pBottomWall, ProjectileTracker.pZigZagBomb); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.WallBomb, ProjectileTracker.pBottomWall, ProjectileTracker.pRollingBomb); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.MissileBomb, ProjectileTracker.pMissile, ProjectileTracker.pDaggerBomb); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.MissileBomb, ProjectileTracker.pMissile, ProjectileTracker.pZigZagBomb); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.MissileBomb, ProjectileTracker.pMissile, ProjectileTracker.pRollingBomb); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShipBomb, ProjectileTracker.pShip, ProjectileTracker.pDaggerBomb); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShipBomb, ProjectileTracker.pShip, ProjectileTracker.pZigZagBomb); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.ShipBomb, ProjectileTracker.pShip, ProjectileTracker.pRollingBomb); ColliPairManager.getInstance().AddCollisionPair(CollisionPair.Name.UFOMissile, ProjectileTracker.pUFO, ProjectileTracker.pMissile); }
public static void InitializeAlienFactory() { if (pInstance == null) { pInstance = new ShieldFactory(); } Debug.Assert(pInstance != null); }
public static void SetParent(GameObject pComp) { Debug.Assert(pComp != null); ShieldFactory pFactory = ShieldFactory.PrivGetInstance(); Debug.Assert(pFactory != null); pFactory.pParent = pComp; }
public static ShieldZone CreateShieldZone(float xOrigin, float yOrigin, float xDeltaBetween, int numShields = 4) { ShieldFactory pZoneSF = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes); ShieldZone pShieldZone = (ShieldZone)pZoneSF.Create(ShieldFactory.Type.Zone, 0, 0); for (int i = 0; i < numShields; i++) { CreateShield(xOrigin + (i * xDeltaBetween), yOrigin, pShieldZone); } return(pShieldZone); }
private FactoryManager() { SpriteBatch alienBatch = SpriteBatchManager.add(SpriteBatch.SpriteBatchName.Aliens); PCSTree alienPcsTree = new PCSTree(); this.alienFactory = new AlienFactory(alienPcsTree, alienBatch); SpriteBatch bombBatch = SpriteBatchManager.add(SpriteBatch.SpriteBatchName.Bombs); PCSTree bombPcsTree = new PCSTree(); this.bombFactory = new BombFactory(bombPcsTree, bombBatch); SpriteBatch missileBatch = SpriteBatchManager.add(SpriteBatch.SpriteBatchName.Missiles); PCSTree missilePcsTree = new PCSTree(); this.missileFactory = new MissileFactory(missilePcsTree, missileBatch); SpriteBatch shieldBatch = SpriteBatchManager.add(SpriteBatch.SpriteBatchName.Shields); PCSTree shieldPcsTree = new PCSTree(); this.shieldFactory = new ShieldFactory(shieldPcsTree, shieldBatch); SpriteBatch shipBatch = SpriteBatchManager.add(SpriteBatch.SpriteBatchName.Ships); PCSTree shipPcsTree = new PCSTree(); this.shipFactory = new ShipFactory(shipPcsTree, shipBatch); SpriteBatch wallBatch = SpriteBatchManager.add(SpriteBatch.SpriteBatchName.Walls); PCSTree wallPcsTree = new PCSTree(); this.wallFactory = new WallFactory(wallPcsTree, wallBatch); SpriteBatch ufoBatch = SpriteBatchManager.add(SpriteBatch.SpriteBatchName.UFOs); PCSTree ufoPcsTree = new PCSTree(); this.ufoFactory = new UFOFactory(ufoPcsTree, ufoBatch); sndEngine = new IrrKlang.ISoundEngine(); }
//----------------------------------------------------------------------------- // Game::LoadContent() // Allows you to load all content needed for your engine, // such as objects, graphics, etc. //----------------------------------------------------------------------------- public override void LoadContent() { Debug.WriteLine("----------------------------------"); Debug.WriteLine("Load Content"); Debug.WriteLine("----------------------------------\n"); //----------------------------------------------- //Create Game Simulation instance Simulation.Create(); //----------------------------------------------- //Manager Load //------------------------------ //Texture Manager Create TextureManager.Create(); //------------------------------ //Image Manager Create ImageManager.Create(); //------------------------------ //Game/Box Sprite Manager Create GameSpriteManager.Create(5, 2); BoxSpriteManager.Create(); //------------------------------ //SpriteBatch Manager Create SpriteBatchManager.Create(); //------------------------------ //ProxySprite Manager Create ProxySpriteManager.Create(10, 1); //------------------------------ //GameObject Manager Create GameObjectManager.Create(); //------------------------------ //CollisionPair Manager Create ColPairManager.Create(); //------------------------------ //TimerEvent Manager Create TimerEventManager.Create(); //------------------------------ //Glyph/Font Manager Create/Load GlyphManager.Create(); FontManager.Create(); //------------------------------ //Death/Ghost Manager Create DeathManager.Create(1, 1); GhostManager.Create(1, 1); //----------------------------------------------- // Input Manager - Key Observer Load InputManager.LoadKeyInputObservers(); //----------------------------------------------- //Print some initial stats TextureManager.DumpStats(); ImageManager.DumpStats(); GameSpriteManager.DumpStats(); BoxSpriteManager.DumpStats(); SpriteBatchManager.DumpStats(); ProxySpriteManager.DumpStats(); TimerEventManager.DumpStats(); GameObjectManager.DumpStats(); DeathManager.DumpStats(); GhostManager.DumpStats(); ColPairManager.DumpStats(); GlyphManager.DumpStats(); //------------------------------ //Asset Loading //Texture/Image/Font Load TextureManager.LoadTextures(); ImageManager.LoadImages(); FontManager.LoadFonts(); //----------------------------------------------- //Sprite Batch /Sprite Load SpriteBatch pSB_GameSprites = SpriteBatchManager.Add(SpriteBatch.Name.GameSprites); SpriteBatch pShields = SpriteBatchManager.Add(SpriteBatch.Name.Shields); SpriteBatch pSB_Boxes = SpriteBatchManager.Add(SpriteBatch.Name.SpriteBoxes); SpriteBatch pSB_Texts = SpriteBatchManager.Add(SpriteBatch.Name.TextLetters); //----------------------------------------------- //Sprites/BoxSprites Load //NOTE that the following coordinates will not matter //once proxy sprites are used! //35w x 35h for all sprites; float const_AlienSpriteSize = 30.0f; //render dimensions/coordinates float squid_sX = 400.0f; float squid_sY = 400.0f; float crab_sX = 400.0f; float crab_sY = 350.0f; float octo_sX = 400.0f; float octo_sY = 300.0f; float missileSpriteWidth = 4.0f; float missileSpriteHeight = 8.0f; float alienBombSpriteWidth = 6.0f; float alienBombSpriteHeight = 12.0f; float shipSpriteWidth = 55.0f; float shipSpriteHeight = 25.0f; float verticalWallWidth = 678.0f; float verticalWallHeight = 10.0f; float horizontalWallWidth = 678.0f; float horizontalWallHeight = 10.0f; //---------------------- //aliens (initial sprites only) //note that the alien grid and alien column are game sprites for box sprite rendering, //but will pass a null image since they don't have anything to render GameSpriteManager.Add(GameSprite.Name.AlienGrid, Image.Name.NullObject, 0, 0, 0, 0); GameSpriteManager.Add(GameSprite.Name.AlienColumn, Image.Name.NullObject, 0, 0, 0, 0); //squid game sprite GameSpriteManager.Add(GameSprite.Name.Squid, Image.Name.SquidOpen, squid_sX, squid_sY, const_AlienSpriteSize, const_AlienSpriteSize); //crab game sprite GameSpriteManager.Add(GameSprite.Name.Crab, Image.Name.CrabOpen, crab_sX, crab_sY, const_AlienSpriteSize, const_AlienSpriteSize); //octopus game sprite GameSpriteManager.Add(GameSprite.Name.Octopus, Image.Name.OctopusOpen, octo_sX, octo_sY, const_AlienSpriteSize, const_AlienSpriteSize); //alien explosion (for explosion animation after alien is destroyed) GameSpriteManager.Add(GameSprite.Name.AlienExplosion, Image.Name.AlienExplosionPop, 0, 0, const_AlienSpriteSize, const_AlienSpriteSize); //---------------------- //alien bombs (initial sprites only) //zigzag bomb GameSpriteManager.Add(GameSprite.Name.ZigZagAlienBomb, Image.Name.AlienBombZigZag_One, 0, 0, alienBombSpriteWidth, alienBombSpriteHeight); //cross bomb GameSpriteManager.Add(GameSprite.Name.CrossAlienBomb, Image.Name.AlienBombCross_One, 0, 0, alienBombSpriteWidth, alienBombSpriteHeight); //rolling bomb GameSpriteManager.Add(GameSprite.Name.RollingAlienBomb, Image.Name.AlienBombRolling_Two, 0, 0, alienBombSpriteWidth, alienBombSpriteHeight); //---------------------- //hero ship GameSpriteManager.Add(GameSprite.Name.Ship, Image.Name.Ship, 640.0f, 440.0f, shipSpriteWidth, shipSpriteHeight); //hero missile GameSpriteManager.Add(GameSprite.Name.Missile, Image.Name.Missile, 0, 0, missileSpriteWidth, missileSpriteHeight); //---------------------- //walls (2: top/bottom, left/right) //note screen w = 672px wide by 768px GameSpriteManager.Add(GameSprite.Name.VerticalWall, Image.Name.NullObject, 0, 0, verticalWallWidth, verticalWallHeight); GameSpriteManager.Add(GameSprite.Name.HorizontalWall, Image.Name.NullObject, 0, 0, horizontalWallWidth, horizontalWallHeight); //---------------------- //shield bricks (6) float brickSpriteWidth = 15.0f; float brickSpriteHeight = 10.0f; GameSpriteManager.Add(GameSprite.Name.ShieldBrick, Image.Name.ShieldBrick, 0.0f, 0.0f, brickSpriteWidth, brickSpriteHeight); GameSpriteManager.Add(GameSprite.Name.ShieldBrickLeft_Top, Image.Name.ShieldBrickLeft_Top, 0.0f, 0.0f, brickSpriteWidth, brickSpriteHeight); GameSpriteManager.Add(GameSprite.Name.ShieldBrickRight_Top, Image.Name.ShieldBrickRight_Top, 0, 0, brickSpriteWidth, brickSpriteHeight); GameSpriteManager.Add(GameSprite.Name.ShieldBrickMidLeft_Bottom, Image.Name.ShieldBrickMidLeft_Bottom, 0, 0, brickSpriteWidth, brickSpriteHeight); GameSpriteManager.Add(GameSprite.Name.ShieldBrickMid_Bottom, Image.Name.ShieldBrickMid_Bottom, 0, 0, brickSpriteWidth, brickSpriteHeight); GameSpriteManager.Add(GameSprite.Name.ShieldBrickMidRight_Bottom, Image.Name.ShieldBrickMidRight_Bottom, 0, 0, brickSpriteWidth, brickSpriteHeight); //---------------------- //alien UFO ship float ufoSpriteWidth = 30.0f; float ufoSpriteHeight = 10.0f; GameSpriteManager.Add(GameSprite.Name.AlienUFO, Image.Name.AlienUFO, 0, 0, ufoSpriteWidth, ufoSpriteHeight); //---------------------- //BoxSprites are added in the CollisionObject constructor depending on the sprite! //----------------------------------------------- //Load the Animations (TimerEvents) TimerEventManager.LoadAlienAnimations(); TimerEventManager.LoadBombAnimations(); //----------------------------------------------- //Set the Game Simulation State; Simulation.SetState(Simulation.State.Realtime); //----------------------------------------------- //GameObject Load (Factory) //get the PCSRootTree that was created by GameObjectManager PCSTree rootGamObjTree = GameObjectManager.GetRootTree(); //make sure root tree and root have been created; Debug.Assert(rootGamObjTree != null); Debug.Assert(rootGamObjTree.GetRoot() != null); //check the tree rootGamObjTree.DumpTree(); //------------------------------------------------ // Create Missile Tree MissileRoot pMissileRoot = new MissileRoot(GameObject.Name.MissileRoot, GameSprite.Name.NullObject, 0, 0.0f, 0.0f); rootGamObjTree.Insert(pMissileRoot, null); //pMissileRoot.ActivateCollisionSprite(pSB_Boxes); //GameObjectManager.AttachTree(pMissileRoot, rootGamObjTree); GameObjectManager.AttachTree(pMissileRoot); //TEST------------------ //PCSTree missileTree = new PCSTree(); //MissileRoot pMissileRoot = new MissileRoot(GameObject.Name.MissileRoot, GameSprite.Name.NullObject, 0, 0.0f, 0.0f); //missileTree.Insert(pMissileRoot, null); //pMissileRoot.ActivateCollisionSprite(pSB_Boxes); //GameObjectManager.AttachTree(pMissileRoot, rootGamObjTree); //rootGamObjTree.Insert(pMissileRoot, rootGamObjTree.GetRoot()); //------------------------------------------------ // Create Ship Tree ShipRoot shipRoot = new ShipRoot(GameObject.Name.ShipRoot, GameSprite.Name.NullObject, 0, 0.0f, 0.0f); DeathManager.Attach(shipRoot); //check the tree rootGamObjTree.DumpTree(); //attach the shipRoot to the rootGameObjTree, with the gamObjRoot as parent rootGamObjTree.Insert(shipRoot, null); //check the tree rootGamObjTree.DumpTree(); //attach the shipRoot to the root game object tree //GameObjectManager.AttachTree(shipRoot, rootGamObjTree); GameObjectManager.AttachTree(shipRoot); //create the ship manager that handles all the ship's states ShipManager.CreateShipManager(); //check the tree rootGamObjTree.DumpTree(); //------------------------------------------------ // Create an Alien Tree //AlienRoot alienRoot = new AlienRoot(GameObject.Name.AlienRoot, GameSprite.SpriteName.Null_Object, 0, 0.0f, 0.0f); //create the PCS tree that will hold all alien game objects PCSTree pAlienTree = new PCSTree(); DeathManager.Attach(pAlienTree); //create the alien game object factory with pAlienTree as the factory's tree //factory will attach all alien game objects to pAlienTree AlienFactory pAlienFactory = new AlienFactory(SpriteBatch.Name.GameSprites, pAlienTree); DeathManager.Attach(pAlienFactory); //attach grid as a child of game object root; grid will be parent of all alien game objects Grid pGrid = (Grid)pAlienFactory.Create(AlienType.Type.AlienGrid, GameObject.Name.Grid); // set the grid as the root parent to attach all aliens to; pAlienFactory.SetParent(pGrid); //Build the grid (builder pattern) int numberOfColumns = 11; //numberOfColumns = 1; AlienFactory.BuildAlienGrid(pAlienFactory, pGrid, numberOfColumns); //check the tree rootGamObjTree.DumpTree(); //GameObjectManager.AttachTree(pGrid, rootGamObjTree); GameObjectManager.AttachTree(pGrid); //------------------------------------------------ // Create Alien Bomb tree //create the root BombRoot pBombRoot = new BombRoot(GameObject.Name.BombRoot, GameSprite.Name.NullObject, 0, 0.0f, 0.0f); //insert root into the bomb tree rootGamObjTree.Insert(pBombRoot, null); //pBombRoot.ActivateCollisionSprite(pSB_Boxes); //add the bombtree to the root tree //GameObjectManager.AttachTree(pBombRoot, rootGamObjTree); GameObjectManager.AttachTree(pBombRoot); //check the tree rootGamObjTree.DumpTree(); //------------------------------------------------ // Associate and Create Walls //note screen = 672px wide by 768px WallRoot pWallRoot = new WallRoot(GameObject.Name.WallRoot, GameSprite.Name.NullObject, 0, 0.0f, 0.0f); rootGamObjTree.Insert(pWallRoot, null); WallTop pWallTop = new WallTop(GameObject.Name.WallTop, GameSprite.Name.HorizontalWall, 0, 336.0f, 728.0f, 612.0f, 10.0f); rootGamObjTree.Insert(pWallTop, pWallRoot); pWallTop.ActivateCollisionSprite(pSB_Boxes); WallBottom pWallBottom = new WallBottom(GameObject.Name.WallBottom, GameSprite.Name.HorizontalWall, 0, 336.0f, 40.0f, 612.0f, 10.0f); rootGamObjTree.Insert(pWallBottom, pWallRoot); pWallBottom.ActivateCollisionSprite(pSB_Boxes); WallRight pWallRight = new WallRight(GameObject.Name.WallRight, GameSprite.Name.HorizontalWall, 0, 652.0f, 384.0f, 10.0f, 693.0f); rootGamObjTree.Insert(pWallRight, pWallRoot); pWallRight.ActivateCollisionSprite(pSB_Boxes); WallLeft pWallLeft = new WallLeft(GameObject.Name.WallLeft, GameSprite.Name.HorizontalWall, 0, 20.0f, 384.0f, 10.0f, 693.0f); rootGamObjTree.Insert(pWallLeft, pWallRoot); pWallLeft.ActivateCollisionSprite(pSB_Boxes); //now that it's fully created, attach the newly created wall tree to the main game object tree //GameObjectManager.AttachTree(pWallRoot, rootGamObjTree); GameObjectManager.AttachTree(pWallRoot); //--------------------------------------------------------------------------------------------------------- // Shield //--------------------------------------------------------------------------------------------------------- //create the root ShieldRoot pShieldRoot = new ShieldRoot(GameObject.Name.ShieldRoot, GameSprite.Name.NullObject, 0, 0.0f, 0.0f); rootGamObjTree.Insert(pShieldRoot, null); //attach to game object tree GameObjectManager.AttachTree(pShieldRoot); // create the factory ShieldFactory shieldFactory = new ShieldFactory(SpriteBatch.Name.Shields, SpriteBatch.Name.Shields, rootGamObjTree); // set the parent for hierarchy inside the factory, grid is root, so parent is null //shieldFactory.setParent(pShieldRoot); // create and attach grid to Root //ShieldGrid pShieldGrid = (ShieldGrid)shieldFactory.Create(ShieldCategory.Type.ShieldGrid, GameObject.Name.ShieldGrid); float startPos_X = 50.0f; float startPos_y = 100.0f; //shield 1 - far left shieldFactory.BuildShield(pShieldRoot, startPos_X, startPos_y, brickSpriteWidth, brickSpriteHeight); //move to the right startPos_X = 210.0f; shieldFactory.BuildShield(pShieldRoot, startPos_X, startPos_y, brickSpriteWidth, brickSpriteHeight); //move to the right startPos_X = 370.0f; shieldFactory.BuildShield(pShieldRoot, startPos_X, startPos_y, brickSpriteWidth, brickSpriteHeight); //move to the right startPos_X = 520.0f; shieldFactory.BuildShield(pShieldRoot, startPos_X, startPos_y, brickSpriteWidth, brickSpriteHeight); //check the tree rootGamObjTree.DumpTree(); //------------------------------------------------ // Associate and Create Collision Pairs ColPair pColPair = null; // IMPORTANT: At LEAST two steps when establishing the collision pairs // 1) associate object roots in a collision pair, // 2) then attach all relevent Observer objects that will execute their specified response to collision //todo create an observerObject manager that pools all of these observer objects! //--------------------------------------------------------------------------------------------- //Missile CollisionPairs //Missile vs Wall (Top) Collision // associate object roots in a collision pair pColPair = ColPairManager.Add(ColPair.Name.Missile_Wall, pMissileRoot, pWallRoot); //attach all observers that will react to collision pColPair.Attach(new ShipReadyObserver()); pColPair.Attach(new ShipRemoveMissileObserver()); //-------------------- // Missile vs Shield collision // associate object roots in a collision pair pColPair = ColPairManager.Add(ColPair.Name.Misslie_Shield, pMissileRoot, pShieldRoot); //attach all observers that will react to this collision pColPair.Attach(new RemoveMissileObserver()); //pColPair.Attach(new DegradeBrickSpriteObserver()); pColPair.Attach(new RemoveBrickObserver()); pColPair.Attach(new ShipReadyObserver()); //-------------------- //Missile vs AlienGrid collision // associate object roots in a collision pair pColPair = ColPairManager.Add(ColPair.Name.Alien_Missile, pMissileRoot, pGrid); //attach all observers that will react to collision pColPair.Attach(new RemoveMissileObserver()); //todo alien explosion animation isn't working pColPair.Attach(new AnimateAlienExplosionObserver()); pColPair.Attach(new RemoveAlienObserver()); //pColPair.Attach(new AlienDeathSoundObserver()); //pColPair.Attach(new AlienScoreUpdateObserver()); pColPair.Attach(new ShipReadyObserver()); //--------------------------------------------------------------------------------------------- //Bomb CollisionPairs //Bomb vs Wall (Bottom) Collision // associate object roots in a collision pair pColPair = ColPairManager.Add(ColPair.Name.Bomb_Wall, pBombRoot, pWallRoot); //attach all observers that will react to collision //pColPair.Attach(new BombObserver()); pColPair.Attach(new RemoveBombObserver()); //todo broken collision - fix //-------------------- //Bomb vs Shield Collision // associate object roots in a collision pair pColPair = ColPairManager.Add(ColPair.Name.Bomb_Shield, pBombRoot, pShieldRoot); //attach all observers that will react to collision pColPair.Attach(new RemoveBombObserver()); pColPair.Attach(new RemoveBrickObserver()); //todo need to implement collision reaction for bomb v ship ////-------------------- ////Bomb vs Ship Collision //// associate object roots in a collision pair //pColPair = ColPairManager.Add(ColPair.Name.Bomb_Ship, pBombRoot, shipRoot); ////attach all observers that will react to collision //pColPair.Attach(new RemoveBombObserver()); ////pColPair.Attach(new ShipExplosionSoundObserver()); ////pColPair.Attach(new TriggerGameOverStateObserver()); //todo need to implement collision reaction for grid v wall, grid vs shield; //--------------------------------------------------------------------------------------------- //AlienGrid/Column CollisionPairs ////AlienGrid vs Walls //// associate object roots in a collision pair //pColPair = ColPairManager.Add(ColPair.Name.Alien_Wall, pGrid, pWallRoot); ////attach all observers that will react to collision //pColPair.Attach(new AlienGridPivotObserver()); //-------------------- //AlienColumn vs Shield Collision //// associate object roots in a collision pair //pColPair = ColPairManager.Add(ColPair.Name.Alien_Shield, pGrid, pShieldRoot); ////attach all observers that will react to collision //pColPair.Attach(new RemoveShieldBrickObserver()); //--------------------------------------------------------------------------------------------- //Ship CollisionPairs Debug.WriteLine("\n\n\n\n\n"); GameObjectManager.DumpAll(); Debug.WriteLine("\n\nLoad Content Complete\n----------------------------------\n"); //----------------------------------------------- //Data Dump; TextureManager.DumpStats(); ImageManager.DumpStats(); GameSpriteManager.DumpStats(); BoxSpriteManager.DumpStats(); SpriteBatchManager.DumpStats(); ProxySpriteManager.DumpStats(); TimerEventManager.DumpStats(); GameObjectManager.DumpStats(); DeathManager.DumpStats(); GhostManager.DumpStats(); ColPairManager.DumpStats(); GlyphManager.DumpStats(); //TextureManager.DumpLists(); //ImageManager.DumpLists(); //GameSpriteManager.DumpLists(); BoxSpriteManager.DumpLists(); //SpriteBatchManager.DumpLists(); //ProxySpriteManager.DumpLists(); //TimerEventManager.DumpLists(); //GameObjectManager.DumpLists(); //DeathManager.DumpLists(); //GhostManager.DumpLists(); //ColPairManager.DumpLists(); //GlyphManager.DumpLists(); //TextureManager.DumpAll(); //ImageManager.DumpAll(); //GameSpriteManager.DumpAll(); //BoxSpriteManager.DumpAll(); //SpriteBatchManager.DumpAll(); //ProxySpriteManager.DumpAll(); //TimerEventManager.DumpAll(); //GameObjectManager.DumpAll(); //DeathManager.DumpAll(); //GhostManager.DumpAll(); //ColPairManager.DumpAll(); //GlyphManager.DumpAll(); }
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(); } }
private ShieldRoot GenerateShield(PCSTree pRootTree, float startX, float startY, int idx) { ShieldRoot pShieldRoot = new ShieldRoot(GameObjectName.ShieldRoot, SpriteBaseName.Null, 0.0f, 0.0f, idx); pRootTree.Insert(pShieldRoot, null); GameObjectManager.AttachTree(pShieldRoot); ShieldFactory shieldFactory = new ShieldFactory(SpriteBatchName.Shields, SpriteBatchName.Boxes, pRootTree); shieldFactory.SetParent(pShieldRoot); ShieldCategory pShieldGrid = shieldFactory.Create(ShieldType.Grid, GameObjectName.ShieldGrid); int j = 0; ShieldCategory pCol; shieldFactory.SetParent(pShieldGrid); pCol = shieldFactory.Create(ShieldType.Column, GameObjectName.ShieldColumn, j++); shieldFactory.SetParent(pCol); int i = 0; float start_x = startX; float start_y = startY; float off_x = 0; float brickWidth = 15.0f; float brickHeight = 10.0f; for (int x = 0; x < 8; x++) { shieldFactory.Create(ShieldType.Brick, GameObjectName.ShieldBrick, start_x, start_y + x * brickHeight, i++); } shieldFactory.Create(ShieldType.LeftTop1, GameObjectName.ShieldBrick, start_x, start_y + 8 * brickHeight, i++); shieldFactory.Create(ShieldType.LeftTop0, GameObjectName.ShieldBrick, start_x, start_y + 9 * brickHeight, i++); shieldFactory.SetParent(pShieldGrid); pCol = shieldFactory.Create(ShieldType.Column, GameObjectName.Column, j++); shieldFactory.SetParent(pCol); off_x += brickWidth; for (int x = 0; x < 10; x++) { shieldFactory.Create(ShieldType.Brick, GameObjectName.ShieldBrick, start_x + off_x, start_y + x * brickHeight, i++); } shieldFactory.SetParent(pShieldGrid); pCol = shieldFactory.Create(ShieldType.Column, GameObjectName.Column, j++); shieldFactory.SetParent(pCol); off_x += brickWidth; shieldFactory.Create(ShieldType.LeftBottom, GameObjectName.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); for (int x = 3; x < 10; x++) { shieldFactory.Create(ShieldType.Brick, GameObjectName.ShieldBrick, start_x + off_x, start_y + x * brickHeight, i++); } shieldFactory.SetParent(pShieldGrid); pCol = shieldFactory.Create(ShieldType.Column, GameObjectName.Column, j++); shieldFactory.SetParent(pCol); off_x += brickWidth; for (int x = 3; x < 10; x++) { shieldFactory.Create(ShieldType.Brick, GameObjectName.ShieldBrick, start_x + off_x, start_y + x * brickHeight, i++); } shieldFactory.SetParent(pShieldGrid); pCol = shieldFactory.Create(ShieldType.Column, GameObjectName.Column, j++); shieldFactory.SetParent(pCol); off_x += brickWidth; shieldFactory.Create(ShieldType.RightBottom, GameObjectName.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight, i++); for (int x = 3; x < 10; x++) { shieldFactory.Create(ShieldType.Brick, GameObjectName.ShieldBrick, start_x + off_x, start_y + x * brickHeight, i++); } shieldFactory.SetParent(pShieldGrid); pCol = shieldFactory.Create(ShieldType.Column, GameObjectName.Column, j++); shieldFactory.SetParent(pCol); off_x += brickWidth; for (int x = 0; x < 10; x++) { shieldFactory.Create(ShieldType.Brick, GameObjectName.ShieldBrick, start_x + off_x, start_y + x * brickHeight, i++); } shieldFactory.SetParent(pShieldGrid); pCol = shieldFactory.Create(ShieldType.Column, GameObjectName.Column, j++); shieldFactory.SetParent(pCol); off_x += brickWidth; for (int x = 0; x < 8; x++) { shieldFactory.Create(ShieldType.Brick, GameObjectName.ShieldBrick, start_x + off_x, start_y + x * brickHeight, i++); } shieldFactory.Create(ShieldType.RightTop1, GameObjectName.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); shieldFactory.Create(ShieldType.RightTop0, GameObjectName.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); return(pShieldRoot); }
public override void Initialize() { this.poGameObjectManager = new GameObjectManager(3, 1); GameObjectManager.SetActive(this.poGameObjectManager); this.poTimerManager = new TimerManager(3, 1); TimerManager.SetActive(this.poTimerManager); this.poCollisionPairManager = new CollisionPairManager(3, 1); CollisionPairManager.SetActive(this.poCollisionPairManager); //--------------------------------------------------------------------------------------------------------- // Create SpriteBatch //--------------------------------------------------------------------------------------------------------- this.poSpriteBatchManager = new SpriteBatchManager(3, 1); SpriteBatchManager.SetActive(this.poSpriteBatchManager); SpriteBatch pAliensBatch = SpriteBatchManager.Add(SpriteBatch.Name.Aliens, 1); SpriteBatch pBoxBatch = SpriteBatchManager.Add(SpriteBatch.Name.Boxes, 2); SpriteBatch pShieldsBatch = SpriteBatchManager.Add(SpriteBatch.Name.Shields, 3); SpriteBatch pNullBatch = SpriteBatchManager.Add(SpriteBatch.Name.NullObjects, 4); SpriteBatch pTexts = SpriteBatchManager.Add(SpriteBatch.Name.Texts, 5); pBoxBatch.SetDrawBool(false); //--------------------------------------------------------------------------------------------------------- // Input //--------------------------------------------------------------------------------------------------------- this.poInputManager = new InputManager(); InputManager.SetActive(this.poInputManager); InputSubject pInputSubject; pInputSubject = InputManager.GetArrowRightSubject(); pInputSubject.Attach(new MoveRightObserver()); pInputSubject = InputManager.GetArrowLeftSubject(); pInputSubject.Attach(new MoveLeftObserver()); pInputSubject = InputManager.GetSpaceSubject(); pInputSubject.Attach(new ShootObserver()); pInputSubject.Attach(new ShootSoundObserver()); pInputSubject = InputManager.GetCKeySubject(); pInputSubject.Attach(new ToggleCollisionBoxObserver()); Simulation.SetState(Simulation.State.Realtime); //--------------------------------------------------------------------------------------------------------- // Create Texts //--------------------------------------------------------------------------------------------------------- this.poFontManager = new FontManager(3, 1); FontManager.SetActive(this.poFontManager); FontManager.Add(Font.Name.Header, SpriteBatch.Name.Texts, "SCORE<1> HI-SCORE SCORE<2>", 20f, SpaceInvaders.ScreenHeight - 20f, 15f, 25f); FontManager.Add(Font.Name.Player1Score, SpriteBatch.Name.Texts, "0000", 65f, SpaceInvaders.ScreenHeight - 70f, 15f, 25f); FontManager.Add(Font.Name.Player2Score, SpriteBatch.Name.Texts, "0000", SpaceInvaders.ScreenWidth - 156f, SpaceInvaders.ScreenHeight - 70f, 15f, 25f); FontManager.Add(Font.Name.HiScore, SpriteBatch.Name.Texts, "0000", 380f, SpaceInvaders.ScreenHeight - 70f, 15f, 25f); FontManager.Add(Font.Name.Lives, SpriteBatch.Name.Texts, "3", 40f, 40f, 15f, 25f); //--------------------------------------------------------------------------------------------------------- // Create Walls //--------------------------------------------------------------------------------------------------------- // Wall Root WallGroup pWallGroup = new WallGroup(GameObject.Name.WallGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pWallGroup.ActivateGameSprite(pAliensBatch);//even need this? pWallGroup.ActivateCollisionSprite(pBoxBatch); WallRight pWallRight = new WallRight(GameObject.Name.WallRight, GameSprite.Name.NullObject, SpaceInvaders.ScreenWidth - 15, SpaceInvaders.ScreenHeight / 2, 20, SpaceInvaders.ScreenHeight - 110); pWallRight.ActivateCollisionSprite(pBoxBatch); WallLeft pWallLeft = new WallLeft(GameObject.Name.WallLeft, GameSprite.Name.NullObject, 20, SpaceInvaders.ScreenHeight / 2, 20, SpaceInvaders.ScreenHeight - 110); pWallLeft.ActivateCollisionSprite(pBoxBatch); WallTop pWallTop = new WallTop(GameObject.Name.WallTop, GameSprite.Name.NullObject, 450, SpaceInvaders.ScreenHeight - 70, SpaceInvaders.ScreenWidth - 10, 30); pWallTop.ActivateCollisionSprite(pBoxBatch); WallBottom pWallBottom = new WallBottom(GameObject.Name.WallBottom, GameSprite.Name.Ground, 450, 60, SpaceInvaders.ScreenWidth - 10, 5); pWallBottom.ActivateGameSprite(pAliensBatch); pWallBottom.ActivateCollisionSprite(pBoxBatch); // Add to the composite the children pWallGroup.Add(pWallRight); pWallGroup.Add(pWallLeft); pWallGroup.Add(pWallTop); pWallGroup.Add(pWallBottom); GameObjectManager.Attach(pWallGroup); //--------------------------------------------------------------------------------------------------------- // Create Bomb Root //--------------------------------------------------------------------------------------------------------- BombRoot pBombRoot = new BombRoot(GameObject.Name.BombRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); pBombRoot.ActivateGameSprite(pAliensBatch);//change? even need this? pBombRoot.ActivateCollisionSprite(pBoxBatch); GameObjectManager.Attach(pBombRoot); DropBombEvent pBombEvent = new DropBombEvent(); TimerManager.Add(TimeEvent.Name.DropBomb, pBombEvent, 3.0f); //--------------------------------------------------------------------------------------------------------- // Create Missile Root //--------------------------------------------------------------------------------------------------------- // Missile Root MissileGroup pMissileGroup = new MissileGroup(GameObject.Name.MissileGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pMissileGroup.ActivateGameSprite(pAliensBatch);//change? even need this? pMissileGroup.ActivateCollisionSprite(pBoxBatch); GameObjectManager.Attach(pMissileGroup); //--------------------------------------------------------------------------------------------------------- // Create Ship Root //--------------------------------------------------------------------------------------------------------- ShipRoot pShipRoot = new ShipRoot(GameObject.Name.ShipRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); pShipRoot.ActivateGameSprite(pAliensBatch);//change? even need this? pShipRoot.ActivateCollisionSprite(pBoxBatch); GameObjectManager.Attach(pShipRoot); ShipManager.ActivateShip(); ShipManager.ActivateMissile(); //--------------------------------------------------------------------------------------------------------- // Create UFO and UFO Root //--------------------------------------------------------------------------------------------------------- UFORoot pUFORoot = new UFORoot(GameObject.Name.UFORoot, GameSprite.Name.NullObject, 0.0f, 0.0f); pUFORoot.ActivateGameSprite(pAliensBatch);//change? even need this? pUFORoot.ActivateCollisionSprite(pBoxBatch); GameObjectManager.Attach(pUFORoot); OrangeSaucer pUFO = new OrangeSaucer(GameObject.Name.OrangeSaucer, GameSprite.Name.OrangeSaucer, 20f, SpaceInvaders.ScreenHeight - 110f); pUFO.ActivateGameSprite(pAliensBatch);//change? even need this? pUFO.ActivateCollisionSprite(pBoxBatch); pUFORoot.Add(pUFO); pUFO.Remove(); SpawnUFOEvent pUFOEvent = new SpawnUFOEvent(); TimerManager.Add(TimeEvent.Name.UFOSpawn, pUFOEvent, RandomManager.RandomInt(15, 45)); //--------------------------------------------------------------------------------------------------------- // Create Aliens //--------------------------------------------------------------------------------------------------------- AlienFactory AF = new AlienFactory(SpriteBatch.Name.Aliens, SpriteBatch.Name.Boxes); AlienGrid pAlienGrid = (AlienGrid)AF.Create(GameObject.Name.AlienGrid); for (int i = 0; i < 11; i++) { GameObject pCol = AF.Create(GameObject.Name.AlienColumn); GameObject pGameObject; pGameObject = AF.Create(GameObject.Name.PurpleOctopus, 50.0f + 66 * i, SpaceInvaders.ScreenHeight - 364f); pCol.Add(pGameObject); pGameObject = AF.Create(GameObject.Name.PurpleOctopus, 50.0f + 66 * i, SpaceInvaders.ScreenHeight - 298f); pCol.Add(pGameObject); pGameObject = AF.Create(GameObject.Name.BlueCrab, 50.0f + 66 * i, SpaceInvaders.ScreenHeight - 232f); pCol.Add(pGameObject); pGameObject = AF.Create(GameObject.Name.BlueCrab, 50.0f + 66 * i, SpaceInvaders.ScreenHeight - 166f); pCol.Add(pGameObject); pGameObject = AF.Create(GameObject.Name.GreenSquid, 50.0f + 66 * i, SpaceInvaders.ScreenHeight - 100f); pCol.Add(pGameObject); pAlienGrid.Add(pCol); } GameObjectManager.Attach(pAlienGrid); pAlienGrid.Attach(new MoveAlienSoundObserver()); pAlienGrid.Attach(new MoveAlienGridObserver()); AlienGridMoveEvent pGridMoveEvent = new AlienGridMoveEvent(); TimerManager.Add(TimeEvent.Name.MoveAlienGrid, pGridMoveEvent, pAlienGrid.GetMoveRate()); //--------------------------------------------------------------------------------------------------------- // Timer Animations //--------------------------------------------------------------------------------------------------------- // Create an animation sprite AnimationSprite pAnimOctopus = new AnimationSprite(GameSprite.Name.PurpleOctopus); AnimationSprite pAnimCrab = new AnimationSprite(GameSprite.Name.BlueCrab); AnimationSprite pAnimSquid = new AnimationSprite(GameSprite.Name.GreenSquid); // attach several images to cycle pAnimOctopus.Attach(Image.Name.OctopusA); pAnimOctopus.Attach(Image.Name.OctopusB); pAnimCrab.Attach(Image.Name.AlienA); pAnimCrab.Attach(Image.Name.AlienB); pAnimSquid.Attach(Image.Name.SquidA); pAnimSquid.Attach(Image.Name.SquidB); // add AnimationSprite to timer TimerManager.Add(TimeEvent.Name.SpriteAnimation, pAnimOctopus, pAlienGrid.GetMoveRate()); TimerManager.Add(TimeEvent.Name.SpriteAnimation, pAnimCrab, pAlienGrid.GetMoveRate()); TimerManager.Add(TimeEvent.Name.SpriteAnimation, pAnimSquid, pAlienGrid.GetMoveRate()); //--------------------------------------------------------------------------------------------------------- // Shield //--------------------------------------------------------------------------------------------------------- // Create the factory Composite pShieldRoot = (Composite) new ShieldRoot(GameObject.Name.ShieldRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); GameObjectManager.Attach(pShieldRoot); ShieldFactory SF = new ShieldFactory(SpriteBatch.Name.Shields, SpriteBatch.Name.Boxes, pShieldRoot); float start_x = 160.0f; float start_y = 200.0f; float off_x; float brickWidth = 12.0f; float brickHeight = 7.0f; GameObject pShieldGrid; GameObject pShieldCol; for (int i = 0; i < 4; i++) { off_x = 0; SF.SetParent(pShieldRoot); pShieldGrid = SF.Create(GameObject.Name.ShieldGrid); //------Col1 SF.SetParent(pShieldGrid); pShieldCol = SF.Create(GameObject.Name.ShieldColumn); SF.SetParent(pShieldCol); SF.Create(GameObject.Name.ShieldBrick, start_x, start_y); SF.Create(GameObject.Name.ShieldBrick, start_x, start_y + brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x, start_y + 2 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x, start_y + 3 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x, start_y + 4 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x, start_y + 5 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x, start_y + 6 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x, start_y + 7 * brickHeight); SF.Create(GameObject.Name.ShieldBrick_LeftTop1, start_x, start_y + 8 * brickHeight); SF.Create(GameObject.Name.ShieldBrick_LeftTop0, start_x, start_y + 9 * brickHeight); //-------Col2 SF.SetParent(pShieldGrid); pShieldCol = SF.Create(GameObject.Name.ShieldColumn); SF.SetParent(pShieldCol); off_x += brickWidth; SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); //-------Col3 SF.SetParent(pShieldGrid); pShieldCol = SF.Create(GameObject.Name.ShieldColumn); SF.SetParent(pShieldCol); off_x += brickWidth; SF.Create(GameObject.Name.ShieldBrick_LeftBottom, start_x + off_x, start_y + 2 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); //-------Col4 SF.SetParent(pShieldGrid); pShieldCol = SF.Create(GameObject.Name.ShieldColumn); SF.SetParent(pShieldCol); off_x += brickWidth; SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); //-------Col5 SF.SetParent(pShieldGrid); pShieldCol = SF.Create(GameObject.Name.ShieldColumn); SF.SetParent(pShieldCol); off_x += brickWidth; SF.Create(GameObject.Name.ShieldBrick_RightBottom, start_x + off_x, start_y + 2 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); //-------Col6 SF.SetParent(pShieldGrid); pShieldCol = SF.Create(GameObject.Name.ShieldColumn); SF.SetParent(pShieldCol); off_x += brickWidth; SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 0 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 1 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); //-------Col7 SF.SetParent(pShieldGrid); pShieldCol = SF.Create(GameObject.Name.ShieldColumn); SF.SetParent(pShieldCol); off_x += brickWidth; SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 0 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 1 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(GameObject.Name.ShieldBrick_RightTop1, start_x + off_x, start_y + 8 * brickHeight); SF.Create(GameObject.Name.ShieldBrick_RightTop0, start_x + off_x, start_y + 9 * brickHeight); start_x += 170; } //--------------------------------------------------------------------------------------------------------- // Create Null Ship Lives //--------------------------------------------------------------------------------------------------------- ScenePlay.ShipLives = 3; PlayerLivesComposite pNullObjs = new PlayerLivesComposite(); Ship pNullShip1 = new Ship(GameObject.Name.Null_Object, GameSprite.Name.Ship, 120.0f, 40.0f); pNullShip1.ActivateGameSprite(pNullBatch); pNullObjs.Add(pNullShip1); Ship pNullShip2 = new Ship(GameObject.Name.Null_Object, GameSprite.Name.Ship, 180.0f, 40.0f); pNullShip2.ActivateGameSprite(pNullBatch); pNullObjs.Add(pNullShip2); GameObjectManager.Attach(pNullObjs); //--------------------------------------------------------------------------------------------------------- // Create CollisionPairs //--------------------------------------------------------------------------------------------------------- //Why does the order that left/right wall are added matter??????? reverse order breaks game CollisionPair pShipWallRightPair = CollisionPairManager.Add(CollisionPair.Name.Ship_Wall_Right, pShipRoot, pWallRight); Debug.Assert(pShipWallRightPair != null); CollisionPair pShipWallLeftPair = CollisionPairManager.Add(CollisionPair.Name.Ship_Wall_Left, pShipRoot, pWallLeft); Debug.Assert(pShipWallLeftPair != null); CollisionPair pAlienMissilePair = CollisionPairManager.Add(CollisionPair.Name.Alien_Missile, pMissileGroup, pAlienGrid); Debug.Assert(pAlienMissilePair != null); CollisionPair pMissileWallPair = CollisionPairManager.Add(CollisionPair.Name.Missile_Wall_Top, pMissileGroup, pWallTop); Debug.Assert(pMissileWallPair != null); CollisionPair pAlienWallPair = CollisionPairManager.Add(CollisionPair.Name.Alien_Wall, pAlienGrid, pWallGroup); Debug.Assert(pAlienWallPair != null); CollisionPair pAlienWallBottomPair = CollisionPairManager.Add(CollisionPair.Name.Alien_WallBottom, pAlienGrid, pWallBottom); Debug.Assert(pAlienWallBottomPair != null); CollisionPair pBombWallPair = CollisionPairManager.Add(CollisionPair.Name.Bomb_Wall_Bottom, pBombRoot, pWallBottom); Debug.Assert(pBombWallPair != null); CollisionPair pBombShieldPair = CollisionPairManager.Add(CollisionPair.Name.Bomb_Shield, pBombRoot, pShieldRoot); Debug.Assert(pBombShieldPair != null); CollisionPair pMissileShieldPair = CollisionPairManager.Add(CollisionPair.Name.Missile_Shield, pMissileGroup, pShieldRoot); Debug.Assert(pMissileShieldPair != null); CollisionPair pBombShipPair = CollisionPairManager.Add(CollisionPair.Name.Bomb_Ship, pBombRoot, ShipManager.GetShip()); Debug.Assert(pBombShipPair != null); CollisionPair pBombMissilePair = CollisionPairManager.Add(CollisionPair.Name.Bomb_Missile, pBombRoot, ShipManager.GetMissile()); Debug.Assert(pBombMissilePair != null); CollisionPair pAlienShieldPair = CollisionPairManager.Add(CollisionPair.Name.Alien_Shield, pShieldRoot, pAlienGrid); Debug.Assert(pAlienShieldPair != null); CollisionPair pUFOMissilePair = CollisionPairManager.Add(CollisionPair.Name.UFO_Missile, pMissileGroup, pUFORoot); Debug.Assert(pUFOMissilePair != null); //TODO consolidate these news pShipWallLeftPair.Attach(new ShipStopLeftObserver()); pShipWallRightPair.Attach(new ShipStopRightObserver()); pMissileWallPair.Attach(new ShipRemoveMissileObserver()); pAlienMissilePair.Attach(new ShipRemoveMissileObserver()); pAlienMissilePair.Attach(new RemoveAlienObserver()); pAlienMissilePair.Attach(new DeadAlienSoundObserver()); pAlienMissilePair.Attach(new AddP1PointsObserver()); pAlienMissilePair.Attach(new IncreaseAlienSpeedObserver()); pAlienWallPair.Attach(new GridObserver()); pBombWallPair.Attach(new RemoveBombObserver()); pBombShieldPair.Attach(new RemoveBombObserver()); pBombShieldPair.Attach(new RemoveBrickObserver()); pMissileShieldPair.Attach(new ShipRemoveMissileObserver()); pMissileShieldPair.Attach(new RemoveBrickObserver()); pBombShipPair.Attach(new RemoveBombObserver()); pBombShipPair.Attach(new RemoveShipObserver()); pBombShipPair.Attach(new DeadShipSoundObserver()); pBombShipPair.Attach(new RemoveLifeObserver()); pBombShipPair.Attach(new ChangeStateObserver()); pBombMissilePair.Attach(new RemoveBombObserver()); pBombMissilePair.Attach(new ShipRemoveMissileObserverAltPair()); pAlienShieldPair.Attach(new RemoveBrickObserver()); pUFOMissilePair.Attach(new RemoveUFOObserver()); pUFOMissilePair.Attach(new ShipRemoveMissileObserver()); pUFOMissilePair.Attach(new AddP1PointsObserver()); pUFOMissilePair.Attach(new DeadUFOSoundObserver()); pAlienWallBottomPair.Attach(new DeadShipSoundObserver()); pAlienWallBottomPair.Attach(new RemoveAllP1LivesObserver()); }
//----------------------------------------------------------------------------- // Game::LoadContent() // Allows you to load all content needed for your engine, // such as objects, graphics, etc. //----------------------------------------------------------------------------- public override void LoadContent() { // Set to current state for initialization GameStateManager.GetGame().SetGameState(GameStateManager.GameState.Player1); //--------------------------------------------------------------------------------------------------------- // Initialize State-Scoped Managers //--------------------------------------------------------------------------------------------------------- this.pSpriteBatchManager = new SpriteBatchManager(3, 1); this.pGameObjectManager = new GameObjectManager(300, 10); this.pDelayedObjectManager = new DelayedObjectManager(); this.pQueuedTimeEventManager = new QueuedTimeEventManager(50, 5); this.pGhostManager = new GhostManager(50, 5); this.pCompositeManager = new CompositeManager(20, 2); //--------------------------------------------------------------------------------------------------------- // Create Colors //--------------------------------------------------------------------------------------------------------- pGreenColor = new Azul.Color(0.1137f, 0.8196f, 0.2667f, 1.0f); //--------------------------------------------------------------------------------------------------------- // Create SpriteBatches //--------------------------------------------------------------------------------------------------------- pCollisionBox_SpriteBatch = this.pSpriteBatchManager.Add(SpriteBatch.Name.CollisionBox); pCollisionBox_SpriteBatch.SetDraw(false); pWall_SpriteBatch = this.pSpriteBatchManager.Add(SpriteBatch.Name.Wall); pAlien_SpriteBatch = this.pSpriteBatchManager.Add(SpriteBatch.Name.Alien); pCoreCannon_SpriteBatch = this.pSpriteBatchManager.Add(SpriteBatch.Name.CoreCannon); pMissile_SpriteBatch = this.pSpriteBatchManager.Add(SpriteBatch.Name.Missile); pBomb_SpriteBatch = this.pSpriteBatchManager.Add(SpriteBatch.Name.Bomb); pShield_SpriteBatch = this.pSpriteBatchManager.Add(SpriteBatch.Name.Shield); pFlyingSaucer_SpriteBatch = this.pSpriteBatchManager.Add(SpriteBatch.Name.FlyingSaucer); pTexts_SpriteBatch = this.pSpriteBatchManager.Add(SpriteBatch.Name.Player1Texts); //--------------------------------------------------------------------------------------------------------- // Flying Saucer //--------------------------------------------------------------------------------------------------------- FlyingSaucerRoot pFlyingSaucerRoot = new FlyingSaucerRoot(Composite.CompositeName.FlyingSaucerRoot, 0.0f, 0.0f); pFlyingSaucerRoot.ActivateSprite(pFlyingSaucer_SpriteBatch); pFlyingSaucerRoot.ActivateCollisionSprite(pCollisionBox_SpriteBatch); this.pGameObjectManager.Attach(pFlyingSaucerRoot); this.pCompositeManager.Attach(pFlyingSaucerRoot); DeployFlyingSaucerCommand pDeployFlyingSaucer = new DeployFlyingSaucerCommand(); this.pQueuedTimeEventManager.Enqueue(TimeEvent.Name.DeployFlyingSaucer, pDeployFlyingSaucer, r.Next(30, 46)); //--------------------------------------------------------------------------------------------------------- // Core Cannon //--------------------------------------------------------------------------------------------------------- CoreCannonGroup pCoreCannonGroup = new CoreCannonGroup(Composite.CompositeName.CoreCannonGroup, 0.0f, 0.0f); this.pGameObjectManager.Attach(pCoreCannonGroup); this.pCompositeManager.Attach(pCoreCannonGroup); this.pCoreCannonManager = new CoreCannonManager(); this.pCoreCannonManager.ActivateCoreCannon(); //--------------------------------------------------------------------------------------------------------- // Sprite Animations //--------------------------------------------------------------------------------------------------------- // Squid Alien this.pQueuedTimeEventManager.Enqueue(TimeEvent.Name.SpriteAnimation, SpriteAnimationManager.Find(SpriteAnimation.Name.SquidAlien), 0.8f); // Crab Alien this.pQueuedTimeEventManager.Enqueue(TimeEvent.Name.SpriteAnimation, SpriteAnimationManager.Find(SpriteAnimation.Name.CrabAlien), 0.8f); // JellyFish Alien this.pQueuedTimeEventManager.Enqueue(TimeEvent.Name.SpriteAnimation, SpriteAnimationManager.Find(SpriteAnimation.Name.JellyfishAlien), 0.8f); //--------------------------------------------------------------------------------------------------------- // Bomb //--------------------------------------------------------------------------------------------------------- BombRoot pBombRoot = new BombRoot(Composite.CompositeName.BombRoot, 0.0f, 0.0f); pBombRoot.ActivateSprite(pBomb_SpriteBatch); //pBombRoot.ActivateCollisionSprite(pCollisionBox_SpriteBatch); this.pCompositeManager.Attach(pBombRoot); this.pGameObjectManager.Attach(pBombRoot); // Add initial drop bomb events this.pQueuedTimeEventManager.Enqueue(TimeEvent.Name.DropBomb, new DropBombCommand(), 1.0f); this.pQueuedTimeEventManager.Enqueue(TimeEvent.Name.DropBomb, new DropBombCommand(), 3.0f); //--------------------------------------------------------------------------------------------------------- // Missile //--------------------------------------------------------------------------------------------------------- MissileGroup pMissileGroup = new MissileGroup(Composite.CompositeName.MissileGroup, 0.0f, 0.0f); pMissileGroup.ActivateSprite(pMissile_SpriteBatch); pMissileGroup.ActivateCollisionSprite(pCollisionBox_SpriteBatch); this.pGameObjectManager.Attach(pMissileGroup); this.pCompositeManager.Attach(pMissileGroup); //--------------------------------------------------------------------------------------------------------- // Create Walls //--------------------------------------------------------------------------------------------------------- // Wall Root pWallGroup = new WallGroup(GameObject.Name.ShieldGroup, Sprite.Name.NullSprite, 0.0f, 0.0f); pWallGroup.ActivateSprite(pWall_SpriteBatch); pWallGroup.ActivateCollisionSprite(pCollisionBox_SpriteBatch); LeftWall pLeftWall = new LeftWall(GameObject.Name.LeftWall, Sprite.Name.NullSprite, 20, 425, 15, 800); pLeftWall.ActivateSprite(pWall_SpriteBatch); pLeftWall.ActivateCollisionSprite(pCollisionBox_SpriteBatch); RightWall pRightWall = new RightWall(GameObject.Name.RightWall, Sprite.Name.NullSprite, 875, 425, 15, 800); pRightWall.ActivateSprite(pWall_SpriteBatch); pRightWall.ActivateCollisionSprite(pCollisionBox_SpriteBatch); TopWall pTopWall = new TopWall(GameObject.Name.TopWall, Sprite.Name.NullSprite, 450, 825, 870, 15); pTopWall.ActivateSprite(pWall_SpriteBatch); pTopWall.ActivateCollisionSprite(pCollisionBox_SpriteBatch); BottomWall pBottomWall = new BottomWall(GameObject.Name.BottomWall, Sprite.Name.NullSprite, 450, 55, 870, 15); pBottomWall.ActivateSprite(pWall_SpriteBatch); pBottomWall.ActivateCollisionSprite(pCollisionBox_SpriteBatch); LeftBumper pLeftBumper = new LeftBumper(GameObject.Name.LeftBumper, Sprite.Name.NullSprite, 45, 100, 30, 50); pLeftBumper.ActivateSprite(pWall_SpriteBatch); pLeftBumper.ActivateCollisionSprite(pCollisionBox_SpriteBatch); RightBumper pRightBumper = new RightBumper(GameObject.Name.RightBumper, Sprite.Name.NullSprite, 850, 100, 30, 50); pRightBumper.ActivateSprite(pWall_SpriteBatch); pRightBumper.ActivateCollisionSprite(pCollisionBox_SpriteBatch); pWallGroup.Add(pLeftWall); pWallGroup.Add(pRightWall); pWallGroup.Add(pTopWall); pWallGroup.Add(pBottomWall); pWallGroup.Add(pLeftBumper); pWallGroup.Add(pRightBumper); this.pCompositeManager.Attach(pWallGroup); this.pGameObjectManager.Attach(pWallGroup); this.pGameObjectManager.Attach(pLeftWall); this.pGameObjectManager.Attach(pRightWall); this.pGameObjectManager.Attach(pTopWall); this.pGameObjectManager.Attach(pBottomWall); this.pGameObjectManager.Attach(pLeftBumper); this.pGameObjectManager.Attach(pRightBumper); //--------------------------------------------------------------------------------------------------------- // Shield //--------------------------------------------------------------------------------------------------------- //Shield Root ShieldGroup pShieldGroup = new ShieldGroup(Composite.CompositeName.ShieldGroup, 0.0f, 0.0f); pShieldGroup.ActivateSprite(pShield_SpriteBatch); pShieldGroup.ActivateCollisionSprite(pCollisionBox_SpriteBatch); GameObject pShield; pShield = ShieldFactory.CreateShield(110, 150); pShieldGroup.Add(pShield); pShield = ShieldFactory.CreateShield(310, 150); pShieldGroup.Add(pShield); pShield = ShieldFactory.CreateShield(510, 150); pShieldGroup.Add(pShield); pShield = ShieldFactory.CreateShield(710, 150); pShieldGroup.Add(pShield); this.pGameObjectManager.Attach(pShieldGroup); this.pCompositeManager.Attach(pShieldGroup); //--------------------------------------------------------------------------------------------------------- // Create Alien Grid Composite //--------------------------------------------------------------------------------------------------------- this.levelInitialAlienGridSpeed = SpaceInvadersGameState.gameInitialAlienGridSpeed; this.currAlienGridSpeed = SpaceInvadersGameState.gameInitialAlienGridSpeed; this.currLevelInitialAlienGridY = SpaceInvadersGameState.gameInitialAlienGridY; pAlienGrid = (Composite)AlienFactory.CreateAlienGrid(SpaceInvadersGameState.gameInitialAlienGridX, currLevelInitialAlienGridY); // Add Initial AlienGridMovementSound Event AlienGridMovementSound pAlienGridMovementSound = new AlienGridMovementSound(); this.pQueuedTimeEventManager.Enqueue(TimeEvent.Name.AlienGridMovementSound, pAlienGridMovementSound, levelInitialAlienGridSpeed); //--------------------------------------------------------------------------------------------------------- // Associate Collision Pairs //--------------------------------------------------------------------------------------------------------- // Alien vs Missile CollisionPair pAlienMissileColPair = CollisionPairManager.Add(CollisionPair.Name.Alien_Missile, pAlienGrid, pMissileGroup); Debug.Assert(pAlienMissileColPair != null); pAlienMissileColPair.Attach(new ShipReadyObserver()); pAlienMissileColPair.Attach(new RemoveMissileObserver()); pAlienMissileColPair.Attach(new RemoveAlienObserver()); pAlienMissileColPair.Attach(new AddPlayerPointsObserver(Player.Name.Player1)); pAlienMissileColPair.Attach(new InvaderKilledSoundObserver()); // FlyingSaucer vs Missile CollisionPair pFlyingSaucerMissileColPair = CollisionPairManager.Add(CollisionPair.Name.FlyingSaucer_Missile, pFlyingSaucerRoot, pMissileGroup); Debug.Assert(pFlyingSaucerMissileColPair != null); pFlyingSaucerMissileColPair.Attach(new ShipReadyObserver()); pFlyingSaucerMissileColPair.Attach(new RemoveMissileObserver()); pFlyingSaucerMissileColPair.Attach(new RemoveFlyingSaucerObserver()); pFlyingSaucerMissileColPair.Attach(new ExplosionSoundObserver()); // FlyingSaucer vs Wall CollisionPair pFlyingSaucerWallColPair = CollisionPairManager.Add(CollisionPair.Name.FlyingSaucer_Wall, pFlyingSaucerRoot, pWallGroup); Debug.Assert(pFlyingSaucerWallColPair != null); pFlyingSaucerWallColPair.Attach(new RemoveFlyingSaucerObserver()); // Alien vs Wall CollisionPair pAlienWallColPair = CollisionPairManager.Add(CollisionPair.Name.Alien_Wall, pAlienGrid, pWallGroup); Debug.Assert(pAlienWallColPair != null); pAlienWallColPair.Attach(new GridWallCollisionObserver()); // Alien vs Shield CollisionPair pAlienShieldColPair = CollisionPairManager.Add(CollisionPair.Name.Alien_Shield, pAlienGrid, pShieldGroup); Debug.Assert(pAlienShieldColPair != null); pAlienShieldColPair.Attach(new RemoveShieldBrickObserver()); // Missile vs Wall CollisionPair pMissileWallColPair = CollisionPairManager.Add(CollisionPair.Name.Missile_Wall, pMissileGroup, pWallGroup); Debug.Assert(pMissileWallColPair != null); pMissileWallColPair.Attach(new ShipReadyObserver()); pMissileWallColPair.Attach(new RemoveMissileObserver()); // Missile vs Shield CollisionPair pMissileShieldColPair = CollisionPairManager.Add(CollisionPair.Name.Missile_Shield, pMissileGroup, pShieldGroup); Debug.Assert(pMissileShieldColPair != null); pMissileShieldColPair.Attach(new ShipReadyObserver()); pMissileShieldColPair.Attach(new RemoveMissileObserver()); pMissileShieldColPair.Attach(new RemoveShieldBrickObserver()); // Bomb vs Shield CollisionPair pBombShieldColPair = CollisionPairManager.Add(CollisionPair.Name.Bomb_Shield, pBombRoot, pShieldGroup); Debug.Assert(pBombShieldColPair != null); pBombShieldColPair.Attach(new RemoveBombObserver()); pBombShieldColPair.Attach(new RemoveShieldBrickObserver()); // Bomb vs Wall CollisionPair pBombWallColPair = CollisionPairManager.Add(CollisionPair.Name.Bomb_Wall, pBombRoot, pWallGroup); Debug.Assert(pBombWallColPair != null); pBombWallColPair.Attach(new RemoveBombObserver()); // CoreCannon vs Bumpers CollisionPair pCoreCannonWallColPair = CollisionPairManager.Add(CollisionPair.Name.CoreCannon_Wall, pCoreCannonGroup, pWallGroup); Debug.Assert(pCoreCannonWallColPair != null); pCoreCannonWallColPair.Attach(new CoreCannonBumperCollisionObserver()); // Bomb vs Missile CollisionPair pBombMissileColPair = CollisionPairManager.Add(CollisionPair.Name.Bomb_Missile, pBombRoot, pMissileGroup); Debug.Assert(pBombMissileColPair != null); pBombMissileColPair.Attach(new ShipReadyObserver()); pBombMissileColPair.Attach(new RemoveBombObserver()); pBombMissileColPair.Attach(new RemoveMissileObserver()); // Bomb vs CoreCannon CollisionPair pBombShipColPair = CollisionPairManager.Add(CollisionPair.Name.Bomb_Ship, pBombRoot, pCoreCannonGroup); Debug.Assert(pBombShipColPair != null); pBombShipColPair.Attach(new PlayerDeathObserver(Player.Name.Player1)); pBombShipColPair.Attach(new RemoveBombObserver()); pBombShipColPair.Attach(new ExplosionSoundObserver()); //--------------------------------------------------------------------------------------------------------- // Fonts //--------------------------------------------------------------------------------------------------------- FontManager.Add(Font.Name.Player1Lives, pTexts_SpriteBatch, "LIVES " + GameStateManager.GetGame().GetPlayer(Player.Name.Player1).GetNumLives().ToString(), Glyph.Name.Consolas36pt, 50, 50); }
public override void LoadContent() { // ----------------------------------------------------------------------------- // ---------------------- Sound Setup ------------------------------------------ // ----------------------------------------------------------------------------- SoundManager.Add(Sound.Name.Fastinvader1, "fastinvader1.wav"); SoundManager.Add(Sound.Name.Fastinvader2, "fastinvader2.wav"); SoundManager.Add(Sound.Name.Fastinvader3, "fastinvader3.wav"); SoundManager.Add(Sound.Name.Fastinvader4, "fastinvader4.wav"); SoundManager.Add(Sound.Name.Shoot, "shoot.wav"); SoundManager.Add(Sound.Name.Explosion, "explosion.wav"); SoundManager.Add(Sound.Name.InvaderKilled, "invaderkilled.wav"); SoundManager.Add(Sound.Name.UFO_HighPitch, "ufo_highpitch.wav"); SoundManager.Add(Sound.Name.UFO_LowPitch, "ufo_lowpitch.wav"); // ----------------------------------------------------------------------------- // ------------------- Load the Textures --------------------------------------- // ----------------------------------------------------------------------------- TextureManager.Add(Texture.Name.SpaceInvaders, "SpaceInvaders.tga"); TextureManager.Add(Texture.Name.Invaders, "birds_N_shield.tga"); Texture pTexture = TextureManager.Add(Texture.Name.Consolas36pt, "Consolas36pt.tga"); GlyphManager.AddXml(Glyph.Name.Consolas36pt, "Consolas36pt.xml", Texture.Name.Consolas36pt); // ----------------------------------------------------------------------------- // -------------------- Creating Images ---------------------------------------- // ----------------------------------------------------------------------------- ImageManager.Add(Image.Name.OctopusA, Texture.Name.SpaceInvaders, 3, 3, 12, 8); ImageManager.Add(Image.Name.OctopusB, Texture.Name.SpaceInvaders, 18, 3, 12, 8); ImageManager.Add(Image.Name.AlienA, Texture.Name.SpaceInvaders, 33, 3, 11, 8); ImageManager.Add(Image.Name.AlienB, Texture.Name.SpaceInvaders, 47, 3, 11, 8); ImageManager.Add(Image.Name.SquidA, Texture.Name.SpaceInvaders, 61, 3, 8, 8); ImageManager.Add(Image.Name.SquidB, Texture.Name.SpaceInvaders, 72, 3, 8, 8); ImageManager.Add(Image.Name.AlienExplosion, Texture.Name.SpaceInvaders, 83, 3, 13, 8); ImageManager.Add(Image.Name.Saucer, Texture.Name.SpaceInvaders, 99, 3, 16, 8); ImageManager.Add(Image.Name.SaucerExplosion, Texture.Name.SpaceInvaders, 118, 3, 21, 8); ImageManager.Add(Image.Name.Ship, Texture.Name.SpaceInvaders, 3, 14, 13, 8); ImageManager.Add(Image.Name.ShipExplosionA, Texture.Name.SpaceInvaders, 19, 14, 16, 8); ImageManager.Add(Image.Name.ShipExplosionB, Texture.Name.SpaceInvaders, 38, 14, 16, 8); ImageManager.Add(Image.Name.Missile, Texture.Name.SpaceInvaders, 3, 29, 1, 4); ImageManager.Add(Image.Name.MissileExplosion, Texture.Name.SpaceInvaders, 7, 25, 8, 8); ImageManager.Add(Image.Name.Wall, Texture.Name.Invaders, 40, 185, 20, 10); ImageManager.Add(Image.Name.BombStraight, Texture.Name.Invaders, 111, 101, 5, 49); ImageManager.Add(Image.Name.BombZigZagA, Texture.Name.SpaceInvaders, 18, 26, 3, 7); ImageManager.Add(Image.Name.BombZigZagB, Texture.Name.SpaceInvaders, 24, 26, 3, 7); ImageManager.Add(Image.Name.BombZigZagC, Texture.Name.SpaceInvaders, 30, 26, 3, 7); ImageManager.Add(Image.Name.BombZigZagD, Texture.Name.SpaceInvaders, 36, 26, 3, 7); ImageManager.Add(Image.Name.BombDaggerA, Texture.Name.SpaceInvaders, 42, 27, 3, 6); ImageManager.Add(Image.Name.BombDaggerB, Texture.Name.SpaceInvaders, 48, 27, 3, 6); ImageManager.Add(Image.Name.BombDaggerC, Texture.Name.SpaceInvaders, 54, 27, 3, 6); ImageManager.Add(Image.Name.BombDaggerD, Texture.Name.SpaceInvaders, 60, 27, 3, 6); ImageManager.Add(Image.Name.BombRollingA, Texture.Name.SpaceInvaders, 65, 26, 3, 7); ImageManager.Add(Image.Name.BombRollingB, Texture.Name.SpaceInvaders, 70, 26, 3, 7); ImageManager.Add(Image.Name.BombRollingC, Texture.Name.SpaceInvaders, 75, 26, 3, 7); ImageManager.Add(Image.Name.BombRollingD, Texture.Name.SpaceInvaders, 80, 26, 3, 7); ImageManager.Add(Image.Name.BombExplosion, Texture.Name.SpaceInvaders, 86, 25, 6, 8); ImageManager.Add(Image.Name.Brick, Texture.Name.Invaders, 20, 210, 10, 5); ImageManager.Add(Image.Name.BrickLeft_Top0, Texture.Name.Invaders, 15, 180, 10, 5); ImageManager.Add(Image.Name.BrickLeft_Top1, Texture.Name.Invaders, 15, 185, 10, 5); ImageManager.Add(Image.Name.BrickLeft_Bottom, Texture.Name.Invaders, 35, 215, 10, 5); ImageManager.Add(Image.Name.BrickRight_Top0, Texture.Name.Invaders, 75, 180, 10, 5); ImageManager.Add(Image.Name.BrickRight_Top1, Texture.Name.Invaders, 75, 185, 10, 5); ImageManager.Add(Image.Name.BrickRight_Bottom, Texture.Name.Invaders, 55, 215, 10, 5); // ----------------------------------------------------------------------------- // ---------------------- Creating GameSprites --------------------------------- // ----------------------------------------------------------------------------- float dim = 33.0f; float sm = dim; float md = dim * 1.15f; float lg = dim * 1.30f; GameSpriteManager.Add(GameSprite.Name.Squid, Image.Name.SquidA, 200, 400, sm, sm); GameSpriteManager.Add(GameSprite.Name.Alien, Image.Name.AlienA, 200, 200, md, md); GameSpriteManager.Add(GameSprite.Name.Octopus, Image.Name.OctopusA, 200, 300, lg, lg); GameSpriteManager.Add(GameSprite.Name.Saucer, Image.Name.Saucer, 300, 250, 60, 30); GameSpriteManager.Add(GameSprite.Name.SaucerExplosion, Image.Name.SaucerExplosion, 300, 250, 60, 30); GameSpriteManager.Add(GameSprite.Name.AlienExplosion, Image.Name.AlienExplosion, -10, -10, dim, dim); // Utility for ship state movement float projWidth = 8.0f; float projHeight = 16.0f; GameSpriteManager.Add(GameSprite.Name.Missile, Image.Name.Missile, 0, 0, 0.5f * projWidth, 0.75f * projHeight); GameSpriteManager.Add(GameSprite.Name.MissileExplosion, Image.Name.MissileExplosion, 0, 0, 0.7f * dim, 0.7f * dim); GameSpriteManager.Add(GameSprite.Name.Ship, Image.Name.Ship, 400, 100, 60, 21); GameSpriteManager.Add(GameSprite.Name.ShipExplosionA, Image.Name.ShipExplosionA, 400, 100, 90, 31); GameSpriteManager.Add(GameSprite.Name.ShipExplosionB, Image.Name.ShipExplosionB, 400, 100, 90, 31); GameSpriteManager.Add(GameSprite.Name.Wall, Image.Name.Wall, 448, 100, 850, 4); GameSpriteManager.Add(GameSprite.Name.BombStraight, Image.Name.BombStraight, 100, 100, projWidth, projHeight); GameSpriteManager.Add(GameSprite.Name.BombZigZag, Image.Name.BombZigZagA, 200, 200, projWidth, projHeight); GameSpriteManager.Add(GameSprite.Name.BombDagger, Image.Name.BombDaggerA, 100, 100, projWidth, projHeight); GameSpriteManager.Add(GameSprite.Name.BombRolling, Image.Name.BombRollingA, 100, 100, projWidth, projHeight); GameSpriteManager.Add(GameSprite.Name.BombExplosion, Image.Name.BombExplosion, 100, 100, 0.5f * dim, 0.7f * dim); float brick_w = 12.0f; float brick_h = 6.0f; GameSpriteManager.Add(GameSprite.Name.Brick, Image.Name.Brick, 50, 25, brick_w, brick_h); GameSpriteManager.Add(GameSprite.Name.Brick_LeftTop0, Image.Name.BrickLeft_Top0, 50, 25, brick_w, brick_h); GameSpriteManager.Add(GameSprite.Name.Brick_LeftTop1, Image.Name.BrickLeft_Top1, 50, 25, brick_w, brick_h); GameSpriteManager.Add(GameSprite.Name.Brick_LeftBottom, Image.Name.BrickLeft_Bottom, 50, 25, brick_w, brick_h); GameSpriteManager.Add(GameSprite.Name.Brick_RightTop0, Image.Name.BrickRight_Top0, 50, 25, brick_w, brick_h); GameSpriteManager.Add(GameSprite.Name.Brick_RightTop1, Image.Name.BrickRight_Top1, 50, 25, brick_w, brick_h); GameSpriteManager.Add(GameSprite.Name.Brick_RightBottom, Image.Name.BrickRight_Bottom, 50, 25, brick_w, brick_h); // ----------------------------------------------------------------------------- // ---------------------- Create Sprite Node Batches --------------------------- // ----------------------------------------------------------------------------- SpriteNodeBatch pBatch_Texts = SpriteNodeBatchManager.Add(SpriteNodeBatch.Name.Texts, 2); SpriteNodeBatch pBatch_Player = SpriteNodeBatchManager.Add(SpriteNodeBatch.Name.Players, 5); SpriteNodeBatch pBatch_TheSwarm = SpriteNodeBatchManager.Add(SpriteNodeBatch.Name.TheSwarm, 10); SpriteNodeBatch pBatch_Explosions = SpriteNodeBatchManager.Add(SpriteNodeBatch.Name.Explosions, 20); SpriteNodeBatch pBatch_Shields = SpriteNodeBatchManager.Add(SpriteNodeBatch.Name.Shields, 200); SpriteNodeBatch pBatch_Boxes = SpriteNodeBatchManager.Add(SpriteNodeBatch.Name.Boxes, 400); pBatch_Boxes.SetDrawStatus(false); Debug.WriteLine("Finished : Loading Sprite Batches"); // ----------------------------------------------------------------------------- // ---------------------- Instantiate Local GameObject Manager ----------------- // ----------------------------------------------------------------------------- // Moved to CreateManagers() // ----------------------------------------------------------------------------- // ---------------------- Font Setup ------------------------------------------ // ----------------------------------------------------------------------------- Font pFont; int topTextLine = 980; pFont = FontManager.Add(Font.Name.Score1_Title, SpriteNodeBatch.Name.Texts, "SCORE<1>", Glyph.Name.Consolas36pt, 100, topTextLine); pFont = FontManager.Add(Font.Name.HighScore_Title, SpriteNodeBatch.Name.Texts, "HI-SCORE<1>", Glyph.Name.Consolas36pt, 350, topTextLine); pFont = FontManager.Add(Font.Name.Score2_Title, SpriteNodeBatch.Name.Texts, "SCORE<2>", Glyph.Name.Consolas36pt, 650, topTextLine); int scoreTextLine = 940; int x_shift = 40; pFont = FontManager.Add(Font.Name.Score1, SpriteNodeBatch.Name.Texts, "0000", Glyph.Name.Consolas36pt, 100 + x_shift, scoreTextLine); pFont = FontManager.Add(Font.Name.HighScore, SpriteNodeBatch.Name.Texts, "0000", Glyph.Name.Consolas36pt, 350 + x_shift, scoreTextLine); pFont = FontManager.Add(Font.Name.Score2, SpriteNodeBatch.Name.Texts, "0000", Glyph.Name.Consolas36pt, 650 + x_shift, scoreTextLine); FontManager.Add(Font.Name.LifeCount, SpriteNodeBatch.Name.Texts, "3", Glyph.Name.Consolas36pt, 100, 50); // ----------------------------------------------------------------------------- // ---------------------- Create Bomb GameObjects ------------------------------- // ----------------------------------------------------------------------------- BombRoot pBombRoot = new BombRoot(GameObject.Name.BombRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); pBombRoot.ActivateCollisionSprite(pBatch_Boxes); GameObjectManager.Attach(pBombRoot); // ----------------------------------------------------------------------------- // ---------------------- Create Explosion GameObjects ------------------------------- // ----------------------------------------------------------------------------- ExplosionFactory EF = new ExplosionFactory(SpriteNodeBatch.Name.Explosions, SpriteNodeBatch.Name.Boxes); GameObject pExplosionRoot = EF.Build(GameObject.Name.ExplosionRoot, 0.0f, 0.0f); // ----------------------------------------------------------------------------- // ---------------------- Create Grids of Nested GameObjects ------------------- // ----------------------------------------------------------------------------- GameObject pWallGroup; GameObject pSwarmGrid; GameObject pUFOGrid; GameObject pShieldRoot; MissileGroup pMissileGroup = CreateMissleGroup(pBatch_Player, pBatch_Boxes); GameObject pBumperGroup = CreateBumperGroup(pBatch_Player, pBatch_Boxes); pWallGroup = CreateWalls(pBatch_TheSwarm, pBatch_Boxes); Debug.WriteLine("Finished : Creating the walls"); AlienFactory AF = new AlienFactory(SpriteNodeBatch.Name.TheSwarm, SpriteNodeBatch.Name.Boxes); pSwarmGrid = AF.Build(GameObject.Name.AlienGrid); AF.swarmAnimation(pSwarmGrid); Debug.WriteLine("Finished : Creating the Swarm"); pUFOGrid = AF.Build(GameObject.Name.UFOGrid); AF.UFOAnimation(pUFOGrid); Debug.WriteLine("Finished : Creating the UfO Boss"); Debug.WriteLine("Create Animations Gamesprites"); pShieldRoot = new ShieldRoot(GameObject.Name.ShieldRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); ShieldFactory SF = new ShieldFactory(SpriteNodeBatch.Name.Shields, SpriteNodeBatch.Name.Boxes, pShieldRoot); pShieldRoot = SF.Build(GameObject.Name.ShieldRoot); // ----------------------------------------------------------------------------- // ---------------------- Create Ship GameObject ---------------------- // ----------------------------------------------------------------------------- ShipRoot pShipRoot = new ShipRoot(GameObject.Name.ShipRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); GameObjectManager.Attach(pShipRoot); ShipMan.Create(); Debug.WriteLine("Finished : Creating the ShipRoot and Ship"); // ----------------------------------------------------------------------------- // ---------------------- Collision Pairs -------------------------------------- // ----------------------------------------------------------------------------- // Alien vs Missile CollPair pAttackAliens = CollPairManager.Add(CollPair.Name.Alien_Missle, pMissileGroup, pSwarmGrid); Debug.Assert(pAttackAliens != null); pAttackAliens.Attach(new ShipReadyObserver()); pAttackAliens.Attach(new RemoveMissileObserver()); pAttackAliens.Attach(new RemoveAlienObserver()); pAttackAliens.Attach(new SoundObserverKillAlien()); pAttackAliens.Attach(new ExplosionSpriteObserver(GameSprite.Name.AlienExplosion)); // Alien vs Shild CollPair pAlienHitShield = CollPairManager.Add(CollPair.Name.Alien_Shield, pSwarmGrid, pShieldRoot); pAlienHitShield.Attach(new RemoveBrickObserver()); pAlienHitShield.Attach(new SoundObserverExplosion()); // AlienGrid vs Left/Right Wall CollPair pHitWall = CollPairManager.Add(CollPair.Name.Alien_SideWalls, pSwarmGrid, pWallGroup); Debug.Assert(pHitWall != null); pHitWall.Attach(new GridObserver()); //// AlienGrid vs Bottom Wall //CollPair pBottomWall = CollPairManager.Add(CollPair.Name.Alien_BottomWall, pSwarmGrid, pWallGroup); //Debug.Assert(pHitWall != null); //pBottomWall.Attach(new GameOverObserver()); // Bumper vs Ship CollPair pHitBumper = CollPairManager.Add(CollPair.Name.Bumper_Ship, pBumperGroup, pShipRoot); pHitBumper.Attach(new BumperObserver()); // Bomb vs Ship CollPair pHitShip = CollPairManager.Add(CollPair.Name.Bomb_Ship, pBombRoot, pShipRoot); pHitShip.Attach(new RemoveBombObserver()); pHitShip.Attach(new ExplosionSpriteObserver(GameSprite.Name.BombExplosion)); pHitShip.Attach(new SoundObserverExplosion()); pHitShip.Attach(new ShipTakeDamageObserver()); // triggers GAMEOVER pHitShip.Attach(new ExplosionSpriteObserver(GameSprite.Name.ShipExplosionA)); pHitShip.Attach(new ExplosionSpriteObserver(GameSprite.Name.ShipExplosionB, 0.4f)); //pHitShip.Attach(new GameOverObserver()); // Bomb vs Bottom CollPair pHitBottom = CollPairManager.Add(CollPair.Name.Bomb_WallBottom, pBombRoot, pWallGroup); pHitBottom.Attach(new RemoveBombObserver()); pHitBottom.Attach(new ExplosionSpriteObserver(GameSprite.Name.BombExplosion)); // Bomb vs Missile CollPair pBombvsMissile = CollPairManager.Add(CollPair.Name.Bomb_Missile, pBombRoot, pMissileGroup); pBombvsMissile.Attach(new ShipReadyObserver()); pBombvsMissile.Attach(new RemoveBombObserver()); pBombvsMissile.Attach(new RemoveMissileObserver()); pBombvsMissile.Attach(new ExplosionSpriteObserver(GameSprite.Name.BombExplosion)); pBombvsMissile.Attach(new SoundObserverExplosion()); // Bomb vs Shield CollPair pHitBombShield = CollPairManager.Add(CollPair.Name.Bomb_Shield, pBombRoot, pShieldRoot); pHitBombShield.Attach(new RemoveBombObserver()); pHitBombShield.Attach(new RemoveBrickObserver()); pHitBombShield.Attach(new SoundObserverExplosion()); pHitBombShield.Attach(new ExplosionSpriteObserver(GameSprite.Name.BombExplosion)); // Missile vs Top-Wall CollPair pHitTopWall = CollPairManager.Add(CollPair.Name.Missile_WallTop, pMissileGroup, pWallGroup); Debug.Assert(pHitTopWall != null); pHitTopWall.Attach(new ShipReadyObserver()); pHitTopWall.Attach(new RemoveMissileObserver()); //ShipRemoveMissileObserver() pHitTopWall.Attach(new ExplosionSpriteObserver(GameSprite.Name.MissileExplosion)); // Missile vs Shield CollPair pColPair = CollPairManager.Add(CollPair.Name.Missile_Shield, pMissileGroup, pShieldRoot); pColPair.Attach(new ShipReadyObserver()); pColPair.Attach(new RemoveMissileObserver()); pColPair.Attach(new RemoveBrickObserver()); pColPair.Attach(new SoundObserverExplosion()); // UFO vs WallGroup CollPair pUFOvsWall = CollPairManager.Add(CollPair.Name.Saucer_Wall, pUFOGrid, pWallGroup); pUFOvsWall.Attach(new GridObserverUFO()); // UFO vs Missile CollPair pUFOvsMissile = CollPairManager.Add(CollPair.Name.Missile_UFO, pMissileGroup, pUFOGrid); pUFOvsMissile.Attach(new ShipReadyObserver()); pUFOvsMissile.Attach(new RemoveMissileObserver()); pUFOvsMissile.Attach(new RemoveUFOObserver()); pUFOvsMissile.Attach(new SoundObserverKillAlien()); pUFOvsMissile.Attach(new ExplosionSpriteObserver(GameSprite.Name.SaucerExplosion)); Debug.WriteLine("Finished : Loading Collision Pairs"); // ----------------------------------------------------------------------------- // ---------------------- Test Input Handles ----------------------------------- // ----------------------------------------------------------------------------- // Creation moved to createManagers() InputSubject pInputSubject; pInputSubject = InputManager.GetArrowRightSubject(); pInputSubject.Attach(new MoveRightObserver()); pInputSubject = InputManager.GetArrowLeftSubject(); pInputSubject.Attach(new MoveLeftObserver()); pInputSubject = InputManager.GetSpaceSubject(); pInputSubject.Attach(new ShootObserver()); pInputSubject = InputManager.GetBkeySubject(); pInputSubject.Attach(new RenderCollisionBoxesObserver()); Simulation.SetState(Simulation.State.Realtime); Debug.WriteLine("Finished : Loading Input Subject"); }
public void loadShields() { ShieldFactory shieldFactory = FactoryManager.getShieldFactry(); Shield shieldGrid = shieldFactory.createShield(Shield.ShieldType.ShieldGrid, GameObject.GameObjectName.ShieldGrid); shieldFactory.setParent(shieldGrid); for (int x = 0; x < 8; x = x + 2) { shieldFactory.setParent(shieldGrid); Shield shieldUnit = shieldFactory.createShield(Shield.ShieldType.ShieldUnit, GameObject.GameObjectName.ShieldUnit); shieldFactory.setParent(shieldUnit); Shield pColumn; pColumn = shieldFactory.createShield(Shield.ShieldType.ShieldColumn, GameObject.GameObjectName.ShieldColumn, 0); shieldFactory.setParent(pColumn); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (100 + (x * 100)), 150); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (100 + (x * 100)), 140); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (100 + (x * 100)), 130); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (100 + (x * 100)), 120); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (100 + (x * 100)), 110); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (100 + (x * 100)), 100); shieldFactory.setParent(shieldUnit); pColumn = shieldFactory.createShield(Shield.ShieldType.ShieldColumn, GameObject.GameObjectName.Column, 0); shieldFactory.setParent(pColumn); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (110 + (x * 100)), 160); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (110 + (x * 100)), 150); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (110 + (x * 100)), 140); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (110 + (x * 100)), 130); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (110 + (x * 100)), 120); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (110 + (x * 100)), 110); shieldFactory.setParent(shieldUnit); pColumn = shieldFactory.createShield(Shield.ShieldType.ShieldColumn, GameObject.GameObjectName.Column, 0); shieldFactory.setParent(pColumn); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (120 + (x * 100)), 170); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (120 + (x * 100)), 160); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (120 + (x * 100)), 150); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (120 + (x * 100)), 140); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (120 + (x * 100)), 130); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (120 + (x * 100)), 120); shieldFactory.setParent(shieldUnit); pColumn = shieldFactory.createShield(Shield.ShieldType.ShieldColumn, GameObject.GameObjectName.Column, 0); shieldFactory.setParent(pColumn); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (130 + (x * 100)), 170); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (130 + (x * 100)), 160); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (130 + (x * 100)), 150); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (130 + (x * 100)), 140); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (130 + (x * 100)), 130); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (130 + (x * 100)), 120); shieldFactory.setParent(shieldUnit); pColumn = shieldFactory.createShield(Shield.ShieldType.ShieldColumn, GameObject.GameObjectName.Column, 0); shieldFactory.setParent(pColumn); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (140 + (x * 100)), 170); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (140 + (x * 100)), 160); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (140 + (x * 100)), 150); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (140 + (x * 100)), 140); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (140 + (x * 100)), 130); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (140 + (x * 100)), 120); shieldFactory.setParent(shieldUnit); pColumn = shieldFactory.createShield(Shield.ShieldType.ShieldColumn, GameObject.GameObjectName.Column, 0); shieldFactory.setParent(pColumn); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (150 + (x * 100)), 160); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (150 + (x * 100)), 150); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (150 + (x * 100)), 140); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (150 + (x * 100)), 130); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (150 + (x * 100)), 120); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (150 + (x * 100)), 110); shieldFactory.setParent(shieldUnit); pColumn = shieldFactory.createShield(Shield.ShieldType.ShieldColumn, GameObject.GameObjectName.ShieldColumn, 0); shieldFactory.setParent(pColumn); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (160 + (x * 100)), 150); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (160 + (x * 100)), 140); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (160 + (x * 100)), 130); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (160 + (x * 100)), 120); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (160 + (x * 100)), 110); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (160 + (x * 100)), 100); } }
// 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); }
//need to create the root node first before using public static void ShieldCreator(float startX, float startY, GameObject.Name shieldName) { Composite pShieldRoot = (Composite)GONodeMan.Find(GameObject.Name.ShieldRoot); Debug.Assert(pShieldRoot != null); ShieldFactory SF = new ShieldFactory(SpriteBatch.Name.Shields, SpriteBatch.Name.Boxes, pShieldRoot); GameObject pShieldGrid; SF.SetParent(pShieldRoot); pShieldGrid = SF.Create(ShieldCategory.Type.Grid, shieldName); //j represents the columns int j = 0; GameObject pShieldColumn; SF.SetParent(pShieldGrid); pShieldColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_1 + j++); SF.SetParent(pShieldColumn); float start_x = startX; float start_y = startY; float off_x = 0; float brickWidth = 10.0f; float brickHeight = 5.0f; SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 2 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 3 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 4 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 5 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 6 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 7 * brickHeight); SF.Create(ShieldCategory.Type.LeftTop2, GameObject.Name.ShieldBrick, start_x, start_y + 8 * brickHeight); SF.Create(ShieldCategory.Type.LeftTop1, GameObject.Name.ShieldBrick, start_x, start_y + 9 * brickHeight); SF.SetParent(pShieldGrid); pShieldColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_1 + j++); SF.SetParent(pShieldColumn); off_x += brickWidth; SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); SF.SetParent(pShieldGrid); pShieldColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_1 + j++); SF.SetParent(pShieldColumn); off_x += brickWidth; SF.Create(ShieldCategory.Type.LeftBottom, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); SF.SetParent(pShieldGrid); pShieldColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_1 + j++); SF.SetParent(pShieldColumn); off_x += brickWidth; SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); SF.SetParent(pShieldGrid); pShieldColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_1 + j++); SF.SetParent(pShieldColumn); off_x += brickWidth; SF.Create(ShieldCategory.Type.RightBottom, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); SF.SetParent(pShieldGrid); pShieldColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_1 + j++); SF.SetParent(pShieldColumn); off_x += brickWidth; SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 0 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 1 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); SF.SetParent(pShieldGrid); pShieldColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_1 + j++); SF.SetParent(pShieldColumn); off_x += brickWidth; SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 0 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 1 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(ShieldCategory.Type.RightTop2, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(ShieldCategory.Type.RightTop1, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); }
public static GameObject Create(ShieldCategory.Type type, int _Index, float posX = 0.0f, float posY = 0.0f) { ShieldFactory pFactory = ShieldFactory.PrivGetInstance(); Debug.Assert(pFactory != null); GameObject pGameObj = null; switch (type) { case ShieldCategory.Type.Brick: pGameObj = new ShieldBrick(GameObject.Name.ShieldBrick, GameSprite.Name.Brick, _Index, posX, posY); break; case ShieldCategory.Type.LeftBottom: pGameObj = new ShieldBrick(GameObject.Name.ShieldBrick, GameSprite.Name.BrickLeft_Bottom, _Index, posX, posY); break; case ShieldCategory.Type.LeftTop0: pGameObj = new ShieldBrick(GameObject.Name.ShieldBrick, GameSprite.Name.BrickLeft_Top0, _Index, posX, posY); break; case ShieldCategory.Type.LeftTop1: pGameObj = new ShieldBrick(GameObject.Name.ShieldBrick, GameSprite.Name.BrickLeft_Top1, _Index, posX, posY); break; case ShieldCategory.Type.RightBottom: pGameObj = new ShieldBrick(GameObject.Name.ShieldBrick, GameSprite.Name.BrickRight_Bottom, _Index, posX, posY); break; case ShieldCategory.Type.RightTop0: pGameObj = new ShieldBrick(GameObject.Name.ShieldBrick, GameSprite.Name.BrickRight_Top0, _Index, posX, posY); break; case ShieldCategory.Type.RightTop1: pGameObj = new ShieldBrick(GameObject.Name.ShieldBrick, GameSprite.Name.BrickRight_Top1, _Index, posX, posY); break; case ShieldCategory.Type.Column: pGameObj = new ShieldColumn(GameObject.Name.ShieldColumn, GameSprite.Name.NullObject, _Index, posX, posY); break; case ShieldCategory.Type.Group: pGameObj = new ShieldGroup(GameObject.Name.ShieldRoot, GameSprite.Name.NullObject, _Index, posX, posY); break; default: Debug.Assert(false); break; } Debug.Assert(pGameObj != null); // Attach to SpriteBatch if (pGameObj.type == Component.Container.LEAF) { pFactory.pParent.Add(pGameObj); pGameObj.ActivateGameSprite(pFactory.pShieldSpriteBatch); } pGameObj.ActivateCollisionSprite(pFactory.pBoxSpriteBatch); return(pGameObj); }
//public ShieldGroupFactory() //{ //} public static Composite Create(float startPosX, float startPosY, GameObjectMan pGameObjectMan) { //if (shieldsCreated == false) //{ pShieldRoot = (Composite) new ShieldRoot(GameObject.Name.ShieldRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); GameObjectMan.Attach(pShieldRoot); ShieldFactory SF = new ShieldFactory(SpriteBatch.Name.Shields, SpriteBatch.Name.Boxes, pShieldRoot); float start_x = startPosX; float start_y = startPosY; // load by column for (int i = 0; i < 4; i++) { int j = 0; GameObject pColumn; SF.SetParent(pShieldRoot); pColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++); SF.SetParent(pColumn); start_x = 100.0f + i * 170; float off_x = 0; float brickWidth = 15.0f; float brickHeight = 6.0f; SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 2 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 3 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 4 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 5 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 6 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 7 * brickHeight); SF.Create(ShieldCategory.Type.LeftTop1, GameObject.Name.ShieldBrick, start_x, start_y + 8 * brickHeight); SF.Create(ShieldCategory.Type.LeftTop0, GameObject.Name.ShieldBrick, start_x, start_y + 9 * brickHeight); SF.SetParent(pShieldRoot); pColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++); SF.SetParent(pColumn); off_x += brickWidth; SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); SF.SetParent(pShieldRoot); pColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++); SF.SetParent(pColumn); off_x += brickWidth; SF.Create(ShieldCategory.Type.LeftBottom, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); SF.SetParent(pShieldRoot); pColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++); SF.SetParent(pColumn); off_x += brickWidth; SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); SF.SetParent(pShieldRoot); pColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++); SF.SetParent(pColumn); off_x += brickWidth; SF.Create(ShieldCategory.Type.RightBottom, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); SF.SetParent(pShieldRoot); pColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++); SF.SetParent(pColumn); off_x += brickWidth; SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 0 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 1 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); SF.SetParent(pShieldRoot); pColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++); SF.SetParent(pColumn); off_x += brickWidth; SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 0 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 1 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(ShieldCategory.Type.RightTop1, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(ShieldCategory.Type.RightTop0, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); } // shieldsCreated = true; //} return(pShieldRoot); }
public static Shield CreateShield(float xOrigin, float yOrigin, GameObjectComposite pGOComposite = null) { // 21 x 18 ShieldFactory pShieldSF = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pGOComposite); Shield pShield = (Shield)pShieldSF.Create(ShieldFactory.Type.Shield, 0, 0); ShieldFactory pColumnSF = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShield); ShieldColumn pShieldColumn0 = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0); ShieldColumn pShieldColumn1 = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0); ShieldColumn pShieldColumn2 = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0); ShieldColumn pShieldColumn3 = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0); ShieldColumn pShieldColumn4 = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0); ShieldColumn pShieldColumn5 = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0); ShieldColumn pShieldColumn6 = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0); // Columns 7 through 13 are produced in a loop below. ShieldColumn pShieldColumn14 = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0); ShieldColumn pShieldColumn15 = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0); ShieldColumn pShieldColumn16 = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0); ShieldColumn pShieldColumn17 = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0); ShieldColumn pShieldColumn18 = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0); ShieldColumn pShieldColumn19 = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0); ShieldColumn pShieldColumn20 = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0); // make shield columns 0 and 20 for (int i = 0; i < 12; i++) { ShieldFactory pShieldBrickFactory = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn0); ShieldBrick shieldBrick = (ShieldBrick)pShieldBrickFactory.Create(ShieldFactory.Type.Brick, xOrigin, yOrigin + i * Constants.shieldBrickHeight); ShieldFactory pShieldBrickFactory20 = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn20); pShieldBrickFactory20.Create(ShieldFactory.Type.Brick, xOrigin + 20 * Constants.shieldBrickHeight, yOrigin + i * Constants.shieldBrickHeight); } // make shield columns 1 and 19 for (int i = 0; i < 13; i++) { ShieldFactory pShieldBrickFactory = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn1); ShieldBrick shieldBrick = (ShieldBrick)pShieldBrickFactory.Create(ShieldFactory.Type.Brick, xOrigin + 1 * Constants.shieldBrickHeight, yOrigin + i * Constants.shieldBrickHeight); ShieldFactory pShieldBrickFactory19 = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn19); pShieldBrickFactory19.Create(ShieldFactory.Type.Brick, xOrigin + 19 * Constants.shieldBrickHeight, yOrigin + i * Constants.shieldBrickHeight); } // make shield columns 2 and 18 for (int i = 0; i < 14; i++) { ShieldFactory pShieldBrickFactory = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn2); ShieldBrick shieldBrick = (ShieldBrick)pShieldBrickFactory.Create(ShieldFactory.Type.Brick, xOrigin + 2 * Constants.shieldBrickHeight, yOrigin + i * Constants.shieldBrickHeight); ShieldFactory pShieldBrickFactory18 = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn18); pShieldBrickFactory18.Create(ShieldFactory.Type.Brick, xOrigin + 18 * Constants.shieldBrickHeight, yOrigin + i * Constants.shieldBrickHeight); } // make shield columns 3 and 17 for (int i = 0; i < 15; i++) { ShieldFactory pShieldBrickFactory3 = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn3); pShieldBrickFactory3.Create(ShieldFactory.Type.Brick, xOrigin + 3 * Constants.shieldBrickHeight, yOrigin + i * Constants.shieldBrickHeight); ShieldFactory pShieldBrickFactory17 = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn17); pShieldBrickFactory17.Create(ShieldFactory.Type.Brick, xOrigin + 17 * Constants.shieldBrickHeight, yOrigin + i * Constants.shieldBrickHeight); } // make shield columns 4 and 16 for (int i = 0; i < 16; i++) { ShieldFactory pShieldBrickFactory4 = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn4); pShieldBrickFactory4.Create(ShieldFactory.Type.Brick, xOrigin + 4 * Constants.shieldBrickHeight, yOrigin + i * Constants.shieldBrickHeight); ShieldFactory pShieldBrickFactory16 = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn16); pShieldBrickFactory16.Create(ShieldFactory.Type.Brick, xOrigin + 16 * Constants.shieldBrickHeight, yOrigin + i * Constants.shieldBrickHeight); } // make shield columns 5 and 15 for (int i = 0; i < 14; i++) { ShieldFactory pShieldBrickFactor5 = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn5); pShieldBrickFactor5.Create(ShieldFactory.Type.Brick, xOrigin + 5 * Constants.shieldBrickHeight, yOrigin + 2 * Constants.shieldBrickHeight + i * Constants.shieldBrickHeight); ShieldFactory pShieldBrickFactor15 = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn15); pShieldBrickFactor15.Create(ShieldFactory.Type.Brick, xOrigin + 15 * Constants.shieldBrickHeight, yOrigin + 2 * Constants.shieldBrickHeight + i * Constants.shieldBrickHeight); } // make shield columns 6 and 14 for (int i = 0; i < 13; i++) { ShieldFactory pShieldBrickFactory6 = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn6); pShieldBrickFactory6.Create(ShieldFactory.Type.Brick, xOrigin + 6 * Constants.shieldBrickHeight, yOrigin + 3 * Constants.shieldBrickHeight + i * Constants.shieldBrickHeight); ShieldFactory pShieldBrickFactory14 = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn14); pShieldBrickFactory14.Create(ShieldFactory.Type.Brick, xOrigin + 14 * Constants.shieldBrickHeight, yOrigin + 3 * Constants.shieldBrickHeight + i * Constants.shieldBrickHeight); } // make shield columns 7 thru 13 for (int i = 0; i < 7; i++) { float x = xOrigin + 7 * Constants.shieldBrickHeight + i * Constants.shieldBrickHeight; ShieldColumn pShieldColumn = (ShieldColumn)pColumnSF.Create(ShieldFactory.Type.Column, 0, 0); ShieldFactory pShieldBrickFactory = new ShieldFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pShieldColumn); for (int j = 0; j < 12; j++) { float y = yOrigin + 4 * Constants.shieldBrickHeight + j * Constants.shieldBrickHeight; pShieldBrickFactory.Create(ShieldFactory.Type.Brick, x, y); } } return(pShield); }
public static GameObject RecreateShield(float start_x = 0.0f, float start_y = 0.0f) { GhostManager pGhostManager = GameStateManager.GetGame().GetStateGhostManager(); GameObjectManager pGameObjectManager = GameStateManager.GetGame().GetStateGameObjectManager(); Composite pShieldRoot = (Composite)pGhostManager.Find(GameObject.Name.ShieldRoot); pGhostManager.Detach(pShieldRoot); GameStateManager.GetGame().GetStateGameObjectManager().Attach(pShieldRoot); pShieldRoot.ActivateSprite(GameStateManager.GetGame().GetStateSpriteBatchManager().Find(SpriteBatch.Name.Shield)); pShieldRoot.ActivateCollisionSprite(GameStateManager.GetGame().GetStateSpriteBatchManager().Find(SpriteBatch.Name.CollisionBox)); ShieldFactory SF = new ShieldFactory(SpriteBatch.Name.Shield, SpriteBatch.Name.CollisionBox, pShieldRoot); // load by column GameObject pColumn; SF.SetParent(pShieldRoot); pColumn = SF.Recreate(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn); SF.SetParent(pColumn); float off_x = 0; float brickWidth = 12.0f; float brickHeight = 6.0f; SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 2 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 3 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 4 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 5 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 6 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 7 * brickHeight); SF.Recreate(ShieldCategory.Type.LeftTop1, GameObject.Name.ShieldBrick, start_x, start_y + 8 * brickHeight); SF.Recreate(ShieldCategory.Type.LeftTop0, GameObject.Name.ShieldBrick, start_x, start_y + 9 * brickHeight); SF.SetParent(pShieldRoot); pColumn = SF.Recreate(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn); SF.SetParent(pColumn); off_x += brickWidth; SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); SF.SetParent(pShieldRoot); pColumn = SF.Recreate(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn); SF.SetParent(pColumn); off_x += brickWidth; SF.Recreate(ShieldCategory.Type.LeftBottom, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); SF.SetParent(pShieldRoot); pColumn = SF.Recreate(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn); SF.SetParent(pColumn); off_x += brickWidth; SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); SF.SetParent(pShieldRoot); pColumn = SF.Recreate(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn); SF.SetParent(pColumn); off_x += brickWidth; SF.Recreate(ShieldCategory.Type.RightBottom, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); SF.SetParent(pShieldRoot); pColumn = SF.Recreate(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn); SF.SetParent(pColumn); off_x += brickWidth; SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 0 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 1 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); SF.SetParent(pShieldRoot); pColumn = SF.Recreate(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn); SF.SetParent(pColumn); off_x += brickWidth; SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 0 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 1 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Recreate(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Recreate(ShieldCategory.Type.RightTop1, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Recreate(ShieldCategory.Type.RightTop0, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); return(pShieldRoot); }
public override void LoadContent() { ShipMan.Create(); GraveyardMan.Create(); SpriteBatch pSB_Aliens = SpriteBatchMan.Find(SpriteBatch.Name.Aliens); pSB_Aliens.bToggle = true; SpriteBatch pSB_Boxes = SpriteBatchMan.Find(SpriteBatch.Name.Boxes); pSB_Boxes.bToggle = false; SpriteBatch pSB_Shields = SpriteBatchMan.Find(SpriteBatch.Name.Shields); pSB_Shields.bToggle = true; SpriteBatch pSB_InGame = SpriteBatchMan.Find(SpriteBatch.Name.InGameScreen); pSB_InGame.bToggle = true; SpriteBatch pSB_Projectiles = SpriteBatchMan.Find(SpriteBatch.Name.Projectiles); pSB_Projectiles.bToggle = true; //SpriteBatch pSB_Splats = SpriteBatchMan.Find(SpriteBatch.Name.Splats); //pSB_Splats.bToggle = true; SpaceInvaders pGame = GameMan.GetGame(); IrrKlang.ISoundEngine pSndEngine = pGame.GetSndEngine(); //------------------------------------------------------------------------------------------------------- //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 < 11; 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, 600); pGameObj = AF.Create(GameObject.Name.Crab, AlienCategory.Type.Crab, 70.0f + i * 43.0f, 560); pGameObj = AF.Create(GameObject.Name.Crab, AlienCategory.Type.Crab, 70.0f + i * 43.0f, 520); pGameObj = AF.Create(GameObject.Name.Squid, AlienCategory.Type.Squid, 70.0f + i * 43.0f, 480); pGameObj = AF.Create(GameObject.Name.Squid, AlienCategory.Type.Squid, 70.0f + i * 43.0f, 440); } //Debug.WriteLine("-------------------"); //pAlienGroup.Print(); //--------------------------------------------------------------------------------------------------------- // Shields //--------------------------------------------------------------------------------------------------------- float posX = 80; float posY = 120; for (int i = 0; i < 4; i++) { ShieldFactory.ShieldCreator(posX, posY, GameObject.Name.ShieldGrid_1 + i); posX += 130; } //Debug.WriteLine("-------------------"); //GameObject pShieldRoot = GONodeMan.Find(GameObject.Name.ShieldRoot); //pShieldRoot.Print(); //-------------------------------------------------------------------------------------------------------------- //Time Events //-------------------------------------------------------------------------------------------------------------- UFORoot pUFORoot = (UFORoot)GONodeMan.Find(GameObject.Name.UFORoot); MoveGrid pMove = new MoveGrid(pAlienGroup, pSndEngine); SendUFO pSendIt = new SendUFO(pUFORoot); //BombDrop pBombDrop0 = new BombDrop((AlienGroup)pAlienGroup); BombDrop pBombDrop1 = new BombDrop((AlienGroup)pAlienGroup); BombDrop pBombDrop2 = new BombDrop((AlienGroup)pAlienGroup); SpeedUpCheck pSpeedCheck = new SpeedUpCheck((AlienGroup)pAlienGroup); //--------------------------------------------------------------------------------------------------------- //Add Events //--------------------------------------------------------------------------------------------------------- AnimateCrab pAnimCrab = (AnimateCrab)AnimMan.Find(Animation.Name.AnimateCrab); AnimateSquid pAnimSquid = (AnimateSquid)AnimMan.Find(Animation.Name.AnimateSquid); AnimateOcto pAnimOcto = (AnimateOcto)AnimMan.Find(Animation.Name.AnimateOcto); TimerMan.Add(TimeEvent.Name.AnimateOcto, pAnimOcto, 0.60f); TimerMan.Add(TimeEvent.Name.AnimateSquid, pAnimSquid, 0.60f); TimerMan.Add(TimeEvent.Name.AnimateCrab, pAnimCrab, 0.60f); TimerMan.Add(TimeEvent.Name.MoveGrid, pMove, 0.60f); //TimerMan.Add(TimeEvent.Name.ColumnShoot, pBombDrop0, 1.0f); TimerMan.Add(TimeEvent.Name.ColumnShoot, pBombDrop1, 2.0f); TimerMan.Add(TimeEvent.Name.ColumnShoot, pBombDrop2, 4.0f); TimerMan.Add(TimeEvent.Name.SpeedCheck, pSpeedCheck, 12.0f); TimerMan.Add(TimeEvent.Name.SendUFO, pSendIt, 25.0f); }
// strategy() public override void LoadContent() { pSpriteBatchMan = new SpriteBatchMan(1, 1); playLives = 3; numOfAliens = 55; //--------------------------------------------------------------------------------------------------------- // Manager initialization //--------------------------------------------------------------------------------------------------------- TimerMan.Create(3, 1); TextureMan.Create(2, 1); ImageMan.Create(5, 2); GameSpriteMan.Create(4, 2); BoxSpriteMan.Create(3, 1); ProxySpriteMan.Create(10, 1); if (GameObjectMan.pInstance != null) { GameObjectMan.Destroy(); } GameObjectMan.Create(3, 1); ColPairMan.Create(1, 1); GlyphMan.Create(3, 1); FontMan.Create(1, 1); //--------------------------------------------------------------------------------------------------------- // Sound Experiment //--------------------------------------------------------------------------------------------------------- // start up the engine // SpaceInvaders.GetInstance().sndEngine = new IrrKlang.ISoundEngine(); //--------------------------------------------------------------------------------------------------------- // Load the Textures //--------------------------------------------------------------------------------------------------------- TextureMan.Add(Texture.Name.Shields, "birds_N_shield.tga"); TextureMan.Add(Texture.Name.Aliens, "aliensNew.tga"); TextureMan.Add(Texture.Name.Consolas36pt, "Consolas36pt.tga"); FontMan.AddXml(Glyph.Name.Consolas36pt, "Consolas36pt.xml", Texture.Name.Consolas36pt); //--------------------------------------------------------------------------------------------------------- // Create Images //--------------------------------------------------------------------------------------------------------- ImageMan.Add(Image.Name.CrabUp, Texture.Name.Aliens, 322.5f, 27.0f, 150.0f, 111.0f); ImageMan.Add(Image.Name.CrabDown, Texture.Name.Aliens, 324.0f, 180.0f, 150.0f, 114.0f); ImageMan.Add(Image.Name.OctopusOut, Texture.Name.Aliens, 54f, 28.5f, 168f, 111f); ImageMan.Add(Image.Name.OctopusIn, Texture.Name.Aliens, 54f, 180f, 168f, 111f); ImageMan.Add(Image.Name.SquidOut, Texture.Name.Aliens, 612f, 25.5f, 117f, 117f); ImageMan.Add(Image.Name.SquidIn, Texture.Name.Aliens, 612f, 180f, 117f, 117f); ImageMan.Add(Image.Name.Missile, Texture.Name.Shields, 73, 53, 5, 4); ImageMan.Add(Image.Name.Ship, Texture.Name.Shields, 10, 93, 30, 18); ImageMan.Add(Image.Name.Wall, Texture.Name.Shields, 40, 185, 20, 10); ImageMan.Add(Image.Name.BombStraight, Texture.Name.Shields, 111, 101, 5, 49); ImageMan.Add(Image.Name.BombZigZag, Texture.Name.Shields, 132, 100, 20, 50); ImageMan.Add(Image.Name.BombCross, Texture.Name.Shields, 219, 103, 19, 47); 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); ImageMan.Add(Image.Name.UFO, Texture.Name.Aliens, 84, 505, 225, 96); ImageMan.Add(Image.Name.Splash, Texture.Name.Aliens, 573, 486, 183, 115); ImageMan.Add(Image.Name.TopSplash, Texture.Name.Aliens, 403, 487, 113, 113); ImageMan.Add(Image.Name.PlayerEnd, Texture.Name.Aliens, 558, 336, 222, 110); //--------------------------------------------------------------------------------------------------------- // Create Sprites //--------------------------------------------------------------------------------------------------------- GameSpriteMan.Add(GameSprite.Name.Crab, Image.Name.CrabUp, 500.0f, 300.0f, 18.0f, 18.0f); GameSpriteMan.Add(GameSprite.Name.Octopus, Image.Name.OctopusOut, 50, 200, 20, 20); GameSpriteMan.Add(GameSprite.Name.Squid, Image.Name.SquidOut, 300, 400, 16, 16); GameSpriteMan.Add(GameSprite.Name.Missile, Image.Name.Missile, 0, 0, 2, 10); pShip = GameSpriteMan.Add(GameSprite.Name.ShipImage, Image.Name.Ship, 40, 20, 30, 14); GameSpriteMan.Add(GameSprite.Name.Ship, Image.Name.Ship, 500, 100, 30, 14); GameSpriteMan.Add(GameSprite.Name.WallHorizontal, Image.Name.Wall, 448, 900, 850, 30); GameSpriteMan.Add(GameSprite.Name.WallVertical, Image.Name.Wall, 50, 448, 30, 950); GameSpriteMan.Add(GameSprite.Name.UFO, Image.Name.UFO, 50, 448, 20, 14); GameSpriteMan.Add(GameSprite.Name.BombZigZag, Image.Name.BombZigZag, 200, 200, 10, 20); GameSpriteMan.Add(GameSprite.Name.BombStraight, Image.Name.BombStraight, 100, 100, 5, 20); GameSpriteMan.Add(GameSprite.Name.BombDagger, Image.Name.BombCross, 100, 100, 10, 20); GameSpriteMan.Add(GameSprite.Name.Brick, Image.Name.Brick, 50, 25, 10, 5); GameSpriteMan.Add(GameSprite.Name.Brick_LeftTop0, Image.Name.BrickLeft_Top0, 50, 25, 10, 5); GameSpriteMan.Add(GameSprite.Name.Brick_LeftTop1, Image.Name.BrickLeft_Top1, 50, 25, 10, 5); GameSpriteMan.Add(GameSprite.Name.Brick_LeftBottom, Image.Name.BrickLeft_Bottom, 50, 25, 10, 5); GameSpriteMan.Add(GameSprite.Name.Brick_RightTop0, Image.Name.BrickRight_Top0, 50, 25, 10, 5); GameSpriteMan.Add(GameSprite.Name.Brick_RightTop1, Image.Name.BrickRight_Top1, 50, 25, 10, 5); GameSpriteMan.Add(GameSprite.Name.Brick_RightBottom, Image.Name.BrickRight_Bottom, 50, 25, 10, 5); GameSpriteMan.Add(GameSprite.Name.Splash, Image.Name.Splash, 0, 0, 18, 18); GameSpriteMan.Add(GameSprite.Name.TopSplash, Image.Name.TopSplash, 0, 0, 20, 14); GameSpriteMan.Add(GameSprite.Name.PlayerEnd, Image.Name.PlayerEnd, 0, 0, 40, 20); //--------------------------------------------------------------------------------------------------------- // Create BoxSprite //--------------------------------------------------------------------------------------------------------- BoxSpriteMan.Add(BoxSprite.Name.Box1, 550.0f, 500.0f, 50.0f, 150.0f, new Azul.Color(1.0f, 1.0f, 1.0f, 1.0f)); BoxSpriteMan.Add(BoxSprite.Name.Box2, 550.0f, 100.0f, 50.0f, 100.0f); //--------------------------------------------------------------------------------------------------------- // Create SpriteBatch //--------------------------------------------------------------------------------------------------------- SpriteBatch pSB_Box = pSpriteBatchMan.Add(SpriteBatch.Name.Boxes); SpriteBatch pSB_Aliens = pSpriteBatchMan.Add(SpriteBatch.Name.Aliens); SpriteBatch pSB_Texts = pSpriteBatchMan.Add(SpriteBatch.Name.Texts); SpriteBatch pSB_Shields = pSpriteBatchMan.Add(SpriteBatch.Name.Shields); SpriteBatch pSB_Walls = pSpriteBatchMan.Add(SpriteBatch.Name.Walls); SpriteBatch pSB_UFOs = pSpriteBatchMan.Add(SpriteBatch.Name.UFOs); SpriteBatch pSB_Bombs = pSpriteBatchMan.Add(SpriteBatch.Name.Bombs); pSB_Aliens.Attach(pShip); pSB_Walls.display = false; pSB_Box.display = false; //--------------------------------------------------------------------------------------------------------- //Font //--------------------------------------------------------------------------------------------------------- FontMan.Add(pSpriteBatchMan, Font.Name.Title, SpriteBatch.Name.Texts, "SCORE<1> HIGH-SCORE SCORE<2>", Glyph.Name.Consolas36pt, 200, 680); FontMan.Add(pSpriteBatchMan, Font.Name.ScoreOne, SpriteBatch.Name.Texts, "00", Glyph.Name.Consolas36pt, 240, 650); FontMan.Add(pSpriteBatchMan, Font.Name.HighestScore, SpriteBatch.Name.Texts, "00", Glyph.Name.Consolas36pt, 440, 650); FontMan.Add(pSpriteBatchMan, Font.Name.ScoreTwo, SpriteBatch.Name.Texts, "00", Glyph.Name.Consolas36pt, 650, 650); FontMan.Add(pSpriteBatchMan, Font.Name.PlayerLives, SpriteBatch.Name.Texts, "X" + playLives, Glyph.Name.Consolas36pt, 52, 20); //--------------------------------------------------------------------------------------------------------- // Input //--------------------------------------------------------------------------------------------------------- InputSubject pInputSubject; pInputSubject = InputMan.GetArrowRightSubject(); pInputSubject.Attach(new MoveRightObserver()); pInputSubject = InputMan.GetArrowLeftSubject(); pInputSubject.Attach(new MoveLeftObserver()); pInputSubject = InputMan.GetSpaceSubject(); pInputSubject.Attach(new ShootObserver()); Simulation.SetState(Simulation.State.Realtime); //--------------------------------------------------------------------------------------------------------- // Bomb //--------------------------------------------------------------------------------------------------------- BombRoot pBombRoot = new BombRoot(GameObject.Name.BombRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); //pBombRoot.ActivateCollisionSprite(pSB_Box); GameObjectMan.Attach(pBombRoot); //--------------------------------------------------------------------------------------------------------- // Walls //--------------------------------------------------------------------------------------------------------- WallGroup pWallGroup = new WallGroup(GameObject.Name.WallGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pWallGroup.ActivateGameSprite(pSB_Walls); //pWallGroup.ActivateCollisionSprite(pSB_Box); WallFactory WF = new WallFactory(pSpriteBatchMan, SpriteBatch.Name.Walls, SpriteBatch.Name.Boxes, pWallGroup); WF.Create(WallCategory.Type.Bottom, GameObject.Name.WallBottom, 448, 20, 850, 30); WF.Create(WallCategory.Type.Top, GameObject.Name.WallTop, 448, 650, 850, 30); WF.Create(WallCategory.Type.Left, GameObject.Name.WallLeft, 50, 448, 30, 950); WF.Create(WallCategory.Type.Right, GameObject.Name.WallRight, 846, 448, 30, 950); GameObjectMan.Attach(pWallGroup); //--------------------------------------------------------------------------------------------------------- // Missile //--------------------------------------------------------------------------------------------------------- // Missile Root MissileGroup pMissileGroup = new MissileGroup(GameObject.Name.MissileGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pMissileGroup.ActivateGameSprite(pSB_Aliens); pMissileGroup.ActivateCollisionSprite(pSB_Box); GameObjectMan.Attach(pMissileGroup); //--------------------------------------------------------------------------------------------------------- // Ship //--------------------------------------------------------------------------------------------------------- ShipRoot pShipRoot = new ShipRoot(GameObject.Name.ShipRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); GameObjectMan.Attach(pShipRoot); pMissileGroup.ActivateGameSprite(pSB_Aliens); pMissileGroup.ActivateCollisionSprite(pSB_Box); ShipMan.Create(pSpriteBatchMan); //pShipRoot.Print(); //--------------------------------------------------------------------------------------------------------- // Shield //--------------------------------------------------------------------------------------------------------- // Create the factory ... prototype Composite pShieldRoot = (Composite) new ShieldRoot(GameObject.Name.ShieldRoot, GameSprite.Name.NullObject, 300.0f, 300.0f); GameObjectMan.Attach(pShieldRoot); pShieldRoot.ActivateCollisionSprite(pSB_Box); pShieldRoot.ActivateGameSprite(pSB_Shields); ShieldFactory SF = new ShieldFactory(pSpriteBatchMan, SpriteBatch.Name.Shields, SpriteBatch.Name.Boxes, pShieldRoot); float brickWidth = 10.0f; float brickHeight = 5.0f; for (int i = 0; i < 4; i++) { float start_x = 150.0f + 180 * i; float start_y = 100.0f; float off_x = 0; SF.SetParent(pShieldRoot); GameObject pShieldGrid = SF.Create(ShieldCategory.Type.Grid, GameObject.Name.ShieldGrid); { int j = 0; GameObject pColumn; SF.SetParent(pShieldGrid); pColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++); SF.SetParent(pColumn); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 2 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 3 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 4 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 5 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 6 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x, start_y + 7 * brickHeight); SF.Create(ShieldCategory.Type.LeftTop1, GameObject.Name.ShieldBrick, start_x, start_y + 8 * brickHeight); SF.Create(ShieldCategory.Type.LeftTop0, GameObject.Name.ShieldBrick, start_x, start_y + 9 * brickHeight); SF.SetParent(pShieldGrid); pColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++); SF.SetParent(pColumn); off_x += brickWidth; SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); SF.SetParent(pShieldGrid); pColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++); SF.SetParent(pColumn); off_x += brickWidth; SF.Create(ShieldCategory.Type.LeftBottom, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); SF.SetParent(pShieldGrid); pColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++); SF.SetParent(pColumn); off_x += brickWidth; SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); SF.SetParent(pShieldGrid); pColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++); SF.SetParent(pColumn); off_x += brickWidth; SF.Create(ShieldCategory.Type.RightBottom, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); SF.SetParent(pShieldGrid); pColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++); SF.SetParent(pColumn); off_x += brickWidth; SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 0 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 1 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); SF.SetParent(pShieldGrid); pColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++); SF.SetParent(pColumn); off_x += brickWidth; SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 0 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 1 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(ShieldCategory.Type.RightTop1, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(ShieldCategory.Type.RightTop0, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); } } // load by column //pShieldRoot.Print(); //Debug.WriteLine("-------------------"); //ForwardIterator pFor = new ForwardIterator(pShieldRoot); //Component pNode = pFor.First(); //while (!pFor.IsDone()) //{ // pNode.DumpNode(); // pNode = pFor.Next(); //} //Debug.WriteLine("-------------------"); //ReverseIterator pRev = new ReverseIterator(pShieldRoot); //Component pNode2 = pRev.First(); //while (!pRev.IsDone()) //{ // pNode2.DumpNode(); // pNode2 = pRev.Next(); //} //Debug.WriteLine("-------------------"); //--------------------------------------------------------------------------------------------------------- // display 55 aliens on the screen //--------------------------------------------------------------------------------------------------------- //create the AlienRoot Composite pAlienRoot = (Composite) new AlienRoot(GameObject.Name.AlienRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); AlienFactory AF = new AlienFactory(pSpriteBatchMan, SpriteBatch.Name.Aliens, SpriteBatch.Name.Boxes, pAlienRoot); GameObjectMan.Attach(pAlienRoot); GameObject pAlienGrid = AF.Create(AlienCategory.Type.AlienGrid, GameObject.Name.AlienRoot); //create the AlienCloumn GameObject pAlienColumn; for (int i = 0; i < 11; i++) { AF.SetParent(pAlienGrid); pAlienColumn = AF.Create(AlienCategory.Type.AlienColumn, GameObject.Name.AlienColumn); AF.SetParent(pAlienColumn); AF.Create(AlienCategory.Type.Squid, GameObject.Name.Squid, 300.0f + 25 * i, 550.0f); AF.Create(AlienCategory.Type.Crab, GameObject.Name.Crab, 300.0f + 25 * i, 525.0f); AF.Create(AlienCategory.Type.Crab, GameObject.Name.Crab, 300.0f + 25 * i, 500.0f); AF.Create(AlienCategory.Type.Octopus, GameObject.Name.Octopus, 300.0f + 25 * i, 475.0f); AF.Create(AlienCategory.Type.Octopus, GameObject.Name.Octopus, 300.0f + 25 * i, 450.0f); } //create AnimationSprite and attach 2 images to the animation sprite //and add them to the TimerManager //float time; AnimationSprite pAniSquid = new AnimationSprite(GameSprite.Name.Squid); pAniSquid.Attach(Image.Name.SquidIn); pAniSquid.Attach(Image.Name.SquidOut); TimerMan.Add(TimeEvent.Name.SquidAnimation, pAniSquid, 1F); AnimationSprite pAniCrab = new AnimationSprite(GameSprite.Name.Crab); pAniCrab.Attach(Image.Name.CrabDown); pAniCrab.Attach(Image.Name.CrabUp); TimerMan.Add(TimeEvent.Name.CrabAnimation, pAniCrab, 1F); AnimationSprite pAniOcto = new AnimationSprite(GameSprite.Name.Octopus); pAniOcto.Attach(Image.Name.OctopusIn); pAniOcto.Attach(Image.Name.OctopusOut); TimerMan.Add(TimeEvent.Name.OctopusAnimation, pAniOcto, 1F); Movement pAlienMove = new Movement(pAlienRoot, pSB_Bombs, pSB_Box, pBombRoot); TimerMan.Add(TimeEvent.Name.AlienGridMovement, pAlienMove, 1F); //--------------------------------------------------------------------------------------------------------- // UFO //--------------------------------------------------------------------------------------------------------- pUFOGroup = new UFOGroup(GameObject.Name.UFOGroup, GameSprite.Name.NullObject, 1.0f, 1.0f); GameObjectMan.Attach(pUFOGroup); UFODisplay pUFODisplay = new UFODisplay(pSpriteBatchMan, SpriteBatch.Name.UFOs, SpriteBatch.Name.Boxes, GameObject.Name.UFO, GameSprite.Name.UFO, pUFOGroup); TimerMan.Add(TimeEvent.Name.DisplayUFO, pUFODisplay, 40f); //UFODisplay pUFODisplayRight = new UFODisplay(SpriteBatch.Name.UFOs, SpriteBatch.Name.Boxes, GameObject.Name.UFO, GameSprite.Name.UFO, UFOCategory.Type.RightMovingUFO, pUFOGroup); //TimerMan.Add(TimeEvent.Name.DisplayUFO, pUFODisplayRight, 20f); //GameObject pUFO = new LeftUFO(GameObject.Name.UFO, GameSprite.Name.UFO, 800, 700); ////GameObjectMan.Attach(pUFO); //pUFO.ActivateGameSprite(pSB_UFOs); //pUFO.ActivateCollisionSprite(pSB_Box); // UFO pUFO=new UFO(GameObject.Name.UFO, GameSprite.Name.UFO,) //pUFOGroup.ActivateGameSprite(pSB_UFOs); //pUFOGroup.ActivateCollisionSprite(pSB_Box); //GameObjectMan.Attach(pUFOGroup); //--------------------------------------------------------------------------------------------------------- // ColPair //--------------------------------------------------------------------------------------------------------- ColPair pColPair; // associate in a collision pair //bomb vs ship(player) pColPair = ColPairMan.Add(ColPair.Name.Bombs_Player, pBombRoot, pShipRoot); pColPair.Attach(new CheckPlayerStatusObserver(pSpriteBatchMan)); pColPair.Attach(new SndObserver(SpaceInvaders.GetInstance().sndEngine, "explosion.wav")); pColPair.Attach(new SwitchToSplashObserver(GameSprite.Name.PlayerEnd, pSpriteBatchMan)); pColPair.Attach(new RemoveBombObserver(pSpriteBatchMan)); pColPair.Attach(new ShipEndObserver()); // Missile vs Wall pColPair = ColPairMan.Add(ColPair.Name.Missile_Wall, pMissileGroup, pWallGroup); Debug.Assert(pColPair != null); pColPair.Attach(new RemoveMissileObserver(pSpriteBatchMan)); pColPair.Attach(new ShipReadyObserver()); pColPair.Attach(new SndObserver(SpaceInvaders.GetInstance().sndEngine, "shoot.wav")); //pColPair.Attach(new SwitchToSplashObserver(GameSprite.Name.TopSplash)); // Bomb vs Bottom pColPair = ColPairMan.Add(ColPair.Name.Bomb_Wall, pBombRoot, pWallGroup); pColPair.Attach(new RemoveBombObserver(pSpriteBatchMan)); // Missile vs Shield pColPair = ColPairMan.Add(ColPair.Name.Misslie_Shield, pMissileGroup, pShieldRoot); pColPair.Attach(new RemoveMissileObserver(pSpriteBatchMan)); pColPair.Attach(new RemoveBrickObserver(pSpriteBatchMan)); pColPair.Attach(new ShipReadyObserver()); //pColPair.Attach(new SndObserver(SpaceInvaders.GetInstance().sndEngine, "fastinvader1.wav")); // pColPair.Attach(new SndObserver(sndEngine, "fastinvader1.wav")); //bomb vs shield pColPair = ColPairMan.Add(ColPair.Name.Bomb_Shield, pBombRoot, pShieldRoot); pColPair.Attach(new RemoveBrickObserver(pSpriteBatchMan)); pColPair.Attach(new RemoveBombObserver(pSpriteBatchMan)); //pColPair.Attach(new SndObserver(SpaceInvaders.GetInstance().sndEngine, "fastinvader1.wav")); //alien vs wall pColPair = ColPairMan.Add(ColPair.Name.Aleins_Wall, pAlienRoot, pWallGroup); pColPair.Attach(new GridObserver()); //UFO vs wall pColPair = ColPairMan.Add(ColPair.Name.UFO_Wall, pUFOGroup, pWallGroup); pColPair.Attach(new RemoveUFOObserver(pSpriteBatchMan)); //Aliens vs missile pColPair = ColPairMan.Add(ColPair.Name.Aliens_Missiles, pAlienRoot, pMissileGroup); //pColPair.Attach(new RemoveAlienObserver()); pColPair.Attach(new RemoveMissileObserver(pSpriteBatchMan)); pColPair.Attach(new ShipReadyObserver()); pColPair.Attach(new SndObserver(SpaceInvaders.GetInstance().sndEngine, "shoot.wav")); pColPair.Attach(new SwitchToSplashObserver(GameSprite.Name.Splash, pSpriteBatchMan)); pColPair.Attach(new AddScoreObserver()); //missile vs UFO pColPair = ColPairMan.Add(ColPair.Name.Missiles_UFOs, pMissileGroup, pUFOGroup); pColPair.Attach(new SndObserver(SpaceInvaders.GetInstance().sndEngine, "shoot.wav")); pColPair.Attach(new SwitchToSplashObserver(GameSprite.Name.Splash, pSpriteBatchMan)); pColPair.Attach(new RemoveMissileObserver(pSpriteBatchMan)); pColPair.Attach(new ShipReadyObserver()); pColPair.Attach(new AddScoreObserver()); //missile vs bomb pColPair = ColPairMan.Add(ColPair.Name.Bombs_Missiles, pBombRoot, pMissileGroup); pColPair.Attach(new SndObserver(SpaceInvaders.GetInstance().sndEngine, "shoot.wav")); pColPair.Attach(new SwitchToSplashObserver(GameSprite.Name.Splash, pSpriteBatchMan)); pColPair.Attach(new RemoveMissileObserver(pSpriteBatchMan)); pColPair.Attach(new ShipReadyObserver()); ////aliengrid vs brickshields //pColPair = ColPairMan.Add(ColPair.Name.Aliens_Shields, pAlienRoot, pShieldRoot); //pColPair.Attach(new RemoveShieldsObserver()); }
public override void load() { Unit.level1(); AlienFactory alienFactory = FactoryManager.getAlienFactry(); AlienGrid alienGrid = (AlienGrid)alienFactory.cPCSTree.getRoot(); alienGrid.updateDelta(); PCSTree pcsTree = FactoryManager.getAlienFactry().cPCSTree; SpriteBatch cSpriteBatch = alienFactory.cSpriteBatch; for (int i = 0; i < 6; i++) { FactoryManager.getAlienFactry().setParent(alienGrid); Alien pColumn = (Alien)GhostManager.find(GameObject.GameObjectName.Column); GhostManager.remove(pColumn); pColumn.set(Sprite.SpriteName.NullObject, i + 1, 0, 0); alienFactory.activate(pColumn); alienFactory.setParent(pColumn); float x = Unit.alienPosX; float y = Unit.alienPosY; Alien alien = (Alien)GhostManager.find(GameObject.GameObjectName.Crab); GhostManager.remove(alien); alien.set(Sprite.SpriteName.Crab, i + 2, x + i * 60.0f, y); alienFactory.activate(alien); Alien alien2 = (Alien)GhostManager.find(GameObject.GameObjectName.Squid); GhostManager.remove(alien2); alien2.set(Sprite.SpriteName.Squid, i + 2, x + i * 60.0f, y - 60); alienFactory.activate(alien2); Alien alien3 = (Alien)GhostManager.find(GameObject.GameObjectName.Squid); GhostManager.remove(alien3); alien3.set(Sprite.SpriteName.Squid, i + 2, x + i * 60.0f, y - 120); alienFactory.activate(alien3); Alien alien4 = (Alien)GhostManager.find(GameObject.GameObjectName.Octopus); GhostManager.remove(alien4); alien4.set(Sprite.SpriteName.Octopus, i + 2, x + i * 60.0f, y - 180); alienFactory.activate(alien4); Alien alien5 = (Alien)GhostManager.find(GameObject.GameObjectName.Octopus); GhostManager.remove(alien5); alien5.set(Sprite.SpriteName.Octopus, i + 6, x + i * 60.0f, y - 240); alienFactory.activate(alien5); } ShipFactory shipFactory = FactoryManager.getShipFactry(); ShipRoot shipGrid = (ShipRoot)shipFactory.cPCSTree.getRoot(); CannonShip Ship = Ship = (CannonShip)GhostManager.find(GameObject.GameObjectName.CannonShip); GhostManager.remove(Ship); shipFactory.activate(Ship); Ship.x = Unit.shipPosX; Ship.y = Unit.shipPosY; Ship = (CannonShip)GhostManager.find(GameObject.GameObjectName.CannonShip); GhostManager.remove(Ship); shipFactory.activate(Ship); Ship.x = 40; Ship.y = 30; Ship = (CannonShip)GhostManager.find(GameObject.GameObjectName.CannonShip); GhostManager.remove(Ship); shipFactory.activate(Ship); Ship.x = 110; Ship.y = 30; //42 brics //7 col //4 bricks ShieldFactory shieldFactory = FactoryManager.getShieldFactry(); ShieldGrid shieldGrid = (ShieldGrid)shieldFactory.cPCSTree.getRoot(); shieldFactory.setParent(shieldGrid); for (int x = 0; x < 8; x = x + 2) { shieldFactory.setParent(shieldGrid); Shield shieldUnit = shieldFactory.createShield(Shield.ShieldType.ShieldUnit, GameObject.GameObjectName.ShieldUnit); shieldFactory.setParent(shieldUnit); Shield pColumn; pColumn = shieldFactory.createShield(Shield.ShieldType.ShieldColumn, GameObject.GameObjectName.ShieldColumn, 0); shieldFactory.setParent(pColumn); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (60 + (x * 100)), 150); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (60 + (x * 100)), 140); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (60 + (x * 100)), 130); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (60 + (x * 100)), 120); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (60 + (x * 100)), 110); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (60 + (x * 100)), 100); shieldFactory.setParent(shieldUnit); pColumn = shieldFactory.createShield(Shield.ShieldType.ShieldColumn, GameObject.GameObjectName.Column, 0); shieldFactory.setParent(pColumn); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (70 + (x * 100)), 160); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (70 + (x * 100)), 150); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (70 + (x * 100)), 140); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (70 + (x * 100)), 130); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (70 + (x * 100)), 120); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (70 + (x * 100)), 110); shieldFactory.setParent(shieldUnit); pColumn = shieldFactory.createShield(Shield.ShieldType.ShieldColumn, GameObject.GameObjectName.Column, 0); shieldFactory.setParent(pColumn); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (80 + (x * 100)), 170); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (80 + (x * 100)), 160); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (80 + (x * 100)), 150); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (80 + (x * 100)), 140); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (80 + (x * 100)), 130); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (80 + (x * 100)), 120); shieldFactory.setParent(shieldUnit); pColumn = shieldFactory.createShield(Shield.ShieldType.ShieldColumn, GameObject.GameObjectName.Column, 0); shieldFactory.setParent(pColumn); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (90 + (x * 100)), 170); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (90 + (x * 100)), 160); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (90 + (x * 100)), 150); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (90 + (x * 100)), 140); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (90 + (x * 100)), 130); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (90 + (x * 100)), 120); shieldFactory.setParent(shieldUnit); pColumn = shieldFactory.createShield(Shield.ShieldType.ShieldColumn, GameObject.GameObjectName.Column, 0); shieldFactory.setParent(pColumn); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (100 + (x * 100)), 170); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (100 + (x * 100)), 160); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (100 + (x * 100)), 150); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (100 + (x * 100)), 140); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (100 + (x * 100)), 130); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (100 + (x * 100)), 120); shieldFactory.setParent(shieldUnit); pColumn = shieldFactory.createShield(Shield.ShieldType.ShieldColumn, GameObject.GameObjectName.Column, 0); shieldFactory.setParent(pColumn); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (110 + (x * 100)), 160); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (110 + (x * 100)), 150); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (110 + (x * 100)), 140); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (110 + (x * 100)), 130); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (110 + (x * 100)), 120); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (110 + (x * 100)), 110); shieldFactory.setParent(shieldUnit); pColumn = shieldFactory.createShield(Shield.ShieldType.ShieldColumn, GameObject.GameObjectName.ShieldColumn, 0); shieldFactory.setParent(pColumn); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (120 + (x * 100)), 150); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (120 + (x * 100)), 140); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (120 + (x * 100)), 130); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (120 + (x * 100)), 120); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (120 + (x * 100)), 110); shieldFactory.createShield(Shield.ShieldType.ShieldBrick, GameObject.GameObjectName.ShieldBrick, 0, (120 + (x * 100)), 100); } }
public override void loadContent(Scene pScene) { ManagerFactory managerFactory = new ManagerFactory(); //--------------------------------------------------------------------------------------------------------- // Create SpriteBatch //--------------------------------------------------------------------------------------------------------- SpriteBatch pSB_Box = SpriteBatchMan.Add(SpriteBatch.Name.Boxes); SpriteBatch pSB_ShieldBoxes = SpriteBatchMan.Add(SpriteBatch.Name.ShieldBoxes); SpriteBatchMan.Add(SpriteBatch.Name.Aliens); SpriteBatchMan.Add(SpriteBatch.Name.Walls); SpriteBatchMan.Add(SpriteBatch.Name.Bumps); SpriteBatch pSB_Ship = SpriteBatchMan.Add(SpriteBatch.Name.Ships); SpriteBatch pSB_Missile = SpriteBatchMan.Add(SpriteBatch.Name.Missiles); SpriteBatch pSB_Shield = SpriteBatchMan.Add(SpriteBatch.Name.Shields); SpriteBatch pSB_Bomb = SpriteBatchMan.Add(SpriteBatch.Name.Bombs); SpriteBatchMan.Add(SpriteBatch.Name.PlainTexts); SpriteBatch pSB_Life = SpriteBatchMan.Add(SpriteBatch.Name.Lifes); SpriteBatch pSB_Explosion = SpriteBatchMan.Add(SpriteBatch.Name.Explosions); SpriteBatch pSB_UFO = SpriteBatchMan.Add(SpriteBatch.Name.UFO); //--------------------------------------------------------------------------------------------------------- // Set Input //--------------------------------------------------------------------------------------------------------- InputSubject pInputSubject; pInputSubject = InputMan.GetArrowLeftSubject(); pInputSubject.attach(new MoveLeftObserver()); pInputSubject = InputMan.GetArrowRightSubject(); pInputSubject.attach(new MoveRightObserver()); pInputSubject = InputMan.GetSpaceSubject(); pInputSubject.attach(new ShootObserver()); pInputSubject = InputMan.GetTSubject(); pInputSubject.attach(new ToggleBoxObserver()); //--------------------------------------------------------------------------------------------------------- // Create Ship //--------------------------------------------------------------------------------------------------------- // create ship life group ShipLifeGroup pShipLifeGroup = new ShipLifeGroup(GameObject.Name.ShipLifeGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pShipLifeGroup.activateGameSprite(pSB_Life); pShipLifeGroup.activateCollisionSprite(pSB_Box); GameObjectMan.Attach(pShipLifeGroup); ShipGroup pShipGroup = new ShipGroup(GameObject.Name.ShipGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pShipGroup.activateGameSprite(pSB_Ship); pShipGroup.activateCollisionSprite(pSB_Box); GameObjectMan.Attach(pShipGroup); ShipMan.CreateShipLifes(); //--------------------------------------------------------------------------------------------------------- // Create UFO //--------------------------------------------------------------------------------------------------------- UFORoot pUFORoot = new UFORoot(GameObject.Name.UFORoot, GameSprite.Name.NullObject, 0.0f, 0.0f); UFORoot pUFOGroup = new UFORoot(GameObject.Name.UFORoot, GameSprite.Name.NullObject, 0.0f, 0.0f); pUFORoot.activateGameSprite(pSB_UFO); pUFORoot.activateCollisionSprite(pSB_Box); pUFOGroup.add(pUFORoot); GameObjectMan.Attach(pUFOGroup); //managerFactory.create(Manager.Name.UFOMan); //--------------------------------------------------------------------------------------------------------- // Create Missile //--------------------------------------------------------------------------------------------------------- MissileGroup pMissileGroup = new MissileGroup(GameObject.Name.MissileGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pMissileGroup.activateGameSprite(pSB_Missile); pMissileGroup.activateCollisionSprite(pSB_Box); GameObjectMan.Attach(pMissileGroup); //--------------------------------------------------------------------------------------------------------- // Create Bombs //--------------------------------------------------------------------------------------------------------- BombRoot pBombRoot = new BombRoot(GameObject.Name.BombGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pBombRoot.activateGameSprite(pSB_Bomb); pBombRoot.activateCollisionSprite(pSB_Box); GameObjectMan.Attach(pBombRoot); //managerFactory.create(Manager.Name.BombMan); //--------------------------------------------------------------------------------------------------------- // Create walls //--------------------------------------------------------------------------------------------------------- WallFactory wallFactory = new WallFactory(SpriteBatch.Name.Walls, SpriteBatch.Name.Boxes); GameObject pWallGroup = wallFactory.create(GameObject.Name.WallGroup, WallCategory.Type.WallGroup); pWallGroup.add(wallFactory.create(GameObject.Name.WallLeft, WallCategory.Type.Left, 5, 511, 10, 912)); pWallGroup.add(wallFactory.create(GameObject.Name.WallRight, WallCategory.Type.Right, 891, 511, 10, 912)); pWallGroup.add(wallFactory.create(GameObject.Name.WallTop, WallCategory.Type.Top, 448, 993, 896, 50)); pWallGroup.add(wallFactory.create(GameObject.Name.WallBottom, WallCategory.Type.Bottom, 448, 30, 896, 50)); GameObjectMan.Attach(pWallGroup); //--------------------------------------------------------------------------------------------------------- // Create bumps //--------------------------------------------------------------------------------------------------------- BumpFactory bumpFactory = new BumpFactory(SpriteBatch.Name.Bumps, SpriteBatch.Name.Boxes); GameObject pBumpGroup = bumpFactory.create(GameObject.Name.BumpGroup, BumpCategory.Type.BumpGroup); pBumpGroup.add(bumpFactory.create(GameObject.Name.BumpLeft, BumpCategory.Type.Left, 10, 90, 25, 60)); pBumpGroup.add(bumpFactory.create(GameObject.Name.BumpRight, BumpCategory.Type.Right, 886, 90, 25, 60)); GameObjectMan.Attach(pBumpGroup); //--------------------------------------------------------------------------------------------------------- // Create Aliens //--------------------------------------------------------------------------------------------------------- //managerFactory.create(Manager.Name.AlienMan); AlienFactory alienFactory = new AlienFactory(SpriteBatch.Name.Aliens, SpriteBatch.Name.Boxes); // create alien groups AlienGroup pAlienGroup = (AlienGroup)alienFactory.create(GameObject.Name.AlienGroup, AlienCategory.Type.Group); pAlienGroup.nextLevel(); AlienGroup pAlienRoot = new AlienGroup(GameObject.Name.AlienGroup, GameSprite.Name.NullObject, 0.0f, 0.0f);; pAlienRoot.add(pAlienGroup); GameObjectMan.Attach(pAlienRoot); //--------------------------------------------------------------------------------------------------------- // create Shield //--------------------------------------------------------------------------------------------------------- ShieldFactory SF = new ShieldFactory(SpriteBatch.Name.Shields, SpriteBatch.Name.ShieldBoxes); ShieldRoot pShieldGroup = (ShieldRoot)SF.Create(ShieldCategory.Type.Root, GameObject.Name.ShieldRoot, 0.0f, 0.0f); pShieldGroup.storeShield(); ShieldRoot pShieldRoot = new ShieldRoot(GameObject.Name.ShieldRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); pShieldRoot.add(pShieldGroup); GameObjectMan.Attach(pShieldRoot); //--------------------------------------------------------------------------------------------------------- // Create explosion group //--------------------------------------------------------------------------------------------------------- ExplosionGroup pExplosionGroup = new ExplosionGroup(GameObject.Name.ExplosionGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pExplosionGroup.activateGameSprite(pSB_Explosion); pExplosionGroup.activateCollisionSprite(pSB_Box); GameObjectMan.Attach(pExplosionGroup); //--------------------------------------------------------------------------------------------------------- // Attach sprites to Sprite Batch //--------------------------------------------------------------------------------------------------------- //pSB_Boxes.attach(BoxSprite.Name.Box1); // Create animation sprites AnimationSprite pAnimOctopus = new AnimationSprite(GameSprite.Name.Octopus); pAnimOctopus.attach(Image.Name.OctopusMovement); pAnimOctopus.attach(Image.Name.Octopus); pAnimOctopus.attach("fastinvader1.wav"); pAnimOctopus.attach("fastinvader2.wav"); pAnimOctopus.attach("fastinvader3.wav"); pAnimOctopus.attach("fastinvader4.wav"); TimerMan.Add(TimeEvent.Name.OctopusAnimation, pAnimOctopus, 0.75f); AnimationSprite pAnimCrab = new AnimationSprite(GameSprite.Name.Crab); pAnimCrab.attach(Image.Name.CrabMovement); pAnimCrab.attach(Image.Name.Crab); pAnimCrab.attach("fastinvader1.wav"); pAnimCrab.attach("fastinvader2.wav"); pAnimCrab.attach("fastinvader3.wav"); pAnimCrab.attach("fastinvader4.wav"); TimerMan.Add(TimeEvent.Name.CrabAnimation, pAnimCrab, 0.75f); AnimationSprite pAminSquid = new AnimationSprite(GameSprite.Name.Squid); pAminSquid.attach(Image.Name.SquidMovement); pAminSquid.attach(Image.Name.Squid); pAminSquid.attach("fastinvader1.wav"); pAminSquid.attach("fastinvader2.wav"); pAminSquid.attach("fastinvader3.wav"); pAminSquid.attach("fastinvader4.wav"); TimerMan.Add(TimeEvent.Name.SquidAnimation, pAminSquid, 0.75f); // Create Movement sprite MovementSprite pMovementSprite = new MovementSprite(pAlienGroup); TimerMan.Add(TimeEvent.Name.MovementAnimation, pMovementSprite, 0.5f); // Create drop bomb sprite DropBomb pDropBomb = new DropBomb(pAlienGroup); TimerMan.Add(TimeEvent.Name.DropBombAnination, pDropBomb, 1.5f); // Create UFOEvent sprite UFOEvent pUFOEvent = new UFOEvent(); TimerMan.Add(TimeEvent.Name.MovementAnimation, pUFOEvent, UFOMan.getDeltaTime()); //--------------------------------------------------------------------------------------------------------- // Collision Pair //--------------------------------------------------------------------------------------------------------- CollisionPair pColPair = CollisionPairMan.Add(CollisionPair.Name.Alien_Missile, pMissileGroup, pAlienGroup); Debug.Assert(pColPair != null); pColPair.attach(new RemoveAlienObserver()); pColPair.attach(new PlaySoundObserver("invaderkilled.wav")); pColPair.attach(new AlienNumObserver(pAlienGroup, pShieldGroup)); pColPair.attach(new RemoveMissileObserver()); pColPair.attach(new ShipReadyObserver()); pColPair = CollisionPairMan.Add(CollisionPair.Name.Missile_Wall, pMissileGroup, pWallGroup); Debug.Assert(pColPair != null); pColPair.attach(new RemoveMissileObserver()); pColPair.attach(new ShipReadyObserver()); pColPair = CollisionPairMan.Add(CollisionPair.Name.Alien_Wall, pAlienGroup, pWallGroup); Debug.Assert(pColPair != null); pColPair.attach(new AlienGroupObserver()); pColPair = CollisionPairMan.Add(CollisionPair.Name.Ship_Bump, pBumpGroup, pShipGroup); Debug.Assert(pColPair != null); pColPair.attach(new ShipPositionObserver()); pColPair = CollisionPairMan.Add(CollisionPair.Name.Missile_Shield, pMissileGroup, pShieldRoot); Debug.Assert(pColPair != null); pColPair.attach(new RemoveShieldObserver(GameObject.Name.Missile)); pColPair.attach(new PlaySoundObserver("invaderkilled.wav")); pColPair.attach(new RemoveMissileObserver()); pColPair.attach(new ShipReadyObserver()); pColPair = CollisionPairMan.Add(CollisionPair.Name.Bomb_Shield, pBombRoot, pShieldRoot); Debug.Assert(pColPair != null); pColPair.attach(new RemoveShieldObserver(GameObject.Name.Bomb)); pColPair.attach(new PlaySoundObserver("invaderkilled.wav")); pColPair.attach(new RemoveBombObserver()); pColPair.attach(new AlienReadyObserver()); pColPair = CollisionPairMan.Add(CollisionPair.Name.Bomb_Wall, pBombRoot, pWallGroup); Debug.Assert(pColPair != null); pColPair.attach(new RemoveBombObserver()); pColPair.attach(new AlienReadyObserver()); pColPair = CollisionPairMan.Add(CollisionPair.Name.Bomb_Missile, pBombRoot, pMissileGroup); Debug.Assert(pColPair != null); pColPair.attach(new BombExplosionObsever()); pColPair.attach(new AlienReadyObserver()); pColPair.attach(new RemoveMissileObserver()); pColPair.attach(new ShipReadyObserver()); pColPair = CollisionPairMan.Add(CollisionPair.Name.Bomb_Ship, pShipGroup, pBombRoot); Debug.Assert(pColPair != null); pColPair.attach(new RemoveBombObserver()); pColPair.attach(new AlienReadyObserver()); pColPair.attach(new RemoveShipObserver()); pColPair.attach(new PlaySoundObserver("explosion.wav")); pColPair = CollisionPairMan.Add(CollisionPair.Name.UFO_Wall, pWallGroup, pUFORoot); Debug.Assert(pColPair != null); pColPair.attach(new RemoveUFOObserver()); pColPair = CollisionPairMan.Add(CollisionPair.Name.UFO_Missile, pMissileGroup, pUFORoot); Debug.Assert(pColPair != null); pColPair.attach(new RemoveMissileObserver()); pColPair.attach(new ShipReadyObserver()); pColPair.attach(new UFOExplosionObserver()); pColPair.attach(new PlaySoundObserver("explosion.wav")); //--------------------------------------------------------------------------------------------------------- // Font //--------------------------------------------------------------------------------------------------------- FontMan.Add(Font.Name.Texts, SpriteBatch.Name.PlainTexts, "SCORE<1>", Glyph.Name.Consolas36pt, 20, 1000); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.PlainTexts, "HI-SCORE", Glyph.Name.Consolas36pt, 370, 1000); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.PlainTexts, "SCORE<2>", Glyph.Name.Consolas36pt, 700, 1000); FontMan.Add(Font.Name.ScoreOne, SpriteBatch.Name.PlainTexts, pScene.getScoreOne().ToString("D4"), Glyph.Name.Consolas36pt, 50, 960); FontMan.Add(Font.Name.HighestScore, SpriteBatch.Name.PlainTexts, pScene.getHighestScore().ToString("D4"), Glyph.Name.Consolas36pt, 400, 960); FontMan.Add(Font.Name.ScoreTwo, SpriteBatch.Name.PlainTexts, pScene.getScoreTwo().ToString("D4"), Glyph.Name.Consolas36pt, 730, 960); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.PlainTexts, "CREDIT", Glyph.Name.Consolas36pt, 700, 25); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.PlainTexts, "00", Glyph.Name.Consolas36pt, 830, 25); }
public void storeShield() { ShieldFactory SF = new ShieldFactory(SpriteBatch.Name.Shields, SpriteBatch.Name.ShieldBoxes); GameObject pShieldGrid; GameObject pShieldColumn; float start_x = 60.0f; float start_y = 200.0f; float off_x = 0; float gap = 180.0f; float brickWidth = 10.0f; float brickHeight = 5.0f; // load by column for (int i = 0; i < 4; i++) { int j = 0; pShieldGrid = SF.Create(ShieldCategory.Type.Grid, GameObject.Name.ShieldGrid); // column 0 pShieldColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.LeftTop1, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.LeftTop0, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight)); pShieldGrid.add(pShieldColumn); // column 1 pShieldColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++); off_x += brickWidth; pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight)); pShieldGrid.add(pShieldColumn); // column 2 pShieldColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++); off_x += brickWidth; pShieldColumn.add(SF.Create(ShieldCategory.Type.LeftBottom, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight)); pShieldGrid.add(pShieldColumn); // column 3 pShieldColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++); off_x += brickWidth; pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight)); pShieldGrid.add(pShieldColumn); // column 4 pShieldColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++); off_x += brickWidth; pShieldColumn.add(SF.Create(ShieldCategory.Type.RightBottom, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight)); pShieldGrid.add(pShieldColumn); // column 5 pShieldColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++); off_x += brickWidth; pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 0 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 1 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight)); pShieldGrid.add(pShieldColumn); // column 6 pShieldColumn = SF.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++); off_x += brickWidth; pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 0 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 1 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.RightTop1, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight)); pShieldColumn.add(SF.Create(ShieldCategory.Type.RightTop0, GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight)); pShieldGrid.add(pShieldColumn); // add grid to root this.add(pShieldGrid); off_x += gap; } }
public override void Initialize() { Random pRandom = new Random(); //--------------------------------------------------------------------------------------------------------- // Images //--------------------------------------------------------------------------------------------------------- ImageMan.Add(Image.Name.BlueAlien, Texture.Name.Aliens, new Azul.Rect(341, 337, 65, 64)); ImageMan.Add(Image.Name.BlueAlien2, Texture.Name.Aliens, new Azul.Rect(464, 65, 64, 63)); ImageMan.Add(Image.Name.GreenAlien, Texture.Name.Aliens, new Azul.Rect(27, 337, 79, 64)); ImageMan.Add(Image.Name.GreenAlien2, Texture.Name.Aliens, new Azul.Rect(253, 64, 84, 65)); ImageMan.Add(Image.Name.RedAlien, Texture.Name.Aliens, new Azul.Rect(647, 200, 72, 65)); ImageMan.Add(Image.Name.RedAlien2, Texture.Name.Aliens, new Azul.Rect(26, 201, 94, 65)); ImageMan.Add(Image.Name.Explosion, Texture.Name.Aliens, new Azul.Rect(488, 488, 75, 48)); ImageMan.Add(Image.Name.Explosion_Ground, Texture.Name.Aliens, new Azul.Rect(328, 489, 84, 48)); ImageMan.Add(Image.Name.UFO, Texture.Name.Aliens, new Azul.Rect(120, 489, 98, 49)); ImageMan.Add(Image.Name.Missile, Texture.Name.Aliens, new Azul.Rect(267, 501, 9, 34)); ImageMan.Add(Image.Name.Ship, Texture.Name.Birds2, new Azul.Rect(9, 92, 31, 19)); ImageMan.Add(Image.Name.Wall, Texture.Name.Birds, new Azul.Rect(40, 185, 20, 10)); ImageMan.Add(Image.Name.WallBottom, Texture.Name.Birds, new Azul.Rect(40, 185, 20, 1)); ImageMan.Add(Image.Name.BombStraight, Texture.Name.Birds, new Azul.Rect(110, 100, 7, 49)); ImageMan.Add(Image.Name.BombZigZag, Texture.Name.Birds, new Azul.Rect(132, 100, 20, 50)); ImageMan.Add(Image.Name.BombCross, Texture.Name.Birds, new Azul.Rect(219, 103, 19, 47)); ImageMan.Add(Image.Name.Brick, Texture.Name.Birds, new Azul.Rect(20, 210, 10, 5)); ImageMan.Add(Image.Name.BrickLeft_Top0, Texture.Name.Birds, new Azul.Rect(15, 180, 10, 5)); ImageMan.Add(Image.Name.BrickLeft_Top1, Texture.Name.Birds, new Azul.Rect(15, 185, 10, 5)); ImageMan.Add(Image.Name.BrickLeft_Bottom, Texture.Name.Birds, new Azul.Rect(35, 215, 10, 5)); ImageMan.Add(Image.Name.BrickRight_Top0, Texture.Name.Birds, new Azul.Rect(75, 180, 10, 5)); ImageMan.Add(Image.Name.BrickRight_Top1, Texture.Name.Birds, new Azul.Rect(75, 185, 10, 5)); ImageMan.Add(Image.Name.BrickRight_Bottom, Texture.Name.Birds, new Azul.Rect(55, 215, 10, 5)); //--------------------------------------------------------------------------------------------------------- // Game Sprites //--------------------------------------------------------------------------------------------------------- GameSpriteMan.Add(GameSprite.Name.BlueAlien, Image.Name.BlueAlien, 100, 150, 30, 30); GameSpriteMan.Add(GameSprite.Name.RedAlien, Image.Name.RedAlien, 200, 150, 30, 30); GameSpriteMan.Add(GameSprite.Name.GreenAlien, Image.Name.GreenAlien, 300, 150, 30, 30); GameSpriteMan.Add(GameSprite.Name.UFO, Image.Name.UFO, 120, 489, 70, 25); GameSpriteMan.Add(GameSprite.Name.Explosion_Ground, Image.Name.Explosion_Ground, 328, 489, 30, 20); GameSpriteMan.Add(GameSprite.Name.Explosion, Image.Name.Explosion, 120, 489, 30, 20); GameSpriteMan.Add(GameSprite.Name.Missile, Image.Name.Missile, -100, -100, 3, 12); GameSpriteMan.Add(GameSprite.Name.Ship, Image.Name.Ship, 500, 100, 50, 20); GameSpriteMan.Add(GameSprite.Name.ShipInactive, Image.Name.Ship, 500, 100, 50, 20); GameSpriteMan.Add(GameSprite.Name.Wall, Image.Name.Wall, 448, 900, 850, 30); GameSpriteMan.Add(GameSprite.Name.WallBottom, Image.Name.WallBottom, 448, 900, 850, 1); GameSpriteMan.Add(GameSprite.Name.BombZigZag, Image.Name.BombZigZag, 200, 200, 8, 25); GameSpriteMan.Add(GameSprite.Name.BombStraight, Image.Name.BombStraight, 110, 100, 8, 25); GameSpriteMan.Add(GameSprite.Name.BombDagger, Image.Name.BombCross, 100, 100, 8, 25); GameSpriteMan.Add(GameSprite.Name.Brick, Image.Name.Brick, 50, 25, 10, 5); GameSpriteMan.Add(GameSprite.Name.Brick_LeftTop0, Image.Name.BrickLeft_Top0, 50, 25, 10, 5); GameSpriteMan.Add(GameSprite.Name.Brick_LeftTop1, Image.Name.BrickLeft_Top1, 50, 25, 10, 5); GameSpriteMan.Add(GameSprite.Name.Brick_LeftBottom, Image.Name.BrickLeft_Bottom, 50, 25, 10, 5); GameSpriteMan.Add(GameSprite.Name.Brick_RightTop0, Image.Name.BrickRight_Top0, 50, 25, 10, 5); GameSpriteMan.Add(GameSprite.Name.Brick_RightTop1, Image.Name.BrickRight_Top1, 50, 25, 10, 5); GameSpriteMan.Add(GameSprite.Name.Brick_RightBottom, Image.Name.BrickRight_Bottom, 50, 25, 10, 5); BoxSpriteMan.Add(BoxSprite.Name.Box1, 550.0f, 500.0f, 50.0f, 150.0f, new Azul.Color(1.0f, 1.0f, 1.0f, 1.0f)); BoxSpriteMan.Add(BoxSprite.Name.Box2, 550.0f, 100.0f, 50.0f, 100.0f); this.poSpriteBatchMan = new SpriteBatchMan(3, 1); SpriteBatchMan.SetActive(this.poSpriteBatchMan); this.poGameObjectMan = new GameObjectMan(10, 2); GameObjectMan.SetActive(this.poGameObjectMan); this.poInputMan = new InputMan(); InputMan.SetActive(this.poInputMan); this.poTimerMan = new TimerMan(); TimerMan.SetActive(this.poTimerMan); //--------------------------------------------------------------------------------------------------------- // SpriteBatches //--------------------------------------------------------------------------------------------------------- SpriteBatch pSB_Box = SpriteBatchMan.Add(SpriteBatch.Name.Boxes, 100, false); SpriteBatch pSB_Texts = SpriteBatchMan.Add(SpriteBatch.Name.Texts, 100, true); SpriteBatch pSB_Shields = SpriteBatchMan.Add(SpriteBatch.Name.Shields, 100, true); SpriteBatch pSB_Aliens = SpriteBatchMan.Add(SpriteBatch.Name.Aliens, 100, true); SpriteBatch pSB_Bombs = SpriteBatchMan.Add(SpriteBatch.Name.Bombs, 100, true); //--------------------------------------------------------------------------------------------------------- // Ship //--------------------------------------------------------------------------------------------------------- ShipRoot pShipRoot = new ShipRoot(GameObject.Name.ShipRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); GameObjectMan.Attach(pShipRoot); Ship pShip = ShipMan.CreateShip(); //--------------------------------------------------------------------------------------------------------- // Player //--------------------------------------------------------------------------------------------------------- Player pPlayer = PlayerMan.GetCurrentPlayer(pShip); pShip.SetPlayer(pPlayer); //--------------------------------------------------------------------------------------------------------- // Aliens //--------------------------------------------------------------------------------------------------------- AlienFactory aF = new AlienFactory(SpriteBatch.Name.Aliens, SpriteBatch.Name.Boxes); // Do this somewhere else .. int yPos = 475; if (pPlayer.nCurrLevel == 2) { yPos -= 40; } AlienGrid pGrid = aF.CreateGrid(200, yPos); float pGridDelta = 0.2f; if (pPlayer.nCurrLevel == 2) { pGridDelta = 0.3f; } //--------------------------------------------------------------------------------------------------------- // Missile //--------------------------------------------------------------------------------------------------------- MissileGroup pMissileGroup = new MissileGroup(GameObject.Name.MissileGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pMissileGroup.ActivateGameSprite(pSB_Aliens); GameObjectMan.Attach(pMissileGroup); //--------------------------------------------------------------------------------------------------------- // Bomb //--------------------------------------------------------------------------------------------------------- BombRoot pBombRoot = new BombRoot(GameObject.Name.BombRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); pBombRoot.ActivateCollisionSprite(pSB_Box); pBombRoot.ActivateGameSprite(pSB_Bombs); GameObjectMan.Attach(pBombRoot); //--------------------------------------------------------------------------------------------------------- // Input //--------------------------------------------------------------------------------------------------------- InputSubject pInputSubject; pInputSubject = InputMan.GetArrowRightSubject(); pInputSubject.Attach(new MoveRightObserver(pShip)); pInputSubject = InputMan.GetArrowLeftSubject(); pInputSubject.Attach(new MoveLeftObserver(pShip)); pInputSubject = InputMan.GetSpaceSubject(); pInputSubject.Attach(new ShootObserver(pShip)); pInputSubject = InputMan.GetPeriodSubject(); pInputSubject.Attach(new ToggleRenderBoxSpriteObserver()); pInputSubject = InputMan.GetCommaSubject(); pInputSubject.Attach(new ToggleShieldBricksObserver()); //--------------------------------------------------------------------------------------------------------- // Walls //--------------------------------------------------------------------------------------------------------- WallGroup pWallGroup = new WallGroup(GameObject.Name.WallGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pWallGroup.ActivateGameSprite(pSB_Aliens); WallTop pWallTop = new WallTop(GameObject.Name.WallTop, GameSprite.Name.Wall, 400, 750, 700, 15); pWallTop.ActivateCollisionSprite(pSB_Aliens); WallBottom pWallBottom = new WallBottom(GameObject.Name.WallBottom, GameSprite.Name.WallBottom, 400, 30, 850, 1); pWallBottom.ActivateCollisionSprite(pSB_Box); pWallBottom.ActivateGameSprite(pSB_Aliens); WallLeft pWallLeft = new WallLeft(GameObject.Name.WallLeft, GameSprite.Name.Wall, 0, 300, 15, 600); pWallLeft.ActivateCollisionSprite(pSB_Box); WallRight pWallRight = new WallRight(GameObject.Name.WallRight, GameSprite.Name.Wall, 800, 300, 15, 600); pWallRight.ActivateCollisionSprite(pSB_Box); pWallGroup.Add(pWallTop); pWallGroup.Add(pWallBottom); pWallGroup.Add(pWallRight); pWallGroup.Add(pWallLeft); GameObjectMan.Attach(pWallGroup); //--------------------------------------------------------------------------------------------------------- // Shield //--------------------------------------------------------------------------------------------------------- ShieldFactory SF = new ShieldFactory(SpriteBatch.Name.Shields, SpriteBatch.Name.Boxes, GameObject.Name.ShieldRoot1); Composite pShieldRoot1 = SF.CreateShield(50.0f, 100.0f); GameObjectMan.Attach(pShieldRoot1); SF = new ShieldFactory(SpriteBatch.Name.Shields, SpriteBatch.Name.Boxes, GameObject.Name.ShieldRoot2); Composite pShieldRoot2 = SF.CreateShield(200.0f, 100.0f); GameObjectMan.Attach(pShieldRoot2); SF = new ShieldFactory(SpriteBatch.Name.Shields, SpriteBatch.Name.Boxes, GameObject.Name.ShieldRoot3); Composite pShieldRoot3 = SF.CreateShield(500.0f, 100.0f); GameObjectMan.Attach(pShieldRoot3); SF = new ShieldFactory(SpriteBatch.Name.Shields, SpriteBatch.Name.Boxes, GameObject.Name.ShieldRoot4); Composite pShieldRoot4 = SF.CreateShield(650.0f, 100.0f); GameObjectMan.Attach(pShieldRoot4); //--------------------------------------------------------------------------------------------------------- // Collision Observers //--------------------------------------------------------------------------------------------------------- ColPair pColPair; // Missile vs Wall pColPair = ColPairMan.Add(ColPair.Name.Missile_Wall, pMissileGroup, pWallGroup); pColPair.Attach(new RemoveMissileObserver()); pColPair.Attach(new ShipReadyObserver(pShip)); // Bomb vs Bottom pColPair = ColPairMan.Add(ColPair.Name.Bomb_Wall, pBombRoot, pWallGroup); pColPair.Attach(new RemoveBombObserver()); // Bomb vs Missile pColPair = ColPairMan.Add(ColPair.Name.Bomb_Missile, pBombRoot, pMissileGroup); pColPair.Attach(new RemoveMissileAndBombObserver()); pColPair.Attach(new ShipReadyObserver(pShip)); // Bomb vs Shields pColPair = ColPairMan.Add(ColPair.Name.Bomb_Shield1, pBombRoot, pShieldRoot1); pColPair.Attach(new RemoveBombObserver()); pColPair.Attach(new RemoveBrickObserver()); pColPair = ColPairMan.Add(ColPair.Name.Bomb_Shield2, pBombRoot, pShieldRoot2); pColPair.Attach(new RemoveBombObserver()); pColPair.Attach(new RemoveBrickObserver()); pColPair = ColPairMan.Add(ColPair.Name.Bomb_Shield3, pBombRoot, pShieldRoot3); pColPair.Attach(new RemoveBombObserver()); pColPair.Attach(new RemoveBrickObserver()); pColPair = ColPairMan.Add(ColPair.Name.Bomb_Shield4, pBombRoot, pShieldRoot4); pColPair.Attach(new RemoveBombObserver()); pColPair.Attach(new RemoveBrickObserver()); // Missile vs Shields pColPair = ColPairMan.Add(ColPair.Name.Missile_Shield1, pMissileGroup, pShieldRoot1); pColPair.Attach(new RemoveMissileObserver()); pColPair.Attach(new RemoveBrickObserver()); pColPair.Attach(new ShipReadyObserver(pShip)); pColPair = ColPairMan.Add(ColPair.Name.Missile_Shield2, pMissileGroup, pShieldRoot2); pColPair.Attach(new RemoveMissileObserver()); pColPair.Attach(new RemoveBrickObserver()); pColPair.Attach(new ShipReadyObserver(pShip)); pColPair = ColPairMan.Add(ColPair.Name.Missile_Shield3, pMissileGroup, pShieldRoot3); pColPair.Attach(new RemoveMissileObserver()); pColPair.Attach(new RemoveBrickObserver()); pColPair.Attach(new ShipReadyObserver(pShip)); pColPair = ColPairMan.Add(ColPair.Name.Missile_Shield4, pMissileGroup, pShieldRoot4); pColPair.Attach(new RemoveMissileObserver()); pColPair.Attach(new RemoveBrickObserver()); pColPair.Attach(new ShipReadyObserver(pShip)); // Alien Grid vs Shields pColPair = ColPairMan.Add(ColPair.Name.AlienGrid_Shield1, pGrid, pShieldRoot1); pColPair.Attach(new RemoveBrickObserver()); pColPair = ColPairMan.Add(ColPair.Name.AlienGrid_Shield2, pGrid, pShieldRoot2); pColPair.Attach(new RemoveBrickObserver()); pColPair = ColPairMan.Add(ColPair.Name.AlienGrid_Shield3, pGrid, pShieldRoot3); pColPair.Attach(new RemoveBrickObserver()); pColPair = ColPairMan.Add(ColPair.Name.AlienGrid_Shield4, pGrid, pShieldRoot4); pColPair.Attach(new RemoveBrickObserver()); // Missile vs Alien pColPair = ColPairMan.Add(ColPair.Name.Alien_Missile, pMissileGroup, pGrid); pColPair.Attach(new RemoveMissileObserver()); pColPair.Attach(new RemoveAlienObserver()); pColPair.Attach(new ShipReadyObserver(pShip)); // Alien Grid vs WallLeft pColPair = ColPairMan.Add(ColPair.Name.AlienGrid_WallLeft, pGrid, pWallLeft); pColPair.Attach(new AlienGridWallLeftObserver(pGridDelta)); // Alien Grid vs WallRight pColPair = ColPairMan.Add(ColPair.Name.AlienGrid_WallRight, pGrid, pWallRight); pColPair.Attach(new AlienGridWallRightObserver(pGridDelta)); // Alien Grid vs WallBottom pColPair = ColPairMan.Add(ColPair.Name.AlienGrid_WallBottom, pGrid, pWallBottom); pColPair.Attach(new AlienGridWallBottomObserver()); // Ship vs Bomb pColPair = ColPairMan.Add(ColPair.Name.ShipBomb, pShipRoot, pBombRoot); pColPair.Attach(new BombObserver()); //--------------------------------------------------------------------------------------------------------- // Alien Animations //--------------------------------------------------------------------------------------------------------- RedAlienAnimationCommand pRedAlienAnimation = new RedAlienAnimationCommand(GameSprite.Name.RedAlien); pRedAlienAnimation.Attach(Image.Name.RedAlien); pRedAlienAnimation.Attach(Image.Name.RedAlien2); TimerMan.Add(TimeEvent.Name.RedAlienAnimation, pRedAlienAnimation, 1.0f); BlueAlienAnimationCommand pBlueAlienAnimation = new BlueAlienAnimationCommand(GameSprite.Name.BlueAlien); pBlueAlienAnimation.Attach(Image.Name.BlueAlien); pBlueAlienAnimation.Attach(Image.Name.BlueAlien2); TimerMan.Add(TimeEvent.Name.BlueAlienAnimation, pBlueAlienAnimation, 1.0f); GreenAlienAnimationCommand pGreenAlienAnimation = new GreenAlienAnimationCommand(GameSprite.Name.GreenAlien); pGreenAlienAnimation.Attach(Image.Name.GreenAlien); pGreenAlienAnimation.Attach(Image.Name.GreenAlien2); TimerMan.Add(TimeEvent.Name.GreenAlienAnimation, pGreenAlienAnimation, 1.0f); //--------------------------------------------------------------------------------------------------------- // Alien Bomb Spawns //--------------------------------------------------------------------------------------------------------- BombSpawnEvent pBombSpawn = new BombSpawnEvent(pPlayer.nCurrLevel, pRandom); TimerMan.Add(TimeEvent.Name.BombSpawn, pBombSpawn, pRandom.Next(1, 10)); //--------------------------------------------------------------------------------------------------------- // Scene Play Sound //--------------------------------------------------------------------------------------------------------- ScenePlaySoundCommand pScenePlaySound = new ScenePlaySoundCommand(); pScenePlaySound.Attach(Sound.Name.Invader1); pScenePlaySound.Attach(Sound.Name.Invader2); pScenePlaySound.Attach(Sound.Name.Invader3); pScenePlaySound.Attach(Sound.Name.Invader4); TimerMan.Add(TimeEvent.Name.ScenePlaySound, pScenePlaySound, 1.5f); //--------------------------------------------------------------------------------------------------------- // UFO //--------------------------------------------------------------------------------------------------------- float value = pRandom.Next(10, 60); SpawnUFOCommand pUFO = new SpawnUFOCommand(pRandom, pWallLeft, pWallRight); TimerMan.Add(TimeEvent.Name.UFO, pUFO, value); //--------------------------------------------------------------------------------------------------------- // Texts //--------------------------------------------------------------------------------------------------------- Texture pTexture = TextureMan.Add(Texture.Name.Consolas36pt, "Consolas20pt.tga"); GlyphMan.AddXml(Glyph.Name.Consolas20pt, "Consolas20pt.xml", Texture.Name.Consolas20pt); Font pFont = FontMan.Add(Font.Name.Credits00, SpriteBatch.Name.Texts, "CREDIT 00", Glyph.Name.Consolas20pt, 700, 15); pFont.SetColor(1.0f, 1.0f, 1.0f); pFont = FontMan.Add(Font.Name.Score1, SpriteBatch.Name.Texts, "SCORE <1>", Glyph.Name.Consolas20pt, 150, 585); pFont.SetColor(1.0f, 1.0f, 1.0f); Player pPlayer1 = PlayerMan.GetPlayer(1); string pPlayer1Score; if (pPlayer1 != null) { pPlayer1Score = pPlayer1.nPoints.ToString(); } else { pPlayer1Score = "0"; } pFont = FontMan.Add(Font.Name.Score1Value, SpriteBatch.Name.Texts, pPlayer1Score, Glyph.Name.Consolas20pt, 150, 550); pFont.SetColor(1.0f, 1.0f, 1.0f); pFont = FontMan.Add(Font.Name.HighScore, SpriteBatch.Name.Texts, "HIGH SCORE", Glyph.Name.Consolas20pt, 400, 585); pFont.SetColor(1.0f, 1.0f, 1.0f); HighScore hS = new HighScore(); pFont = FontMan.Add(Font.Name.HighScores, SpriteBatch.Name.Texts, hS.GetScore().ToString(), Glyph.Name.Consolas20pt, 400, 550); pFont.SetColor(1.0f, 1.0f, 1.0f); pFont = FontMan.Add(Font.Name.Score2, SpriteBatch.Name.Texts, "SCORE <2>", Glyph.Name.Consolas20pt, 650, 585); pFont.SetColor(1.0f, 1.0f, 1.0f); Player pPlayer2 = PlayerMan.GetPlayer(2); string pPlayer2Score; if (pPlayer2 != null) { pPlayer2Score = pPlayer2.nPoints.ToString(); } else { pPlayer2Score = "0"; } pFont = FontMan.Add(Font.Name.Score2Value, SpriteBatch.Name.Texts, pPlayer2Score, Glyph.Name.Consolas20pt, 650, 550); pFont.SetColor(1.0f, 1.0f, 1.0f); // Life Totals pFont = FontMan.Add(Font.Name.NumLives1, SpriteBatch.Name.Texts, pPlayer.nLives.ToString(), Glyph.Name.Consolas20pt, 15, 15); pFont.SetColor(1.0f, 1.0f, 1.0f); pShip = ShipMan.CreateInactiveShip(75, 15); pShip = ShipMan.CreateInactiveShip(150, 15); }