Exemplo n.º 1
0
 /// <summary>
 /// Gets the wave object with the given id
 /// </summary>
 /// <param name="waveId">wave id</param>
 /// <returns>wave object</returns>
 public static Wave GetWave(int waveId)
 {
     if (waveId < waves.Count && waveId >= 0)
         return waves[waveId];
     Wave w = new Wave();
     waves.Add(w);
     return w;
 }
Exemplo n.º 2
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="index">id of wave to edit</param>
 public WaveEditor(int index)
 {
     InitializeComponent();
     wave = WaveData.GetWave(index);
     rewardBox.Text = wave.reward.ToString();
     int spawnIndex = 0;
     foreach (SpawnPoint s in wave.spawns)
         spawnBox.Items.Add("Spawn " + ++spawnIndex);
     if (wave.spawns.Count == 0)
         spawnBox.Items.Add("None");
     spawnBox.SelectedIndex = 0;
 }
Exemplo 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;
        }
Exemplo n.º 4
0
 /// <summary>
 /// Loads wave data
 /// </summary>
 /// <param name="data">wave data</param>
 public static void Load(PairList<string, object> data)
 {
     Wave w = new Wave(data);
     waves.Add(w);
 }