Пример #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WeaponStat" /> struct.
 /// </summary>
 /// <param name="name">The name of the weapon.</param>
 /// <param name="imageAtlasID">The image atlas identifier.</param>
 /// <param name="imageFilename">The image filename.</param>
 /// <param name="description">The description.</param>
 /// <param name="size">The physical size of the weapon.</param>
 /// <param name="mass">The mass.</param>
 /// <param name="pwrRqmt">The power required to operate the weapon.</param>
 /// <param name="expense">The expense.</param>
 /// <param name="rangeCat">The range category of the weapon.</param>
 /// <param name="deliveryVehicleStrength">The delivery strength.</param>
 /// <param name="reloadPeriod">The time it takes to reload the weapon in hours.</param>
 /// <param name="damagePotential">The damage potential.</param>
 public AWeaponStat(string name, AtlasID imageAtlasID, string imageFilename, string description, float size, float mass, float pwrRqmt,
     float expense, RangeCategory rangeCat, WDVStrength deliveryVehicleStrength, float reloadPeriod,
     DamageStrength damagePotential)
     : base(name, imageAtlasID, imageFilename, description, size, mass, pwrRqmt, expense, rangeCat) {
     DeliveryVehicleStrength = deliveryVehicleStrength;
     ReloadPeriod = reloadPeriod;
     DamagePotential = damagePotential;
 }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ProjectileWeaponStat" /> struct.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="imageAtlasID">The image atlas identifier.</param>
        /// <param name="imageFilename">The image filename.</param>
        /// <param name="description">The description.</param>
        /// <param name="size">The physical size of the weapon.</param>
        /// <param name="mass">The mass of the weapon.</param>
        /// <param name="pwrRqmt">The power required to operate the weapon.</param>
        /// <param name="expense">The expense.</param>
        /// <param name="rangeCat">The range category of the weapon.</param>
        /// <param name="deliveryVehicleStrength">The delivery strength.</param>
        /// <param name="reloadPeriod">The time it takes to reload the weapon in hours.</param>
        /// <param name="damagePotential">The damage potential.</param>
        /// <param name="ordnanceMaxSpeed">The maximum speed of the ordnance in units per hour in Topography.OpenSpace.</param>
        /// <param name="ordnanceMass">The mass of the ordnance.</param>
        /// <param name="ordnanceDrag">The drag of the ordnance in Topography.OpenSpace.</param>
        /// <param name="maxLaunchInaccuracy">The maximum launch inaccuracy in degrees.</param>

        public ProjectileWeaponStat(string name, AtlasID imageAtlasID, string imageFilename, string description, float size, float mass, float pwrRqmt,
            float expense, RangeCategory rangeCat, WDVStrength deliveryVehicleStrength, float reloadPeriod, DamageStrength damagePotential,
            float ordnanceMaxSpeed, float ordnanceMass, float ordnanceDrag, float maxLaunchInaccuracy)
            : base(name, imageAtlasID, imageFilename, description, size, mass, pwrRqmt, expense, rangeCat, deliveryVehicleStrength, reloadPeriod, damagePotential, ordnanceMaxSpeed, ordnanceMass, ordnanceDrag) {
            if (maxLaunchInaccuracy > 5F) {
                D.Warn("{0} MaxLaunchInaccuracy of {1:0.#} is very high.", DebugName, maxLaunchInaccuracy);
            }
            MaxLaunchInaccuracy = maxLaunchInaccuracy;
        }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AProjectileWeaponStat" /> struct.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="imageAtlasID">The image atlas identifier.</param>
 /// <param name="imageFilename">The image filename.</param>
 /// <param name="description">The description.</param>
 /// <param name="size">The physical size of the weapon.</param>
 /// <param name="mass">The mass of the weapon.</param>
 /// <param name="pwrRqmt">The power required to operate the weapon.</param>
 /// <param name="expense">The expense.</param>
 /// <param name="rangeCat">The range category of the weapon.</param>
 /// <param name="deliveryVehicleStrength">The delivery strength.</param>
 /// <param name="reloadPeriod">The time it takes to reload the weapon in hours.</param>
 /// <param name="damagePotential">The damage potential.</param>
 /// <param name="ordnanceMaxSpeed">The maximum speed of the ordnance in units per hour in Topography.OpenSpace.</param>
 /// <param name="ordnanceMass">The mass of the ordnance.</param>
 /// <param name="ordnanceDrag">The drag of the ordnance in Topography.OpenSpace.</param>
 public AProjectileWeaponStat(string name, AtlasID imageAtlasID, string imageFilename, string description, float size, float mass, float pwrRqmt,
     float expense, RangeCategory rangeCat, WDVStrength deliveryVehicleStrength, float reloadPeriod, DamageStrength damagePotential, float ordnanceMaxSpeed, float ordnanceMass, float ordnanceDrag)
     : base(name, imageAtlasID, imageFilename, description, size, mass, pwrRqmt, expense, rangeCat, deliveryVehicleStrength, reloadPeriod, damagePotential) {
     D.Assert(ordnanceMaxSpeed > Constants.ZeroF);
     D.Assert(ordnanceMass > Constants.ZeroF);
     D.Assert(ordnanceDrag > Constants.ZeroF);
     MaxSpeed = ordnanceMaxSpeed;
     OrdnanceMass = ordnanceMass;
     OrdnanceDrag = ordnanceDrag;
 }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WeaponStat" /> struct.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="imageAtlasID">The image atlas identifier.</param>
 /// <param name="imageFilename">The image filename.</param>
 /// <param name="description">The description.</param>
 /// <param name="size">The physical size of the weapon.</param>
 /// <param name="mass">The mass.</param>
 /// <param name="pwrRqmt">The power required to operate the weapon.</param>
 /// <param name="expense">The expense.</param>
 /// <param name="rangeCat">The range category of the weapon.</param>
 /// <param name="deliveryVehicleStrength">The delivery strength.</param>
 /// <param name="reloadPeriod">The time it takes to reload the weapon in hours.</param>
 /// <param name="damagePotential">The damage potential.</param>
 /// <param name="duration">The firing duration in hours.</param>
 /// <param name="maxLaunchInaccuracy">The maximum launch inaccuracy in degrees.</param>
 public BeamWeaponStat(string name, AtlasID imageAtlasID, string imageFilename, string description, float size, float mass,
     float pwrRqmt, float expense, RangeCategory rangeCat, WDVStrength deliveryVehicleStrength,
     float reloadPeriod, DamageStrength damagePotential, float duration, float maxLaunchInaccuracy)
     : base(name, imageAtlasID, imageFilename, description, size, mass, pwrRqmt, expense, rangeCat, deliveryVehicleStrength, reloadPeriod, damagePotential) {
     D.Assert(duration > Constants.ZeroF);
     if (maxLaunchInaccuracy > 5F) {
         D.Warn("{0} MaxLaunchInaccuracy of {1:0.#} is very high.", DebugName, MaxLaunchInaccuracy);
     }
     Duration = duration;
     MaxLaunchInaccuracy = maxLaunchInaccuracy;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ActiveCountermeasureStat" /> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="imageAtlasID">The image atlas identifier.</param>
 /// <param name="imageFilename">The image filename.</param>
 /// <param name="description">The description.</param>
 /// <param name="size">The size.</param>
 /// <param name="mass">The mass.</param>
 /// <param name="pwrRqmt">The PWR RQMT.</param>
 /// <param name="expense">The expense.</param>
 /// <param name="rangeCat">The range cat.</param>
 /// <param name="interceptStrengths">The intercept strengths.</param>
 /// <param name="interceptAccuracy">The intercept accuracy.</param>
 /// <param name="reloadPeriod">The reload period.</param>
 /// <param name="damageMitigation">The damage mitigation.</param>
 public ActiveCountermeasureStat(string name, AtlasID imageAtlasID, string imageFilename, string description, float size, float mass,
     float pwrRqmt, float expense, RangeCategory rangeCat, WDVStrength[] interceptStrengths, float interceptAccuracy, float reloadPeriod,
     DamageStrength damageMitigation)
     : base(name, imageAtlasID, imageFilename, description, size, mass, pwrRqmt, expense, rangeCat) {
     // confirm if more than one interceptStrength, that they each contain a unique WDVCategory
     D.AssertEqual(interceptStrengths.Length, interceptStrengths.Select(intS => intS.Category).Distinct().Count(), "Duplicate Categories found.");
     InterceptStrengths = interceptStrengths;
     InterceptAccuracy = interceptAccuracy;
     ReloadPeriod = reloadPeriod;
     DamageMitigation = damageMitigation;
 }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WeaponStat" /> struct.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="imageAtlasID">The image atlas identifier.</param>
 /// <param name="imageFilename">The image filename.</param>
 /// <param name="description">The description.</param>
 /// <param name="size">The physical size of the weapon.</param>
 /// <param name="mass">The mass.</param>
 /// <param name="pwrRqmt">The power required to operate the weapon.</param>
 /// <param name="expense">The expense.</param>
 /// <param name="rangeCat">The range category of the weapon.</param>
 /// <param name="baseRangeDistance">The base (no owner multiplier applied) range distance in units.</param>
 /// <param name="deliveryVehicleStrength">The delivery strength.</param>
 /// <param name="accuracy">The accuracy of the weapon. Range 0...1.0</param>
 /// <param name="reloadPeriod">The time it takes to reload the weapon in hours.</param>
 /// <param name="damagePotential">The damage potential.</param>
 /// <param name="duration">The firing duration in hours. Applicable only to Beams.</param>
 public WeaponStat(string name, AtlasID imageAtlasID, string imageFilename, string description, float size, float mass, float pwrRqmt,
     float expense, RangeCategory rangeCat, float baseRangeDistance, WDVStrength deliveryVehicleStrength, float accuracy,
     float reloadPeriod, DamageStrength damagePotential, float duration = Constants.ZeroF)
     : base(name, imageAtlasID, imageFilename, description, size, mass, pwrRqmt, expense, rangeCat, baseRangeDistance) {
     DeliveryVehicleStrength = deliveryVehicleStrength;
     Accuracy = accuracy;
     ReloadPeriod = reloadPeriod;
     DamagePotential = damagePotential;
     Duration = duration;
     Validate();
 }
Пример #7
0
        /// <summary>
        /// The steering accuracy of the missile. Range 0...1.0. Each 1% (0.01) of
        /// inaccuracy introduces up to 1 degree of steering inaccuracy.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="imageAtlasID">The image atlas identifier.</param>
        /// <param name="imageFilename">The image filename.</param>
        /// <param name="description">The description.</param>
        /// <param name="size">The physical size of the weapon.</param>
        /// <param name="mass">The mass of the weapon.</param>
        /// <param name="pwrRqmt">The power required to operate the weapon.</param>
        /// <param name="expense">The expense.</param>
        /// <param name="rangeCat">The range category of the weapon.</param>
        /// <param name="deliveryVehicleStrength">The delivery strength.</param>
        /// <param name="reloadPeriod">The time it takes to reload the weapon in hours.</param>
        /// <param name="damagePotential">The damage potential.</param>
        /// <param name="ordnanceMaxSpeed">The maximum speed of the ordnance in units per hour in Topography.OpenSpace.</param>
        /// <param name="ordnanceMass">The mass of the ordnance.</param>
        /// <param name="ordnanceDrag">The drag of the ordnance in Topography.OpenSpace.</param>
        /// <param name="turnRate">The turn rate of the ordnance in degrees per hour .</param>
        /// <param name="courseUpdateFreq">How often the ordnance's course is updated in updates per hour.</param>
        /// <param name="maxSteeringInaccuracy">The maximum steering inaccuracy in degrees.</param>

        public MissileWeaponStat(string name, AtlasID imageAtlasID, string imageFilename, string description, float size, float mass, float pwrRqmt,
            float expense, RangeCategory rangeCat, WDVStrength deliveryVehicleStrength, float reloadPeriod, DamageStrength damagePotential,
            float ordnanceMaxSpeed, float ordnanceMass, float ordnanceDrag, float turnRate, float courseUpdateFreq, float maxSteeringInaccuracy)
            : base(name, imageAtlasID, imageFilename, description, size, mass, pwrRqmt, expense, rangeCat, deliveryVehicleStrength, reloadPeriod, damagePotential, ordnanceMaxSpeed, ordnanceMass, ordnanceDrag) {
            D.Assert(turnRate > Constants.ZeroF);
            D.Assert(courseUpdateFreq > Constants.ZeroF);
            if (maxSteeringInaccuracy > 5F) {
                D.Warn("{0} MaxSteeringInaccuracy of {1:0.#} is very high.", DebugName, MaxSteeringInaccuracy);
            }
            TurnRate = turnRate;
            CourseUpdateFrequency = courseUpdateFreq;
            MaxSteeringInaccuracy = maxSteeringInaccuracy;
        }
 private IList<ActiveCountermeasureStat> __CreateAvailableActiveCountermeasureStats(int quantity) {
     IList<ActiveCountermeasureStat> statsList = new List<ActiveCountermeasureStat>(quantity);
     for (int i = 0; i < quantity; i++) {
         string name = string.Empty;
         RangeCategory rangeCat = Enums<RangeCategory>.GetRandom(excludeDefault: true);
         WDVStrength[] interceptStrengths;
         float interceptAccuracy;
         float reloadPeriod;
         var damageMitigationCategory = Enums<DamageCategory>.GetRandom(excludeDefault: true);
         float damageMitigationValue = UnityEngine.Random.Range(1F, 2F);
         switch (rangeCat) {
             case RangeCategory.Short:
                 name = "CIWS";
                 interceptStrengths = new WDVStrength[] {
                     new WDVStrength(WDVCategory.Projectile, 0.2F),
                     new WDVStrength(WDVCategory.Missile, 0.5F)
                 };
                 interceptAccuracy = 0.50F;
                 reloadPeriod = 0.1F;
                 break;
             case RangeCategory.Medium:
                 name = "AvengerADS";
                 interceptStrengths = new WDVStrength[] {
                     new WDVStrength(WDVCategory.Missile, 3.0F)
                 };
                 interceptAccuracy = 0.80F;
                 reloadPeriod = 2.0F;
                 break;
             case RangeCategory.Long:
                 name = "PatriotADS";
                 interceptStrengths = new WDVStrength[] {
                     new WDVStrength(WDVCategory.Missile, 1.0F)
                 };
                 interceptAccuracy = 0.70F;
                 reloadPeriod = 3.0F;
                 break;
             case RangeCategory.None:
             default:
                 throw new NotImplementedException(ErrorMessages.UnanticipatedSwitchValue.Inject(rangeCat));
         }
         DamageStrength damageMitigation = new DamageStrength(damageMitigationCategory, damageMitigationValue);
         var countermeasureStat = new ActiveCountermeasureStat(name, AtlasID.MyGui, TempGameValues.AnImageFilename, "Description...", 0F, 0F, 0F, 0F,
             rangeCat, interceptStrengths, interceptAccuracy, reloadPeriod, damageMitigation);
         statsList.Add(countermeasureStat);
     }
     return statsList;
 }
    private IList<AWeaponStat> __CreateAvailableProjectileWeaponStats(int quantity) {
        IList<AWeaponStat> statsList = new List<AWeaponStat>(quantity);
        for (int i = 0; i < quantity; i++) {
            AWeaponStat weapStat;
            RangeCategory rangeCat = RangeCategory.Medium;
            float maxLaunchInaccuracy = UnityEngine.Random.Range(UnityConstants.AngleEqualityPrecision, 3F);  // 0.04 - 3 degrees
            float reloadPeriod = UnityEngine.Random.Range(2F, 4F);
            string name = "KineticKill Projector";
            float deliveryStrengthValue = UnityEngine.Random.Range(6F, 8F);
            var damageCategory = Enums<DamageCategory>.GetRandom(excludeDefault: true);
            float damageValue = UnityEngine.Random.Range(3F, 8F);
            DamageStrength damagePotential = new DamageStrength(damageCategory, damageValue);
            WDVCategory deliveryVehicleCategory = WDVCategory.Projectile;
            WDVStrength deliveryVehicleStrength = new WDVStrength(deliveryVehicleCategory, deliveryStrengthValue);

            float ordMaxSpeed = UnityEngine.Random.Range(6F, 8F);
            float ordMass = 1F;
            float ordDrag = 0.02F;
            weapStat = new ProjectileWeaponStat(name, AtlasID.MyGui, TempGameValues.AnImageFilename, "Description...", 0F, 0F, 0F, 0F, rangeCat,
                deliveryVehicleStrength, reloadPeriod, damagePotential, ordMaxSpeed, ordMass, ordDrag, maxLaunchInaccuracy);
            statsList.Add(weapStat);
        }
        return statsList;
    }
    private IList<AWeaponStat> __CreateAvailableBeamWeaponStats(int quantity) {
        IList<AWeaponStat> statsList = new List<AWeaponStat>(quantity);
        for (int i = 0; i < quantity; i++) {
            RangeCategory rangeCat = RangeCategory.Short;
            float maxLaunchInaccuracy = UnityEngine.Random.Range(UnityConstants.AngleEqualityPrecision, 3F);  // 0.04 - 3 degrees
            float reloadPeriod = UnityEngine.Random.Range(3F, 5F);
            float duration = UnityEngine.Random.Range(1F, 2F);
            string name = "Phaser Projector";
            float deliveryStrengthValue = UnityEngine.Random.Range(6F, 8F);
            var damageCategory = Enums<DamageCategory>.GetRandom(excludeDefault: true);
            float damageValue = UnityEngine.Random.Range(3F, 8F);
            DamageStrength damagePotential = new DamageStrength(damageCategory, damageValue);
            WDVCategory deliveryVehicleCategory = WDVCategory.Beam;
            WDVStrength deliveryVehicleStrength = new WDVStrength(deliveryVehicleCategory, deliveryStrengthValue);

            AWeaponStat weapStat = new BeamWeaponStat(name, AtlasID.MyGui, TempGameValues.AnImageFilename, "Description...", 0F, 0F, 0F, 0F, rangeCat,
                              deliveryVehicleStrength, reloadPeriod, damagePotential, duration, maxLaunchInaccuracy);
            statsList.Add(weapStat);
        }
        return statsList;
    }
    private IList<AWeaponStat> __CreateAvailableMissileWeaponStats(int quantity) {
        IList<AWeaponStat> statsList = new List<AWeaponStat>(quantity);
        for (int i = 0; i < quantity; i++) {
            WDVCategory deliveryVehicleCategory = WDVCategory.Missile;

            RangeCategory rangeCat = RangeCategory.Long; ;
            float maxSteeringInaccuracy = UnityEngine.Random.Range(UnityConstants.AngleEqualityPrecision, 3F);    // 0.04 - 3 degrees
            float reloadPeriod = UnityEngine.Random.Range(10F, 12F);
            string name = "Torpedo Launcher";
            float deliveryStrengthValue = UnityEngine.Random.Range(6F, 8F);
            var damageCategory = Enums<DamageCategory>.GetRandom(excludeDefault: true);
            float damageValue = UnityEngine.Random.Range(3F, 8F);
            float ordMaxSpeed = UnityEngine.Random.Range(4F, 6F);
            float ordMass = 5F;
            float ordDrag = 0.01F;
            float ordTurnRate = 700F;   // degrees per hour
            float ordCourseUpdateFreq = 0.5F; // course updates per hour
            DamageStrength damagePotential = new DamageStrength(damageCategory, damageValue);
            WDVStrength deliveryVehicleStrength = new WDVStrength(deliveryVehicleCategory, deliveryStrengthValue);

            var weapStat = new MissileWeaponStat(name, AtlasID.MyGui, TempGameValues.AnImageFilename, "Description...", 0F, 0F, 0F, 0F,
                rangeCat, deliveryVehicleStrength, reloadPeriod, damagePotential, ordMaxSpeed, ordMass, ordDrag,
                ordTurnRate, ordCourseUpdateFreq, maxSteeringInaccuracy);
            statsList.Add(weapStat);
        }
        return statsList;
    }
 public void TakeHit(WDVStrength interceptStrength) {
     if (DeliveryVehicleStrength.Category != interceptStrength.Category) {
         D.Warn("{0}[{1}] improperly intercepted by {2} interceptor.", Name, DeliveryVehicleStrength.Category.GetValueName(), interceptStrength.Category.GetValueName());
         return;
     }
     if (DeliveryVehicleStrength.Value == Constants.ZeroF) {
         // This problem was caused by the ActiveCMRangeMonitor adding this threat to all ActiveCMs when it came within
         // the monitor's range. As the ActiveCMs that get the add, IMMEDIATELY can try to destroy the threat, the threat can
         // be destroyed before it is ever added to the ActiveCMs later in the list. Thus, with the threat already destroyed, the
         // late CM that is notified of a 'live' threat tries to destroy it, resulting in this warning and the subsequent "object already
         // destroyed" error.
         D.Error("{0} has been intercepted when VehicleStrength.Value = 0. IsOperational = {1}. Bypassing duplicate termination.",
             Name, IsOperational);
     }
     else {
         //D.Log("{0} intercepted. InterceptStrength: {1}, SurvivalStrength: {2}.", Name, interceptStrength, DeliveryVehicleStrength);
         DeliveryVehicleStrength = interceptStrength - DeliveryVehicleStrength;
         if (DeliveryVehicleStrength.Value == Constants.ZeroF) {
             ReportInterdiction();
             if (IsOperational) {
                 // ordnance has not already been terminated by other paths such as the death of the target
                 TerminateNow();
             }
         }
     }
 }