//Resets values needed for gameplay public void InitializeGame() { //Creates new list for explosions explosions = new List <Animation>(); numberOfPlayers = 0; //Checks number of controllers connected for (int i = 0; i < 4; i++) { if (GamePad.GetState((PlayerIndex)i, GamePadDeadZone.None).IsConnected) { numberOfPlayers++; } } //If no controllers connected, add one player for keyboard control if (numberOfPlayers == 0) { numberOfPlayers = 1; } //Changes spawn time of turtles based on number of players spawnTime = TimeSpan.FromSeconds(1.5 / (double)numberOfPlayers); //Set max amount of turtles maxTurtles = 20; //Creates new list for Players, Projectiles, and turtles players = new List <Player>(); projectiles = new List <Projectile>(); turtles = new List <Turtle>(); //Load players based on number of players and control method LoadPlayers(); //Reset game gameOver = false; //Spawn moon in middle of screen, with 100 health moon = new Moon(moonTexture, new Vector2(windowWidth / 2, windowHeight / 2), 100); //Reset all game timers gameTimeScore = TimeSpan.FromSeconds(0); elapsedBigTurtleSpawnTime = TimeSpan.FromSeconds(0); elapsedEndGameTime = TimeSpan.FromSeconds(0); elapsedDifficulityIncreaseTime = TimeSpan.FromSeconds(0); }
//Resets values needed for gameplay public void InitializeGame() { //Creates new list for explosions explosions = new List<Animation>(); numberOfPlayers = 0; //Checks number of controllers connected for (int i = 0; i < 4; i++) { if (GamePad.GetState((PlayerIndex)i, GamePadDeadZone.None).IsConnected) { numberOfPlayers++; } } //If no controllers connected, add one player for keyboard control if (numberOfPlayers == 0) { numberOfPlayers = 1; } //Changes spawn time of turtles based on number of players spawnTime = TimeSpan.FromSeconds(1.5 / (double)numberOfPlayers); //Set max amount of turtles maxTurtles = 20; //Creates new list for Players, Projectiles, and turtles players = new List<Player>(); projectiles = new List<Projectile>(); turtles = new List<Turtle>(); //Load players based on number of players and control method LoadPlayers(); //Reset game gameOver = false; //Spawn moon in middle of screen, with 100 health moon = new Moon(moonTexture, new Vector2(windowWidth / 2, windowHeight / 2), 100); //Reset all game timers gameTimeScore = TimeSpan.FromSeconds(0); elapsedBigTurtleSpawnTime = TimeSpan.FromSeconds(0); elapsedEndGameTime = TimeSpan.FromSeconds(0); elapsedDifficulityIncreaseTime = TimeSpan.FromSeconds(0); }