public override void VisitUFORoot(UFORoot u) { // BombRoot vs WallRoot GameObject pGameObj = (GameObject)Iterator.GetChild(u); ColPair.Collide(pGameObj, this); }
public static UFO ActivateUFO(bool isCollisionBoxActive) { Debug.WriteLine("UFO has been activated!"); UFOManager ufoMan = UFOManager.GetInstance(); PCSTree pcsTree = GameObjectManager.GetRootTree(); Debug.Assert(pcsTree != null); UFOStrategy strat = new UFOMoveRight(); float x = -10.0f; if (pRandom.Next(0, 2) == 0) { strat = new UFOMoveLeft(); x = 915.0f; } UFO pUFO = new UFO(GameObjectName.UFO, SpriteBaseName.UFO, strat, x, 905.0f); ufoMan.pUFO = pUFO; UFORoot pUFORoot = (UFORoot)GameObjectManager.Find(GameObjectName.UFORoot); SpriteBatch sbAliens = SpriteBatchManager.Find(SpriteBatchName.Aliens); SpriteBatch sbBoxes = SpriteBatchManager.Find(SpriteBatchName.Boxes); if (isCollisionBoxActive) { pUFO.ActivateCollisionSprite(sbBoxes); } pUFO.ActivateGameSprite(sbAliens); pcsTree.Insert(ufoMan.pUFO, pUFORoot); SetUFOActive(true); return(ufoMan.pUFO); }
public override void Notify() { //Double-check to verify the different visitor pattern this.pUFO = (UFO)this.pSubject.pObjA; this.pWall = (WallCategory)this.pSubject.pObjB; Debug.Assert(this.pUFO != null); if (pUFO.bMarkForDeath == false) { pUFO.bMarkForDeath = true; //this is to eliminate some of the checks that the UFORoot //does with the wall while it generates another UFO UFORoot pUFORoot = (UFORoot)GONodeMan.Find(GameObject.Name.UFORoot); Debug.Assert(pUFORoot != null); pUFORoot.x = -100; pUFORoot.y = -100; pUFORoot.SetDeltaMove(-1.0f); MissedUFOobserver pObserver = new MissedUFOobserver(this); DelayedObjectMan.Attach(pObserver); } }
public virtual void VisitUFORoot(UFORoot u) { //shouldn't call this //need to implement in concrete class Debug.WriteLine("Visit by UFORoot not implemented"); Debug.Assert(false); }
public void MoveAcross() { UFORoot pUFORoot = (UFORoot)Iterator.GetParent(this); float delta = pUFORoot.GetDeltaMove(); this.x += delta; }
public UFO createUFO(UFO.UFOType mUfoType, GameObject.GameObjectName gameName, int index = 0, float mX = 0.0f, float mY = 0.0f) { UFO ufo = null; switch (mUfoType) { case UFO.UFOType.UFORoot: ufo = new UFORoot(gameName, Sprite.SpriteName.NullObject, index, mX, mY, UFO.UFOType.UFORoot); GameObjectNodeManager.add(ufo, cPCSTree); break; case UFO.UFOType.AlienUFO: ufo = new AlienUFO(gameName, Sprite.SpriteName.AlienUFO, index, mX, mY, UFO.UFOType.AlienUFO); break; case UFO.UFOType.Uninitilized: Debug.WriteLine("ufo Type is Uninitilized"); break; } this.cPCSTree.Insert(ufo, this.cParent); ufo.addSpriteToBatch(this.cSpriteBatch); ufo.addCollisionToBatch(SpriteBatchManager.find(SpriteBatch.SpriteBatchName.Boxes)); return(ufo); }
public UFOFlyingSoundEvent() { this.pSound = SoundManager.Find(Sound.Name.UFO); UFORoot pRoot = (UFORoot)GameObjectManager.Find(GameObject.Name.UFORoot); this.pUFO = (OrangeSaucer)pRoot.GetFirstChild(); }
public override void VisitUFORoot(UFORoot pUFORoot) { CollisionPair pCollisionPair = CollisionPairManager.GetActiveCollisionPair(); Debug.Assert(pCollisionPair != null); pCollisionPair.SetCollision(pUFORoot, this); pCollisionPair.NotifyObservers(); }
public override void VisitUFORoot(UFORoot u) { //UFOroot v Wallroot //Debug.WriteLine("collide: {0}<->{1}", u.GetName(), this.GetName()); GameObject pGameObject = (GameObject)Iterator.GetChild(this); ColPair.Collide(u, pGameObject); }
public override void VisitUFORoot(UFORoot u) { //Debug.WriteLine("collide: {0}<->{1}", u.GetName(), this.GetName()); //go to the UFO object //check the missile v. "this" TopWall GameObject pGameObject = (GameObject)Iterator.GetChild(u); ColPair.Collide(pGameObject, this); }
public void loadUFO() { UFOFactory ufoFactory = FactoryManager.getUfoFactry(); UFORoot ufoRoot = (UFORoot)ufoFactory.createUFO(UFO.UFOType.UFORoot, GameObject.GameObjectName.UFORoot, 0, 0, 0); ufoFactory.setParent(ufoRoot); UFO ufo = ufoFactory.createUFO(UFO.UFOType.AlienUFO, GameObject.GameObjectName.AlienUFO, 1, Unit.ufoPosX, Unit.ufoPosY); Random random = new Random(DateTime.UtcNow.Millisecond); int number = random.Next(1, 40); UFOActivate ufoAct = new UFOActivate(ufo); TimerManager.sortedAdd(TimerEvent.TimerEventName.ActivateUFO, ufoAct, number); }
public override void Execute(float deltaTime) { float NewTime = RandomManager.RandomInt(45, 61); UFORoot pUFORoot = (UFORoot)GameObjectManager.Find(GameObject.Name.UFORoot); OrangeSaucer pUFO = (OrangeSaucer)pUFORoot.GetFirstChild(); pUFO.RandomizeDirection(); // Add itself back to timer TimerManager.Add(TimeEvent.Name.UFOSpawn, this, NewTime); TimerManager.Add(TimeEvent.Name.PlayUFOSound, this.pSoundEvent, 0.17f); }
private void ResetAll() { //-----Reset Everything----- PlayerLivesComposite pNullObjs = (PlayerLivesComposite)GameObjectManager.Find(GameObject.Name.Null_Object); pNullObjs.ResetLives(); AlienGrid pGrid = (AlienGrid)GameObjectManager.Find(GameObject.Name.AlienGrid); pGrid.ResetAliens(); ShieldRoot pSRoot = (ShieldRoot)GameObjectManager.Find(GameObject.Name.ShieldRoot); pSRoot.ResetShields(); UFORoot pUFORoot = (UFORoot)GameObjectManager.Find(GameObject.Name.UFORoot); OrangeSaucer pUFO = (OrangeSaucer)pUFORoot.GetFirstChild(); pUFO.Remove(); TimerManager.Reset(); }
public override void Notify() { this.pUFO = (UFO)this.pSubject.pObjB; Debug.Assert(this.pUFO != null); if (pUFO.bMarkForDeath == false) { pUFO.bMarkForDeath = true; //this is to eliminate some of the checks that the UFORoot //does with the wall while it generates another UFO UFORoot pUFORoot = (UFORoot)GONodeMan.Find(GameObject.Name.UFORoot); Debug.Assert(pUFORoot != null); pUFORoot.x = -100; pUFORoot.y = -100; pUFORoot.SetDeltaMove(-1.0f); RemoveUFOobserver pObserver = new RemoveUFOobserver(this); DelayedObjectMan.Attach(pObserver); } }
public override void Update() { UFORoot pUFORoot = (UFORoot)this.pSubject.goA; UFO pUFO = (UFO)pUFORoot.pChild; if (pUFO != null) { Wall pWall = (Wall)this.pSubject.goB; if ((pUFO.pStrategy is UFOMoveLeft && pWall.gameObjectName == GameObjectName.WallLeft) || (pUFO.pStrategy is UFOMoveRight && pWall.gameObjectName == GameObjectName.WallRight)) { if (UFOManager.IsUFOActive()) { Debug.WriteLine("RemoveUFO TimerEvent added for {0}", pUFO.GetHashCode()); TimerManager.Add(TimerEventName.RemoveUFO, TimerManager.GetCurrentTime() + 1.0f, TimerManager.GetCurrentTime() + 1.0f, new RemoveUFOCommand()); TimerManager.Add(TimerEventName.StopUFOSound, TimerManager.GetCurrentTime() + 0.5f, TimerManager.GetCurrentTime() + 0.5f, new StopUFOSoundCommand()); } //pUFO.Remove(); //pUFORoot.Remove(); } } }
public override void Initialize() { this.poGameObjectManager = new GameObjectManager(3, 1); GameObjectManager.SetActive(this.poGameObjectManager); this.poTimerManager = new TimerManager(3, 1); TimerManager.SetActive(this.poTimerManager); this.poCollisionPairManager = new CollisionPairManager(3, 1); CollisionPairManager.SetActive(this.poCollisionPairManager); //--------------------------------------------------------------------------------------------------------- // Create SpriteBatch //--------------------------------------------------------------------------------------------------------- this.poSpriteBatchManager = new SpriteBatchManager(3, 1); SpriteBatchManager.SetActive(this.poSpriteBatchManager); SpriteBatch pAliensBatch = SpriteBatchManager.Add(SpriteBatch.Name.Aliens, 1); SpriteBatch pBoxBatch = SpriteBatchManager.Add(SpriteBatch.Name.Boxes, 2); SpriteBatch pShieldsBatch = SpriteBatchManager.Add(SpriteBatch.Name.Shields, 3); SpriteBatch pNullBatch = SpriteBatchManager.Add(SpriteBatch.Name.NullObjects, 4); SpriteBatch pTexts = SpriteBatchManager.Add(SpriteBatch.Name.Texts, 5); pBoxBatch.SetDrawBool(false); //--------------------------------------------------------------------------------------------------------- // Input //--------------------------------------------------------------------------------------------------------- this.poInputManager = new InputManager(); InputManager.SetActive(this.poInputManager); InputSubject pInputSubject; pInputSubject = InputManager.GetArrowRightSubject(); pInputSubject.Attach(new MoveRightObserver()); pInputSubject = InputManager.GetArrowLeftSubject(); pInputSubject.Attach(new MoveLeftObserver()); pInputSubject = InputManager.GetSpaceSubject(); pInputSubject.Attach(new ShootObserver()); pInputSubject.Attach(new ShootSoundObserver()); pInputSubject = InputManager.GetCKeySubject(); pInputSubject.Attach(new ToggleCollisionBoxObserver()); Simulation.SetState(Simulation.State.Realtime); //--------------------------------------------------------------------------------------------------------- // Create Texts //--------------------------------------------------------------------------------------------------------- this.poFontManager = new FontManager(3, 1); FontManager.SetActive(this.poFontManager); FontManager.Add(Font.Name.Header, SpriteBatch.Name.Texts, "SCORE<1> HI-SCORE SCORE<2>", 20f, SpaceInvaders.ScreenHeight - 20f, 15f, 25f); FontManager.Add(Font.Name.Player1Score, SpriteBatch.Name.Texts, "0000", 65f, SpaceInvaders.ScreenHeight - 70f, 15f, 25f); FontManager.Add(Font.Name.Player2Score, SpriteBatch.Name.Texts, "0000", SpaceInvaders.ScreenWidth - 156f, SpaceInvaders.ScreenHeight - 70f, 15f, 25f); FontManager.Add(Font.Name.HiScore, SpriteBatch.Name.Texts, "0000", 380f, SpaceInvaders.ScreenHeight - 70f, 15f, 25f); FontManager.Add(Font.Name.Lives, SpriteBatch.Name.Texts, "3", 40f, 40f, 15f, 25f); //--------------------------------------------------------------------------------------------------------- // Create Walls //--------------------------------------------------------------------------------------------------------- // Wall Root WallGroup pWallGroup = new WallGroup(GameObject.Name.WallGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pWallGroup.ActivateGameSprite(pAliensBatch);//even need this? pWallGroup.ActivateCollisionSprite(pBoxBatch); WallRight pWallRight = new WallRight(GameObject.Name.WallRight, GameSprite.Name.NullObject, SpaceInvaders.ScreenWidth - 15, SpaceInvaders.ScreenHeight / 2, 20, SpaceInvaders.ScreenHeight - 110); pWallRight.ActivateCollisionSprite(pBoxBatch); WallLeft pWallLeft = new WallLeft(GameObject.Name.WallLeft, GameSprite.Name.NullObject, 20, SpaceInvaders.ScreenHeight / 2, 20, SpaceInvaders.ScreenHeight - 110); pWallLeft.ActivateCollisionSprite(pBoxBatch); WallTop pWallTop = new WallTop(GameObject.Name.WallTop, GameSprite.Name.NullObject, 450, SpaceInvaders.ScreenHeight - 70, SpaceInvaders.ScreenWidth - 10, 30); pWallTop.ActivateCollisionSprite(pBoxBatch); WallBottom pWallBottom = new WallBottom(GameObject.Name.WallBottom, GameSprite.Name.Ground, 450, 60, SpaceInvaders.ScreenWidth - 10, 5); pWallBottom.ActivateGameSprite(pAliensBatch); pWallBottom.ActivateCollisionSprite(pBoxBatch); // Add to the composite the children pWallGroup.Add(pWallRight); pWallGroup.Add(pWallLeft); pWallGroup.Add(pWallTop); pWallGroup.Add(pWallBottom); GameObjectManager.Attach(pWallGroup); //--------------------------------------------------------------------------------------------------------- // Create Bomb Root //--------------------------------------------------------------------------------------------------------- BombRoot pBombRoot = new BombRoot(GameObject.Name.BombRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); pBombRoot.ActivateGameSprite(pAliensBatch);//change? even need this? pBombRoot.ActivateCollisionSprite(pBoxBatch); GameObjectManager.Attach(pBombRoot); DropBombEvent pBombEvent = new DropBombEvent(); TimerManager.Add(TimeEvent.Name.DropBomb, pBombEvent, 3.0f); //--------------------------------------------------------------------------------------------------------- // Create Missile Root //--------------------------------------------------------------------------------------------------------- // Missile Root MissileGroup pMissileGroup = new MissileGroup(GameObject.Name.MissileGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pMissileGroup.ActivateGameSprite(pAliensBatch);//change? even need this? pMissileGroup.ActivateCollisionSprite(pBoxBatch); GameObjectManager.Attach(pMissileGroup); //--------------------------------------------------------------------------------------------------------- // Create Ship Root //--------------------------------------------------------------------------------------------------------- ShipRoot pShipRoot = new ShipRoot(GameObject.Name.ShipRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); pShipRoot.ActivateGameSprite(pAliensBatch);//change? even need this? pShipRoot.ActivateCollisionSprite(pBoxBatch); GameObjectManager.Attach(pShipRoot); ShipManager.ActivateShip(); ShipManager.ActivateMissile(); //--------------------------------------------------------------------------------------------------------- // Create UFO and UFO Root //--------------------------------------------------------------------------------------------------------- UFORoot pUFORoot = new UFORoot(GameObject.Name.UFORoot, GameSprite.Name.NullObject, 0.0f, 0.0f); pUFORoot.ActivateGameSprite(pAliensBatch);//change? even need this? pUFORoot.ActivateCollisionSprite(pBoxBatch); GameObjectManager.Attach(pUFORoot); OrangeSaucer pUFO = new OrangeSaucer(GameObject.Name.OrangeSaucer, GameSprite.Name.OrangeSaucer, 20f, SpaceInvaders.ScreenHeight - 110f); pUFO.ActivateGameSprite(pAliensBatch);//change? even need this? pUFO.ActivateCollisionSprite(pBoxBatch); pUFORoot.Add(pUFO); pUFO.Remove(); SpawnUFOEvent pUFOEvent = new SpawnUFOEvent(); TimerManager.Add(TimeEvent.Name.UFOSpawn, pUFOEvent, RandomManager.RandomInt(15, 45)); //--------------------------------------------------------------------------------------------------------- // Create Aliens //--------------------------------------------------------------------------------------------------------- AlienFactory AF = new AlienFactory(SpriteBatch.Name.Aliens, SpriteBatch.Name.Boxes); AlienGrid pAlienGrid = (AlienGrid)AF.Create(GameObject.Name.AlienGrid); for (int i = 0; i < 11; i++) { GameObject pCol = AF.Create(GameObject.Name.AlienColumn); GameObject pGameObject; pGameObject = AF.Create(GameObject.Name.PurpleOctopus, 50.0f + 66 * i, SpaceInvaders.ScreenHeight - 364f); pCol.Add(pGameObject); pGameObject = AF.Create(GameObject.Name.PurpleOctopus, 50.0f + 66 * i, SpaceInvaders.ScreenHeight - 298f); pCol.Add(pGameObject); pGameObject = AF.Create(GameObject.Name.BlueCrab, 50.0f + 66 * i, SpaceInvaders.ScreenHeight - 232f); pCol.Add(pGameObject); pGameObject = AF.Create(GameObject.Name.BlueCrab, 50.0f + 66 * i, SpaceInvaders.ScreenHeight - 166f); pCol.Add(pGameObject); pGameObject = AF.Create(GameObject.Name.GreenSquid, 50.0f + 66 * i, SpaceInvaders.ScreenHeight - 100f); pCol.Add(pGameObject); pAlienGrid.Add(pCol); } GameObjectManager.Attach(pAlienGrid); pAlienGrid.Attach(new MoveAlienSoundObserver()); pAlienGrid.Attach(new MoveAlienGridObserver()); AlienGridMoveEvent pGridMoveEvent = new AlienGridMoveEvent(); TimerManager.Add(TimeEvent.Name.MoveAlienGrid, pGridMoveEvent, pAlienGrid.GetMoveRate()); //--------------------------------------------------------------------------------------------------------- // Timer Animations //--------------------------------------------------------------------------------------------------------- // Create an animation sprite AnimationSprite pAnimOctopus = new AnimationSprite(GameSprite.Name.PurpleOctopus); AnimationSprite pAnimCrab = new AnimationSprite(GameSprite.Name.BlueCrab); AnimationSprite pAnimSquid = new AnimationSprite(GameSprite.Name.GreenSquid); // attach several images to cycle pAnimOctopus.Attach(Image.Name.OctopusA); pAnimOctopus.Attach(Image.Name.OctopusB); pAnimCrab.Attach(Image.Name.AlienA); pAnimCrab.Attach(Image.Name.AlienB); pAnimSquid.Attach(Image.Name.SquidA); pAnimSquid.Attach(Image.Name.SquidB); // add AnimationSprite to timer TimerManager.Add(TimeEvent.Name.SpriteAnimation, pAnimOctopus, pAlienGrid.GetMoveRate()); TimerManager.Add(TimeEvent.Name.SpriteAnimation, pAnimCrab, pAlienGrid.GetMoveRate()); TimerManager.Add(TimeEvent.Name.SpriteAnimation, pAnimSquid, pAlienGrid.GetMoveRate()); //--------------------------------------------------------------------------------------------------------- // Shield //--------------------------------------------------------------------------------------------------------- // Create the factory Composite pShieldRoot = (Composite) new ShieldRoot(GameObject.Name.ShieldRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); GameObjectManager.Attach(pShieldRoot); ShieldFactory SF = new ShieldFactory(SpriteBatch.Name.Shields, SpriteBatch.Name.Boxes, pShieldRoot); float start_x = 160.0f; float start_y = 200.0f; float off_x; float brickWidth = 12.0f; float brickHeight = 7.0f; GameObject pShieldGrid; GameObject pShieldCol; for (int i = 0; i < 4; i++) { off_x = 0; SF.SetParent(pShieldRoot); pShieldGrid = SF.Create(GameObject.Name.ShieldGrid); //------Col1 SF.SetParent(pShieldGrid); pShieldCol = SF.Create(GameObject.Name.ShieldColumn); SF.SetParent(pShieldCol); SF.Create(GameObject.Name.ShieldBrick, start_x, start_y); SF.Create(GameObject.Name.ShieldBrick, start_x, start_y + brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x, start_y + 2 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x, start_y + 3 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x, start_y + 4 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x, start_y + 5 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x, start_y + 6 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x, start_y + 7 * brickHeight); SF.Create(GameObject.Name.ShieldBrick_LeftTop1, start_x, start_y + 8 * brickHeight); SF.Create(GameObject.Name.ShieldBrick_LeftTop0, start_x, start_y + 9 * brickHeight); //-------Col2 SF.SetParent(pShieldGrid); pShieldCol = SF.Create(GameObject.Name.ShieldColumn); SF.SetParent(pShieldCol); off_x += brickWidth; SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); //-------Col3 SF.SetParent(pShieldGrid); pShieldCol = SF.Create(GameObject.Name.ShieldColumn); SF.SetParent(pShieldCol); off_x += brickWidth; SF.Create(GameObject.Name.ShieldBrick_LeftBottom, start_x + off_x, start_y + 2 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); //-------Col4 SF.SetParent(pShieldGrid); pShieldCol = SF.Create(GameObject.Name.ShieldColumn); SF.SetParent(pShieldCol); off_x += brickWidth; SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); //-------Col5 SF.SetParent(pShieldGrid); pShieldCol = SF.Create(GameObject.Name.ShieldColumn); SF.SetParent(pShieldCol); off_x += brickWidth; SF.Create(GameObject.Name.ShieldBrick_RightBottom, start_x + off_x, start_y + 2 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); //-------Col6 SF.SetParent(pShieldGrid); pShieldCol = SF.Create(GameObject.Name.ShieldColumn); SF.SetParent(pShieldCol); off_x += brickWidth; SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 0 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 1 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 8 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 9 * brickHeight); //-------Col7 SF.SetParent(pShieldGrid); pShieldCol = SF.Create(GameObject.Name.ShieldColumn); SF.SetParent(pShieldCol); off_x += brickWidth; SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 0 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 1 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 2 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 3 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 4 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 5 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 6 * brickHeight); SF.Create(GameObject.Name.ShieldBrick, start_x + off_x, start_y + 7 * brickHeight); SF.Create(GameObject.Name.ShieldBrick_RightTop1, start_x + off_x, start_y + 8 * brickHeight); SF.Create(GameObject.Name.ShieldBrick_RightTop0, start_x + off_x, start_y + 9 * brickHeight); start_x += 170; } //--------------------------------------------------------------------------------------------------------- // Create Null Ship Lives //--------------------------------------------------------------------------------------------------------- ScenePlay.ShipLives = 3; PlayerLivesComposite pNullObjs = new PlayerLivesComposite(); Ship pNullShip1 = new Ship(GameObject.Name.Null_Object, GameSprite.Name.Ship, 120.0f, 40.0f); pNullShip1.ActivateGameSprite(pNullBatch); pNullObjs.Add(pNullShip1); Ship pNullShip2 = new Ship(GameObject.Name.Null_Object, GameSprite.Name.Ship, 180.0f, 40.0f); pNullShip2.ActivateGameSprite(pNullBatch); pNullObjs.Add(pNullShip2); GameObjectManager.Attach(pNullObjs); //--------------------------------------------------------------------------------------------------------- // Create CollisionPairs //--------------------------------------------------------------------------------------------------------- //Why does the order that left/right wall are added matter??????? reverse order breaks game CollisionPair pShipWallRightPair = CollisionPairManager.Add(CollisionPair.Name.Ship_Wall_Right, pShipRoot, pWallRight); Debug.Assert(pShipWallRightPair != null); CollisionPair pShipWallLeftPair = CollisionPairManager.Add(CollisionPair.Name.Ship_Wall_Left, pShipRoot, pWallLeft); Debug.Assert(pShipWallLeftPair != null); CollisionPair pAlienMissilePair = CollisionPairManager.Add(CollisionPair.Name.Alien_Missile, pMissileGroup, pAlienGrid); Debug.Assert(pAlienMissilePair != null); CollisionPair pMissileWallPair = CollisionPairManager.Add(CollisionPair.Name.Missile_Wall_Top, pMissileGroup, pWallTop); Debug.Assert(pMissileWallPair != null); CollisionPair pAlienWallPair = CollisionPairManager.Add(CollisionPair.Name.Alien_Wall, pAlienGrid, pWallGroup); Debug.Assert(pAlienWallPair != null); CollisionPair pAlienWallBottomPair = CollisionPairManager.Add(CollisionPair.Name.Alien_WallBottom, pAlienGrid, pWallBottom); Debug.Assert(pAlienWallBottomPair != null); CollisionPair pBombWallPair = CollisionPairManager.Add(CollisionPair.Name.Bomb_Wall_Bottom, pBombRoot, pWallBottom); Debug.Assert(pBombWallPair != null); CollisionPair pBombShieldPair = CollisionPairManager.Add(CollisionPair.Name.Bomb_Shield, pBombRoot, pShieldRoot); Debug.Assert(pBombShieldPair != null); CollisionPair pMissileShieldPair = CollisionPairManager.Add(CollisionPair.Name.Missile_Shield, pMissileGroup, pShieldRoot); Debug.Assert(pMissileShieldPair != null); CollisionPair pBombShipPair = CollisionPairManager.Add(CollisionPair.Name.Bomb_Ship, pBombRoot, ShipManager.GetShip()); Debug.Assert(pBombShipPair != null); CollisionPair pBombMissilePair = CollisionPairManager.Add(CollisionPair.Name.Bomb_Missile, pBombRoot, ShipManager.GetMissile()); Debug.Assert(pBombMissilePair != null); CollisionPair pAlienShieldPair = CollisionPairManager.Add(CollisionPair.Name.Alien_Shield, pShieldRoot, pAlienGrid); Debug.Assert(pAlienShieldPair != null); CollisionPair pUFOMissilePair = CollisionPairManager.Add(CollisionPair.Name.UFO_Missile, pMissileGroup, pUFORoot); Debug.Assert(pUFOMissilePair != null); //TODO consolidate these news pShipWallLeftPair.Attach(new ShipStopLeftObserver()); pShipWallRightPair.Attach(new ShipStopRightObserver()); pMissileWallPair.Attach(new ShipRemoveMissileObserver()); pAlienMissilePair.Attach(new ShipRemoveMissileObserver()); pAlienMissilePair.Attach(new RemoveAlienObserver()); pAlienMissilePair.Attach(new DeadAlienSoundObserver()); pAlienMissilePair.Attach(new AddP1PointsObserver()); pAlienMissilePair.Attach(new IncreaseAlienSpeedObserver()); pAlienWallPair.Attach(new GridObserver()); pBombWallPair.Attach(new RemoveBombObserver()); pBombShieldPair.Attach(new RemoveBombObserver()); pBombShieldPair.Attach(new RemoveBrickObserver()); pMissileShieldPair.Attach(new ShipRemoveMissileObserver()); pMissileShieldPair.Attach(new RemoveBrickObserver()); pBombShipPair.Attach(new RemoveBombObserver()); pBombShipPair.Attach(new RemoveShipObserver()); pBombShipPair.Attach(new DeadShipSoundObserver()); pBombShipPair.Attach(new RemoveLifeObserver()); pBombShipPair.Attach(new ChangeStateObserver()); pBombMissilePair.Attach(new RemoveBombObserver()); pBombMissilePair.Attach(new ShipRemoveMissileObserverAltPair()); pAlienShieldPair.Attach(new RemoveBrickObserver()); pUFOMissilePair.Attach(new RemoveUFOObserver()); pUFOMissilePair.Attach(new ShipRemoveMissileObserver()); pUFOMissilePair.Attach(new AddP1PointsObserver()); pUFOMissilePair.Attach(new DeadUFOSoundObserver()); pAlienWallBottomPair.Attach(new DeadShipSoundObserver()); pAlienWallBottomPair.Attach(new RemoveAllP1LivesObserver()); }
public override void loadContent(Scene pScene) { ManagerFactory managerFactory = new ManagerFactory(); //--------------------------------------------------------------------------------------------------------- // Create SpriteBatch //--------------------------------------------------------------------------------------------------------- SpriteBatch pSB_Box = SpriteBatchMan.Add(SpriteBatch.Name.Boxes); SpriteBatch pSB_ShieldBoxes = SpriteBatchMan.Add(SpriteBatch.Name.ShieldBoxes); SpriteBatchMan.Add(SpriteBatch.Name.Aliens); SpriteBatchMan.Add(SpriteBatch.Name.Walls); SpriteBatchMan.Add(SpriteBatch.Name.Bumps); SpriteBatch pSB_Ship = SpriteBatchMan.Add(SpriteBatch.Name.Ships); SpriteBatch pSB_Missile = SpriteBatchMan.Add(SpriteBatch.Name.Missiles); SpriteBatch pSB_Shield = SpriteBatchMan.Add(SpriteBatch.Name.Shields); SpriteBatch pSB_Bomb = SpriteBatchMan.Add(SpriteBatch.Name.Bombs); SpriteBatchMan.Add(SpriteBatch.Name.PlainTexts); SpriteBatch pSB_Life = SpriteBatchMan.Add(SpriteBatch.Name.Lifes); SpriteBatch pSB_Explosion = SpriteBatchMan.Add(SpriteBatch.Name.Explosions); SpriteBatch pSB_UFO = SpriteBatchMan.Add(SpriteBatch.Name.UFO); //--------------------------------------------------------------------------------------------------------- // Set Input //--------------------------------------------------------------------------------------------------------- InputSubject pInputSubject; pInputSubject = InputMan.GetArrowLeftSubject(); pInputSubject.attach(new MoveLeftObserver()); pInputSubject = InputMan.GetArrowRightSubject(); pInputSubject.attach(new MoveRightObserver()); pInputSubject = InputMan.GetSpaceSubject(); pInputSubject.attach(new ShootObserver()); pInputSubject = InputMan.GetTSubject(); pInputSubject.attach(new ToggleBoxObserver()); //--------------------------------------------------------------------------------------------------------- // Create Ship //--------------------------------------------------------------------------------------------------------- // create ship life group ShipLifeGroup pShipLifeGroup = new ShipLifeGroup(GameObject.Name.ShipLifeGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pShipLifeGroup.activateGameSprite(pSB_Life); pShipLifeGroup.activateCollisionSprite(pSB_Box); GameObjectMan.Attach(pShipLifeGroup); ShipGroup pShipGroup = new ShipGroup(GameObject.Name.ShipGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pShipGroup.activateGameSprite(pSB_Ship); pShipGroup.activateCollisionSprite(pSB_Box); GameObjectMan.Attach(pShipGroup); ShipMan.CreateShipLifes(); //--------------------------------------------------------------------------------------------------------- // Create UFO //--------------------------------------------------------------------------------------------------------- UFORoot pUFORoot = new UFORoot(GameObject.Name.UFORoot, GameSprite.Name.NullObject, 0.0f, 0.0f); UFORoot pUFOGroup = new UFORoot(GameObject.Name.UFORoot, GameSprite.Name.NullObject, 0.0f, 0.0f); pUFORoot.activateGameSprite(pSB_UFO); pUFORoot.activateCollisionSprite(pSB_Box); pUFOGroup.add(pUFORoot); GameObjectMan.Attach(pUFOGroup); //managerFactory.create(Manager.Name.UFOMan); //--------------------------------------------------------------------------------------------------------- // Create Missile //--------------------------------------------------------------------------------------------------------- MissileGroup pMissileGroup = new MissileGroup(GameObject.Name.MissileGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pMissileGroup.activateGameSprite(pSB_Missile); pMissileGroup.activateCollisionSprite(pSB_Box); GameObjectMan.Attach(pMissileGroup); //--------------------------------------------------------------------------------------------------------- // Create Bombs //--------------------------------------------------------------------------------------------------------- BombRoot pBombRoot = new BombRoot(GameObject.Name.BombGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pBombRoot.activateGameSprite(pSB_Bomb); pBombRoot.activateCollisionSprite(pSB_Box); GameObjectMan.Attach(pBombRoot); //managerFactory.create(Manager.Name.BombMan); //--------------------------------------------------------------------------------------------------------- // Create walls //--------------------------------------------------------------------------------------------------------- WallFactory wallFactory = new WallFactory(SpriteBatch.Name.Walls, SpriteBatch.Name.Boxes); GameObject pWallGroup = wallFactory.create(GameObject.Name.WallGroup, WallCategory.Type.WallGroup); pWallGroup.add(wallFactory.create(GameObject.Name.WallLeft, WallCategory.Type.Left, 5, 511, 10, 912)); pWallGroup.add(wallFactory.create(GameObject.Name.WallRight, WallCategory.Type.Right, 891, 511, 10, 912)); pWallGroup.add(wallFactory.create(GameObject.Name.WallTop, WallCategory.Type.Top, 448, 993, 896, 50)); pWallGroup.add(wallFactory.create(GameObject.Name.WallBottom, WallCategory.Type.Bottom, 448, 30, 896, 50)); GameObjectMan.Attach(pWallGroup); //--------------------------------------------------------------------------------------------------------- // Create bumps //--------------------------------------------------------------------------------------------------------- BumpFactory bumpFactory = new BumpFactory(SpriteBatch.Name.Bumps, SpriteBatch.Name.Boxes); GameObject pBumpGroup = bumpFactory.create(GameObject.Name.BumpGroup, BumpCategory.Type.BumpGroup); pBumpGroup.add(bumpFactory.create(GameObject.Name.BumpLeft, BumpCategory.Type.Left, 10, 90, 25, 60)); pBumpGroup.add(bumpFactory.create(GameObject.Name.BumpRight, BumpCategory.Type.Right, 886, 90, 25, 60)); GameObjectMan.Attach(pBumpGroup); //--------------------------------------------------------------------------------------------------------- // Create Aliens //--------------------------------------------------------------------------------------------------------- //managerFactory.create(Manager.Name.AlienMan); AlienFactory alienFactory = new AlienFactory(SpriteBatch.Name.Aliens, SpriteBatch.Name.Boxes); // create alien groups AlienGroup pAlienGroup = (AlienGroup)alienFactory.create(GameObject.Name.AlienGroup, AlienCategory.Type.Group); pAlienGroup.nextLevel(); AlienGroup pAlienRoot = new AlienGroup(GameObject.Name.AlienGroup, GameSprite.Name.NullObject, 0.0f, 0.0f);; pAlienRoot.add(pAlienGroup); GameObjectMan.Attach(pAlienRoot); //--------------------------------------------------------------------------------------------------------- // create Shield //--------------------------------------------------------------------------------------------------------- ShieldFactory SF = new ShieldFactory(SpriteBatch.Name.Shields, SpriteBatch.Name.ShieldBoxes); ShieldRoot pShieldGroup = (ShieldRoot)SF.Create(ShieldCategory.Type.Root, GameObject.Name.ShieldRoot, 0.0f, 0.0f); pShieldGroup.storeShield(); ShieldRoot pShieldRoot = new ShieldRoot(GameObject.Name.ShieldRoot, GameSprite.Name.NullObject, 0.0f, 0.0f); pShieldRoot.add(pShieldGroup); GameObjectMan.Attach(pShieldRoot); //--------------------------------------------------------------------------------------------------------- // Create explosion group //--------------------------------------------------------------------------------------------------------- ExplosionGroup pExplosionGroup = new ExplosionGroup(GameObject.Name.ExplosionGroup, GameSprite.Name.NullObject, 0.0f, 0.0f); pExplosionGroup.activateGameSprite(pSB_Explosion); pExplosionGroup.activateCollisionSprite(pSB_Box); GameObjectMan.Attach(pExplosionGroup); //--------------------------------------------------------------------------------------------------------- // Attach sprites to Sprite Batch //--------------------------------------------------------------------------------------------------------- //pSB_Boxes.attach(BoxSprite.Name.Box1); // Create animation sprites AnimationSprite pAnimOctopus = new AnimationSprite(GameSprite.Name.Octopus); pAnimOctopus.attach(Image.Name.OctopusMovement); pAnimOctopus.attach(Image.Name.Octopus); pAnimOctopus.attach("fastinvader1.wav"); pAnimOctopus.attach("fastinvader2.wav"); pAnimOctopus.attach("fastinvader3.wav"); pAnimOctopus.attach("fastinvader4.wav"); TimerMan.Add(TimeEvent.Name.OctopusAnimation, pAnimOctopus, 0.75f); AnimationSprite pAnimCrab = new AnimationSprite(GameSprite.Name.Crab); pAnimCrab.attach(Image.Name.CrabMovement); pAnimCrab.attach(Image.Name.Crab); pAnimCrab.attach("fastinvader1.wav"); pAnimCrab.attach("fastinvader2.wav"); pAnimCrab.attach("fastinvader3.wav"); pAnimCrab.attach("fastinvader4.wav"); TimerMan.Add(TimeEvent.Name.CrabAnimation, pAnimCrab, 0.75f); AnimationSprite pAminSquid = new AnimationSprite(GameSprite.Name.Squid); pAminSquid.attach(Image.Name.SquidMovement); pAminSquid.attach(Image.Name.Squid); pAminSquid.attach("fastinvader1.wav"); pAminSquid.attach("fastinvader2.wav"); pAminSquid.attach("fastinvader3.wav"); pAminSquid.attach("fastinvader4.wav"); TimerMan.Add(TimeEvent.Name.SquidAnimation, pAminSquid, 0.75f); // Create Movement sprite MovementSprite pMovementSprite = new MovementSprite(pAlienGroup); TimerMan.Add(TimeEvent.Name.MovementAnimation, pMovementSprite, 0.5f); // Create drop bomb sprite DropBomb pDropBomb = new DropBomb(pAlienGroup); TimerMan.Add(TimeEvent.Name.DropBombAnination, pDropBomb, 1.5f); // Create UFOEvent sprite UFOEvent pUFOEvent = new UFOEvent(); TimerMan.Add(TimeEvent.Name.MovementAnimation, pUFOEvent, UFOMan.getDeltaTime()); //--------------------------------------------------------------------------------------------------------- // Collision Pair //--------------------------------------------------------------------------------------------------------- CollisionPair pColPair = CollisionPairMan.Add(CollisionPair.Name.Alien_Missile, pMissileGroup, pAlienGroup); Debug.Assert(pColPair != null); pColPair.attach(new RemoveAlienObserver()); pColPair.attach(new PlaySoundObserver("invaderkilled.wav")); pColPair.attach(new AlienNumObserver(pAlienGroup, pShieldGroup)); pColPair.attach(new RemoveMissileObserver()); pColPair.attach(new ShipReadyObserver()); pColPair = CollisionPairMan.Add(CollisionPair.Name.Missile_Wall, pMissileGroup, pWallGroup); Debug.Assert(pColPair != null); pColPair.attach(new RemoveMissileObserver()); pColPair.attach(new ShipReadyObserver()); pColPair = CollisionPairMan.Add(CollisionPair.Name.Alien_Wall, pAlienGroup, pWallGroup); Debug.Assert(pColPair != null); pColPair.attach(new AlienGroupObserver()); pColPair = CollisionPairMan.Add(CollisionPair.Name.Ship_Bump, pBumpGroup, pShipGroup); Debug.Assert(pColPair != null); pColPair.attach(new ShipPositionObserver()); pColPair = CollisionPairMan.Add(CollisionPair.Name.Missile_Shield, pMissileGroup, pShieldRoot); Debug.Assert(pColPair != null); pColPair.attach(new RemoveShieldObserver(GameObject.Name.Missile)); pColPair.attach(new PlaySoundObserver("invaderkilled.wav")); pColPair.attach(new RemoveMissileObserver()); pColPair.attach(new ShipReadyObserver()); pColPair = CollisionPairMan.Add(CollisionPair.Name.Bomb_Shield, pBombRoot, pShieldRoot); Debug.Assert(pColPair != null); pColPair.attach(new RemoveShieldObserver(GameObject.Name.Bomb)); pColPair.attach(new PlaySoundObserver("invaderkilled.wav")); pColPair.attach(new RemoveBombObserver()); pColPair.attach(new AlienReadyObserver()); pColPair = CollisionPairMan.Add(CollisionPair.Name.Bomb_Wall, pBombRoot, pWallGroup); Debug.Assert(pColPair != null); pColPair.attach(new RemoveBombObserver()); pColPair.attach(new AlienReadyObserver()); pColPair = CollisionPairMan.Add(CollisionPair.Name.Bomb_Missile, pBombRoot, pMissileGroup); Debug.Assert(pColPair != null); pColPair.attach(new BombExplosionObsever()); pColPair.attach(new AlienReadyObserver()); pColPair.attach(new RemoveMissileObserver()); pColPair.attach(new ShipReadyObserver()); pColPair = CollisionPairMan.Add(CollisionPair.Name.Bomb_Ship, pShipGroup, pBombRoot); Debug.Assert(pColPair != null); pColPair.attach(new RemoveBombObserver()); pColPair.attach(new AlienReadyObserver()); pColPair.attach(new RemoveShipObserver()); pColPair.attach(new PlaySoundObserver("explosion.wav")); pColPair = CollisionPairMan.Add(CollisionPair.Name.UFO_Wall, pWallGroup, pUFORoot); Debug.Assert(pColPair != null); pColPair.attach(new RemoveUFOObserver()); pColPair = CollisionPairMan.Add(CollisionPair.Name.UFO_Missile, pMissileGroup, pUFORoot); Debug.Assert(pColPair != null); pColPair.attach(new RemoveMissileObserver()); pColPair.attach(new ShipReadyObserver()); pColPair.attach(new UFOExplosionObserver()); pColPair.attach(new PlaySoundObserver("explosion.wav")); //--------------------------------------------------------------------------------------------------------- // Font //--------------------------------------------------------------------------------------------------------- FontMan.Add(Font.Name.Texts, SpriteBatch.Name.PlainTexts, "SCORE<1>", Glyph.Name.Consolas36pt, 20, 1000); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.PlainTexts, "HI-SCORE", Glyph.Name.Consolas36pt, 370, 1000); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.PlainTexts, "SCORE<2>", Glyph.Name.Consolas36pt, 700, 1000); FontMan.Add(Font.Name.ScoreOne, SpriteBatch.Name.PlainTexts, pScene.getScoreOne().ToString("D4"), Glyph.Name.Consolas36pt, 50, 960); FontMan.Add(Font.Name.HighestScore, SpriteBatch.Name.PlainTexts, pScene.getHighestScore().ToString("D4"), Glyph.Name.Consolas36pt, 400, 960); FontMan.Add(Font.Name.ScoreTwo, SpriteBatch.Name.PlainTexts, pScene.getScoreTwo().ToString("D4"), Glyph.Name.Consolas36pt, 730, 960); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.PlainTexts, "CREDIT", Glyph.Name.Consolas36pt, 700, 25); FontMan.Add(Font.Name.Texts, SpriteBatch.Name.PlainTexts, "00", Glyph.Name.Consolas36pt, 830, 25); }
public Game(bool isFirstRound, bool areCollisionBoxesActive) { // Active Game this.SetState(GameStateEnum.Active); SpriteBatch sbBoxes = SpriteBatchManager.Find(SpriteBatchName.Boxes); SpriteBatch sbAliens = SpriteBatchManager.Find(SpriteBatchName.Aliens); PCSTree pRootTree = GameObjectManager.GetRootTree(); WallRoot pWallRoot = (WallRoot)GameObjectManager.Find(GameObjectName.WallRoot); BombRoot pBombRoot = (BombRoot)GameObjectManager.Find(GameObjectName.BombRoot); MissileRoot pMissileRoot = (MissileRoot)GameObjectManager.Find(GameObjectName.MissileRoot); ShipRoot pShipRoot = (ShipRoot)GameObjectManager.Find(GameObjectName.ShipRoot); UFORoot pUFORoot = (UFORoot)GameObjectManager.Find(GameObjectName.UFORoot); ShieldRoot pShieldRoot1 = (ShieldRoot)GameObjectManager.Find(GameObjectName.ShieldRoot, 1); ShieldRoot pShieldRoot2 = (ShieldRoot)GameObjectManager.Find(GameObjectName.ShieldRoot, 2); ShieldRoot pShieldRoot3 = (ShieldRoot)GameObjectManager.Find(GameObjectName.ShieldRoot, 3); ShieldRoot pShieldRoot4 = (ShieldRoot)GameObjectManager.Find(GameObjectName.ShieldRoot, 4); if (isFirstRound) { // Create Walls pWallRoot = new WallRoot(GameObjectName.WallRoot, SpriteBaseName.Null, 0.0f, 0.0f, 0); pRootTree.Insert(pWallRoot, null); if (areCollisionBoxesActive) { pWallRoot.ActivateCollisionSprite(sbBoxes); } WallTop pWallTop = new WallTop(GameObjectName.WallTop, SpriteBaseName.Null, 448.0f, 950.0f, 850.0f, 30.0f, 0); pRootTree.Insert(pWallTop, pWallRoot); if (areCollisionBoxesActive) { pWallTop.ActivateCollisionSprite(sbBoxes); } pWallTop.ActivateGameSprite(sbAliens); WallRight pWallRight = new WallRight(GameObjectName.WallRight, SpriteBaseName.Null, 896.0f, 500.0f, 50.0f, 900.0f, 0); pRootTree.Insert(pWallRight, pWallRoot); if (areCollisionBoxesActive) { pWallRight.ActivateCollisionSprite(sbBoxes); } pWallRight.ActivateGameSprite(sbAliens); WallLeft pWallLeft = new WallLeft(GameObjectName.WallLeft, SpriteBaseName.Null, 0.0f, 500.0f, 50.0f, 900.0f, 0); pRootTree.Insert(pWallLeft, pWallRoot); if (areCollisionBoxesActive) { pWallLeft.ActivateCollisionSprite(sbBoxes); } pWallLeft.ActivateGameSprite(sbAliens); WallBottom pWallBottom = new WallBottom(GameObjectName.WallBottom, SpriteBaseName.Null, 448.0f, 50.0f, 850.0f, 30.0f, 0); pRootTree.Insert(pWallBottom, pWallRoot); if (areCollisionBoxesActive) { pWallBottom.ActivateCollisionSprite(sbBoxes); } pWallBottom.ActivateGameSprite(sbAliens); GameObjectManager.AttachTree(pWallRoot); // Create ShipRoot and MissileRoot pMissileRoot = new MissileRoot(GameObjectName.MissileRoot, SpriteBaseName.Null, 0.0f, 0.0f, 0); pRootTree.Insert(pMissileRoot, null); if (areCollisionBoxesActive) { pMissileRoot.ActivateCollisionSprite(sbBoxes); } GameObjectManager.AttachTree(pMissileRoot); pShipRoot = new ShipRoot(GameObjectName.ShipRoot, SpriteBaseName.Null, 0.0f, 0.0f); pRootTree.Insert(pShipRoot, null); if (areCollisionBoxesActive) { pShipRoot.ActivateCollisionSprite(sbBoxes); } pShipRoot.ActivateGameSprite(sbAliens); GameObjectManager.AttachTree(pShipRoot); ShipManager.Create(areCollisionBoxesActive); // Create BombRoot pBombRoot = new BombRoot(GameObjectName.BombRoot, SpriteBaseName.Null, 0.0f, 0.0f, 0); pRootTree.Insert(pBombRoot, null); if (areCollisionBoxesActive) { pBombRoot.ActivateCollisionSprite(sbBoxes); } GameObjectManager.AttachTree(pBombRoot); // Create UFORoot pUFORoot = new UFORoot(GameObjectName.UFORoot, SpriteBaseName.Null, 0.0f, 0.0f); pRootTree.Insert(pUFORoot, null); if (areCollisionBoxesActive) { pUFORoot.ActivateCollisionSprite(sbBoxes); } pUFORoot.ActivateGameSprite(sbAliens); GameObjectManager.AttachTree(pUFORoot); UFOManager.Create(areCollisionBoxesActive); // Create Shields pShieldRoot1 = GenerateShield(pRootTree, 100.0f, 200.0f, 1); pShieldRoot2 = GenerateShield(pRootTree, 100.0f + 1 * 200, 200.0f, 2); pShieldRoot3 = GenerateShield(pRootTree, 100.0f + 2 * 200, 200.0f, 3); pShieldRoot4 = GenerateShield(pRootTree, 100.0f + 3 * 200, 200.0f, 4); } else { _gridStartingHeight -= 100.0f; } PopulateAlienGrid(_gridStartingHeight); Alien pGridRoot = (Alien)GameObjectManager.Find(GameObjectName.Grid); // Create CollisionPairs CollisionPair cpMissileWall = CollisionPairManager.Add(CollisionPairName.MissilevTop, pMissileRoot, pWallRoot); Debug.Assert(cpMissileWall != null); cpMissileWall.subject.RegisterObserver(new RemoveMissileObserver()); cpMissileWall.subject.RegisterObserver(new ShipReadyObserver()); CollisionPair cpBombWall = CollisionPairManager.Add(CollisionPairName.BombsvBottom, pBombRoot, pWallRoot); Debug.Assert(cpBombWall != null); cpBombWall.subject.RegisterObserver(new RemoveBombObserver()); CollisionPair cpMissilevGrid = CollisionPairManager.Add(CollisionPairName.MissilevGrid, pMissileRoot, pGridRoot); Debug.Assert(cpMissilevGrid != null); cpMissilevGrid.subject.RegisterObserver(new RemoveMissileObserver()); cpMissilevGrid.subject.RegisterObserver(new RemoveAlienObserver()); cpMissilevGrid.subject.RegisterObserver(new ShipReadyObserver()); cpMissilevGrid.subject.RegisterObserver(new AlienDeathSoundObserver()); cpMissilevGrid.subject.RegisterObserver(new SplatObserver()); cpMissilevGrid.subject.RegisterObserver(new UpdateScoreObserver()); CollisionPair cpUFOMissile = CollisionPairManager.Add(CollisionPairName.MissilevUFO, pMissileRoot, pUFORoot); cpUFOMissile.subject.RegisterObserver(new RemoveMissileObserver()); cpUFOMissile.subject.RegisterObserver(new RemoveUFOObserver()); cpUFOMissile.subject.RegisterObserver(new ShipReadyObserver()); cpUFOMissile.subject.RegisterObserver(new AlienDeathSoundObserver()); cpUFOMissile.subject.RegisterObserver(new SplatObserver()); cpUFOMissile.subject.RegisterObserver(new UpdateScoreObserver()); cpUFOMissile.subject.RegisterObserver(new UFODeathSoundObserver()); CollisionPair cpUFOWalls = CollisionPairManager.Add(CollisionPairName.UFOvWalls, pUFORoot, pWallRoot); cpUFOWalls.subject.RegisterObserver(new UFOWallObserver()); CollisionPair cpGridvWalls = CollisionPairManager.Add(CollisionPairName.GridvWalls, pGridRoot, pWallRoot); Debug.Assert(cpGridvWalls != null); cpGridvWalls.subject.RegisterObserver(new GridXObserver()); cpGridvWalls.subject.RegisterObserver(new GridYObserver()); CollisionPair cpGridvShip = CollisionPairManager.Add(CollisionPairName.GridvShip, pGridRoot, pShipRoot); cpGridvShip.subject.RegisterObserver(new GameOverObserver()); cpGridvShip.subject.RegisterObserver(new ShipDeathSoundObserver()); CollisionPair cpMissileShield1 = CollisionPairManager.Add(CollisionPairName.MissilevShields, pMissileRoot, pShieldRoot1); cpMissileShield1.subject.RegisterObserver(new RemoveMissileObserver()); cpMissileShield1.subject.RegisterObserver(new RemoveBrickObserver()); cpMissileShield1.subject.RegisterObserver(new ShipReadyObserver()); CollisionPair cpBombShield1 = CollisionPairManager.Add(CollisionPairName.BombsvShields, pBombRoot, pShieldRoot1); cpBombShield1.subject.RegisterObserver(new RemoveBombObserver()); cpBombShield1.subject.RegisterObserver(new RemoveBrickObserver()); CollisionPair cpMissileShield2 = CollisionPairManager.Add(CollisionPairName.MissilevShields, pMissileRoot, pShieldRoot2); cpMissileShield2.subject.RegisterObserver(new RemoveMissileObserver()); cpMissileShield2.subject.RegisterObserver(new RemoveBrickObserver()); cpMissileShield2.subject.RegisterObserver(new ShipReadyObserver()); CollisionPair cpBombShield2 = CollisionPairManager.Add(CollisionPairName.BombsvShields, pBombRoot, pShieldRoot2); cpBombShield2.subject.RegisterObserver(new RemoveBombObserver()); cpBombShield2.subject.RegisterObserver(new RemoveBrickObserver()); CollisionPair cpBombShield3 = CollisionPairManager.Add(CollisionPairName.BombsvShields, pBombRoot, pShieldRoot3); cpBombShield3.subject.RegisterObserver(new RemoveBombObserver()); cpBombShield3.subject.RegisterObserver(new RemoveBrickObserver()); CollisionPair cpMissileShield3 = CollisionPairManager.Add(CollisionPairName.MissilevShields, pMissileRoot, pShieldRoot3); cpMissileShield3.subject.RegisterObserver(new RemoveMissileObserver()); cpMissileShield3.subject.RegisterObserver(new RemoveBrickObserver()); cpMissileShield3.subject.RegisterObserver(new ShipReadyObserver()); CollisionPair cpBombShield4 = CollisionPairManager.Add(CollisionPairName.BombsvShields, pBombRoot, pShieldRoot4); cpBombShield4.subject.RegisterObserver(new RemoveBombObserver()); cpBombShield4.subject.RegisterObserver(new RemoveBrickObserver()); CollisionPair cpMissileShield4 = CollisionPairManager.Add(CollisionPairName.MissilevShields, pMissileRoot, pShieldRoot4); cpMissileShield4.subject.RegisterObserver(new RemoveMissileObserver()); cpMissileShield4.subject.RegisterObserver(new RemoveBrickObserver()); cpMissileShield4.subject.RegisterObserver(new ShipReadyObserver()); CollisionPair cpBombMissile = CollisionPairManager.Add(CollisionPairName.BombsvMissile, pBombRoot, pMissileRoot); cpBombMissile.subject.RegisterObserver(new RemoveBombObserver()); cpBombMissile.subject.RegisterObserver(new RemoveMissileObserver()); cpBombMissile.subject.RegisterObserver(new ShipReadyObserver()); cpBombMissile.subject.RegisterObserver(new SplatObserver()); CollisionPair cpBombShip = CollisionPairManager.Add(CollisionPairName.BombsvShip, pBombRoot, pShipRoot); cpBombShip.subject.RegisterObserver(new RemoveBombObserver()); cpBombShip.subject.RegisterObserver(new RemoveShipObserver()); cpBombShip.subject.RegisterObserver(new ShipDeathSoundObserver()); cpBombShip.subject.RegisterObserver(new ShipEndObserver()); //TimerManager.ClearTimerManager(); }
//UFO public override void visitUFORoot(UFORoot u) { //Debug.WriteLine("WallRoot UFORoot"); CollisionPair.detectCollision((GameObject)this.pChild, u); }
public override void VisitUFORoot(UFORoot pUFORoot) { CollisionPair.Collide((GameObject)pUFORoot.pChild, this); }
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 virtual void VisitUFORoot(UFORoot u) { Debug.WriteLine("Visit by UFORoot not implemented"); Debug.Assert(false); }
//UFO public override void visitUFORoot(UFORoot u) { // Debug.WriteLine("MissileRoot UFORoot"); CollisionPair.detectCollision((GameObject)u.pChild, this); }
// 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 VisitUFORoot(UFORoot pUFORoot) { CollisionPair.Collide(pUFORoot, (GameObject)this.pChild); }
//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); }
//UFO public override void visitUFORoot(UFORoot u) { // Debug.WriteLine("StraightMissile UFORoot"); CollisionPair.detectCollision(this, (GameObject)u.pChild); }
public virtual void visitUFORoot(UFORoot u) { }
public SendUFO(UFORoot pUFOroot) { this.pUFOroot = pUFOroot; this.pUFO = null; }
public virtual void visitUFORoot(UFORoot ufoRoot) { // no differed to subclass Debug.WriteLine("Visit by UFORoot not implemented"); Debug.Assert(false); }