예제 #1
0
        internal static BenchmarkFuelTank Create(string key, TankObjectKey ownerKey, IEnumerable <IFuelTank> fuelTanks)
        {
            var benchmark = new BenchmarkFuelTank();

            benchmark.Key      = key;
            benchmark.OwnerKey = ownerKey;

            BenchmarkDamageableModule.Initialize(benchmark, fuelTanks);
            return(benchmark);
        }
예제 #2
0
        internal static BenchmarkRadio Create(string key, TankObjectKey ownerKey, IEnumerable <IRadio> radios)
        {
            var benchmark = new BenchmarkRadio();

            benchmark.Key      = key;
            benchmark.OwnerKey = ownerKey;

            BenchmarkDamageableModule.Initialize(benchmark, radios);

            benchmark.Distance = radios.Average(r => r.Distance);

            return(benchmark);
        }
예제 #3
0
        internal static BenchmarkEngine Create(string key, TankObjectKey ownerKey, IEnumerable <IEngine> engines)
        {
            var benchmark = new BenchmarkEngine();

            benchmark.Key      = key;
            benchmark.OwnerKey = ownerKey;

            BenchmarkDamageableModule.Initialize(benchmark, engines);
            benchmark.FireChance = engines.Average(e => e.FireChance);
            benchmark.FuelType   = engines.Majority(e => e.FuelType);
            benchmark.HorsePower = engines.Average(e => e.HorsePower);
            return(benchmark);
        }
예제 #4
0
        internal static BenchmarkHull Create(string key, TankObjectKey ownerKey, IEnumerable <IHull> hulls)
        {
            var benchmark = new BenchmarkHull();

            benchmark.Key      = key;
            benchmark.OwnerKey = ownerKey;

            BenchmarkDamageableModule.Initialize(benchmark, hulls);
            benchmark.AmmoBay      = BenchmarkAmmoBay.Create(hulls.Select(h => h.AmmoBay));
            benchmark.FrontalArmor = hulls.Average(h => h.FrontalArmor);
            benchmark.RearArmor    = hulls.Average(h => h.RearArmor);
            benchmark.SideArmor    = hulls.Average(h => h.SideArmor);

            return(benchmark);
        }
예제 #5
0
        internal static BenchmarkTurret Create(string key, TankObjectKey ownerKey, IEnumerable <ITurret> turrets)
        {
            var benchmark = new BenchmarkTurret();

            benchmark.Key      = key;
            benchmark.OwnerKey = ownerKey;
            BenchmarkDamageableModule.Initialize(benchmark, turrets);

            benchmark.ArmorHomogenization  = turrets.Average(t => t.ArmorHomogenization);
            benchmark.CamouflageFactor     = turrets.Average(t => t.CamouflageFactor);
            benchmark.CircularVisionRadius = (int)turrets.Average(t => t.CircularVisionRadius);

            if (turrets.All(t => !t.IsArmorDefined))
            {
                benchmark.IsArmorDefined = false;
            }
            else
            {
                benchmark.IsArmorDefined = true;
                benchmark.FrontalArmor   = turrets.Where(t => t.IsArmorDefined).Average(t => t.FrontalArmor);
                benchmark.SideArmor      = turrets.Where(t => t.IsArmorDefined).Average(t => t.SideArmor);
                benchmark.RearArmor      = turrets.Where(t => t.IsArmorDefined).Average(t => t.RearArmor);
            }

            benchmark.Gun = VirtualGun.CreateBenchmarkGun(ownerKey + "Gun", benchmark.ObjectKey, turrets.Select(t => BenchmarkTurret.GetEliteGun(t)));

            var horizontallyLimitedTurrets = turrets.Where(t => t.HorizontalTraverse != null);

            if (horizontallyLimitedTurrets.Count() == 0)
            {
                benchmark.HorizontalTraverse = null;
            }
            else
            {
                benchmark.HorizontalTraverse = new HorizontalTraverse(horizontallyLimitedTurrets.Average(t => t.HorizontalTraverse.Left), horizontallyLimitedTurrets.Average(t => t.HorizontalTraverse.Right));
            }

            benchmark.RotationSpeed   = turrets.Average(t => t.RotationSpeed);
            benchmark.SurveyingDevice = BenchmarkSurveyingDevice.Create(turrets.Select(t => t.SurveyingDevice));
            benchmark.TurretRotator   = BenchmarkTurretRotator.Create(turrets.Select(t => t.TurretRotator));

            return(benchmark);
        }
