Esempio n. 1
0
        public WaveSimulatorDamageStats SimulateDamageToEnemies(
            EnemyDescription enemy,
            WaveSolution solution,
            float HandMissileFreqency,
            float HandMissileDamantPctAverage,
            int enemyCount,
            bool invincible)
        {
            DamageStats       = new WaveSimulatorDamageStats();
            InvincibleEnemies = invincible;

            float waveTime  = 0.0F;
            float timeDelta = 1.0F / 72.0F;
            float previousHandMissileTime = 0.0f;

            EnemyWave waveDesc = new EnemyWave();

            waveDesc.Count = enemyCount;
            waveDesc.Enemy = enemy.Name;
            waveDesc.DifficultyMultiplier = 1.0F;

            ResetLevelDescState(LevelDesc);
            TurretManager     turrets     = new TurretManager(LevelDesc);
            ProjectileManager projectiles = new ProjectileManager(LevelDesc, LevelManager.LookupProjectile);
            WaveInstance      wave        = new WaveInstance(LevelDesc, waveDesc, enemy, 0.0F, SimulatorDamageCallback);

            for (int i = 0; i < solution.Turrets.Count; i++)
            {
                turrets.AddTurret(LevelManager.LookupTurret(solution.Turrets[i].Name), solution.Turrets[i].pos, projectiles);
            }

            Debug.Log("----------------------------------------");
            Debug.Log("   Wave of " + enemyCount + " " + enemy.Name + "s");
            Debug.Log("----------------------------------------");

            do
            {
                wave.Advance(waveTime);
                projectiles.AdvanceAll(waveTime);
                turrets.Fire(waveTime);

                float timeSinceLastHandMissile = waveTime - previousHandMissileTime;

                if (timeSinceLastHandMissile >= HandMissileFreqency)
                {
                    // Real projectiles have to incur flight time but we'll simulate
                    // the damage as instanntaneous to keep it simple.  Also real projectiles
                    // have blast radius that should hit multiple enemies. We'll just hit one.
                }

                waveTime += timeDelta;
            } while (!wave.IsCompleted);

            DamageStats.DamagePerEnemy = DamageStats.DamageDealt / enemyCount;

            return(DamageStats);
        }
Esempio n. 2
0
        private void CalculateStatsForWaves(List <TurretStats> Turrets)
        {
            WaveStatList = new List <WaveStats>();

            float maxDPSOverall = 0.0F;
            int   coinNeeded    = 0;

            for (int j = 0; j < Turrets.Count; j++)
            {
                maxDPSOverall += Turrets[j].MaxDPSOverall;
                coinNeeded    += Turrets[j].t.Cost;
            }

            int maxCoinEarned = LevelDesc.StartingCoins;

            for (int i = 0; i < LevelDesc.Waves.Count; i++)
            {
                EnemyWave        wave      = LevelDesc.Waves[i];
                EnemyDescription enemyDesc = LevelManager.LookupEnemy(wave.Enemy);
                WaveSolution     solution  = GenerateWaveSolution();
                WaveStats        stats     = new WaveStats();

                WaveSimulatorDamageStats singleEnemyStats = SimulateWave(enemyDesc, solution, 1, true);
                WaveSimulatorDamageStats fullWaveStats    = SimulateWave(enemyDesc, solution, wave.Count, false);

                EnemyDescription enemy = LevelManager.LookupEnemy(wave.Enemy);
                stats.MaxDmgDealtSingleEnemy = singleEnemyStats.DamageDealt;
                stats.MaxDPSOverall          = maxDPSOverall;
                stats.MaxHPPSProducted       = EnemyEditLayout.CalculateDPSforWave(enemy);
                stats.FullSimulation         = fullWaveStats;
                stats.CoinNeeded             = coinNeeded;
                stats.CoinAvail = maxCoinEarned;

                maxCoinEarned += (enemy.Coins * wave.Count);

                WaveStatList.Add(stats);
            }
        }