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; } } } // } }
public void Update(GraphicsDevice graphicsDevice, PlanetManager planetManager, AudioManager audioManager) { MouseState state = Mouse.GetState(); Vector2 screenCenter = new Vector2(graphicsDevice.Viewport.Width / 2, graphicsDevice.Viewport.Height / 2); foreach (Orbit orbit in orbitCollection) { var planetDestination = new Circle(screenCenter, orbit.radius + 20); bool planetMouseOver = planetDestination.Contains(new Vector2(state.X, state.Y)); int nextPlanetOffset = 70; var nextPlanetDestination = new Circle(screenCenter, orbit.radius - nextPlanetOffset); bool nextPlanetMouseOver = nextPlanetDestination.Contains(new Vector2(state.X, state.Y)); if (planetMouseOver) { if (hoverSoundPlayed == false) { // audioManager.playOrbitHoverSound(); hoverSoundPlayed = true; } } else { hoverSoundPlayed = false; } if (planetMouseOver && !nextPlanetMouseOver) { orbit.sprite.texture = orbit.selectedTexture; if (state.LeftButton == ButtonState.Pressed) { planetManager.accelerateForward(orbit); } else if (state.RightButton == ButtonState.Pressed) { planetManager.accelerateBackward(orbit); } } else { orbit.sprite.texture = orbit.defaultTexture; } } }
public void Update(GameTime gameTime, SunManager sunManager, PlanetManager planetManager, GraphicsDevice graphicsDevice) { CheckGameOver(sunManager, gameTime); checkMouseActions(sunManager, planetManager, graphicsDevice.Viewport); }
public void RestartGame(SunManager sunManager, PlanetManager planetManager, Viewport viewport) { this.ResetScore(viewport); sunManager.ResetSunStates(); planetManager.ResetPlanetStates(); }
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); //} } }
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); } }