Ejemplo n.º 1
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="e">enemy to edit</param>
 public WaveEnemyEditor(EnemyInstance e)
 {
     enemy = e;
     InitializeComponent();
     foreach (string s in EnemyData.GetEnemyNames())
     {
         enemyComboBox.Items.Add(s);
         if (s.Equals(e.name))
             enemyComboBox.SelectedItem = s;
     }
     quantityBox.Text = e.quantity.ToString();
     delayBox.Text = e.delay.ToString();
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds a new enemy
 /// </summary>
 /// <param name="sender">not used</param>
 /// <param name="e">not used</param>
 private void addButton_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         EnemyInstance enemy = new EnemyInstance(EnemyData.GetEnemyNames()[0], 0, 1);
         if (spawn.enemies.Count == 0)
             enemyComboBox.Items.Remove("None");
         spawn.enemies.Add(enemy);
         enemyComboBox.Items.Add(enemy.name);
         WaveEnemyEditor editor = new WaveEnemyEditor(enemy);
         editor.Owner = this;
         editor.ShowDialog();
         enemyComboBox.Items[enemyComboBox.Items.Count - 1] = enemy.name;
         enemyComboBox.SelectedItem = enemy.name;
     }
     catch (Exception)
     {
         MessageBox.Show("There are no enemies to add.");
     }
 }
Ejemplo n.º 3
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;
        }