public override void LoadContent() { pSpriteBatchMan = new SpriteBatchMan(1, 1); TextureMan.Create(2, 1); GlyphMan.Create(3, 1); FontMan.Create(1, 1); TextureMan.Add(Texture.Name.Consolas36pt, "Consolas36pt.tga"); FontMan.AddXml(Glyph.Name.Consolas36pt, "Consolas36pt.xml", Texture.Name.Consolas36pt); SpriteBatch pSB_Texts = pSpriteBatchMan.Add(SpriteBatch.Name.Texts); 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.Title, SpriteBatch.Name.Texts, "SPACE INVADERS", Glyph.Name.Consolas36pt, 320, 500); FontMan.Add(pSpriteBatchMan, Font.Name.Title, SpriteBatch.Name.Texts, "Choose 1 or 2 to play...", Glyph.Name.Consolas36pt, 240, 450); FontMan.Add(pSpriteBatchMan, Font.Name.Title, SpriteBatch.Name.Texts, "1, Single Player", Glyph.Name.Consolas36pt, 300, 350); FontMan.Add(pSpriteBatchMan, Font.Name.Title, SpriteBatch.Name.Texts, "2, Two Player", Glyph.Name.Consolas36pt, 310, 250); InputSubject pInputSubject; pInputSubject = InputMan.GetKeyOneSubject(); pInputSubject.Attach(new MoveToPlayingStateObserver()); pInputSubject = InputMan.GetKeyTwoSubject(); pInputSubject.Attach(new MoveToPlayingStateObserver()); Simulation.SetState(Simulation.State.Realtime); }
public override void LoadContent() { pSpriteBatchMan = new SpriteBatchMan(1, 1); //TimerMan.Create(3, 1); TextureMan.Create(2, 1); GlyphMan.Create(3, 1); FontMan.Create(1, 1); TextureMan.Add(Texture.Name.Consolas36pt, "Consolas36pt.tga"); FontMan.AddXml(Glyph.Name.Consolas36pt, "Consolas36pt.xml", Texture.Name.Consolas36pt); SpriteBatch pSB_Texts = pSpriteBatchMan.Add(SpriteBatch.Name.Texts); 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.Title, SpriteBatch.Name.Texts, "GAME OVER!!", Glyph.Name.Consolas36pt, 350, 400); FontMan.Add(pSpriteBatchMan, Font.Name.Title, SpriteBatch.Name.Texts, "Press 3 to go back to the menu...", Glyph.Name.Consolas36pt, 200, 280); InputSubject pInputSubject; pInputSubject = InputMan.GetKeyThreeSubject(); pInputSubject.Attach(new MoveToMenuObserver()); Simulation.SetState(Simulation.State.Realtime); //CycleBackToMenuState pCylce = new CycleBackToMenuState(); //TimerMan.Add(TimeEvent.Name.CycleBackToMenu, pCylce, 20f); }
public override void Initialize() { this.poSpriteBatchMan = new SpriteBatchMan(3, 1); SpriteBatchMan.SetActive(this.poSpriteBatchMan); this.poFontMan = new FontMan(); FontMan.SetActive(this.poFontMan); this.poInputMan = new InputMan(); InputMan.SetActive(this.poInputMan); SpriteBatch pSB_Texts = SpriteBatchMan.Add(SpriteBatch.Name.Texts, 100, true); HighScore hS = new HighScore(); Texture pTexture = TextureMan.Add(Texture.Name.Consolas36pt, "Consolas36pt.tga"); GlyphMan.AddXml(Glyph.Name.Consolas36pt, "Consolas36pt.xml", Texture.Name.Consolas36pt); Font pFont = FontMan.Add(Font.Name.HighScore, SpriteBatch.Name.Texts, "High Score", Glyph.Name.Consolas36pt, 100, 500); pFont.SetColor(1.0f, 1.0f, 1.0f); pFont = FontMan.Add(Font.Name.HighScores, SpriteBatch.Name.Texts, hS.GetScore().ToString(), Glyph.Name.Consolas20pt, 100, 400); pFont.SetColor(0.40f, 0.40f, 0.40f); pFont = FontMan.Add(Font.Name.Instructions, SpriteBatch.Name.Texts, "Back to Menu", Glyph.Name.Consolas20pt, 100, 100); pFont.SetColor(0.60f, 0.60f, 0.60f); InputSubject pInputSubject = InputMan.GetCursorSubject(); pInputSubject.Attach(new HighlightHoverTextObserver(pFont)); pInputSubject = InputMan.GetMouseLeftKeySubject(); pInputSubject.Attach(new MenuChoiceObserver(pFont)); }
public override void loadContent(Scene pScene) { SpriteBatchMan.Add(SpriteBatch.Name.SelectWindowTexts); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.SelectWindowTexts, "SCORE<1>", Glyph.Name.Consolas36pt, 20, 1000); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.SelectWindowTexts, "HI-SCORE", Glyph.Name.Consolas36pt, 370, 1000); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.SelectWindowTexts, "SCORE<2>", Glyph.Name.Consolas36pt, 700, 1000); FontMan.Add(Font.Name.ScoreOne, SpriteBatch.Name.SelectWindowTexts, pScene.getScoreOne().ToString("D4"), Glyph.Name.Consolas36pt, 50, 960); FontMan.Add(Font.Name.HighestScore, SpriteBatch.Name.SelectWindowTexts, pScene.getHighestScore().ToString("D4"), Glyph.Name.Consolas36pt, 400, 960); FontMan.Add(Font.Name.ScoreTwo, SpriteBatch.Name.SelectWindowTexts, pScene.getScoreTwo().ToString("D4"), Glyph.Name.Consolas36pt, 730, 960); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.SelectWindowTexts, "CREDIT", Glyph.Name.Consolas36pt, 700, 25); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.SelectWindowTexts, "00", Glyph.Name.Consolas36pt, 830, 25); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.SelectWindowTexts, "SPACE INVADERS", Glyph.Name.Consolas36pt, 300, 750); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.SelectWindowTexts, "PUSH <1> OR <2> PLAYERS BUTTON", Glyph.Name.Consolas36pt, 160, 700); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.SelectWindowTexts, "*SCORE ADVANCE TABLE*", Glyph.Name.Consolas36pt, 240, 650); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.SelectWindowTexts, "= 200 POINTS", Glyph.Name.Consolas36pt, 380, 600); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.SelectWindowTexts, "= 30 POINTS", Glyph.Name.Consolas36pt, 380, 550); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.SelectWindowTexts, "= 20 POINTS", Glyph.Name.Consolas36pt, 380, 500); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.SelectWindowTexts, "= 10 POINTS", Glyph.Name.Consolas36pt, 380, 450); SpriteBatch pSB_StartWindowSprites = SpriteBatchMan.Add(SpriteBatch.Name.StartWindowSprites); ShipLifeGroup pStartWindow = new ShipLifeGroup(GameObject.Name.ShipLifeGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pStartWindow.activateGameSprite(pSB_StartWindowSprites); UFO pUFO = new UFO(GameObject.Name.UFO, GameSprite.Name.UFO, 320, 600, true); pUFO.activateGameSprite(pSB_StartWindowSprites); pStartWindow.add(pUFO); Squid pSquid = new Squid(GameObject.Name.Squid, GameSprite.Name.Squid, 320, 550); pSquid.activateGameSprite(pSB_StartWindowSprites); pStartWindow.add(pSquid); Crab pCrab = new Crab(GameObject.Name.Crab, GameSprite.Name.Crab, 320, 500); pCrab.activateGameSprite(pSB_StartWindowSprites); pStartWindow.add(pCrab); Octopus pOctopus = new Octopus(GameObject.Name.Octopus, GameSprite.Name.Octopus, 320, 450); pOctopus.activateGameSprite(pSB_StartWindowSprites); pStartWindow.add(pOctopus); GameObjectMan.Attach(pStartWindow); InputSubject pInputSubject; pInputSubject = InputMan.GetKey1Subject(); pInputSubject.attach(new OnePlayerObserver()); pInputSubject = InputMan.GetKey2Subject(); pInputSubject.attach(new TwoPlayerObserver()); }
public override void Initialize() { this.name = SceneContext.Scene.Over; this.poSpriteBatchMan = new SpriteBatchMan(3, 1); SpriteBatchMan.SetActive(this.poSpriteBatchMan); SpriteBatch pSB_Texts = this.poSpriteBatchMan.Add(SpriteBatch.Name.Texts, 100); Texture pTexture = TextureMan.Add(Texture.Name.Consolas36pt, "Consolas36pt.tga"); GlyphMan.AddXml(Glyph.Name.Consolas36pt, "Consolas36pt.xml", Texture.Name.Consolas36pt); Font pFont = FontMan.Add(Font.Name.GameOver, SpriteBatch.Name.Texts, "GAME OVER", Glyph.Name.Consolas36pt, 310, 350); pFont.SetColor(1.0f, 0.0f, 0.0f); }
public override void Initialize() { this.poSpriteBatchMan = new SpriteBatchMan(3, 1); SpriteBatchMan.SetActive(this.poSpriteBatchMan); this.poInputMan = new InputMan(); InputMan.SetActive(this.poInputMan); SpriteBatch pSB_Texts = SpriteBatchMan.Add(SpriteBatch.Name.Texts, 100, true); Texture pTexture = TextureMan.Add(Texture.Name.Consolas36pt, "Consolas36pt.tga"); GlyphMan.AddXml(Glyph.Name.Consolas36pt, "Consolas36pt.xml", Texture.Name.Consolas36pt); Font pFont = FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, "GAME OVER", Glyph.Name.Consolas36pt, 100, 500); pFont.SetColor(1.0f, 1.0f, 1.0f); }
public override void loadContent(Scene pScene) { if (SpriteBatchMan.Find(SpriteBatch.Name.GameOverWindowTexts) == null) { SpriteBatchMan.Add(SpriteBatch.Name.GameOverWindowTexts); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.GameOverWindowTexts, "GAME OVER", Glyph.Name.Consolas36pt, 350, 750); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.GameOverWindowTexts, "PLAYER1 SCORE:", Glyph.Name.Consolas36pt, 250, 650); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.GameOverWindowTexts, pScene.getScoreOne().ToString("D4"), Glyph.Name.Consolas36pt, 550, 650); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.GameOverWindowTexts, "PLAYER2 SCORE:", Glyph.Name.Consolas36pt, 250, 600); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.GameOverWindowTexts, pScene.getScoreTwo().ToString("D4"), Glyph.Name.Consolas36pt, 550, 600); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.GameOverWindowTexts, "Highest SCORE:", Glyph.Name.Consolas36pt, 250, 550); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.GameOverWindowTexts, pScene.getHighestScore().ToString("D4"), Glyph.Name.Consolas36pt, 550, 550); } else { SpriteBatchMan.Find(SpriteBatch.Name.GameOverWindowTexts).setIsDraw(true); } InputSubject pInputSubject; pInputSubject = InputMan.GetKeyEnterSubject(); pInputSubject.attach(new BackToSelectObserver()); }
// strategy() override public void LoadContent() { Reset(); SpriteBatchMan.Create(3, 1); TextureMan.Create(2, 1); GlyphMan.Create(3, 1); FontMan.Create(1, 1); Texture pTexture = TextureMan.Add(Texture.Name.Consolas36pt, "Consolas36pt.tga"); FontMan.AddXml(Glyph.Name.Consolas36pt, "Consolas36pt.xml", Texture.Name.Consolas36pt); pTexture = TextureMan.Add(Texture.Name.Consolas20pt, "Consolas20pt.tga"); FontMan.AddXml(Glyph.Name.Consolas20pt, "Consolas20pt.xml", Texture.Name.Consolas20pt); SpriteBatch pSB_Texts = SpriteBatchMan.Add(SpriteBatch.Name.Texts); // Font FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, "Game Over", Glyph.Name.Consolas36pt, 250, 550); FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, "HI-SCORE", Glyph.Name.Consolas20pt, 200, 450); FontMan.Add(Font.Name.ScoreHigh, SpriteBatch.Name.Texts, SceneStateGameover.scoreHigh, Glyph.Name.Consolas20pt, 400, 450); FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, "PLAYER <1>", Glyph.Name.Consolas20pt, 200, 400); FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, SceneStateGameover.score1, Glyph.Name.Consolas20pt, 400, 400); FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, "PLAYER <2>", Glyph.Name.Consolas20pt, 200, 350); FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, SceneStateGameover.score2, Glyph.Name.Consolas20pt, 400, 350); // Input InputSubject pInputSubject; pInputSubject = InputMan.GetSlashSubject(); pInputSubject.Attach(new SelectGameObserver()); }
public override void Initialize() { ImageMan.Add(Image.Name.BlueAlien, Texture.Name.Aliens, new Azul.Rect(341, 337, 65, 64)); ImageMan.Add(Image.Name.GreenAlien, Texture.Name.Aliens, new Azul.Rect(27, 337, 79, 64)); ImageMan.Add(Image.Name.RedAlien, Texture.Name.Aliens, new Azul.Rect(647, 200, 72, 65)); ImageMan.Add(Image.Name.UFO, Texture.Name.Aliens, new Azul.Rect(120, 489, 98, 49)); ImageMan.Add(Image.Name.Ship, Texture.Name.Birds, new Azul.Rect(10, 93, 30, 18)); 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)); this.poSpriteBatchMan = new SpriteBatchMan(3, 1); SpriteBatchMan.SetActive(this.poSpriteBatchMan); this.poGameObjectMan = new GameObjectMan(10, 2); GameObjectMan.SetActive(this.poGameObjectMan); this.poFontMan = new FontMan(); FontMan.SetActive(this.poFontMan); this.poInputMan = new InputMan(); InputMan.SetActive(this.poInputMan); 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_Boxes = SpriteBatchMan.Add(SpriteBatch.Name.Boxes, 100, false); 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.Ship, Image.Name.Ship, 500, 100, 60, 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); AlienFactory aF = new AlienFactory(SpriteBatch.Name.Aliens, SpriteBatch.Name.Boxes); Texture pTexture = TextureMan.Add(Texture.Name.Consolas36pt, "Consolas36pt.tga"); GlyphMan.AddXml(Glyph.Name.Consolas36pt, "Consolas36pt.xml", Texture.Name.Consolas36pt); Font pFont = FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, "Aliens", Glyph.Name.Consolas36pt, 100, 500); pFont.SetColor(1.0f, 1.0f, 1.0f); RedAlien redAlien = (RedAlien)aF.Create(GameObject.Name.RedAlien, AlienCategory.Type.Red, 300.0f, 200.0f); pFont = FontMan.Add(Font.Name.Instructions, SpriteBatch.Name.Texts, redAlien.GetPoints().ToString(), Glyph.Name.Consolas20pt, 375.0f, 200.0f); pFont.SetColor(0.60f, 0.60f, 0.60f); GreenAlien greenAlien = (GreenAlien)aF.Create(GameObject.Name.GreenAlien, AlienCategory.Type.Green, 300.0f, 275.0f); pFont = FontMan.Add(Font.Name.Instructions, SpriteBatch.Name.Texts, greenAlien.GetPoints().ToString(), Glyph.Name.Consolas20pt, 375.0f, 275.0f); pFont.SetColor(0.60f, 0.60f, 0.60f); BlueAlien blueAlien = (BlueAlien)aF.Create(GameObject.Name.BlueAlien, AlienCategory.Type.Blue, 300.0f, 350.0f); pFont = FontMan.Add(Font.Name.Instructions, SpriteBatch.Name.Texts, blueAlien.GetPoints().ToString(), Glyph.Name.Consolas20pt, 375.0f, 350.0f); pFont.SetColor(0.60f, 0.60f, 0.60f); UFO ufo = new UFO(GameObject.Name.UFO, GameSprite.Name.UFO, 300.0f, 425.0f); ufo.ActivateGameSprite(pSB_Aliens); GameObjectMan.Attach(ufo); pFont = FontMan.Add(Font.Name.Instructions, SpriteBatch.Name.Texts, "?", Glyph.Name.Consolas20pt, 375.0f, 425.0f); pFont.SetColor(0.60f, 0.60f, 0.60f); pFont = FontMan.Add(Font.Name.Instructions, SpriteBatch.Name.Texts, "Back to Menu", Glyph.Name.Consolas20pt, 100, 100); pFont.SetColor(0.60f, 0.60f, 0.60f); InputSubject pInputSubject = InputMan.GetCursorSubject(); pInputSubject.Attach(new HighlightHoverTextObserver(pFont)); pInputSubject = InputMan.GetMouseLeftKeySubject(); pInputSubject.Attach(new MenuChoiceObserver(pFont)); }
public override void Initialize() { this.name = SceneContext.Scene.Select; this.poSpriteBatchMan = new SpriteBatchMan(3, 1); SpriteBatchMan.SetActive(this.poSpriteBatchMan); this.poGameObjectMan = new GameObjectMan(3, 1); GameObjectMan.SetActive(this.poGameObjectMan); SpriteBatch pSB_Texts = this.poSpriteBatchMan.Add(SpriteBatch.Name.Texts, 100); TextureMan.Add(Texture.Name.Consolas36pt, "Consolas36pt.tga"); GlyphMan.AddXml(Glyph.Name.Consolas36pt, "Consolas36pt.xml", Texture.Name.Consolas36pt); TextureMan.Add(Texture.Name.Consolas48pt, "Consolas48pt.tga"); GlyphMan.AddXml(Glyph.Name.Consolas48pt, "Consolas48pt.xml", Texture.Name.Consolas48pt); FontMan.Add(Font.Name.Select, SpriteBatch.Name.Texts, "SPACE INVADERS", Glyph.Name.Consolas48pt, 280, 480); FontMan.Add(Font.Name.Select, SpriteBatch.Name.Texts, "PRESS <1> and <2> TO SWITCH PLAYERS", Glyph.Name.Consolas36pt, 100, 400); FontMan.Add(Font.Name.Select, SpriteBatch.Name.Texts, "*SCORE ADVANCE TABLE*", Glyph.Name.Consolas36pt, 220, 350); FontMan.Add(Font.Name.Select, SpriteBatch.Name.Texts, "? MYSTERY", Glyph.Name.Consolas36pt, 370, 300); FontMan.Add(Font.Name.Select, SpriteBatch.Name.Texts, "30 POINTS", Glyph.Name.Consolas36pt, 370, 270); FontMan.Add(Font.Name.Select, SpriteBatch.Name.Texts, "20 POINTS", Glyph.Name.Consolas36pt, 370, 240); FontMan.Add(Font.Name.Select, SpriteBatch.Name.Texts, "10 POINTS", Glyph.Name.Consolas36pt, 370, 210); SpriteBatch pSB_Aliens = this.poSpriteBatchMan.Add(SpriteBatch.Name.Aliens, 200); SpriteBatch pSB_Boxes = this.poSpriteBatchMan.Add(SpriteBatch.Name.Boxes, 300); TextureMan.Add(Texture.Name.Aliens, "Invaders_0.tga"); ImageMan.Add(Image.Name.SquidOpen, Texture.Name.Aliens, 616, 28, 112, 112); ImageMan.Add(Image.Name.CrabOpen, Texture.Name.Aliens, 321, 28, 155, 112); ImageMan.Add(Image.Name.OctopusOpen, Texture.Name.Aliens, 56, 28, 167, 112); ImageMan.Add(Image.Name.UFO, Texture.Name.Aliens, 83, 503, 225, 98); this.poGameSpriteMan = new GameSpriteMan(3, 1); GameSpriteMan.SetActive(this.poGameSpriteMan); GameSpriteMan.Add(GameSprite.Name.SquidOpen, Image.Name.SquidOpen, 50, 550, 25, 25); GameSpriteMan.Add(GameSprite.Name.CrabOpen, Image.Name.CrabOpen, 50, 510, 25, 25); GameSpriteMan.Add(GameSprite.Name.OctopusOpen, Image.Name.OctopusOpen, 50, 430, 25, 25); GameSpriteMan.Add(GameSprite.Name.UFO, Image.Name.UFO, 50, 500, 40, 18); // Aliens AlienFactory AF = new AlienFactory(SpriteBatch.Name.Aliens, SpriteBatch.Name.Boxes); GameObject pCol = AF.Create(GameObject.Name.AlienColumn, AlienCategory.Type.Column); GameObject pSquidObj = AF.Create(GameObject.Name.SquidAlien, AlienCategory.Type.Squid, 330, 270); pCol.Add(pSquidObj); GameObject pCrabObj = AF.Create(GameObject.Name.CrabAlien, AlienCategory.Type.Crab, 330, 240); pCol.Add(pCrabObj); GameObject pOctopusObj = AF.Create(GameObject.Name.OctopusAlien, AlienCategory.Type.Octopus, 330, 210); pCol.Add(pOctopusObj); GameObjectMan.Attach(pCol); // UFO UFORoot pUFORoot = new UFORoot(GameObject.Name.UFORoot, GameSprite.Name.NullObject, 0.0f, 0.0f); UFO pUFO = new UFO(GameObject.Name.UFO, GameSprite.Name.UFO, 330, 300); pUFO.ActivateGameSprite(pSB_Aliens); pUFORoot.Add(pUFO); GameObjectMan.Attach(pUFORoot); FontMan.Add(Font.Name.ScoreText, SpriteBatch.Name.Texts, "HI-SCORE: ", Glyph.Name.Consolas36pt, 300, 150); pFontHighScore = FontMan.Add(Font.Name.HighScore, SpriteBatch.Name.Texts, "0000", Glyph.Name.Consolas36pt, 470, 150); }
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); }
// strategy() override public void LoadContent() { AlienGroup.ResetDirection(); TextureMan.Create(2, 1); ImageMan.Create(5, 2); GameSpriteMan.Create(4, 2); BoxSpriteMan.Create(3, 1); SpriteBatchMan.Create(3, 1); TimerMan.Create(3, 1); ProxySpriteMan.Create(10, 1); GameObjectMan.Create(3, 1); ColPairMan.Create(1, 1); Simulation.Create(); GlyphMan.Create(3, 1); FontMan.Create(1, 1); //GhostSpriteBatchMan.Create(2, 1); //--------------------------------------------------------------------------------------------------------- // Sound Experiment //--------------------------------------------------------------------------------------------------------- // start up the engine sndEngine = new IrrKlang.ISoundEngine(); //--------------------------------------------------------------------------------------------------------- // Load the Textures //--------------------------------------------------------------------------------------------------------- TextureMan.Add(Texture.Name.Aliens, "newaliens.tga"); TextureMan.Add(Texture.Name.Shields, "birds_N_shield.tga"); Texture pTexture = TextureMan.Add(Texture.Name.Consolas20pt, "Consolas20pt.tga"); FontMan.AddXml(Glyph.Name.Consolas20pt, "Consolas20pt.xml", Texture.Name.Consolas20pt); //--------------------------------------------------------------------------------------------------------- // Load the Images //--------------------------------------------------------------------------------------------------------- ImageMan.Add(Image.Name.SquidA, Texture.Name.Aliens, 547, 15, 250, 135); ImageMan.Add(Image.Name.CrabA, Texture.Name.Aliens, 281, 15, 250, 135); ImageMan.Add(Image.Name.OctopusA, Texture.Name.Aliens, 15, 15, 250, 135); ImageMan.Add(Image.Name.SquidB, Texture.Name.Aliens, 547, 170, 250, 135); ImageMan.Add(Image.Name.CrabB, Texture.Name.Aliens, 281, 170, 250, 135); ImageMan.Add(Image.Name.OctopusB, Texture.Name.Aliens, 15, 170, 250, 135); ImageMan.Add(Image.Name.MissileBombCol, Texture.Name.Aliens, 395, 480, 130, 130); ImageMan.Add(Image.Name.AlienDies, Texture.Name.Aliens, 550, 480, 220, 130); ImageMan.Add(Image.Name.UFO, Texture.Name.Aliens, 80, 500, 230, 100); ImageMan.Add(Image.Name.UFODies, Texture.Name.Aliens, 15, 630, 355, 140); ImageMan.Add(Image.Name.Missile, Texture.Name.Aliens, 370, 795, 30, 105); ImageMan.Add(Image.Name.MissileBombDies, Texture.Name.Aliens, 685, 790, 110, 130); ImageMan.Add(Image.Name.Ship, Texture.Name.Aliens, 50, 325, 190, 125); ImageMan.Add(Image.Name.ShipDiesA, Texture.Name.Aliens, 280, 325, 245, 130); ImageMan.Add(Image.Name.ShipDiesB, Texture.Name.Aliens, 545, 325, 245, 130); ImageMan.Add(Image.Name.BombRoll, Texture.Name.Aliens, 445, 795, 50, 105); ImageMan.Add(Image.Name.BombZigZag, Texture.Name.Aliens, 560, 630, 70, 140); ImageMan.Add(Image.Name.BombCross, Texture.Name.Aliens, 110, 790, 50, 100); ImageMan.Add(Image.Name.BombFork, Texture.Name.Aliens, 520, 790, 50, 100); ImageMan.Add(Image.Name.BombStraight, Texture.Name.Aliens, 370, 795, 30, 105); ImageMan.Add(Image.Name.Brick, Texture.Name.Shields, 20, 210, 10, 5); ImageMan.Add(Image.Name.BrickLeft_Top0, Texture.Name.Shields, 15, 180, 10, 5); ImageMan.Add(Image.Name.BrickLeft_Top1, Texture.Name.Shields, 15, 185, 10, 5); ImageMan.Add(Image.Name.BrickLeft_Bottom, Texture.Name.Shields, 35, 215, 10, 5); ImageMan.Add(Image.Name.BrickRight_Top0, Texture.Name.Shields, 75, 180, 10, 5); ImageMan.Add(Image.Name.BrickRight_Top1, Texture.Name.Shields, 75, 185, 10, 5); ImageMan.Add(Image.Name.BrickRight_Bottom, Texture.Name.Shields, 55, 215, 10, 5); //--------------------------------------------------------------------------------------------------------- // Create Sprites //--------------------------------------------------------------------------------------------------------- GameSpriteMan.Add(GameSprite.Name.Squid, Image.Name.SquidA, 100, 600, 35, 30, 255, 255, 255, 1); GameSpriteMan.Add(GameSprite.Name.Crab, Image.Name.CrabA, 100, 550, 35, 30, 255, 255, 255, 1); GameSpriteMan.Add(GameSprite.Name.Octopus, Image.Name.OctopusA, 100, 500, 35, 30, 255, 255, 255, 1); GameSpriteMan.Add(GameSprite.Name.AlienDies, Image.Name.AlienDies, 0, 0, 35, 30, 255, 255, 255, 1); GameSpriteMan.Add(GameSprite.Name.UFO, Image.Name.UFO, 100, 500, 35, 30, 255, 0, 0, 1); GameSpriteMan.Add(GameSprite.Name.UFODies, Image.Name.UFODies, 0, 0, 35, 30, 255, 0, 0, 1); GameSpriteMan.Add(GameSprite.Name.Missile, Image.Name.Missile, 100, 200, 10, 20, 255, 255, 0, 1); GameSpriteMan.Add(GameSprite.Name.MissileDies, Image.Name.MissileBombDies, 0, 0, 10, 20, 255, 255, 0, 1); GameSpriteMan.Add(GameSprite.Name.MissileBombCol, Image.Name.MissileBombCol, 0, 0, 10, 20, 255, 255, 255, 1); GameSpriteMan.Add(GameSprite.Name.Ship, Image.Name.Ship, 300, 30, 40, 20, 255, 255, 0, 1); GameSpriteMan.Add(GameSprite.Name.ShipDies, Image.Name.ShipDiesA, 0, 0, 50, 25, 255, 255, 0, 1); GameSpriteMan.Add(GameSprite.Name.BombZigZag, Image.Name.BombZigZag, 0, 0, 10, 20, 255, 0, 0, 1); GameSpriteMan.Add(GameSprite.Name.BombRolling, Image.Name.BombRoll, 0, 0, 10, 20, 255, 0, 0, 1); GameSpriteMan.Add(GameSprite.Name.BombDagger, Image.Name.BombCross, 0, 0, 10, 20, 255, 0, 0, 1); GameSpriteMan.Add(GameSprite.Name.BombStraight, Image.Name.BombStraight, 0, 0, 10, 20, 255, 0, 0, 1); GameSpriteMan.Add(GameSprite.Name.BombFork, Image.Name.BombFork, 0, 0, 12, 24, 255, 0, 0, 1); GameSpriteMan.Add(GameSprite.Name.BombDies, Image.Name.MissileBombDies, 0, 0, 10, 20, 255, 0, 0, 1); GameSpriteMan.Add(GameSprite.Name.Brick, Image.Name.Brick, 50, 25, 10, 5, 0, 255, 0, 1); GameSpriteMan.Add(GameSprite.Name.Brick_LeftTop0, Image.Name.BrickLeft_Top0, 50, 25, 10, 5, 0, 255, 0, 1); GameSpriteMan.Add(GameSprite.Name.Brick_LeftTop1, Image.Name.BrickLeft_Top1, 50, 25, 10, 5, 0, 255, 0, 1); GameSpriteMan.Add(GameSprite.Name.Brick_LeftBottom, Image.Name.BrickLeft_Bottom, 50, 25, 10, 5, 0, 255, 0, 1); GameSpriteMan.Add(GameSprite.Name.Brick_RightTop0, Image.Name.BrickRight_Top0, 50, 25, 10, 5, 0, 255, 0, 1); GameSpriteMan.Add(GameSprite.Name.Brick_RightTop1, Image.Name.BrickRight_Top1, 50, 25, 10, 5, 0, 255, 0, 1); GameSpriteMan.Add(GameSprite.Name.Brick_RightBottom, Image.Name.BrickRight_Bottom, 50, 25, 10, 5, 0, 255, 0, 1); SpriteBatch pSB_Aliens = SpriteBatchMan.Add(SpriteBatch.Name.Aliens); SpriteBatch pSB_Box = SpriteBatchMan.Add(SpriteBatch.Name.Boxes); SpriteBatch pSB_Shields = SpriteBatchMan.Add(SpriteBatch.Name.Shields); SpriteBatch pSB_Texts = SpriteBatchMan.Add(SpriteBatch.Name.Texts); //SpriteBatch pSB_GhostAliens = GhostSpriteBatchMan.Add(SpriteBatch.Name.Aliens); //SpriteBatch pSB_GhostBox = GhostSpriteBatchMan.Add(SpriteBatch.Name.Boxes); //SpriteBatch pSB_GhostShields = GhostSpriteBatchMan.Add(SpriteBatch.Name.Shields); //--------------------------------------------------------------------------------------------------------- // GameObject //--------------------------------------------------------------------------------------------------------- AnimationSprite pAnimSpriteSquid = new AnimationSprite(GameSprite.Name.Squid); AnimationSprite pAnimSpriteCrab = new AnimationSprite(GameSprite.Name.Crab); AnimationSprite pAnimSpriteOctopus = new AnimationSprite(GameSprite.Name.Octopus); pAnimSpriteSquid.Attach(Image.Name.SquidB); pAnimSpriteSquid.Attach(Image.Name.SquidA); pAnimSpriteCrab.Attach(Image.Name.CrabB); pAnimSpriteCrab.Attach(Image.Name.CrabA); pAnimSpriteOctopus.Attach(Image.Name.OctopusB); pAnimSpriteOctopus.Attach(Image.Name.OctopusA); TimerMan.Add(TimerEvent.Name.SquidAnimation, pAnimSpriteSquid, pMoveRate); TimerMan.Add(TimerEvent.Name.CrabAnimation, pAnimSpriteCrab, pMoveRate); TimerMan.Add(TimerEvent.Name.OctopusAnimation, pAnimSpriteOctopus, pMoveRate); //--------------------------------------------------------------------------------------------------------- // Create Walls //--------------------------------------------------------------------------------------------------------- WallGroup pWallGroup = new WallGroup(GameObject.Name.WallGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pWallGroup.ActivateGameSprite(pSB_Aliens); pWallGroup.ActivateCollisionSprite(pSB_Box); WallBottom pWallBottom = new WallBottom(GameObject.Name.WallBottom, GameSprite.Name.NullObject, 336, 35, 750, 10); pWallBottom.ActivateCollisionSprite(pSB_Box); pWallGroup.Add(pWallBottom); WallRight pWallRight = new WallRight(GameObject.Name.WallRight, GameSprite.Name.NullObject, 722, 384, 120, 765); pWallRight.ActivateCollisionSprite(pSB_Box); pWallGroup.Add(pWallRight); WallLeft pWallLeft = new WallLeft(GameObject.Name.WallLeft, GameSprite.Name.NullObject, -45, 384, 120, 765); pWallLeft.ActivateCollisionSprite(pSB_Box); pWallGroup.Add(pWallLeft); WallTop pWallTop = new WallTop(GameObject.Name.WallTop, GameSprite.Name.NullObject, 336, 685, 750, 10); pWallTop.ActivateCollisionSprite(pSB_Box); pWallGroup.Add(pWallTop); GameObjectMan.Attach(pWallGroup); //--------------------------------------------------------------------------------------------------------- // Create Bumper //--------------------------------------------------------------------------------------------------------- BumperGroup pBumperGroup = new BumperGroup(GameObject.Name.BumperGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pBumperGroup.ActivateGameSprite(pSB_Aliens); pBumperGroup.ActivateCollisionSprite(pSB_Box); BumperRight pBumperRight = new BumperRight(GameObject.Name.BumperRight, GameSprite.Name.NullObject, 650, 55, 15, 20); pBumperRight.ActivateCollisionSprite(pSB_Box); pBumperGroup.Add(pBumperRight); BumperLeft pBumperLeft = new BumperLeft(GameObject.Name.BumperLeft, GameSprite.Name.NullObject, 20, 55, 15, 20); pBumperLeft.ActivateCollisionSprite(pSB_Box); pBumperGroup.Add(pBumperLeft); GameObjectMan.Attach(pBumperGroup); //--------------------------------------------------------------------------------------------------------- // Create Ship //--------------------------------------------------------------------------------------------------------- ShipRoot pShipRoot = new ShipRoot(GameObject.Name.ShipRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); pShipRoot.ActivateCollisionSprite(pSB_Box); GameObjectMan.Attach(pShipRoot); ShipMan.Create(new SndObserver(sndEngine, SndObserver.Name.ShootMissile)); Ship pShip = new Ship(GameObject.Name.Ship, GameSprite.Name.Ship, 50, 20, null); pShip.ActivateCollisionSprite(pSB_Box); pShip.ActivateGameSprite(pSB_Aliens); pShipRoot.Add(pShip); //--------------------------------------------------------------------------------------------------------- // Bomb //--------------------------------------------------------------------------------------------------------- BombRoot pBombRoot = new BombRoot(GameObject.Name.BombRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); pBombRoot.ActivateCollisionSprite(pSB_Box); GameObjectMan.Attach(pBombRoot); //--------------------------------------------------------------------------------------------------------- // Explosion //--------------------------------------------------------------------------------------------------------- ExplosionFactory explosionFactory = new ExplosionFactory(SpriteBatch.Name.Aliens, SpriteBatch.Name.Boxes); ExplosionGroup pExplosionGroup = (ExplosionGroup)explosionFactory.Create(GameObject.Name.ExplosionGroup, GameSprite.Name.NullObject); GameObjectMan.Attach(pExplosionGroup); //--------------------------------------------------------------------------------------------------------- // Create Missile //--------------------------------------------------------------------------------------------------------- MissileGroup pMissileGroup = new MissileGroup(GameObject.Name.MissileGroup, GameSprite.Name.NullObject, 0, 0.0f, 0.0f); pMissileGroup.ActivateGameSprite(pSB_Aliens); pMissileGroup.ActivateCollisionSprite(pSB_Box); GameObjectMan.Attach(pMissileGroup); //--------------------------------------------------------------------------------------------------------- // Create Aliens //--------------------------------------------------------------------------------------------------------- AlienGroup pAlienGroup; if (SceneStateGame.loadGhost == false) { GameObject pGameObj; AlienMan.Create(); AlienFactory alienFactory = new AlienFactory(SpriteBatch.Name.Aliens, SpriteBatch.Name.Boxes); pAlienGroup = (AlienGroup)alienFactory.Create(GameObject.Name.AlienGroup, AlienCategory.Type.Group); for (int i = 0; i < 11; i++) { float x = 100.0f + 35 * (i % 11); GameObject pGameObjCol = alienFactory.Create(GameObject.Name.AlienColumn, AlienCategory.Type.Column, pAlienGroup); pGameObj = alienFactory.Create(GameObject.Name.Squid, AlienCategory.Type.Squid, pGameObjCol, x, baseY); pGameObj = alienFactory.Create(GameObject.Name.Crab, AlienCategory.Type.Crab, pGameObjCol, x, baseY - 30); pGameObj = alienFactory.Create(GameObject.Name.Crab, AlienCategory.Type.Crab, pGameObjCol, x, baseY - 30 * 2); pGameObj = alienFactory.Create(GameObject.Name.Octopus, AlienCategory.Type.Octopus, pGameObjCol, x, baseY - 30 * 3); pGameObj = alienFactory.Create(GameObject.Name.Octopus, AlienCategory.Type.Octopus, pGameObjCol, x, baseY - 30 * 4); } } else { GameObjectNode pGhostGameObjNode = GhostGameObjectMan.Find(GameObject.Name.AlienGroup); pAlienGroup = (AlienGroup)pGhostGameObjNode.pGameObj; ForwardIterator pFor = new ForwardIterator(pAlienGroup); Component pNode = pFor.First(); while (!pFor.IsDone()) { GameObject pGameObj = (GameObject)pNode; pGameObj.ActivateGameSprite(pSB_Aliens); pGameObj.ActivateCollisionSprite(pSB_Box); pNode = pFor.Next(); } GhostGameObjectMan.Remove(pGhostGameObjNode); } GameObjectMan.Attach(pAlienGroup); MovementSprite pMvSprite = new MovementSprite(pAlienGroup); pMvSprite.Attach(10.0f, 20.0f, new SndObserver(sndEngine, SndObserver.Name.AlienMove4, 0.5f)); pMvSprite.Attach(10.0f, 20.0f, new SndObserver(sndEngine, SndObserver.Name.AlienMove3, 0.5f)); pMvSprite.Attach(10.0f, 20.0f, new SndObserver(sndEngine, SndObserver.Name.AlienMove2, 0.5f)); pMvSprite.Attach(10.0f, 20.0f, new SndObserver(sndEngine, SndObserver.Name.AlienMove1, 0.5f)); TimerMan.Add(TimerEvent.Name.AlienMovement, pMvSprite, pMoveRate); //--------------------------------------------------------------------------------------------------------- // UFO //--------------------------------------------------------------------------------------------------------- UFORoot pUFORoot = new UFORoot(GameObject.Name.UFORoot, GameSprite.Name.NullObject, 0.0f, 0.0f); pUFORoot.ActivateCollisionSprite(pSB_Box); GameObjectMan.Attach(pUFORoot); UFOMan.Create(new SndObserver(sndEngine, SndObserver.Name.UFOFlyHigh, 0.2f, true)); //--------------------------------------------------------------------------------------------------------- // Shield //--------------------------------------------------------------------------------------------------------- ShieldFactory shieldFactory = new ShieldFactory(SpriteBatch.Name.Shields, SpriteBatch.Name.Boxes); ShieldRoot pShieldRoot = (ShieldRoot)shieldFactory.Create(ShieldCategory.Type.Root, GameObject.Name.NullObject); GameObjectMan.Attach(pShieldRoot); // load by column for (int i = 0; i < 4; i++) { int j = 0; float start_x = 86.0f + i * 146; float start_y = 100.0f; float off_x = 0; float brickWidth = 10.0f; float brickHeight = 5.0f; ShieldGrid pShieldGrid = (ShieldGrid)shieldFactory.Create(ShieldCategory.Type.Grid, GameObject.Name.NullObject, pShieldRoot); GameObject pColumn; pColumn = shieldFactory.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++, pShieldGrid); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x, start_y); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x, start_y + brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x, start_y + 2 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x, start_y + 3 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x, start_y + 4 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x, start_y + 5 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x, start_y + 6 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x, start_y + 7 * brickHeight); shieldFactory.Create(ShieldCategory.Type.LeftTop1, GameObject.Name.ShieldBrick, pColumn, start_x, start_y + 8 * brickHeight); shieldFactory.Create(ShieldCategory.Type.LeftTop0, GameObject.Name.ShieldBrick, pColumn, start_x, start_y + 9 * brickHeight); pColumn = shieldFactory.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++, pShieldGrid); off_x += brickWidth; shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 2 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 3 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 4 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 5 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 6 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 7 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 8 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 9 * brickHeight); pColumn = shieldFactory.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++, pShieldGrid); off_x += brickWidth; shieldFactory.Create(ShieldCategory.Type.LeftBottom, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 2 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 3 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 4 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 5 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 6 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 7 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 8 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 9 * brickHeight); pColumn = shieldFactory.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++, pShieldGrid); off_x += brickWidth; shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 3 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 4 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 5 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 6 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 7 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 8 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 9 * brickHeight); pColumn = shieldFactory.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++, pShieldGrid); off_x += brickWidth; shieldFactory.Create(ShieldCategory.Type.RightBottom, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 2 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 3 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 4 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 5 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 6 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 7 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 8 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 9 * brickHeight); pColumn = shieldFactory.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++, pShieldGrid); off_x += brickWidth; shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 0 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 1 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 2 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 3 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 4 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 5 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 6 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 7 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 8 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 9 * brickHeight); pColumn = shieldFactory.Create(ShieldCategory.Type.Column, GameObject.Name.ShieldColumn_0 + j++, pShieldGrid); off_x += brickWidth; shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 0 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 1 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 2 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 3 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 4 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 5 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 6 * brickHeight); shieldFactory.Create(ShieldCategory.Type.Brick, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 7 * brickHeight); shieldFactory.Create(ShieldCategory.Type.RightTop1, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 8 * brickHeight); shieldFactory.Create(ShieldCategory.Type.RightTop0, GameObject.Name.ShieldBrick, pColumn, start_x + off_x, start_y + 9 * brickHeight); } //--------------------------------------------------------------------------------------------------------- // ColPair //--------------------------------------------------------------------------------------------------------- // associate in a collision pair ColPair pColPair = ColPairMan.Add(ColPair.Name.Alien_Wall, pAlienGroup, pWallGroup); Debug.Assert(pColPair != null); pColPair.Attach(new GridObserver()); //pColPair.Attach(new SndObserver(sndEngine, SndObserver.Name.Alien_Wall)); // Missile vs Wall pColPair = ColPairMan.Add(ColPair.Name.Missile_Wall, pMissileGroup, pWallGroup); Debug.Assert(pColPair != null); pColPair.Attach(new ShipReadyObserver()); pColPair.Attach(new RemoveMissileObserver()); pColPair.Attach(new ExplosionObserver(explosionFactory, GameObject.Name.MissileDies, GameSprite.Name.MissileDies, pExplosionGroup, 1)); // Bomb vs Bottom pColPair = ColPairMan.Add(ColPair.Name.Bomb_Wall, pBombRoot, pWallGroup); pColPair.Attach(new BombObserver(1)); pColPair.Attach(new RemoveBombObserver()); pColPair.Attach(new ExplosionObserver(explosionFactory, GameObject.Name.BombDies, GameSprite.Name.BombDies, pExplosionGroup, 1)); // UFO vs Wall pColPair = ColPairMan.Add(ColPair.Name.UFO_Wall, pUFORoot, pWallGroup); Debug.Assert(pColPair != null); pColPair.Attach(new RemoveUFOObserver()); pColPair.Attach(new UFOReadyObserver(sndEngine)); // Missle vs UFO pColPair = ColPairMan.Add(ColPair.Name.Missile_UFO, pMissileGroup, pUFORoot); Debug.Assert(pColPair != null); pColPair.Attach(new SndObserver(sndEngine, SndObserver.Name.Missile_Shield)); pColPair.Attach(new RemoveUFOObserver2()); pColPair.Attach(new RemoveMissileObserver()); pColPair.Attach(new UFOReadyObserver(sndEngine)); pColPair.Attach(new ScoreObserver()); pColPair.Attach(new ShipReadyObserver()); pColPair.Attach(new ExplosionObserver(explosionFactory, GameObject.Name.UFODies, GameSprite.Name.UFODies, pExplosionGroup, 2)); // missile vs alien pColPair = ColPairMan.Add(ColPair.Name.Alien_Missile, pMissileGroup, pAlienGroup); pColPair.Attach(new ShipReadyObserver()); pColPair.Attach(new RemoveMissileObserver()); pColPair.Attach(new ScoreObserver()); pColPair.Attach(new ExplosionObserver(explosionFactory, GameObject.Name.AlienDies, GameSprite.Name.AlienDies, pExplosionGroup, 2)); pColPair.Attach(new GridRemoveAlienObserver()); pColPair.Attach(new SndObserver(sndEngine, SndObserver.Name.Missile_Alien)); pColPair.Attach(new AlienNumObserver(sndEngine)); // Missile vs Shield pColPair = ColPairMan.Add(ColPair.Name.Misslie_Shield, pMissileGroup, pShieldRoot); pColPair.Attach(new SndObserver(sndEngine, SndObserver.Name.Missile_Shield)); pColPair.Attach(new RemoveMissileObserver()); pColPair.Attach(new RemoveBrickObserver()); pColPair.Attach(new ShipReadyObserver()); pColPair.Attach(new ExplosionObserver(explosionFactory, GameObject.Name.MissileDies, GameSprite.Name.MissileDies, pExplosionGroup, 1)); // Bomb vs Shield pColPair = ColPairMan.Add(ColPair.Name.Bomb_Shield, pBombRoot, pShieldRoot); pColPair.Attach(new SndObserver(sndEngine, SndObserver.Name.Bomb_Shield)); pColPair.Attach(new BombObserver(1)); pColPair.Attach(new RemoveBrickObserver()); pColPair.Attach(new RemoveBombObserver()); pColPair.Attach(new ExplosionObserver(explosionFactory, GameObject.Name.BombDies, GameSprite.Name.BombDies, pExplosionGroup, 1)); // Bomb vs Ship pay attention to the order pColPair = ColPairMan.Add(ColPair.Name.Bomb_Ship, pBombRoot, pShipRoot); pColPair.Attach(new SndObserver(sndEngine, SndObserver.Name.Bomb_Ship)); pColPair.Attach(new BombObserver(1)); pColPair.Attach(new RemoveBombObserver()); pColPair.Attach(new RemoveShipObserver()); pColPair.Attach(new LifeObserver()); pColPair.Attach(new AnimExplosionObserver(explosionFactory, GameObject.Name.ShipDies, GameSprite.Name.ShipDies, pExplosionGroup, 2)); pColPair.Attach(new CreateShipObserver(sndEngine)); // Ship vs Bumper pColPair = ColPairMan.Add(ColPair.Name.Ship_Bumper, pShipRoot, pBumperGroup); pColPair.Attach(new ShipMoveObserver()); // Missle vs Bomb pColPair = ColPairMan.Add(ColPair.Name.Missile_Bomb, pMissileGroup, pBombRoot); Debug.Assert(pColPair != null); pColPair.Attach(new BombObserver(2)); pColPair.Attach(new RemoveMissileObserver()); pColPair.Attach(new RemoveBomb2Observer()); pColPair.Attach(new ShipReadyObserver()); pColPair.Attach(new ExplosionObserver(explosionFactory, GameObject.Name.MissileBombCol, GameSprite.Name.MissileBombCol, pExplosionGroup, 1)); //--------------------------------------------------------------------------------------------------------- // Input //--------------------------------------------------------------------------------------------------------- InputSubject pInputSubject; pInputSubject = InputMan.GetArrowRightSubject(); pInputSubject.Attach(new MoveRightObserver()); pInputSubject = InputMan.GetArrowLeftSubject(); pInputSubject.Attach(new MoveLeftObserver()); pInputSubject = InputMan.GetSpaceSubject(); pInputSubject.Attach(new ShootObserver()); pInputSubject = InputMan.GetTSubject(); pInputSubject.Attach(new ToggleObserver()); pInputSubject = InputMan.GetRSubject(); pInputSubject.Attach(new ToggleShieldObserver()); Simulation.SetState(Simulation.State.Realtime); //--------------------------------------------------------------------------------------------------------- // Font //--------------------------------------------------------------------------------------------------------- FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, "SCORE<1>", Glyph.Name.Consolas20pt, 100, 730); FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, "HI-SCORE", Glyph.Name.Consolas20pt, 300, 730); FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, "SCORE<2>", Glyph.Name.Consolas20pt, 500, 730); FontMan.Add(Font.Name.Score1, SpriteBatch.Name.Texts, score1, Glyph.Name.Consolas20pt, 100, 700); FontMan.Add(Font.Name.ScoreHigh, SpriteBatch.Name.Texts, scoreHigh, Glyph.Name.Consolas20pt, 300, 700); FontMan.Add(Font.Name.Score2, SpriteBatch.Name.Texts, score2, Glyph.Name.Consolas20pt, 500, 700); FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, "X", Glyph.Name.Consolas20pt, 80, 17); FontMan.Add(Font.Name.Life, SpriteBatch.Name.Texts, GetPlayerLife(GetCurrPlayer()).ToString(), Glyph.Name.Consolas20pt, 100, 17); FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, "Player " + currPlayer.ToString(), Glyph.Name.Consolas20pt, 480, 17); FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, currPlayer == 1 ? "Level " + player1Level.ToString() : "Level " + player2Level.ToString(), Glyph.Name.Consolas20pt, 570, 17); //--------------------------------------------------------------------------------------------------------- // State settings //--------------------------------------------------------------------------------------------------------- SceneStateGame.SetLoadGhost(false); }
public override void Initialize() { this.poSpriteBatchMan = new SpriteBatchMan(3, 1); SpriteBatchMan.SetActive(this.poSpriteBatchMan); this.poFontMan = new FontMan(); FontMan.SetActive(this.poFontMan); this.poInputMan = new InputMan(); InputMan.SetActive(this.poInputMan); SpriteBatch pSB_Texts = SpriteBatchMan.Add(SpriteBatch.Name.Texts, 100, true); Texture pTexture = TextureMan.Add(Texture.Name.Consolas36pt, "Consolas36pt.tga"); GlyphMan.AddXml(Glyph.Name.Consolas36pt, "Consolas36pt.xml", Texture.Name.Consolas36pt); Font pFont = FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, "Instructions", Glyph.Name.Consolas36pt, 100, 500); pFont.SetColor(1.0f, 1.0f, 1.0f); pFont = FontMan.Add(Font.Name.Instructions, SpriteBatch.Name.Texts, "Player One", Glyph.Name.Consolas20pt, 100, 450); pFont.SetColor(0.80f, 0.80f, 0.80f); pFont = FontMan.Add(Font.Name.Instructions, SpriteBatch.Name.Texts, "Move Left: ", Glyph.Name.Consolas20pt, 100, 400); pFont.SetColor(0.60f, 0.60f, 0.60f); pFont = FontMan.Add(Font.Name.Instructions, SpriteBatch.Name.Texts, "Left Arrow Key", Glyph.Name.Consolas20pt, 225, 400); pFont.SetColor(0.60f, 0.60f, 0.60f); pFont = FontMan.Add(Font.Name.Instructions, SpriteBatch.Name.Texts, "Move Right: ", Glyph.Name.Consolas20pt, 100, 350); pFont.SetColor(0.60f, 0.60f, 0.60f); pFont = FontMan.Add(Font.Name.Instructions, SpriteBatch.Name.Texts, "Right Arrow Key", Glyph.Name.Consolas20pt, 225, 350); pFont.SetColor(0.60f, 0.60f, 0.60f); pFont = FontMan.Add(Font.Name.Instructions, SpriteBatch.Name.Texts, "Shoot: ", Glyph.Name.Consolas20pt, 100, 300); pFont.SetColor(0.60f, 0.60f, 0.60f); pFont = FontMan.Add(Font.Name.Instructions, SpriteBatch.Name.Texts, "Spacebar", Glyph.Name.Consolas20pt, 175, 300); pFont.SetColor(0.60f, 0.60f, 0.60f); pFont = FontMan.Add(Font.Name.Instructions, SpriteBatch.Name.Texts, "Player Two", Glyph.Name.Consolas20pt, 500, 450); pFont.SetColor(0.80f, 0.80f, 0.80f); pFont = FontMan.Add(Font.Name.Instructions, SpriteBatch.Name.Texts, "Move Left: ", Glyph.Name.Consolas20pt, 500, 400); pFont.SetColor(0.60f, 0.60f, 0.60f); pFont = FontMan.Add(Font.Name.Instructions, SpriteBatch.Name.Texts, "A", Glyph.Name.Consolas20pt, 625, 400); pFont.SetColor(0.60f, 0.60f, 0.60f); pFont = FontMan.Add(Font.Name.Instructions, SpriteBatch.Name.Texts, "Move Right: ", Glyph.Name.Consolas20pt, 500, 350); pFont.SetColor(0.60f, 0.60f, 0.60f); pFont = FontMan.Add(Font.Name.Instructions, SpriteBatch.Name.Texts, "D", Glyph.Name.Consolas20pt, 625, 350); pFont.SetColor(0.60f, 0.60f, 0.60f); pFont = FontMan.Add(Font.Name.Instructions, SpriteBatch.Name.Texts, "Shoot: ", Glyph.Name.Consolas20pt, 500, 300); pFont.SetColor(0.60f, 0.60f, 0.60f); pFont = FontMan.Add(Font.Name.Instructions, SpriteBatch.Name.Texts, "S", Glyph.Name.Consolas20pt, 625, 300); pFont.SetColor(0.60f, 0.60f, 0.60f); pFont = FontMan.Add(Font.Name.Instructions, SpriteBatch.Name.Texts, "Back to Menu", Glyph.Name.Consolas20pt, 100, 100); pFont.SetColor(0.60f, 0.60f, 0.60f); InputSubject pInputSubject = InputMan.GetCursorSubject(); pInputSubject.Attach(new HighlightHoverTextObserver(pFont)); pInputSubject = InputMan.GetMouseLeftKeySubject(); pInputSubject.Attach(new MenuChoiceObserver(pFont)); }
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); }
//This loadContent is called in the actual Game.cs //So its done before the player even presses input // and only called once public override void LoadContent() { //--------------------------------------------------------------------------------------------------------- // Create Managers //--------------------------------------------------------------------------------------------------------- TextureMan.Create(6, 1); ImageMan.Create(25, 2); GameSpriteMan.Create(20, 1); //i'm grossly inefficient at this point //------------------------------------------------ BoxSpriteMan.Create(200, 100); ProxySpriteMan.Create(200, 100); //------------------------------------------------- SpriteBatchMan.Create(8, 1); GlyphMan.Create(); FontMan.Create(12, 1); GONodeMan.Create(10, 3); TimerMan.Create(7, 3); ColPairMan.Create(16, 1); //Experimental managers AnimMan.Create(3, 1); Simulation.Create(); PlayerMan.Create(); SpaceInvaders pGame = GameMan.GetGame(); IrrKlang.ISoundEngine pSndEngine = pGame.GetSndEngine(); //--------------------------------------------------------------------------------------------------------- // Load the Textures and Font {Consolas20pt} //--------------------------------------------------------------------------------------------------------- TextureMan.Add(Texture.Name.Aliens14x14, "aliens14x14.tga"); TextureMan.Add(Texture.Name.Aliens, "SpaceInvadersSprites.tga"); TextureMan.Add(Texture.Name.Consolas36pt, "Consolas36pt.tga"); TextureMan.Add(Texture.Name.Consolas20pt, "Consolas20pt.tga"); FontMan.AddXml(Glyph.Name.Consolas20pt, "Consolas20pt.xml", Texture.Name.Consolas20pt); FontMan.AddXml(Glyph.Name.Consolas36pt, "Consolas36pt.xml", Texture.Name.Consolas36pt); //--------------------------------------------------------------------------------------------------------- // Load Images //--------------------------------------------------------------------------------------------------------- ImageMan.Add(Image.Name.CrabU, Texture.Name.Aliens14x14, 318, 180, 160, 116); ImageMan.Add(Image.Name.CrabD, Texture.Name.Aliens14x14, 318, 24, 160, 116); ImageMan.Add(Image.Name.OctopusU, Texture.Name.Aliens14x14, 610, 25, 122, 115); ImageMan.Add(Image.Name.OctopusD, Texture.Name.Aliens14x14, 610, 180, 119, 112); ImageMan.Add(Image.Name.SquidU, Texture.Name.Aliens14x14, 51, 24, 175, 116); ImageMan.Add(Image.Name.SquidD, Texture.Name.Aliens14x14, 51, 180, 175, 110); ImageMan.Add(Image.Name.Ship, Texture.Name.Aliens14x14, 52, 336, 194, 114); ImageMan.Add(Image.Name.UFO, Texture.Name.Aliens14x14, 81, 502, 229, 98); ImageMan.Add(Image.Name.Missile, Texture.Name.Aliens14x14, 378, 798, 14, 98); ImageMan.Add(Image.Name.AlienSplat, Texture.Name.Aliens14x14, 573, 490, 183, 110); ImageMan.Add(Image.Name.ShipSplat, Texture.Name.Aliens, 651, 942, 117, 72); ImageMan.Add(Image.Name.BombSplat, Texture.Name.Aliens, 350, 90, 49, 72); ImageMan.Add(Image.Name.UFOSplat, Texture.Name.Aliens, 224, 230, 187, 77); ImageMan.Add(Image.Name.BombStraight, Texture.Name.Aliens, 216, 94, 16, 56); ImageMan.Add(Image.Name.BombZigZag, Texture.Name.Aliens, 349, 161, 23, 59); ImageMan.Add(Image.Name.BombCross, Texture.Name.Aliens, 210, 163, 30, 48); ImageMan.Add(Image.Name.Brick, Texture.Name.Aliens, 50, 120, 20, 10); ImageMan.Add(Image.Name.BrickLeft_Top1, Texture.Name.Aliens, 40, 100, 20, 10); ImageMan.Add(Image.Name.BrickLeft_Top2, Texture.Name.Aliens, 40, 110, 20, 10); ImageMan.Add(Image.Name.BrickLeft_Bottom, Texture.Name.Aliens, 75, 190, 15, 10); ImageMan.Add(Image.Name.BrickRight_Top1, Texture.Name.Aliens, 189, 125, 20, 10); ImageMan.Add(Image.Name.BrickRight_Top2, Texture.Name.Aliens, 186, 126, 20, 10); ImageMan.Add(Image.Name.BrickRight_Bottom, Texture.Name.Aliens, 130, 190, 20, 10); //--------------------------------------------------------------------------------------------------------- // Create Sprites //--------------------------------------------------------------------------------------------------------- GameSpriteMan.Add(GameSprite.Name.UFO, Image.Name.UFO, 400, 550, 50.0f, 25.0f); GameSpriteMan.Add(GameSprite.Name.Ship, Image.Name.Ship, 400, 25, 40.0f, 25.0f); GameSpriteMan.Add(GameSprite.Name.Crab, Image.Name.CrabU, 700, 480, 35, 20); GameSpriteMan.Add(GameSprite.Name.Squid, Image.Name.SquidU, 325, 350, 35, 20); GameSpriteMan.Add(GameSprite.Name.Octopus, Image.Name.OctopusU, 260, 350, 25, 20); GameSpriteMan.Add(GameSprite.Name.AlienSplat, Image.Name.AlienSplat, 50, 50, 30, 20); GameSpriteMan.Add(GameSprite.Name.ShipSplat, Image.Name.ShipSplat, 50, 50, 40, 25); GameSpriteMan.Add(GameSprite.Name.UFOsplat, Image.Name.UFOSplat, 50, 50, 50, 25); GameSpriteMan.Add(GameSprite.Name.BombSplat, Image.Name.BombSplat, 50, 50, 10, 15); GameSpriteMan.Add(GameSprite.Name.Missile, Image.Name.Missile, 100, 100, 5.0f, 15.0f); 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_LeftTop1, Image.Name.BrickLeft_Top1, 50, 25, 10, 5); GameSpriteMan.Add(GameSprite.Name.Brick_LeftTop2, Image.Name.BrickLeft_Top2, 50, 25, 10, 5); GameSpriteMan.Add(GameSprite.Name.Brick_LeftBottom, Image.Name.BrickLeft_Bottom, 50, 25, 10, 5); GameSpriteMan.Add(GameSprite.Name.Brick_RightTop1, Image.Name.BrickRight_Top1, 50, 25, 10, 5); GameSpriteMan.Add(GameSprite.Name.Brick_RightTop2, Image.Name.BrickRight_Top2, 50, 25, 10, 5); GameSpriteMan.Add(GameSprite.Name.Brick_RightBottom, Image.Name.BrickRight_Bottom, 50, 25, 10, 5); //------------------------------------------------------------------------------------------ //Attaching the sprites/batches //------------------------------------------------------------------------------------------ SpriteBatch pSB_Intro = SpriteBatchMan.Add(SpriteBatch.Name.IntroScreen); SpriteBatch pSB_Aliens = SpriteBatchMan.Add(SpriteBatch.Name.Aliens); pSB_Aliens.bToggle = false; SpriteBatch pSB_Boxes = SpriteBatchMan.Add(SpriteBatch.Name.Boxes); SpriteBatch pSB_Shields = SpriteBatchMan.Add(SpriteBatch.Name.Shields); pSB_Shields.bToggle = false; SpriteBatch pSB_InGame = SpriteBatchMan.Add(SpriteBatch.Name.InGameScreen); pSB_InGame.bToggle = false; SpriteBatch pSB_Projectiles = SpriteBatchMan.Add(SpriteBatch.Name.Projectiles); pSB_Projectiles.bToggle = false; SpriteBatch pSB_GameOver = SpriteBatchMan.Add(SpriteBatch.Name.GameOver); pSB_GameOver.bToggle = false; //SpriteBatch pSB_Splats = SpriteBatchMan.Add(SpriteBatch.Name.Splats); //pSB_Splats.bToggle = false; //--------------------------------------------------------------------------------------------------------- // Font //--------------------------------------------------------------------------------------------------------- FontMan.Add(Font.Name.Title, SpriteBatch.Name.IntroScreen, "Space Invaders", Glyph.Name.Consolas36pt, 200, 700); FontMan.Add(Font.Name.NumOfPlayers, SpriteBatch.Name.IntroScreen, "Press 1 for Single Player", Glyph.Name.Consolas36pt, 120, 650); FontMan.Add(Font.Name.ShootButton, SpriteBatch.Name.IntroScreen, "Space <Bar> To Shoot", Glyph.Name.Consolas36pt, 140, 580); FontMan.Add(Font.Name.MoveButtons, SpriteBatch.Name.IntroScreen, "Left and Right Arrows To Move", Glyph.Name.Consolas36pt, 60, 540); FontMan.Add(Font.Name.SquidScore, SpriteBatch.Name.IntroScreen, "Squid = 30 points", Glyph.Name.Consolas36pt, 200, 480); FontMan.Add(Font.Name.CrabScore, SpriteBatch.Name.IntroScreen, "Crab = 40 points", Glyph.Name.Consolas36pt, 200, 440); FontMan.Add(Font.Name.OctoScore, SpriteBatch.Name.IntroScreen, "Octo = 50 points", Glyph.Name.Consolas36pt, 200, 400); FontMan.Add(Font.Name.UFOScore, SpriteBatch.Name.IntroScreen, "UFO = 100 points", Glyph.Name.Consolas36pt, 200, 360); FontMan.Add(Font.Name.TBD, SpriteBatch.Name.IntroScreen, "2 Player Coming Soon!", Glyph.Name.Consolas36pt, 160, 300); FontMan.Add(Font.Name.ScoreP1, SpriteBatch.Name.InGameScreen, "<P1 Score>", Glyph.Name.Consolas36pt, 20, 720); FontMan.Add(Font.Name.LivesP1, SpriteBatch.Name.InGameScreen, "P1 Lives:", Glyph.Name.Consolas36pt, 20, 20); FontMan.Add(Font.Name.P1Points, SpriteBatch.Name.InGameScreen, "0", Glyph.Name.Consolas36pt, 20, 680); FontMan.Add(Font.Name.HiScore, SpriteBatch.Name.InGameScreen, "<HiScore>", Glyph.Name.Consolas36pt, 230, 720); FontMan.Add(Font.Name.HiPoints, SpriteBatch.Name.InGameScreen, "0", Glyph.Name.Consolas36pt, 250, 680); FontMan.Add(Font.Name.ScoreP2, SpriteBatch.Name.InGameScreen, "<P2 Score>", Glyph.Name.Consolas36pt, 425, 720); FontMan.Add(Font.Name.LivesP2, SpriteBatch.Name.InGameScreen, "P2 Lives:", Glyph.Name.Consolas36pt, 400, 20); FontMan.Add(Font.Name.P2Points, SpriteBatch.Name.InGameScreen, "0", Glyph.Name.Consolas36pt, 400, 680); FontMan.Add(Font.Name.GameOver, SpriteBatch.Name.GameOver, "Game, Set and Match", Glyph.Name.Consolas36pt, 100, 450); FontMan.Add(Font.Name.Credits, SpriteBatch.Name.GameOver, "Created By: James Corcoran", Glyph.Name.Consolas36pt, 100, 350); FontMan.Add(Font.Name.Thankyou, SpriteBatch.Name.GameOver, "Thanks for Playing!!!", Glyph.Name.Consolas36pt, 100, 250); //---------------------------------------------------------------------- //Missile //---------------------------------------------------------------------- MissileGroup pMissileGroup = new MissileGroup(GameObject.Name.MissileGroup, GameSprite.Name.NullObject, 0, 0.0f, 0.0f); pMissileGroup.ActivateGameSprite(pSB_Projectiles); pMissileGroup.ActivateCollisionSprite(pSB_Boxes); GONodeMan.Attach(pMissileGroup); Debug.WriteLine("-------------------"); pMissileGroup.Print(); //---------------------------------------------------------------------- //Ship //---------------------------------------------------------------------- ShipRoot pShipRoot = new ShipRoot(GameObject.Name.ShipRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); GONodeMan.Attach(pShipRoot); Debug.WriteLine("-------------------"); pShipRoot.Print(); //---------------------------------------------------------------------- //UFO //---------------------------------------------------------------------- UFORoot pUFORoot = new UFORoot(GameObject.Name.UFORoot, GameSprite.Name.NullObject, 0.0f, 0.0f); GONodeMan.Attach(pUFORoot); Debug.WriteLine("-------------------"); pUFORoot.Print(); //--------------------------------------------------------------------------------------------------------- // Bomb //--------------------------------------------------------------------------------------------------------- BombRoot pBombRoot = new BombRoot(GameObject.Name.BombRoot, GameSprite.Name.NullObject, -100.0f, -100.0f); GONodeMan.Attach(pBombRoot); Debug.WriteLine("-------------------"); pBombRoot.Print(); //--------------------------------------------------------------------- //Wall Creation //--------------------------------------------------------------------- WallRoot pTWallRoot = new WallRoot(GameObject.Name.WallRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); GONodeMan.Attach(pTWallRoot); TopWall pTWall = new TopWall(GameObject.Name.TopWall, GameSprite.Name.NullObject, 336, 748, 600, 40); pTWall.ActivateCollisionSprite(pSB_Boxes); pTWallRoot.Add(pTWall); WallRoot pLWallRoot = new WallRoot(GameObject.Name.WallRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); GONodeMan.Attach(pLWallRoot); LeftWall pLWall = new LeftWall(GameObject.Name.LeftWall, GameSprite.Name.NullObject, 20, 384, 40, 700); pLWall.ActivateCollisionSprite(pSB_Boxes); pLWallRoot.Add(pLWall); WallRoot pRWallRoot = new WallRoot(GameObject.Name.WallRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); GONodeMan.Attach(pRWallRoot); RightWall pRWall = new RightWall(GameObject.Name.RightWall, GameSprite.Name.NullObject, 653, 384, 40, 700); pRWall.ActivateCollisionSprite(pSB_Boxes); pRWallRoot.Add(pRWall); WallRoot pBWallRoot = new WallRoot(GameObject.Name.WallRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); GONodeMan.Attach(pBWallRoot); BottomWall pBWall = new BottomWall(GameObject.Name.BottomWall, GameSprite.Name.NullObject, 336, 20, 700, 40); pBWall.ActivateCollisionSprite(pSB_Boxes); pBWallRoot.Add(pBWall); Debug.WriteLine("-------------------"); //--------------------------------------------------------------------- //AlienRoot(Group) and ShieldRoot //--------------------------------------------------------------------- Composite pAlienGroup = new AlienGroup(GameObject.Name.AlienGrid, GameSprite.Name.NullObject, 0.0f, 0.0f); pAlienGroup.ActivateCollisionSprite(pSB_Boxes); GONodeMan.Attach(pAlienGroup); Composite pShieldRoot = new ShieldRoot(GameObject.Name.ShieldRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); GONodeMan.Attach(pShieldRoot); //Composite pSplatRoot = new SplatRoot(GameObject.Name.SplatRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); //GONodeMan.Attach(pSplatRoot); //-------------------------------------------------------------------------- // Collision Pair //-------------------------------------------------------------------------- ColPair pGrid_V_LWall = ColPairMan.Add(ColPair.Name.Aliens_V_LWall, pAlienGroup, pLWallRoot); Debug.Assert(pGrid_V_LWall != null); pGrid_V_LWall.Attach(new GridObserver()); ColPair pGrid_V_RWall = ColPairMan.Add(ColPair.Name.Aliens_V_RWall, pAlienGroup, pRWallRoot); Debug.Assert(pGrid_V_RWall != null); pGrid_V_RWall.Attach(new GridObserver()); ColPair pGrid_V_BWall = ColPairMan.Add(ColPair.Name.Aliens_V_BWall, pAlienGroup, pBWallRoot); Debug.Assert(pGrid_V_BWall != null); pGrid_V_BWall.Attach(new GridObserver()); ColPair pMissile_V_Alien = ColPairMan.Add(ColPair.Name.Missile_V_Alien, pMissileGroup, pAlienGroup); Debug.Assert(pMissile_V_Alien != null); pMissile_V_Alien.Attach(new SplatObserver()); pMissile_V_Alien.Attach(new RemoveAlienObserver()); pMissile_V_Alien.Attach(new RemoveMissileObserver()); pMissile_V_Alien.Attach(new ShipReadyObserver()); pMissile_V_Alien.Attach(new SndObserver(pSndEngine, "invaderkilled.wav")); ColPair pAlien_V_Shield = ColPairMan.Add(ColPair.Name.Aliens_V_Shield, pAlienGroup, pShieldRoot); Debug.Assert(pAlien_V_Shield != null); pAlien_V_Shield.Attach(new RemoveBrickObserver()); //pAlien_V_Shield.Attach(new SndObserver(pSndEngine, "explosion.wav")); ColPair pAlien_V_Ship = ColPairMan.Add(ColPair.Name.Aliens_V_Ship, pAlienGroup, pShipRoot); Debug.Assert(pAlien_V_Ship != null); pAlien_V_Ship.Attach(new SplatShipObserver()); pAlien_V_Ship.Attach(new HitShipObserver()); pAlien_V_Ship.Attach(new SndObserver(pSndEngine, "explosion.wav")); pAlien_V_Ship.Attach(new P1GameOverObs()); //-------------------------------------------------------------------------------------------------------------- ColPair pCollide_UFO_RWall = ColPairMan.Add(ColPair.Name.UFO_V_RWall, pUFORoot, pRWallRoot); Debug.Assert(pCollide_UFO_RWall != null); pCollide_UFO_RWall.Attach(new MissedUFOobserver()); pCollide_UFO_RWall.Attach(new RemoveSndUFO()); ColPair pCollide_UFO_LWall = ColPairMan.Add(ColPair.Name.UFO_V_LWall, pUFORoot, pLWallRoot); Debug.Assert(pCollide_UFO_LWall != null); pCollide_UFO_LWall.Attach(new MissedUFOobserver()); pCollide_UFO_LWall.Attach(new RemoveSndUFO()); ColPair pCollide_Missile_V_UFO = ColPairMan.Add(ColPair.Name.Missile_V_UFO, pMissileGroup, pUFORoot); Debug.Assert(pCollide_Missile_V_UFO != null); pCollide_Missile_V_UFO.Attach(new RemoveMissileObserver()); pCollide_Missile_V_UFO.Attach(new RemoveUFOobserver()); pCollide_Missile_V_UFO.Attach(new ShipReadyObserver()); pCollide_Missile_V_UFO.Attach(new UFOSplatObs()); pCollide_Missile_V_UFO.Attach(new SndObserver(pSndEngine, "invaderkilled.wav")); pCollide_Missile_V_UFO.Attach(new RemoveSndUFO()); //----------------------------------------------------------------------------------------------------------------- ColPair pMissile_V_TWall = ColPairMan.Add(ColPair.Name.Missile_V_TWall, pMissileGroup, pTWallRoot); Debug.Assert(pMissile_V_TWall != null); pMissile_V_TWall.Attach(new ShipReadyObserver()); pMissile_V_TWall.Attach(new RemoveMissileObserver()); ColPair pBomb_V_Wall = ColPairMan.Add(ColPair.Name.Bomb_V_Wall, pBombRoot, pBWallRoot); Debug.Assert(pBomb_V_Wall != null); pBomb_V_Wall.Attach(new BombObserver()); ColPair pMissile_V_Shield = ColPairMan.Add(ColPair.Name.Missile_V_Shield, pMissileGroup, pShieldRoot); Debug.Assert(pMissile_V_Shield != null); pMissile_V_Shield.Attach(new RemoveBrickObserver()); pMissile_V_Shield.Attach(new RemoveMissileObserver()); pMissile_V_Shield.Attach(new ShipReadyObserver()); pMissile_V_Shield.Attach(new SndObserver(pSndEngine, "explosion.wav")); ColPair pBomb_V_Shield = ColPairMan.Add(ColPair.Name.Bomb_V_Shield, pBombRoot, pShieldRoot); Debug.Assert(pBomb_V_Shield != null); pBomb_V_Shield.Attach(new RemoveBrickObserver()); pBomb_V_Shield.Attach(new BombObserver()); pBomb_V_Shield.Attach(new SndObserver(pSndEngine, "explosion.wav")); ColPair pBomb_V_Ship = ColPairMan.Add(ColPair.Name.Ship_V_Bomb, pBombRoot, pShipRoot); Debug.Assert(pBomb_V_Ship != null); pBomb_V_Ship.Attach(new SplatShipObserver()); pBomb_V_Ship.Attach(new BombObserver()); pBomb_V_Ship.Attach(new HitShipObserver()); pBomb_V_Ship.Attach(new SndObserver(pSndEngine, "explosion.wav")); pBomb_V_Ship.Attach(new P1GameOverObs()); ColPair pBomb_V_Missile = ColPairMan.Add(ColPair.Name.Bomb_V_Missile, pBombRoot, pMissileGroup); Debug.Assert(pBomb_V_Missile != null); pBomb_V_Missile.Attach(new BombSplatObs()); pBomb_V_Missile.Attach(new BombMissileObserver()); pBomb_V_Missile.Attach(new SndObserver(pSndEngine, "explosion.wav")); pBomb_V_Missile.Attach(new ShipReadyObserver()); //------------------------------------------------------------------------------------------------------------------ ColPair pShip_V_LWall = ColPairMan.Add(ColPair.Name.Ship_V_LWall, pShipRoot, pLWallRoot); Debug.Assert(pShip_V_LWall != null); pShip_V_LWall.Attach(new ShipMovementObserver()); ColPair pShip_V_RWall = ColPairMan.Add(ColPair.Name.Ship_V_RWall, pShipRoot, pRWallRoot); Debug.Assert(pShip_V_RWall != null); pShip_V_RWall.Attach(new ShipMovementObserver()); //---------------------------------------------------------------------------------------------------------- //Animate Sprites and Movement Commands //---------------------------------------------------------------------------------------------------------- //Tests on my Animation Manager AnimateCrab pAnimS1 = new AnimateCrab(Animation.Name.AnimateCrab, GameSprite.Name.Crab); pAnimS1.Attach(Image.Name.CrabD); pAnimS1.Attach(Image.Name.CrabU); AnimateSquid pAnimS2 = new AnimateSquid(Animation.Name.AnimateSquid, GameSprite.Name.Squid); pAnimS2.Attach(Image.Name.SquidD); pAnimS2.Attach(Image.Name.SquidU); AnimateOcto pAnimS3 = new AnimateOcto(Animation.Name.AnimateOcto, GameSprite.Name.Octopus); pAnimS3.Attach(Image.Name.OctopusD); pAnimS3.Attach(Image.Name.OctopusU); AnimMan.Attach(pAnimS1); AnimMan.Attach(pAnimS2); AnimMan.Attach(pAnimS3); //--------------------------------------------------------------------------------------------------------- //Add Input //--------------------------------------------------------------------------------------------------------- InputSubject pInputSubject; pInputSubject = InputManager.GetArrowRightSubject(); pInputSubject.Attach(new MoveRightObserver()); pInputSubject = InputManager.GetArrowLeftSubject(); pInputSubject.Attach(new MoveLeftObserver()); pInputSubject = InputManager.GetSpaceBarSubject(); pInputSubject.Attach(new ShootObserver()); //first player pInputSubject = InputManager.Get1keySubject(); pInputSubject.Attach(new Player1Observer()); //add second player observer pInputSubject = InputManager.Get2keySubject(); pInputSubject.Attach(new Player2Observer()); pInputSubject = InputManager.GetCkeySubject(); pInputSubject.Attach(new ToggleColObserver()); //Simulator //I am testing because i think we will need to pause the game //for the timer manager and the lives for the ship Simulation.SetState(Simulation.State.RealTime); }
public override void Initialize() { //this.name = SceneContext.Scene.Play; this.numLives = 3; this.isDead = false; //--------------------------------------------------------------------------------------------------------- // Unique Managers //--------------------------------------------------------------------------------------------------------- this.poSpriteBatchMan = new SpriteBatchMan(3, 1); SpriteBatchMan.SetActive(this.poSpriteBatchMan); this.poGameObjectMan = new GameObjectMan(3, 1); GameObjectMan.SetActive(this.poGameObjectMan); this.poTimerMan = new TimerMan(3, 1); TimerMan.SetActive(this.poTimerMan); this.poDelayedObjectMan = new DelayedObjectMan(); DelayedObjectMan.SetActive(this.poDelayedObjectMan); //--------------------------------------------------------------------------------------------------------- // Initialize Input Keys //--------------------------------------------------------------------------------------------------------- this.poInputMan = new InputMan(); InputMan.SetActive(this.poInputMan); 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.GetKey_B_Subject(); pInputSubject.Attach(new Key_B_Observer()); pInputSubject = InputMan.GetKey_1_Subject(); pInputSubject.Attach(new Key_1_Observer()); pInputSubject = InputMan.GetKey_2_Subject(); pInputSubject.Attach(new Key_2_Observer()); pInputSubject = InputMan.GetKey_Q_Subject(); pInputSubject.Attach(new Key_Q_Observer()); //--------------------------------------------------------------------------------------------------------- // Sound //--------------------------------------------------------------------------------------------------------- // start up the engine SoundEngineMan.Add(SoundEngine.Name.AlienA, "fastinvader1.wav", 0.2f); SoundEngineMan.Add(SoundEngine.Name.AlienB, "fastinvader2.wav", 0.2f); SoundEngineMan.Add(SoundEngine.Name.AlienC, "fastinvader3.wav", 0.2f); SoundEngineMan.Add(SoundEngine.Name.AlienD, "fastinvader4.wav", 0.2f); SoundEngineMan.Add(SoundEngine.Name.Shoot, "shoot.wav", 0.2f); SoundEngineMan.Add(SoundEngine.Name.Invaderkilled, "invaderkilled.wav", 0.2f); SoundEngineMan.Add(SoundEngine.Name.Explosion, "explosion.wav", 0.2f); SoundEngineMan.Add(SoundEngine.Name.UFO_HighPitch, "ufo_highpitch.wav", 0.5f); SoundEngineMan.Add(SoundEngine.Name.UFO_LowPitch, "ufo_lowpitch.wav", 0.2f); //--------------------------------------------------------------------------------------------------------- // Font //--------------------------------------------------------------------------------------------------------- Texture pTexture = TextureMan.Add(Texture.Name.Consolas36pt, "Consolas36pt.tga"); GlyphMan.AddXml(Glyph.Name.Consolas36pt, "Consolas36pt.xml", Texture.Name.Consolas36pt); //--------------------------------------------------------------------------------------------------------- // Create Sprites //--------------------------------------------------------------------------------------------------------- this.poGameSpriteMan = new GameSpriteMan(3, 1); GameSpriteMan.SetActive(this.poGameSpriteMan); // ----- Aliens ----- GameSpriteMan.Add(GameSprite.Name.SquidOpen, Image.Name.SquidOpen, 50, 550, 22, 22); GameSpriteMan.Add(GameSprite.Name.CrabOpen, Image.Name.CrabOpen, 50, 510, 25, 25); GameSpriteMan.Add(GameSprite.Name.OctopusOpen, Image.Name.OctopusOpen, 50, 430, 28, 28); // ----- UFO ----- GameSpriteMan.Add(GameSprite.Name.UFO, Image.Name.UFO, 0, 500, 40, 18); // ----- Missile ----- GameSpriteMan.Add(GameSprite.Name.Missile, Image.Name.Missile, 50, 430, 4, 15); // ----- Ship ----- GameSpriteMan.Add(GameSprite.Name.Ship, Image.Name.Ship, 50, 430, 50, 25); // ----- Splats ----- GameSpriteMan.Add(GameSprite.Name.SplatAlien, Image.Name.AlienSplat, 100, 100, 22, 22); GameSpriteMan.Add(GameSprite.Name.SplatBomb, Image.Name.BombSplat, 100, 100, 7, 17); GameSpriteMan.Add(GameSprite.Name.SplatMissile, Image.Name.MissleSplat, 100, 100, 20, 15); GameSpriteMan.Add(GameSprite.Name.SplatUFO, Image.Name.UFOSplat, 100, 100, 40, 18); GameSpriteMan.Add(GameSprite.Name.SplatShip, Image.Name.ShipSplat, 100, 100, 50, 25); // ----- Bombs ----- GameSpriteMan.Add(GameSprite.Name.BombDragger, Image.Name.BombDragger, 100, 100, 7, 17); GameSpriteMan.Add(GameSprite.Name.BombZigZag, Image.Name.BombZigZag, 100, 100, 7, 17); GameSpriteMan.Add(GameSprite.Name.BombRolling, Image.Name.BombRolling, 100, 100, 7, 17); GameSpriteMan.Add(GameSprite.Name.BombStraight, Image.Name.BombStraight, 100, 100, 5, 17); // ----- Shields ----- float brick_W = 15.0f; float brick_H = 6.0f; GameSpriteMan.Add(GameSprite.Name.Brick, Image.Name.Brick, 50, 25, brick_W, brick_H); GameSpriteMan.Add(GameSprite.Name.Brick_LeftTop0, Image.Name.BrickLeft_Top0, 50, 25, brick_W, brick_H); GameSpriteMan.Add(GameSprite.Name.Brick_LeftTop1, Image.Name.BrickLeft_Top1, 50, 25, brick_W, brick_H); GameSpriteMan.Add(GameSprite.Name.Brick_LeftBottom, Image.Name.BrickLeft_Bottom, 50, 25, brick_W, brick_H); GameSpriteMan.Add(GameSprite.Name.Brick_RightTop0, Image.Name.BrickRight_Top0, 50, 25, brick_W, brick_H); GameSpriteMan.Add(GameSprite.Name.Brick_RightTop1, Image.Name.BrickRight_Top1, 50, 25, brick_W, brick_H); GameSpriteMan.Add(GameSprite.Name.Brick_RightBottom, Image.Name.BrickRight_Bottom, 50, 25, brick_W, brick_H); //--------------------------------------------------------------------------------------------------------- // Create SpriteBatch //--------------------------------------------------------------------------------------------------------- SpriteBatch pSB_Aliens = this.poSpriteBatchMan.Add(SpriteBatch.Name.Aliens, 100); SpriteBatch pSB_Shields = this.poSpriteBatchMan.Add(SpriteBatch.Name.Shields, 200); SpriteBatch pSB_Texts = this.poSpriteBatchMan.Add(SpriteBatch.Name.Texts, 300); SpriteBatch pSB_Box = this.poSpriteBatchMan.Add(SpriteBatch.Name.Boxes, 400); //--------------------------------------------------------------------------------------------------------- // Create Aliens //--------------------------------------------------------------------------------------------------------- // Create the Aliens factory AlienFactory AF = new AlienFactory(SpriteBatch.Name.Aliens, SpriteBatch.Name.Boxes); // Initialize Grid AlienGrid pGrid = (AlienGrid)AF.Create(GameObject.Name.AlienGrid, AlienCategory.Type.Grid); // Generate Aliens pGrid.GenerateAlien(this.poGameObjectMan); MoveCommand pMoveGrid = new MoveCommand(pGrid); TimerMan.Add(TimeEvent.Name.MoveGrid, pMoveGrid, 0.5f); //--------------------------------------------------------------------------------------------------------- // Timer //--------------------------------------------------------------------------------------------------------- // Create animation for Squid sprite AnimationSprite pAnimSquid = new AnimationSprite(GameSprite.Name.SquidOpen); // Attach Squid images to cycle pAnimSquid.Attach(Image.Name.SquidOpen); pAnimSquid.Attach(Image.Name.SquidClosed); // Create animation for Crab sprite AnimationSprite pAnimCrab = new AnimationSprite(GameSprite.Name.CrabOpen); // Attach Crab images to cycle pAnimCrab.Attach(Image.Name.CrabOpen); pAnimCrab.Attach(Image.Name.CrabClosed); // Create animation for Octopus sprite AnimationSprite pAnimOctopus = new AnimationSprite(GameSprite.Name.OctopusOpen); // Attach Octopus images to cycle pAnimOctopus.Attach(Image.Name.OctopusOpen); pAnimOctopus.Attach(Image.Name.OctopusClosed); // Add AnimationSprite to timer TimerMan.Add(TimeEvent.Name.SwapAliens, pAnimSquid, 0.5f); TimerMan.Add(TimeEvent.Name.SwapAliens, pAnimCrab, 0.5f); TimerMan.Add(TimeEvent.Name.SwapAliens, pAnimOctopus, 0.5f); // Add Grid Tempo GridSoundTempoEvent pGridTempo = new GridSoundTempoEvent(); pGridTempo.Attach(SoundEngine.Name.AlienA); pGridTempo.Attach(SoundEngine.Name.AlienB); pGridTempo.Attach(SoundEngine.Name.AlienC); pGridTempo.Attach(SoundEngine.Name.AlienD); TimerMan.Add(TimeEvent.Name.GridSoundTempo, pGridTempo, 0.5f); //--------------------------------------------------------------------------------------------------------- // Create 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); //--------------------------------------------------------------------------------------------------------- // Splat Root //--------------------------------------------------------------------------------------------------------- BombRoot pSplatRoot = new BombRoot(GameObject.Name.SplatRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); pSplatRoot.ActivateCollisionSprite(pSB_Box); GameObjectMan.Attach(pSplatRoot); //--------------------------------------------------------------------------------------------------------- // Bomb Root //--------------------------------------------------------------------------------------------------------- BombRoot pBombRoot = new BombRoot(GameObject.Name.BombRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); pBombRoot.ActivateCollisionSprite(pSB_Box); GameObjectMan.Attach(pBombRoot); TimerMan.Add(TimeEvent.Name.BombRandom, new BombSpawnEvent(pRandom, pGrid), 1.0f); //--------------------------------------------------------------------------------------------------------- // Create Walls //--------------------------------------------------------------------------------------------------------- // Wall Root WallGroup pWallGroup = new WallGroup(GameObject.Name.WallGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pWallGroup.ActivateGameSprite(pSB_Aliens); pWallGroup.ActivateCollisionSprite(pSB_Box); WallRight pWallRight = new WallRight(GameObject.Name.WallRight, GameSprite.Name.NullObject, 775, 290, 20, 500); pWallRight.ActivateCollisionSprite(pSB_Box); WallLeft pWallLeft = new WallLeft(GameObject.Name.WallLeft, GameSprite.Name.NullObject, 25, 290, 20, 500); pWallLeft.ActivateCollisionSprite(pSB_Box); // Add to the composite the children pWallGroup.Add(pWallRight); pWallGroup.Add(pWallLeft); GameObjectMan.Attach(pWallGroup); //--------------------------------------------------------------------------------------------------------- // Create No Score Items //--------------------------------------------------------------------------------------------------------- WallGroup pNoScoreGroup = new WallGroup(GameObject.Name.NoScoreGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pNoScoreGroup.ActivateGameSprite(pSB_Aliens); pNoScoreGroup.ActivateCollisionSprite(pSB_Box); WallTop pWallTop = new WallTop(GameObject.Name.WallTop, GameSprite.Name.NullObject, 400, 540, 700, 0); pWallTop.ActivateCollisionSprite(pSB_Aliens); WallBottom pWallBottom = new WallBottom(GameObject.Name.WallBottom, GameSprite.Name.NullObject, 400, 40, 730, 0); pWallBottom.ActivateGameSprite(pSB_Aliens); pWallBottom.ActivateCollisionSprite(pSB_Box); pNoScoreGroup.Add(pWallTop); pNoScoreGroup.Add(pWallBottom); GameObjectMan.Attach(pNoScoreGroup); //--------------------------------------------------------------------------------------------------------- // Ship //--------------------------------------------------------------------------------------------------------- ShipRoot pShipRoot = new ShipRoot(GameObject.Name.ShipRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); pShipRoot.ActivateGameSprite(pSB_Aliens); pShipRoot.ActivateCollisionSprite(pSB_Box); GameObjectMan.Attach(pShipRoot); //ShipMan.Create(); this.poShipMan = new ShipMan(); ShipMan.SetActive(this.poShipMan); this.poShipMan.pShip = ShipMan.ActivateShip(); this.poShipMan.pShip.SetState(ShipMan.State.Ready); //--------------------------------------------------------------------------------------------------------- // UFO //--------------------------------------------------------------------------------------------------------- UFORoot pUFORoot = new UFORoot(GameObject.Name.UFORoot, GameSprite.Name.NullObject, 0.0f, 0.0f); pUFORoot.ActivateGameSprite(pSB_Aliens); pUFORoot.ActivateCollisionSprite(pSB_Box); GameObjectMan.Attach(pUFORoot); TimerMan.Add(TimeEvent.Name.UFORandom, new UFOSpawnEvent(pRandom), 5.0f); //--------------------------------------------------------------------------------------------------------- // Shields //--------------------------------------------------------------------------------------------------------- Composite pShieldRoot = ShieldsGroupFactory.Create(100, 130, this.poGameObjectMan); //--------------------------------------------------------------------------------------------------------- // ColPair //--------------------------------------------------------------------------------------------------------- // Grid vs Right Left Walls ColPair pColPair_GW = ColPairMan.Add(ColPair.Name.Alien_Wall, pGrid, pWallGroup); Debug.Assert(pColPair_GW != null); pColPair_GW.Attach(new GridDropObserver()); // Ship vs Right Left Walls ColPair pColPair_SW = ColPairMan.Add(ColPair.Name.Ship_Wall, pShipRoot, pWallGroup); Debug.Assert(pColPair_SW != null); pColPair_SW.Attach(new StopShipMoveObserver()); // Grid vs Shield ColPair pColPair_AS = ColPairMan.Add(ColPair.Name.Bomb_Shield, pGrid, pShieldRoot); Debug.Assert(pColPair_AS != null); pColPair_AS.Attach(new RemoveBrickObserver()); // Missile vs Alien ColPair pColPair_MA = ColPairMan.Add(ColPair.Name.Missile_Alien, pMissileGroup, pGrid); Debug.Assert(pColPair_MA != null); pColPair_MA.Attach(new ShipReadyObserver()); pColPair_MA.Attach(new RemoveAlienObserver(this)); pColPair_MA.Attach(new ShipRemoveMissileObserver(false)); pColPair_MA.Attach(new SndAlienHitObserver()); pColPair_MA.Attach(new SpeedGridObserver()); // Missile vs UFO ColPair pColPair_MU = ColPairMan.Add(ColPair.Name.Missile_UFO, pMissileGroup, pUFORoot); Debug.Assert(pColPair_MU != null); pColPair_MU.Attach(new ShipReadyObserver()); pColPair_MU.Attach(new ShipRemoveMissileObserver(false)); pColPair_MU.Attach(new RemoveUFOObserver()); pColPair_MU.Attach(new SndAlienHitObserver()); // Missle vs Bomb ColPair pColPair_MB = ColPairMan.Add(ColPair.Name.Missile_Bomb, pMissileGroup, pBombRoot); Debug.Assert(pColPair_MB != null); pColPair_MB.Attach(new ShipReadyObserver()); pColPair_MB.Attach(new ShipRemoveMissileObserver(false)); pColPair_MB.Attach(new BombObserver(true)); // Missile vs Top Wall ColPair pColPair_MW = ColPairMan.Add(ColPair.Name.Missile_Wall, pMissileGroup, pNoScoreGroup); Debug.Assert(pColPair_MW != null); pColPair_MW.Attach(new ShipReadyObserver()); pColPair_MW.Attach(new ShipRemoveMissileObserver(true)); // Missile vs Shield ColPair pColPair_MS = ColPairMan.Add(ColPair.Name.Misslie_Shield, pMissileGroup, pShieldRoot); Debug.Assert(pColPair_MS != null); pColPair_MS.Attach(new ShipRemoveMissileObserver(false)); pColPair_MS.Attach(new RemoveBrickObserver()); pColPair_MS.Attach(new ShipReadyObserver()); pColPair_MS.Attach(new SndAlienHitObserver()); // Bomb vs Bottom Wall ColPair pColPair_BW = ColPairMan.Add(ColPair.Name.Bomb_Wall, pBombRoot, pNoScoreGroup); Debug.Assert(pColPair_BW != null); pColPair_BW.Attach(new BombObserver(true)); // Bomb vs Shield ColPair pColPair_BS = ColPairMan.Add(ColPair.Name.Bomb_Shield, pBombRoot, pShieldRoot); Debug.Assert(pColPair_BS != null); pColPair_BS.Attach(new RemoveBombObserver(this)); pColPair_BS.Attach(new RemoveBrickObserver()); pColPair_BS.Attach(new SndAlienHitObserver()); // Bomb vs Player's Ship ColPair pColPair_BP = ColPairMan.Add(ColPair.Name.Bomb_Ship, pBombRoot, pShipRoot); Debug.Assert(pColPair_BP != null); pColPair_BP.Attach(new RemoveShipObserver(this)); pColPair_BP.Attach(new RemoveBombObserver(this)); pColPair_BP.Attach(new SndShipHitObserver()); pColPair_BP.Attach(new ReCreateShipObserver(this)); //--------------------------------------------------------------------------------------------------------- // Fonts //--------------------------------------------------------------------------------------------------------- FontMan.Add(Font.Name.ScoreText, SpriteBatch.Name.Texts, "SCORE<1>", Glyph.Name.Consolas36pt, 60, 585); pFontScore1 = FontMan.Add(Font.Name.Score1, SpriteBatch.Name.Texts, "0000", Glyph.Name.Consolas36pt, 85, 558); FontMan.Add(Font.Name.ScoreText, SpriteBatch.Name.Texts, "HI-SCORE", Glyph.Name.Consolas36pt, 325, 585); pFontHighScore = FontMan.Add(Font.Name.HighScore, SpriteBatch.Name.Texts, "0000", Glyph.Name.Consolas36pt, 350, 558); FontMan.Add(Font.Name.ScoreText, SpriteBatch.Name.Texts, "SCORE<2>", Glyph.Name.Consolas36pt, 600, 585); pFontScore2 = FontMan.Add(Font.Name.Score2, SpriteBatch.Name.Texts, "0000", Glyph.Name.Consolas36pt, 625, 558); FontMan.Add(Font.Name.ScoreText, SpriteBatch.Name.Texts, "LIVES: ", Glyph.Name.Consolas36pt, 50, 25); pFontLives = FontMan.Add(Font.Name.Lives, SpriteBatch.Name.Texts, "3", Glyph.Name.Consolas36pt, 160, 25); }
// 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 Initialize() { ImageMan.Add(Image.Name.Logo, Texture.Name.Aliens, new Azul.Rect(24, 78, 85, 40)); GameSpriteMan.Add(GameSprite.Name.Logo, Image.Name.Logo, 200, 350, 180, 90); 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.poFontMan = new FontMan(); FontMan.SetActive(this.poFontMan); this.poTimerMan = new TimerMan(); TimerMan.SetActive(this.poTimerMan); SpriteBatch pSB_texts = SpriteBatchMan.Add(SpriteBatch.Name.Texts, 100, true); Logo logo = new Logo(GameObject.Name.Logo, GameSprite.Name.Logo, 400, 400); logo.ActivateGameSprite(pSB_texts); GameObjectMan.Attach(logo); Texture pTexture = TextureMan.Add(Texture.Name.Consolas36pt, "Consolas36pt.tga"); GlyphMan.AddXml(Glyph.Name.Consolas36pt, "Consolas36pt.xml", Texture.Name.Consolas36pt); pTexture = TextureMan.Add(Texture.Name.Consolas20pt, "Consolas20pt.tga"); GlyphMan.AddXml(Glyph.Name.Consolas20pt, "Consolas20pt.xml", Texture.Name.Consolas20pt); pTexture = TextureMan.Add(Texture.Name.Consolas20pt, "Consolas20pt.tga"); GlyphMan.AddXml(Glyph.Name.NullObject, "Consolas20pt.xml", Texture.Name.Consolas20pt); Font pFont = FontMan.Add(Font.Name.SinglePlayer, SpriteBatch.Name.Texts, "Single Player", Glyph.Name.Consolas20pt, 200, 300); pFont.SetColor(0.60f, 0.60f, 0.60f); InputSubject pInputSubject = InputMan.GetCursorSubject(); pInputSubject.Attach(new HighlightHoverTextObserver(pFont)); pInputSubject = InputMan.GetMouseLeftKeySubject(); pInputSubject.Attach(new SinglePlayerChoiceObserver(pFont)); pFont = FontMan.Add(Font.Name.MultiPlayer, SpriteBatch.Name.Texts, "Multi Player", Glyph.Name.Consolas20pt, 200, 275); pFont.SetColor(0.60f, 0.60f, 0.60f); pInputSubject = InputMan.GetCursorSubject(); pInputSubject.Attach(new HighlightHoverTextObserver(pFont)); pInputSubject = InputMan.GetMouseLeftKeySubject(); pInputSubject.Attach(new MultiPlayerChoiceObserver(pFont)); pFont = FontMan.Add(Font.Name.Instructions, SpriteBatch.Name.Texts, "Instructions", Glyph.Name.Consolas20pt, 200, 250); pFont.SetColor(0.60f, 0.60f, 0.60f); pInputSubject = InputMan.GetCursorSubject(); pInputSubject.Attach(new HighlightHoverTextObserver(pFont)); pInputSubject = InputMan.GetMouseLeftKeySubject(); pInputSubject.Attach(new InstructionsChoiceObserver(pFont)); pFont = FontMan.Add(Font.Name.HighScores, SpriteBatch.Name.Texts, "High Scores", Glyph.Name.Consolas20pt, 200, 225); pFont.SetColor(0.60f, 0.60f, 0.60f); pInputSubject = InputMan.GetCursorSubject(); pInputSubject.Attach(new HighlightHoverTextObserver(pFont)); pInputSubject = InputMan.GetMouseLeftKeySubject(); pInputSubject.Attach(new HighScoresChoiceObserver(pFont)); pFont = FontMan.Add(Font.Name.Aliens, SpriteBatch.Name.Texts, "Aliens", Glyph.Name.Consolas20pt, 200, 200); pFont.SetColor(0.60f, 0.60f, 0.60f); pInputSubject = InputMan.GetCursorSubject(); pInputSubject.Attach(new HighlightHoverTextObserver(pFont)); pInputSubject = InputMan.GetMouseLeftKeySubject(); pInputSubject.Attach(new AliensChoiceObserver(pFont)); pFont = FontMan.Add(Font.Name.Credits, SpriteBatch.Name.Texts, "Credits", Glyph.Name.Consolas20pt, 200, 175); pFont.SetColor(0.60f, 0.60f, 0.60f); pInputSubject = InputMan.GetCursorSubject(); pInputSubject.Attach(new HighlightHoverTextObserver(pFont)); pInputSubject = InputMan.GetMouseLeftKeySubject(); pInputSubject.Attach(new CreditsChoiceObserver(pFont)); pFont = FontMan.Add(Font.Name.Exit, SpriteBatch.Name.Texts, "Exit", Glyph.Name.Consolas20pt, 200, 150); pFont.SetColor(0.60f, 0.60f, 0.60f); pInputSubject = InputMan.GetCursorSubject(); pInputSubject.Attach(new HighlightHoverTextObserver(pFont)); pInputSubject = InputMan.GetMouseLeftKeySubject(); pInputSubject.Attach(new ExitObserver(pFont)); }
// strategy() override public void LoadContent() { SpriteBatchMan.Create(3, 1); TextureMan.Create(2, 1); GlyphMan.Create(3, 1); FontMan.Create(1, 1); ImageMan.Create(5, 2); GameSpriteMan.Create(4, 2); ProxySpriteMan.Create(10, 1); BoxSpriteMan.Create(3, 1); GameObjectMan.Create(3, 1); GhostGameObjectMan.Create(3, 1); //ImageMan.Create(5, 2); //GameSpriteMan.Create(4, 2); //ImageMan.Create(5, 2); //GameSpriteMan.Create(4, 2); //GameObjectMan.Create(3, 1); //ProxySpriteMan.Create(10, 1); TextureMan.Add(Texture.Name.Aliens, "newaliens.tga"); Texture pTexture = TextureMan.Add(Texture.Name.Consolas20pt, "Consolas20pt.tga"); FontMan.AddXml(Glyph.Name.Consolas20pt, "Consolas20pt.xml", Texture.Name.Consolas20pt); SpriteBatch pSB_Texts = SpriteBatchMan.Add(SpriteBatch.Name.Texts); SpriteBatch pSB_Aliens = SpriteBatchMan.Add(SpriteBatch.Name.Aliens); // 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, "0000", Glyph.Name.Consolas20pt, 100, 700); if (scoreHigh == null) { scoreHigh = "0000"; } FontMan.Add(Font.Name.ScoreHigh, SpriteBatch.Name.Texts, scoreHigh, Glyph.Name.Consolas20pt, 300, 700); FontMan.Add(Font.Name.Score2, SpriteBatch.Name.Texts, "0000", Glyph.Name.Consolas20pt, 500, 700); FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, "PLAY", Glyph.Name.Consolas20pt, 320, 550); FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, "SPACE INVADERS", Glyph.Name.Consolas20pt, 260, 500); FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, "PUSH <1> OR <2> PLAYERS BUTTON", Glyph.Name.Consolas20pt, 200, 450); FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, "*SCORE ADVANCE TABLE*", Glyph.Name.Consolas20pt, 220, 400); FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, " = 200 POINTS", Glyph.Name.Consolas20pt, 270, 350); FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, " = 30 POINTS", Glyph.Name.Consolas20pt, 270, 300); FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, " = 20 POINTS", Glyph.Name.Consolas20pt, 270, 250); FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Texts, " = 10 POINTS", Glyph.Name.Consolas20pt, 270, 200); // Alien 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.UFO, Texture.Name.Aliens, 80, 500, 230, 100); 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.UFO, Image.Name.UFO, 100, 500, 35, 30, 255, 0, 0, 1); GameObject pAlienGroup = new AlienGroup(GameObject.Name.AlienGroup, GameSprite.Name.NullObject, 100, 100); pAlienGroup.ActivateGameSprite(pSB_Aliens); GameObject pAlienColumn = new AlienGroup(GameObject.Name.AlienColumn, GameSprite.Name.NullObject, 100, 100); pAlienGroup.Add(pAlienColumn); pAlienColumn.ActivateGameSprite(pSB_Aliens); GameObject pSquid = new Squid(GameObject.Name.Squid, GameSprite.Name.Squid, 250, 300); pAlienColumn.Add(pSquid); pSquid.ActivateGameSprite(pSB_Aliens); GameObject pCrab = new Crab(GameObject.Name.Crab, GameSprite.Name.Crab, 250, 250); pAlienColumn.Add(pCrab); pCrab.ActivateGameSprite(pSB_Aliens); GameObject pOctopus = new Octopus(GameObject.Name.Octopus, GameSprite.Name.Octopus, 250, 200); pAlienColumn.Add(pOctopus); pOctopus.ActivateGameSprite(pSB_Aliens); UFO pUFO = new UFO(GameObject.Name.UFO, GameSprite.Name.UFO, 250, 350, null); pAlienColumn.Add(pUFO); pUFO.ActivateGameSprite(pSB_Aliens); GameObjectMan.Attach(pAlienGroup); // Input InputSubject pInputSubject; pInputSubject = InputMan.Get1Subject(); pInputSubject.Attach(new StartGameObserver(1)); pInputSubject = InputMan.Get2Subject(); pInputSubject.Attach(new StartGameObserver(2)); }
//----------------------------------------------------------------------------- // Game::LoadContent() // Allows you to load all content needed for your engine, // such as objects, graphics, etc. //----------------------------------------------------------------------------- public override void LoadContent() { //--------------------------------------------------------------------------------------------------------- // Setup Managers //--------------------------------------------------------------------------------------------------------- TextureMan.Create(1, 1); ImageMan.Create(5, 2); GameSpriteMan.Create(4, 2); BoxSpriteMan.Create(3, 1); SpriteBatchMan.Create(3, 1); TimerMan.Create(3, 1); ProxyMan.Create(10, 1); GameObjectMan.Create(10, 5); ColPairMan.Create(3, 1); GlyphMan.Create(3, 1); FontMan.Create(1, 1); //--------------------------------------------------------------------------------------------------------- // Sound Experiment //--------------------------------------------------------------------------------------------------------- SoundMan.Create(5, 3); SoundMan.LoadAll(); // play a sound file SoundMan.PlayMusic(Sound.Name.Snd_Theme); SoundMan.Find(Sound.Name.Snd_Theme).SetVolume(0.2f); //--------------------------------------------------------------------------------------------------------- // Load the Textures //--------------------------------------------------------------------------------------------------------- TextureMan.Add(Texture.Name.Birds, "Birds.tga"); TextureMan.Add(Texture.Name.PacMan, "PacMan.tga"); TextureMan.Add(Texture.Name.Consolas, "Consolas20pt.tga"); TextureMan.Add(Texture.Name.Invader_3, "Invaders_3.tga"); TextureMan.Add(Texture.Name.Invader_4, "Invaders_4.tga"); TextureMan.LoadTexture(); //--------------------------------------------------------------------------------------------------------- // Create Images //--------------------------------------------------------------------------------------------------------- // --- angry birds --- ImageMan.Add(Image.Name.RedBird, Texture.Name.Birds, 47, 41, 48, 46); ImageMan.Add(Image.Name.YellowBird, Texture.Name.Birds, 124, 34, 60, 56); ImageMan.Add(Image.Name.GreenBird, Texture.Name.Birds, 246, 135, 99, 72); ImageMan.Add(Image.Name.WhiteBird, Texture.Name.Birds, 139, 131, 84, 97); ImageMan.Add(Image.Name.BlueBird, Texture.Name.Birds, 301, 49, 33, 33); // --- Pacman Ghosts --- ImageMan.Add(Image.Name.RedGhost, Texture.Name.PacMan, 616, 148, 33, 33); ImageMan.Add(Image.Name.PinkGhost, Texture.Name.PacMan, 663, 148, 33, 33); ImageMan.Add(Image.Name.BlueGhost, Texture.Name.PacMan, 710, 148, 33, 33); ImageMan.Add(Image.Name.OrangeGhost, Texture.Name.PacMan, 757, 148, 33, 33); // --- Alians --- ImageMan.LoadImage(); //--------------------------------------------------------------------------------------------------------- // Create Sprites //--------------------------------------------------------------------------------------------------------- // --- BoxSprites --- BoxSpriteMan.Add(550.0f, 500.0f, 50.0f, 150.0f, new Azul.Color(1.0f, 1.0f, 1.0f, 1.0f)); BoxSpriteMan.Add(550.0f, 100.0f, 50.0f, 100.0f); GameSpriteMan.Add(GameSprite.Name.RedBird, Image.Name.RedBird, 50, 500, 50, 50); GameSpriteMan.Add(GameSprite.Name.YellowBird, Image.Name.YellowBird, 300, 400, 50, 50); GameSpriteMan.Add(GameSprite.Name.GreenBird, Image.Name.GreenBird, 400, 200, 50, 50); GameSpriteMan.Add(GameSprite.Name.WhiteBird, Image.Name.WhiteBird, 600, 200, 100, 100); GameSpriteMan.Add(GameSprite.Name.BlueBird, Image.Name.BlueBird, 50, 50, 50, 50); GameSpriteMan.Add(GameSprite.Name.RedGhost, Image.Name.RedGhost, 100, 300, 100, 100); GameSpriteMan.Add(GameSprite.Name.PinkGhost, Image.Name.PinkGhost, 300, 300, 100, 100); GameSpriteMan.Add(GameSprite.Name.BlueGhost, Image.Name.BlueGhost, 500, 300, 100, 100); GameSpriteMan.Add(GameSprite.Name.OrangeGhost, Image.Name.OrangeGhost, 700, 300, 100, 100); GameSpriteMan.LoadGameSprite(); // Create SpriteBatch //--------------------------------------------------------------------------------------------------------- SpriteBatch pSB_Texts = SpriteBatchMan.Add(SpriteBatch.Name.Batch_Texts); SpriteBatch pSB_Birds = SpriteBatchMan.Add(SpriteBatch.Name.Batch_AngryBirds); SpriteBatch pSB_Alieans = SpriteBatchMan.Add(SpriteBatch.Name.Batch_Aliens); SpriteBatch pSB_Box = SpriteBatchMan.Add(SpriteBatch.Name.Batch_Boxes); //--------------------------------------------------------------------------------------------------------- // Attach to Sprite Batch //--------------------------------------------------------------------------------------------------------- pSB_Birds.Attach(GameSprite.Name.RedBird); pSB_Birds.Attach(GameSprite.Name.YellowBird); pSB_Birds.Attach(GameSprite.Name.GreenBird); pSB_Birds.Attach(GameSprite.Name.WhiteBird); //--------------------------------------------------------------------------------------------------------- // Proxy //--------------------------------------------------------------------------------------------------------- // create 10 proxies for (int i = 0; i < 10; i++) { ProxySprite pProxy = ProxyMan.Add(GameSprite.Name.YellowBird); pProxy.x = 50.0f + 70 * i; pProxy.y = 100.0f; pSB_Birds.Attach(pProxy); } //--------------------------------------------------------------------------------------------------------- // Game Object //--------------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------------- // Create Birds //--------------------------------------------------------------------------------------------------------- // create the factory BirdFactory BF = new BirdFactory(SpriteBatch.Name.Batch_AngryBirds); BirdGrid pGrid = (BirdGrid)BF.Create(GameObject.Name.BirdGrid, BirdCategory.Type.Grid); GameObjectMan.Attach(pGrid); BF.LoadAll(pGrid); AliensFactory af = new AliensFactory(SpriteBatch.Name.Batch_Aliens); GameObject pAlienGrid = af.Create(GameObject.Name.Aliens_Grid, AlienCategory.Type.Grid); GameObjectMan.Attach(pAlienGrid); af.LoadAll(pAlienGrid); //pAlienGrid.Print(); //--------------------------------------------------------------------------------------------------------- // Create Walls //--------------------------------------------------------------------------------------------------------- // Wall Root WallFactory WF = new WallFactory(); WallGrid pWallGrid = (WallGrid)WF.Create(GameObject.Name.Wall_Grid, WallCategory.Type.Wall_Grid, 0.0f, 0.0f); GameObjectMan.Attach(pWallGrid); WallLeft pWallLeft = (WallLeft)WF.Create(GameObject.Name.Wall_Left, WallCategory.Type.Wall_Left, 20, 280, 20, 500); WallRight pWallRight = (WallRight)WF.Create(GameObject.Name.Wall_Right, WallCategory.Type.Wall_Right, 780, 280, 20, 500); WallTop pWallTop = (WallTop)WF.Create(GameObject.Name.Wall_Top, WallCategory.Type.Wall_Top, 400, 530, 700, 20); WallBottom pWallBottom = (WallBottom)WF.Create(GameObject.Name.Wall_Bottom, WallCategory.Type.Wall_Bottom, 400, 20, 700, 20); // Add to the composite the children pWallGrid.Add(pWallRight); pWallGrid.Add(pWallLeft); pWallGrid.Add(pWallTop); pWallGrid.Add(pWallBottom); //--------------------------------------------------------------------------------------------------------- // Create Missile //--------------------------------------------------------------------------------------------------------- MissileFactory MF = new MissileFactory(SpriteBatch.Name.Batch_Aliens); MissileGrid pMissileGrid = (MissileGrid)MF.Create(GameObject.Name.Missile_Grid, MissileCategory.Type.Missile_Grid); GameObjectMan.Attach(pMissileGrid); Missile pMissile = (Missile)MF.Create(GameObject.Name.Missile, MissileCategory.Type.Missile, 405, 100); pMissileGrid.Add(pMissile); Debug.WriteLine("-------------------"); //--------------------------------------------------------------------------------------------------------- // ColPair //--------------------------------------------------------------------------------------------------------- // associate in a collision pair ColPair pair = ColPairMan.Add(pMissileGrid, pAlienGrid); pair.Attach(new MissileHitAlienAnim()); pair.Attach(new MissileHitAlienSnd()); ColPairMan.Add(pWallGrid, pAlienGrid); ColPairMan.Add(pWallGrid, pMissileGrid); //--------------------------------------------------------------------------------------------------------- // Font Experiment //--------------------------------------------------------------------------------------------------------- GlyphMan.AddXml(Glyph.Name.Consolas36pt, "Consolas36pt.xml", Texture.Name.Consolas); FontMan.Add(Font.Name.TestMessage, SpriteBatch.Name.Batch_Texts, "ABC", Glyph.Name.Consolas36pt, 500, 500); FontMan.Add(Font.Name.TestOneOff, SpriteBatch.Name.Batch_Texts, "XYZ1234!#=+ZYX", Glyph.Name.Consolas36pt, 200, 200); }