// TODO maybe this becomes a init crit method and make activategrid just display the grid rather than create a new one public static InvaderGrid GenerateGrid(int level) { // Get factory for producing gameobjects and adding them to the gameobject manager and spritebatches InvaderFactory rootLevelIF = new InvaderFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes); // create the grid composite data structure InvaderGrid pGrid = (InvaderGrid)rootLevelIF.ActiveCreate(GameObject.Type.InvaderGrid, 0, 0); // Get another factory for producing gameobjects and adding them to the Grid as well as the gameobject manager and sprite batches InvaderFactory columnIF = new InvaderFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pGrid); for (int i = 0; i < 11; i++) { InvaderColumn pColumn = (InvaderColumn)columnIF.ActiveCreate(GameObject.Type.InvaderColumn, 0, 0); InvaderFactory gridAliensIF = new InvaderFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes, pColumn); float xPos = Constants.gridXOrigin + i * Constants.gridColumnDelta; gridAliensIF.ActiveCreate(GameObject.Type.SmallInvader, xPos, Constants.smallInvaderYPos - level * 10); gridAliensIF.ActiveCreate(GameObject.Type.MediumInvader, xPos, Constants.MediumInvaderYPos1 - level * 10); gridAliensIF.ActiveCreate(GameObject.Type.MediumInvader, xPos, Constants.MediumInvaderYPos2 - level * 10); gridAliensIF.ActiveCreate(GameObject.Type.LargeInvader, xPos, Constants.LargeInvaderYPos1 - level * 10); gridAliensIF.ActiveCreate(GameObject.Type.LargeInvader, xPos, Constants.LargeInvaderYPos2 - level * 10); } pGrid.SetState(InvaderGridManager.State.NotCollingWithWall); return(pGrid); }
// Should be called at some point after enter a new state public override void Initialize(GameManager pGameManager) { //Debug.WriteLine("Initializing the Attract Screen"); //--------------------------------------------------------------------------------------------------------- // Create Header Fonts //--------------------------------------------------------------------------------------------------------- FontManager.Add(Font.Name.Play, SpriteBatch.Name.Texts, "PLAY", Glyph.Name.Consolas36pt, 400, 800); FontManager.Add(Font.Name.SpaceInvader, SpriteBatch.Name.Texts, "SPACE INVADERS", Glyph.Name.Consolas36pt, 300, 700); FontManager.Add(Font.Name.ScoringTable, SpriteBatch.Name.Texts, "*SCORING ADVANCE TABLE*", Glyph.Name.Consolas36pt, 220, 600); FontManager.Add(Font.Name.ScoreMystery, SpriteBatch.Name.Texts, "= ? Mystery", Glyph.Name.Consolas36pt, 400, 550); FontManager.Add(Font.Name.ScoreSmInvader, SpriteBatch.Name.Texts, "= 30 POINTS", Glyph.Name.Consolas36pt, 400, 500); FontManager.Add(Font.Name.ScoreMedInvader, SpriteBatch.Name.Texts, "= 20 POINTS", Glyph.Name.Consolas36pt, 400, 450); FontManager.Add(Font.Name.ScoreLgInvader, SpriteBatch.Name.Texts, "= 10 POINTS", Glyph.Name.Consolas36pt, 400, 400); FontManager.Add(Font.Name.PressSpace, SpriteBatch.Name.Texts, "<PRESS SPACE TO CONTINUE>", Glyph.Name.Consolas36pt, 200, 200); InvaderFactory rootLevelIF = new InvaderFactory(SpriteBatch.Name.Sprites, SpriteBatch.Name.Boxes); UFO pUFO = (UFO)rootLevelIF.ActiveCreate(GameObject.Type.UFO, 350, 550); pUFO.speedX = 0; rootLevelIF.ActiveCreate(GameObject.Type.SmallInvader, 350, 500); rootLevelIF.ActiveCreate(GameObject.Type.MediumInvader, 350, 450); rootLevelIF.ActiveCreate(GameObject.Type.LargeInvader, 350, 400); InputSubject pInputSubject = InputManager.GetSpaceSubject(); pInputSubject.Attach(new AdvanceGameStateObserver()); }