Ejemplo 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);
        }
Ejemplo n.º 2
0
    private bool OnTurretSelected(int index, string turretName, object context)
    {
        MapPos position       = GameObjectFactory.WorldVec3ToMapPos(GameplayUI.SelectedObject.transform.position);
        Turret turretSelected = LevelLoader.LookupTurret(LevelDesc.AllowedTurrets[index]);

        if (Coin >= turretSelected.Cost)
        {
            Turrets.AddTurret(LevelLoader.LookupTurret(LevelDesc.AllowedTurrets[index]), position, Projectiles);
            Coin -= turretSelected.Cost;
        }

        return(false);
    }