/// <summary> /// Gets called when a Scene is unpaused /// </summary> protected override void OnSceneUnpaused() { // Make the aliens move again AlienCoordinator aliens = GameObjectManager.Active.Find(GameObject.Name.AlienCoordinator, this.AlienCoordinatorId) as AlienCoordinator; if (aliens != null) { aliens.StartMovingAgain(); } // Make the UFO play a sound, if it exists UFO ufo = GameObjectManager.Active.Find(GameObject.Name.UFO, this.UfoId) as UFO; if (ufo != null) { ufo.PlayLoopingSound(); } }
/// <summary> /// Add the given root as the root of collision checking on behalf of all aliens /// </summary> /// <param name="newRoot"></param> private void AddAlienRootToCollisionSystem(AlienCoordinator newRoot) { CollisionPairEvaluator collisonPair = null; // Alien collisions ================= // Wall Vs Alien collisonPair = CollisonPairManager.Active.Find(CollisionPairEvaluator.Name.Wall_vs_Alien); collisonPair.SetSecondCollisonRoot(newRoot); // PlayerLaser vs Alien collisonPair = CollisonPairManager.Active.Find(CollisionPairEvaluator.Name.PlayerLaser_vs_Alien); collisonPair.SetSecondCollisonRoot(newRoot); // Player vs Alien collisonPair = CollisonPairManager.Active.Find(CollisionPairEvaluator.Name.Player_vs_Alien); collisonPair.SetSecondCollisonRoot(newRoot); // Alien vs Shield collisonPair = CollisonPairManager.Active.Find(CollisionPairEvaluator.Name.Alien_vs_Shield); collisonPair.SetFirstCollisonRoot(newRoot); // AlienLaser collisions ============== GameObject alienLaserRoot = newRoot.AlienLaserRoot; // PlayerLaser vs AlienLaser collisonPair = CollisonPairManager.Active.Find(CollisionPairEvaluator.Name.PlayerLaser_vs_AlienLaser); collisonPair.SetSecondCollisonRoot(alienLaserRoot); // Player vs AlienLaser collisonPair = CollisonPairManager.Active.Find(CollisionPairEvaluator.Name.Player_vs_AlienLaser); collisonPair.SetSecondCollisonRoot(alienLaserRoot); // AlienLaser vs Shields collisonPair = CollisonPairManager.Active.Find(CollisionPairEvaluator.Name.AlienLaser_vs_Shield); collisonPair.SetFirstCollisonRoot(alienLaserRoot); // AlienLaser vs WallBottom collisonPair = CollisonPairManager.Active.Find(CollisionPairEvaluator.Name.AlienLaser_vs_WallBottom); collisonPair.SetFirstCollisonRoot(alienLaserRoot); }
// // Methods // public void ExecuteCommand() { // Not Game Over yet if (GameSessionData.Active.Lives > 0) { // Make the aliens move again AlienCoordinator aliens = GameObjectManager.Active.Find(GameObject.Name.AlienCoordinator, SceneManager.Self.ActiveScene.AlienCoordinatorId) as AlienCoordinator; Debug.Assert(aliens != null, "The AlienCoordinator could not be found upon respawning the Player!"); aliens.StartMovingAgain(); // Respawn player GameScene scene = SceneManager.Self.ActiveScene as GameScene; Debug.Assert(scene != null, "Trying to respawn a player in a non-GameScene!"); PlayerFactory factory = new PlayerFactory(scene); factory.CreatePlayer(); // Go to the next scene. See OnLoadNextScene() in P1Scene and P2Scene SceneManager.Self.ActiveScene.TransitionToNextScene(); } // Game Over else { // Create a new Game Over text for the HUD HudText gameOverText = new HudText(HudDisplayer.LabelGameOverX, HudDisplayer.LabelGameOverY, "GAME OVER", Azul.AZUL_FONTS.Consolas36pt, Colors.Red); SceneManager.Self.ActiveScene.HudDisplay.AddHudText(gameOverText); // Test for new highscore bool isNewHighscore = SceneManager.Self.DetermineNewHighscore(GameSessionData.Active.Score); if (isNewHighscore) { HudText highScoreLabel = new HudText(HudDisplayer.LabelGameOverX + 27.0f, HudDisplayer.LabelGameOverY + 70.0f, "NEW HIGHSCORE", Azul.AZUL_FONTS.Consolas12pt, Colors.White); SceneManager.Self.ActiveScene.HudDisplay.AddHudText(highScoreLabel); } // Create a GameOver delay. Which will go to the next scene. GameOverDelayEvent gameOver = new GameOverDelayEvent(); } // This thing is done this.timedEvent = null; }
/// <summary> /// Load the Alien GameObjects /// </summary> private void LoadGameObjects() { AlienName[] alienNames = new AlienName[this.Rows]; alienNames[0] = AlienName.Squid; alienNames[1] = AlienName.Crab; alienNames[2] = AlienName.Crab; alienNames[3] = AlienName.Octopus; alienNames[4] = AlienName.Octopus; AlienCoordinator coordinator = new AlienCoordinator(Rows, Columns, InitX, InitY, XGap, YGap); // Add coordinator as root of collision checking this.AddAlienRootToCollisionSystem(coordinator); // Attach coordinator last to call it's Start event GameObjectManager.Active.Attach(coordinator); // Create all the Aliens (bottom row first) for (int i = (int)this.Rows - 1; i >= 0; i--) { this.LoadAlienRow(alienNames[i], this.Columns, this.InitX, this.InitY - this.YGap * (uint)i, this.XGap, coordinator ); } // Calculate colliders of columns for (uint j = 0; j < this.Rows; j++) { coordinator.Columns[j].RecalculateCollider(); } // Calculate collider of coodinator coordinator.RecalculateCollider(); }
private void LoadAlienRow(AlienName alienName, uint numOfAliens, float initX, float initY, float xSpacing, AlienCoordinator coordinator) { // Determine correct enum names GameObject.Name objectName = GameObject.Name.UNINITIALIZED; Sprite.Name spriteName = Sprite.Name.UNINITIALIZED; switch (alienName) { case AlienName.Crab: objectName = GameObject.Name.AlienCrab; spriteName = Sprite.Name.AlienCrab; break; case AlienName.Squid: objectName = GameObject.Name.AlienSquid; spriteName = Sprite.Name.AlienSquid; break; case AlienName.Octopus: objectName = GameObject.Name.AlienOctopus; spriteName = Sprite.Name.AlienOctopus; break; default: break; } // Use a loop to create a row of aliens // Each "i" is a column for (uint i = 0; i < numOfAliens; i++) { Aliens alien = this.LoadIndividualAlien(objectName, spriteName, alienName, initX + xSpacing * i, initY ); coordinator.Columns[i].AddChild(alien); } }