public GameplayScreen() { TransitionOffTime = TimeSpan.FromSeconds(0.5f); //Initialize interval spawn time to 2 seconds spawnTimeInterval = 2000; previousSpawnTime = 0; //Initialize collections obstacles = new List<Obstacle>(); enemies = new List<Enemy>(); enemiesWithObject = new List<EnemyWithObject>(); flyingEnemies = new List<FlyingEnemy>(); gems = new List<Gem>(); horizontalEnemies = new List<HorizontalEnemy>(); collisionAnimations = new List<Animation>(); // Initialize random number generator random = new Random(); //Set the initial player score to zero score = 0; GameStarted = false; gameOver = false; gameOverTime = TimeSpan.Zero; //Three seconds for the game over screen to be displayed after game over initiateGameOver = TimeSpan.FromSeconds(3.0); //Set the number of obstacles to be spawned at a time to be one numberOfObstacles = 1; //Set the distance between subsequent obstacles to 200 pixels obstacleTimeDifference = 0; numOfObjects = EnemyWithObject.NumberOfObjects.One; }
//Updates the interval at which the items spawn based on player score private void UpdateSpawnTimeInterval() { if (score > 400 && score < 800) { spawnTimeInterval = 1500; } else if (score >= 800 && score <= 1500) { spawnTimeInterval = 1200; numberOfObstacles = 2; obstacleTimeDifference = 250; } else if (score > 1500 && score <= 2500) { spawnTimeInterval = 1000; numOfObjects = EnemyWithObject.NumberOfObjects.Two; } else if (score > 2500 && score <= 3500) { spawnTimeInterval = 800; numberOfObstacles = 3; } else if (score > 3500 && score <= 4500) { spawnTimeInterval = 700; } else if (score > 3500 && score <= 4000) { spawnTimeInterval = 600; } else if (score > 4000 && score <= 5000) { spawnTimeInterval = 700; } else if (score > 5000 && score <= 6000) { spawnTimeInterval = 600; } else if (score > 6000 && score <= 7000) { spawnTimeInterval = 500; } else if (score > 7000) { spawnTimeInterval = 400; } if (score > 4000) { GenerateRandomNumberOfObstacles(); } }