public AlienGridAnimation(AlienGrid grid, IrrKlang.ISoundEngine eng) { this.grid = grid; Debug.Assert(eng != null); this.soundEngine = eng; count = 0; }
override public void Execute(float deltaTime) { int pFreq = pRandom.Next(1, 10) / this.nCurrLevel; AlienGrid pGrid = (AlienGrid)GameObjectMan.Find(GameObject.Name.AlienGrid); AlienCategory pAlien = pGrid.GetRandomAlien(); // HACK don't crash pleease if (pAlien == null) { TimerMan.Add(TimeEvent.Name.BombSpawn, this, pFreq); return; } int type = pRandom.Next(0, 2); FallStrategy pFallStrategy = null; switch (type) { case (0): pFallStrategy = new FallZigZag(); break; case (1): pFallStrategy = new FallDagger(); break; case (2): pFallStrategy = new FallStraight(); break; } type = pRandom.Next(0, 2); GameSprite.Name pGameSpriteName = GameSprite.Name.Uninitialized; switch (type) { case (0): pGameSpriteName = GameSprite.Name.BombZigZag; break; case (1): pGameSpriteName = GameSprite.Name.BombDagger; break; case (2): pGameSpriteName = GameSprite.Name.BombStraight; break; } Bomb pBomb = new Bomb(GameObject.Name.Bomb, pGameSpriteName, pFallStrategy, pAlien.x, pAlien.y); pBomb.ActivateCollisionSprite(this.pSB_Boxes); pBomb.ActivateGameSprite(this.pSB_Bombs); GameObject pBombRoot = GameObjectMan.Find(GameObject.Name.BombRoot); Debug.Assert(pBombRoot != null); pBombRoot.Add(pBomb); TimerMan.Add(TimeEvent.Name.BombSpawn, this, pFreq); }
public override void Notify() { //Debug.WriteLine("Grid_Observer: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB); // OK do some alphabetic magic AlienGrid pGrid = (AlienGrid)this.pSubject.pObjA; WallCategory pWall = (WallCategory)this.pSubject.pObjB; if (pWall.GetCategoryType() == WallCategory.Type.Right) { // Was set true in the collision if (pGrid.GetIsOnWall()) { Debug.WriteLine("---- Hiding : Wall Hit"); TimerManager.Add(TimeEvent.Name.HideUFO, new HideUFO(pGrid), pGrid.movementTimeInterval); } } else if (pWall.GetCategoryType() == WallCategory.Type.Left) { // Was set true in the collision if (pGrid.GetIsOnWall()) { Debug.WriteLine("---- Hiding : Wall Hit"); TimerManager.Add(TimeEvent.Name.HideUFO, new HideUFO(pGrid), pGrid.movementTimeInterval); } } else { Debug.Assert(false); } }
public override void Notify() { Debug.WriteLine("Grid_Observer: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB); // OK do some magic AlienGrid pGrid = (AlienGrid)this.pSubject.pObjA; WallCategory pWall = (WallCategory)this.pSubject.pObjB; if (pWall.GetCategoryType() == WallCategory.Type.Right) { if (pGrid.flag == true) { pGrid.SetDelta(-20.0f); pGrid.MoveDownGrid(); pGrid.flag = false; } } else if (pWall.GetCategoryType() == WallCategory.Type.Left) { if (pGrid.flag == false) { pGrid.SetDelta(20.0f); pGrid.MoveDownGrid(); pGrid.flag = true; } } else { Debug.Assert(false); } }
public override void Update(float systemTime) { InputManager.Update(); FontManager.Update(Font.Name.Player1Score, SpaceInvaders.pPlayer1Score); FontManager.Update(Font.Name.Player2Score, SpaceInvaders.pPlayer2Score); FontManager.Update(Font.Name.HiScore, SpaceInvaders.pHiScore); FontManager.Update(Font.Name.Lives, ScenePlay.ShipLives.ToString()); this.RunTime = Simulation.GetTotalTime() - ScenePlay.StartTimeDelta; //Debug.WriteLine(this.RunTime); TimerManager.Update(this.RunTime); GameObjectManager.Update(); //Collision Checks CollisionPairManager.Process(); // Delete any objects here... DelayedObjectManager.Process(); //check if all alien killed AlienGrid pGrid = (AlienGrid)GameObjectManager.Find(GameObject.Name.AlienGrid); if (pGrid.GetAlienCount() < 1) { pGrid.IncreaseStartRate(); this.ResetAll(); } }
public void loadAliens() { AlienFactory alienFactory = FactoryManager.getAlienFactry(); AlienGrid alienGrid = (AlienGrid)alienFactory.createAlien(Alien.AlienType.AlienGrid, GameObject.GameObjectName.AlienGrid, 0); alienFactory.setParent(alienGrid); for (int i = 0; i < 11; i++) { alienFactory.setParent(alienGrid); Alien pColumn = alienFactory.createAlien(Alien.AlienType.Column, GameObject.GameObjectName.Column, i + 1, 0.0f, 0.0f); //set Parent alienFactory.setParent(pColumn); float x = Unit.alienPosX; float y = Unit.alienPosY; alienFactory.createAlien(Alien.AlienType.Crab, GameObject.GameObjectName.Crab, i + 2, x + i * 50.0f, y); alienFactory.createAlien(Alien.AlienType.Squid, GameObject.GameObjectName.Squid, i + 3, x + i * 50.0f, y - 60); alienFactory.createAlien(Alien.AlienType.Squid, GameObject.GameObjectName.Squid, i + 4, x + i * 50.0f, y - 120); alienFactory.createAlien(Alien.AlienType.Octopus, GameObject.GameObjectName.Octopus, i + 5, x + i * 50.0f, y - 180); alienFactory.createAlien(Alien.AlienType.Octopus, GameObject.GameObjectName.Octopus, i + 6, x + i * 50.0f, y - 240); } IrrKlang.ISoundEngine sndEngine = FactoryManager.getSoundEngine(); AlienGridAnimation alienGridAni = new AlienGridAnimation(alienGrid, sndEngine); TimerManager.sortedAdd(TimerEvent.TimerEventName.SpriteAnimation, alienGridAni, Unit.AlienGridMoveEventTime); }
public override void execute(float deltaTime) { Column col = (Column)alien.pParent; alien.remove(); AlienFactory af = FactoryManager.getAlienFactry(); af.reduceCount(alien); if (af.alienCount == 20) { Unit.level1Mid(); AlienGrid ag = (AlienGrid)af.cPCSTree.getRoot(); ag.updateDelta(); } if (af.alienCount == 5) { Unit.level1Last(); AlienGrid ag = (AlienGrid)af.cPCSTree.getRoot(); ag.updateDelta(); } //Commnetd for level 2 if (col.death) { af.reduceCount(col); col.remove(); } }
public AlienGrid CreateGrid(int xPos, int yPos) { AlienGrid pGrid = (AlienGrid)Create(GameObject.Name.AlienGrid, AlienCategory.Type.Grid, xPos, yPos); GameObject pGameObj; for (int i = 0; i < 11; i++) { GameObject pCol = Create(GameObject.Name.AlienColumn + i, AlienCategory.Type.Column, xPos, yPos); pGameObj = Create(GameObject.Name.BlueAlien, AlienCategory.Type.Blue, xPos + i * 50.0f, yPos); pCol.Add(pGameObj); pGameObj = Create(GameObject.Name.GreenAlien, AlienCategory.Type.Green, xPos + i * 50.0f, yPos - 50); pCol.Add(pGameObj); pGameObj = Create(GameObject.Name.GreenAlien, AlienCategory.Type.Green, xPos + i * 50.0f, yPos - 100); pCol.Add(pGameObj); pGameObj = Create(GameObject.Name.RedAlien, AlienCategory.Type.Red, xPos + i * 50.0f, yPos - 150); pCol.Add(pGameObj); pGameObj = Create(GameObject.Name.RedAlien, AlienCategory.Type.Red, xPos + i * 50.0f, yPos - 200); pCol.Add(pGameObj); pGrid.Add(pCol); pGrid.nNumActive += 5; } GameObjectMan.Attach(pGrid); return(pGrid); }
public override void VisitGroup(AlienGrid a) { ColPair pColPair = ColPairMan.GetActiveColPair(); pColPair.SetCollision(a, this); pColPair.NotifyListeners(); }
internal static void DestroyAlienGrid(AlienGrid pAlienGrid) { // Iterate through AlienGridColumns AlienGridColumn pGridColumn = (AlienGridColumn)pAlienGrid.GetFirstChild(); while (pGridColumn != null) { // Iterate through shield bricks Alien pAlien = (Alien)pGridColumn.GetFirstChild(); while (pAlien != null) { // Remove Alien from composite pGridColumn.Remove(pAlien); // Kill Alien pAlien.Remove(SpriteBatch.Name.Alien, SpriteBatch.Name.CollisionBox); // Get next Alien pAlien = (Alien)pGridColumn.GetFirstChild(); } // Remove AlienGridColumn from composite pAlienGrid.Remove(pGridColumn); // Kill AlienGridColumn pGridColumn.Remove(SpriteBatch.Name.Alien, SpriteBatch.Name.CollisionBox); // Get next AlienGridColumn pGridColumn = (AlienGridColumn)pAlienGrid.GetFirstChild(); } }
public static GameObject RecreateAlienGrid(AlienGrid pAlienGrid, float startingGridSpeed, float start_x = 0.0f, float start_y = 0.0f) { GhostManager pGhostManager = GameStateManager.GetGame().GetStateGhostManager(); GameObjectManager pGameObjectManager = GameStateManager.GetGame().GetStateGameObjectManager(); // Attach Composite objects Composite pCol; for (int i = 0; i < 11; i++) { pCol = (Composite)pGhostManager.Find(GameObject.Name.AlienGridColumn); pGhostManager.Detach(pCol); pGameObjectManager.Attach(pCol); // Recreate Aliens & Attach to Column RecreateAlienGridColumn(pCol, (start_x + (60.0f * i)), start_y); // Append Columns to AlienGrid pAlienGrid.Add(pCol); } // Add Initial AlienGridMovement Event AlienGridMovement pAlienGridMovement = new AlienGridMovement(pAlienGrid); GameStateManager.GetGame().GetStateQueuedTimeEventManager().Enqueue(TimeEvent.Name.AlienGridMovement, pAlienGridMovement, startingGridSpeed); return(pAlienGrid); }
public static GameObject CreateAlienGrid(float start_x = 0.0f, float start_y = 0.0f) { // Create Composite objects Composite pAlienGrid = new AlienGrid(Composite.CompositeName.AlienGrid, 20.0f, 0.0f); pAlienGrid.SetCollisionObjectLineColor(1.0f, 1.0f, 0.0f); pAlienGrid.ActivateSprite(GameStateManager.GetGame().GetStateSpriteBatchManager().Find(SpriteBatch.Name.Alien)); pAlienGrid.ActivateCollisionSprite(GameStateManager.GetGame().GetStateSpriteBatchManager().Find(SpriteBatch.Name.CollisionBox)); GameStateManager.GetGame().GetStateCompositeManager().Attach(pAlienGrid); GameStateManager.GetGame().GetStateGameObjectManager().Attach(pAlienGrid); Composite pCol; for (int i = 0; i < 11; i++) { pCol = new AlienGridColumn(Composite.CompositeName.AlienCol1 + i); GameStateManager.GetGame().GetStateGameObjectManager().Attach(pCol); // Generate Aliens & Attach to Column GenerateNewAlienGridColumn(pCol, (start_x + (60.0f * i)), start_y); // Append Columns to AlienGrid pAlienGrid.Add(pCol); } // Add Initial AlienGridMovement Event AlienGridMovement pAlienGridMovement = new AlienGridMovement(pAlienGrid); GameStateManager.GetGame().GetStateQueuedTimeEventManager().Enqueue(TimeEvent.Name.AlienGridMovement, pAlienGridMovement, GameStateManager.GetGame().GetStateLevelInitialAlienGridSpeed()); return(pAlienGrid); }
public void AlienBullet() { List <System.Windows.Controls.Image> alien_armoury = new List <System.Windows.Controls.Image> { AlienBullet1, AlienBullet2, AlienBullet3, AlienBullet4, AlienBullet5 }; foreach (System.Windows.Controls.Image bullet in alien_armoury) { if (rnd.Next(0, 50) == 15) { if (bullet.Visibility == Visibility.Collapsed) { current_alien_bullets.Add(bullet); int random_margin = rnd.Next(0, (int)Math.Abs((AlienGrid.Margin.Left / 2))); random_margin = (int)AlienGrid.Margin.Left - random_margin; if (random_margin % 2 == 0) { random_margin = random_margin + (int)AlienGrid.Margin.Left; } current_allien_bullet_margins.Add(random_margin); bullet.Margin = AlienGrid.Margin; bullet.SetValue(Grid.RowProperty, AlienGrid.GetValue(Grid.RowProperty)); bullet.Visibility = Visibility.Visible; } } } }
public override void load() { Unit.level2Start(); AlienFactory alienFactory = FactoryManager.getAlienFactry(); AlienGrid alienGrid = (AlienGrid)FactoryManager.getAlienFactry().cPCSTree.getRoot(); alienGrid.updateDelta(); PCSTree pcsTree = FactoryManager.getAlienFactry().cPCSTree; SpriteBatch cSpriteBatch = FactoryManager.getAlienFactry().cSpriteBatch; for (int i = 0; i < 11; i++) { FactoryManager.getAlienFactry().setParent(alienGrid); Alien pColumn = (Alien)GhostManager.find(GameObject.GameObjectName.Column); GhostManager.remove(pColumn); pColumn.set(Sprite.SpriteName.NullObject, i + 1, 0, 0); alienFactory.activate(pColumn); alienFactory.setParent(pColumn); float x = Unit.alienPosX; float y = Unit.alienPosY; Alien alien = (Alien)GhostManager.find(GameObject.GameObjectName.Crab); GhostManager.remove(alien); alien.set(Sprite.SpriteName.Crab, i + 2, x + i * 60.0f, y); alienFactory.activate(alien); Alien alien2 = (Alien)GhostManager.find(GameObject.GameObjectName.Squid); GhostManager.remove(alien2); alien2.set(Sprite.SpriteName.Squid, i + 2, x + i * 60.0f, y - 60); alienFactory.activate(alien2); Alien alien3 = (Alien)GhostManager.find(GameObject.GameObjectName.Squid); GhostManager.remove(alien3); alien3.set(Sprite.SpriteName.Squid, i + 2, x + i * 60.0f, y - 120); alienFactory.activate(alien3); Alien alien4 = (Alien)GhostManager.find(GameObject.GameObjectName.Octopus); GhostManager.remove(alien4); alien4.set(Sprite.SpriteName.Octopus, i + 2, x + i * 60.0f, y - 180); alienFactory.activate(alien4); Alien alien5 = (Alien)GhostManager.find(GameObject.GameObjectName.Octopus); GhostManager.remove(alien5); alien5.set(Sprite.SpriteName.Octopus, i + 6, x + i * 60.0f, y - 240); alienFactory.activate(alien5); // alienFactory.createAlien(Alien.AlienType.Squid, GameObject.GameObjectName.Squid, i + 3, x + i * 60.0f, y - 60); // alienFactory.createAlien(Alien.AlienType.Squid, GameObject.GameObjectName.Squid, i+4, x + i * 60.0f, y-120); // alienFactory.createAlien(Alien.AlienType.Octopus, GameObject.GameObjectName.Octopus, i+5, x + i * 60.0f, y-180); // alienFactory.createAlien(Alien.AlienType.Octopus, GameObject.GameObjectName.Octopus, i+6, x + i * 60.0f, y-240); } }
public override void VisitGroup(AlienGrid a) { CollisionPair pColPair = CollisionPairManager.GetActiveColPair(); Debug.Assert(pColPair != null); pColPair.SetCollision(a, this); pColPair.NotifyListeners(); }
public override void VisitAlienGrid(AlienGrid a) { // Debug.WriteLine("collide: {0} with {1}", a, this); // AlienGrid vs WallGroup // go down a level in Wall Group. GameObject pGameObj = Iterator.GetChildGameObject(this); CollisionPair.Collide(a, pGameObj); }
public override void VisitGrid(AlienGrid a) { // AlienGroup vs WallBottom (You Lose the Video Game) ColPair pColPair = ColPairMan.GetActiveColPair(); Debug.Assert(pColPair != null); pColPair.SetCollision(a, this); pColPair.NotifyListeners(); }
//---------------------------------------------------------------------------------- // Constructor //---------------------------------------------------------------------------------- public AnimationSprite(GameSprite.Name theName, AlienGrid ag) { this.pSprite = GameSpriteManager.Find(theName); Debug.Assert(this.pSprite != null); this.pCurrentImage = null; this.poFirstImage = null; this.pAlienGrid = ag; }
/// Grid Visit public override void visitAlienGrid(AlienGrid a) { // Debug.WriteLine("WallRight AlienGrid"); CollisionPair currColPair = CollisionPairManager.getCurrentColPair(); Debug.Assert(currColPair != null); currColPair.setSubject(a, this); currColPair.notifyObserver(); }
public override void VisitAlienGrid(AlienGrid ag) { //Debug.WriteLine("collide: {0} with {1}", ag, this); // AlienGrid vs Shield Brick // go down a level in AlienGrid composite. GameObject pGameObj = Iterator.GetChildGameObject(ag); CollisionPair.Collide(pGameObj, this); }
public override void VisitAlienGrid(AlienGrid ag) { // AlienGrid vs Missile //Debug.WriteLine(" collide: {0} <-> {1}", ag.GetName(), this.name); // AlienGridColumn vs Missile GameObject pGameObj = Iterator.GetChildGameObject(ag); CollisionPair.Collide(pGameObj, this); }
public override void VisitAlienGrid(AlienGrid a) { // AlienGrid vs LeftWall // Debug.WriteLine("collide: {0} with {1}", this, a); CollisionPair pColPair = CollisionPairManager.GetActiveColPair(); Debug.Assert(pColPair != null); pColPair.SetCollision(a, this); pColPair.NotifyListeners(); }
//Alien public override void visitAlienGrid(AlienGrid a) { Debug.WriteLine("ShipRootss AlienGrid"); Debug.WriteLine("Both tress finished to roots"); CollisionPair currColPair = CollisionPairManager.getCurrentColPair(); Debug.Assert(currColPair != null); currColPair.setSubject(a, this); currColPair.notifyObserver(); }
public void MoveAliens() { AlienGrid.Margin = new Thickness(AlienGrid.Margin.Left + ship_margin_rate, 0, 0, 0); if ((int)AlienGrid.GetValue(Grid.RowProperty) == 4) { GameOver(); } if ((int)AlienGrid.Margin.Left == 160 || (int)AlienGrid.Margin.Left == 0 & ship_margin_rate < 0) { ChangeRow(AlienGrid, false); ship_margin_rate = ship_margin_rate * -1; } }
//---------------------------------------------------------------------------------- // Methods //---------------------------------------------------------------------------------- public GameObject Create(GameObject.Name theName, AlienCategory.Type type, float posx = 0.0f, float posy = 0.0f) { GameObject pGameObj = null; switch (type) { case AlienCategory.Type.AlienGrid: pGameObj = new AlienGrid(theName, GameSprite.Name.NullObject, posx, posy); ((AlienGrid)pGameObj).SetCanDropBombs(true); break; case AlienCategory.Type.Column: pGameObj = new AlienColumn(theName, GameSprite.Name.NullObject, posx, posy); break; case AlienCategory.Type.Alien: pGameObj = new AlienGO(theName, GameSprite.Name.Alien, 20, posx, posy); break; case AlienCategory.Type.Octopus: pGameObj = new AlienGO(theName, GameSprite.Name.Octopus, 10, posx, posy); break; case AlienCategory.Type.Squid: pGameObj = new AlienGO(theName, GameSprite.Name.Squid, 30, posx, posy); break; case AlienCategory.Type.UFOGrid: pGameObj = new AlienGrid(theName, GameSprite.Name.NullObject, posx, posy); ((AlienGrid)pGameObj).SetCanDropBombs(false); break; case AlienCategory.Type.Saucer: pGameObj = new AlienGO(theName, GameSprite.Name.Saucer, 100, posx, posy); break; default: Debug.WriteLine("Choose the Space Invader you want by name."); Debug.Assert(false); break; } // add it to the Game Object Manager Debug.Assert(pGameObj != null); // Should only attach root elements in the Scene // attach to the group pGameObj.ActivateGameSprite(this.pSpriteBatch); pGameObj.ActivateCollisionSprite(this.pCollisionSpriteBatch); return(pGameObj); }
public override void Execute(float deltaTime) { Debug.Assert(this.pAlien != null); this.pAlien.Remove(); if (this.pAlien.name != GameObject.Name.OrangeSaucer) { AlienGrid pGrid = (AlienGrid)GameObjectManager.Find(GameObject.Name.AlienGrid); Debug.Assert(pGrid != null); pGrid.DecreaseAlienCount(); } }
public override void VisitGrid(AlienGrid a) { Debug.WriteLine("\ncollide: {0} with {1}", this, a); Debug.WriteLine(" --->DONE<----"); ColPair pColPair = ColPairMan.GetActiveColPair(); Debug.Assert(pColPair != null); pColPair.SetCollision(a, this); pColPair.NotifyListeners(); }
public override void VisitGroup(AlienGrid a) { //a.DropGrid(); //a.SetDelta(-1.0f); //Debug.WriteLine("reverse grid right"); ColPair pColPair = ColPairMan.GetActiveColPair(); pColPair.SetCollision(a, this); pColPair.NotifyListeners(); }
public override void Notify() { //Debug.WriteLine(" Grid_Wall_Observer: {0} {1}", this.pSubject.pObjA, this.pSubject.pObjB); AlienGrid pAlienGrid = (AlienGrid)this.pSubject.pObjA; // If AlienGrid is not already changing directions if (!pAlienGrid.GetSwitchXDirection() && !pAlienGrid.IsDirectionChangePending()) { // Tell AlienGrid to move down and change directions pAlienGrid.SetSwitchXDirection(true); } }
public override void notify() { // Debug.WriteLine("Action after the Alien Grid / Wall goes here"); // Debug.WriteLine("AlienGrid & Wall Observer: {0} {1}", this.colSubject.gameObjA.cGameObjectName, this.colSubject.gameObjB.cGameObjectName); AlienGrid ag = (AlienGrid)this.colSubject.gameObjA; Wall wall = (Wall)this.colSubject.gameObjB; if (!ag.edgeHit) { ag.deltaX *= -1.0f; ag.setEdgeHit(); } }