/// <summary> /// Adds a new spawn point /// </summary> /// <param name="sender">not used</param> /// <param name="e">not used</param> private void addButton_Click(object sender, RoutedEventArgs e) { SpawnPoint spawn = new SpawnPoint(); if (wave.spawns.Count == 0) spawnBox.Items.Remove("None"); spawnBox.Items.Add("Spawn" + (spawnBox.Items.Count + 1)); wave.spawns.Add(spawn); SpawnEditor editor = new SpawnEditor(spawn); editor.Owner = this; editor.ShowDialog(); }
/// <summary> /// Constructor /// </summary> /// <param name="s">spawn to edit</param> public SpawnEditor(SpawnPoint s) { InitializeComponent(); spawn = s; foreach (EnemyInstance e in s.enemies) enemyComboBox.Items.Add(e.name); if (enemyComboBox.Items.Count == 0) enemyComboBox.Items.Add("None"); enemyComboBox.SelectedIndex = 0; }
/// <summary> /// Gets the wave at the given index /// </summary> /// <param name="x">wave index</param> /// <returns></returns> public override Wave GetWave(int x) { // Create a new wave if trying to access the next wave if (x != currentWaveId) { // Initialize the wave currentWave = new Wave(); currentWave.reward = 0; // Initialize the spawn point SpawnPoint spawn = new SpawnPoint(); spawn.xStart = start[0]; spawn.xEnd = end[0]; spawn.yStart = start[1]; spawn.yEnd = end[1]; // Add a boss on every 10th wave if (x % 10 == 9) { // Choose a random boss int enemyId = random.Next(numberOfEnemies, numberOfEnemies + numberOfBosses); Enemy enemy = enemies[enemyId]; // Get a random multiplier for the enemy health beween 0.9 and 1.1 double randomChange = random.Next(90, 111) / 100.0; // Calculate the boss health depending on its speed, whether or not if flies, the wave, and the random multiplier enemy.Health = (int)(Math.Pow(2, x / 10) // Exponential Wave multiplier * (enemy.speed + 4) // Speed multiplier * randomChange // Random multiplier * (enemy.flying ? 1 : 1.2) // Flying multiplier * 100); // Boss Constant // Calculate the boss reward depending on the wave (increases by 10 each boss spawn) enemy.Reward = 10 * ((x + 1) / 10); // Create an enemy instance pointing to this boss EnemyInstance instance = new EnemyInstance(enemy.Name, 0, 1); // Add the enemy instance to the spawn point spawn.enemies.Add(instance); } // Add 1 enemy spawn plus an additional for each 10 waves that have passed for (int i = 0; i < x / 10 + 1; ++i) { // Choose a random enemy int enemyId = random.Next(0, numberOfEnemies); Enemy enemy = enemies[enemyId]; // Get a random multiplier for the enemy health between 0.9 and 1.1 double randomChange = random.Next(90, 111) / 100.0; // Calculate the quantity depending on what wave it is (between 15 and 25, adding 10 to each every 25 waves) int quantity = random.Next(15 + 10 * (x / 25), 25 + 15 * (x / 25)); // Calculate the enemy health depending on the enemy speed, whether or not it flies, the wave, and the random multiplier enemy.Health = (int)((x + 5 * (x / 10 + 1)) // Wave multiplier * (enemy.speed + 4) // Speed multiplier * randomChange // Random multiplier * (enemy.flying ? 0.9 : 1.2) // Flying multiplier * Math.Pow(2, x/25)); // Exponential multiplier // Set the reward to 1, increasing every 50 waves enemy.Reward = 1 + (x / 50); // Create an enemy instance point to the created enemy EnemyInstance instance = new EnemyInstance(enemy.Name, 15 / (x / 6 + 1), quantity); // Add the enemy instance to the spawn point spawn.enemies.Add(instance); } // Add the spawn point to the wave currentWave.spawns.Add(spawn); } // Return the current wave return currentWave; }