예제 #6
0
        internal static BenchmarkChassis Create(string key, TankObjectKey ownerKey, IEnumerable <IChassis> chassis)
        {
            var benchmark = new BenchmarkChassis();

            benchmark.Key      = key;
            benchmark.OwnerKey = ownerKey;

            BenchmarkDamageableModule.Initialize(benchmark, chassis);
            benchmark.BrakeForce        = chassis.Average(c => c.BrakeForce);
            benchmark.CanTraverse       = chassis.Majority(c => c.CanTraverse);
            benchmark.MaxClimbAngle     = chassis.Average(c => c.MaxClimbAngle);
            benchmark.MaxLoad           = chassis.Average(c => c.MaxLoad);
            benchmark.RotationSpeed     = chassis.Average(c => c.RotationSpeed);
            benchmark.ShotDispersion    = new ChassisShotDispersion(chassis.Average(c => c.ShotDispersion.Movement), chassis.Average(c => c.ShotDispersion.Rotation));
            benchmark.SpeedLimits       = new SpeedLimits(chassis.Average(c => c.SpeedLimits.Forward), chassis.Average(c => c.SpeedLimits.Backward));
            benchmark.TerrainResistance = new TerrainResistance(chassis.Average(c => c.TerrainResistance.HardTerrain), chassis.Average(c => c.TerrainResistance.MediumTerrain), chassis.Average(c => c.TerrainResistance.SoftTerrain));
            benchmark.TrackArmor        = chassis.Average(c => c.TrackArmor);
            return(benchmark);
        }
예제 #7
0
 public HierachyInfoKey(TankObjectKey target, int experiencePrice)
 {
     this.Target          = target;
     this.ExperiencePrice = experiencePrice;
 }
예제 #8
0
        internal static IGun CreateBenchmarkGun(string key, TankObjectKey ownerKey, IEnumerable <IGun> guns)
        {
            var benchmark = new VirtualGun();

            benchmark.Key      = key;
            benchmark.OwnerKey = ownerKey;
            BenchmarkDamageableModule.Initialize(benchmark, guns);
            benchmark.Accuracy   = guns.Average(g => g.Accuracy);
            benchmark.AimingTime = guns.Average(g => g.AimingTime);
            benchmark.GunArmor   = guns.Average(g => g.GunArmor);

            var burstGuns = guns.Where(g => g.Burst != null);

            if (burstGuns.Count() == 0)
            {
                benchmark.Burst = null;
            }
            else
            {
                benchmark.Burst = new Burst((int)burstGuns.Average(g => g.Burst.Count), burstGuns.Average(g => g.Burst.Rate));
            }

            benchmark.CamouflageFactorAfterShot = guns.Average(g => g.CamouflageFactorAfterShot);

            var clipGuns = guns.Where(g => g.Clip != null);

            if (clipGuns.Count() == 0)
            {
                benchmark.Clip = null;
            }
            else
            {
                benchmark.Clip = new Clip((int)clipGuns.Average(g => g.Clip.Count), clipGuns.Average(g => g.Clip.Rate));
            }

            benchmark.HorizontalTraverse = new HorizontalTraverse(guns.Median(g => g.HorizontalTraverse.Left), guns.Median(g => g.HorizontalTraverse.Right));
            benchmark.MaxAmmo            = (int)guns.Average(g => g.MaxAmmo);
            benchmark.ReloadTime         = guns.Average(g => g.ReloadTime);
            benchmark.RotationSpeed      = guns.Average(g => g.RotationSpeed);
            benchmark.ShotDispersion     = new TurretShotDispersion(guns.Average(g => g.ShotDispersion.AfterShot), guns.Average(g => g.ShotDispersion.TurretRotation), guns.Average(g => g.ShotDispersion.GunDamaged));

            var shellGroups = new List <KeyValuePair <IGun, IShell> > [4];

            for (int i = 0; i < 4; ++i)
            {
                shellGroups[i] = new List <KeyValuePair <IGun, IShell> >();
            }

            foreach (var gun in guns)
            {
                foreach (var shell in gun.Shots)
                {
                    var kineticFlag = shell.Type.IsKineticShellType() ? 2 : 0;
                    var premiumFlag = shell.CurrencyType == CurrencyType.Gold ? 1 : 0;
                    shellGroups[kineticFlag | premiumFlag].Add(new KeyValuePair <IGun, IShell>(gun, shell));
                }
            }

            int shellIndex = 0;
            var shots      = new List <IShell>();

            foreach (var shellGroup in shellGroups.Where(g => g.Count > 0))
            {
                var shellKey       = $"{key}Shell{shellIndex++}";
                var benchmarkShell = BenchmarkShell.Create(shellKey, shellGroup.Select(g => g.Value));
                benchmarkShell.DamagePerMinute = shellGroup.Average(g => VirtualGun.CalculateDpm(g.Key, g.Value));
                shots.Add(benchmarkShell);
            }

            benchmark.Shots = shots.ToArray();

            benchmark.VerticalTraverse = new GunVerticalTraverse();
            benchmark.VerticalTraverse.DefaultPitchLimits = new PitchLimits(guns.Average(g => g.VerticalTraverse.Front.Elevation), guns.Average(g => g.VerticalTraverse.Front.Depression));
            return(benchmark);
        }