Ejemplo n.º 1
0
        public void checkMouseActions(SunManager sunManager, PlanetManager planetManager, Viewport viewport)
        {
            //  if (sunManager.getState().Equals("Dead"))
            //  {
            var mouseState    = Mouse.GetState();
            var mousePosition = new Point(mouseState.X, mouseState.Y);

            foreach (Score score in scoreCollection)
            {
                if (score.type == "PlayAgain")
                {
                    if (score.GetRect().Contains(mousePosition))
                    {
                        // Hover
                        score.texture = score.hoverTexture;
                        // Left click
                        if (mouseState.LeftButton == ButtonState.Pressed)
                        {
                            Console.WriteLine("Left Button Pressed");
                            RestartGame(sunManager, planetManager, viewport);
                            // gameState = GameState.Gameplay;
                        }
                    }
                    else
                    {
                        score.texture = score.defaultTexture;
                    }
                }
            }
            // }
        }
Ejemplo n.º 2
0
 public void CheckGameOver(SunManager sunManager, GameTime gameTime)
 {
     foreach (Score score in scoreCollection)
     {
         string sunState = sunManager.getState();
         if ((score.type == "GameOver" || score.type == "PlayAgain") && sunState == "Dead")
         {
             gameOverElapsedTime += (float)gameTime.ElapsedGameTime.TotalSeconds;
             while (gameOverElapsedTime > 0.05)
             {
                 if (score.scale.X < 1.0f && score.scale.Y < 1.0f && score.type == "GameOver")
                 {
                     score.scale   += new Vector2(0.03f, 0.03f);
                     score.position = new Vector2(score.position.X - (25 * score.scale.X), score.position.Y);
                 }
                 else if (score.scale.X < 0.5f && score.scale.Y < 0.5f && score.type == "PlayAgain")
                 {
                     score.scale   += new Vector2(0.015f, 0.015f);
                     score.position = new Vector2(score.position.X - (25 * score.scale.X), score.position.Y);
                 }
                 gameOverElapsedTime = 0;
             }
         }
     }
 }
Ejemplo n.º 3
0
 public void CheckAsteroidCollision(SunManager sunManager, Viewport viewport, Asteroid asteroid, ScoreManager scoreManager, PlanetManager planetManager, AudioManager audioManager)
 {
     if (asteroid.type == "RedMeteor")
     {
         bool didAsteroidCollideTheSun = asteroid.GetCircle().Intersects(sunManager.GetFirstObjectCircle());
         if (didAsteroidCollideTheSun)
         {
             ResetAndRandomlyGenerateAsteroid(viewport, asteroid);
             scoreManager.DecreaseSunHealth();
         }
         // Planet collision logic
         bool didAsteroidCollideThePlanets = planetManager.CheckPlanetCollision(asteroid, scoreManager);
         if (didAsteroidCollideThePlanets)
         {
             audioManager.playDecreaseSound();
             ResetAndRandomlyGenerateAsteroid(viewport, asteroid);
         }
     }
     else if (asteroid.type == "BlueMeteor")
     {
         // Do planet collision logic here
         bool didAsteroidCollideThePlanets = planetManager.CheckPlanetCollision(asteroid, scoreManager);
         if (didAsteroidCollideThePlanets)
         {
             audioManager.playIncreaseSound();
             // Remove the asteroid from the screen
             asteroid.sprite.position = new Vector2(3000, 3000);
         }
         //int maxEscapeDistance = (viewport.Width / 2) + 500;
         //float meteorDistance = Vector2.Distance(asteroid.sprite.position, new Vector2(viewport.Width/2, viewport.Height/2));
         //if (meteorDistance > maxEscapeDistance) {
         //    ResetAndRandomlyGenerateAsteroid(viewport, asteroid);
         //}
     }
 }
Ejemplo n.º 4
0
 public void Draw(SpriteBatch spriteBatch, SunManager sunManager)
 {
     foreach (Asteroid asteroid in asteroidCollection)
     {
         asteroid.Draw(spriteBatch, sunManager);
     }
 }
Ejemplo n.º 5
0
 public void Update(GameTime gameTime, GraphicsDevice graphicsDevice, SunManager sunManager, ScoreManager scoreManager, PlanetManager planetManager, AudioManager audioManager)
 {
     foreach (Asteroid asteroid in asteroidCollection)
     {
         asteroid.Update(gameTime, graphicsDevice, sunManager);
         CheckAsteroidCollision(sunManager, graphicsDevice.Viewport, asteroid, scoreManager, planetManager, audioManager);
         RestartBlueAsteroid(asteroid, gameTime, graphicsDevice.Viewport);
     }
 }
Ejemplo n.º 6
0
 public void Update(GameTime gameTime, SunManager sunManager, PlanetManager planetManager, GraphicsDevice graphicsDevice)
 {
     CheckGameOver(sunManager, gameTime);
     checkMouseActions(sunManager, planetManager, graphicsDevice.Viewport);
 }
Ejemplo n.º 7
0
 public void RestartGame(SunManager sunManager, PlanetManager planetManager, Viewport viewport)
 {
     this.ResetScore(viewport);
     sunManager.ResetSunStates();
     planetManager.ResetPlanetStates();
 }