예제 #1
0
 protected virtual void RecalcDefensiveValues() {
     var undamagedCMs = PassiveCountermeasures.Where(cm => !cm.IsDamaged);
     var defaultValueIfEmpty = default(DamageStrength);
     DamageMitigation = undamagedCMs.Select(cm => cm.DamageMitigation).Aggregate(defaultValueIfEmpty, (accum, cmDmgMit) => accum + cmDmgMit);
     DefensiveStrength = new CombatStrength(undamagedCMs.Cast<ICountermeasure>());
 }
예제 #2
0
 public override void TakeHit(CombatStrength attackerWeaponStrength) {
     if (CurrentState == PlanetoidState.Dead) {
         return;
     }
     LogEvent();
     float damage = Data.Strength - attackerWeaponStrength;
     if (damage == Constants.ZeroF) {
         return;
     }
     bool isAlive = ApplyDamage(damage);
     if (!isAlive) {
         CurrentState = PlanetoidState.Dead;
         return;
     }
     OnShowAnimation(EffectID.Hit);
 }
예제 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WeaponStat" /> struct.
 /// </summary>
 /// <param name="category">The ArmamentCategory this weapon belongs too.</param>
 /// <param name="strength">The combat strength of the weapon.</param>
 /// <param name="range">The range of the weapon.</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="size">The physical size of the weapon.</param>
 /// <param name="pwrRqmt">The power required to operate the weapon.</param>
 /// <param name="duration">The firing duration in hours.</param>
 /// <param name="rootName">The root name to use for this weapon before adding supplemental attributes.</param>
 public BeamWeaponStat(WDVCategory category, CombatStrength strength, RangeCategory range, float accuracy, float reloadPeriod, float size, float pwrRqmt, float duration = Constants.ZeroF, string rootName = Constants.Empty)
     : base(category, strength, range, accuracy, reloadPeriod, size, pwrRqmt, rootName) {
     Duration = duration;
 }
 public ColoredTextList_Combat(CombatStrength cs, string format = Constants.FormatFloat_0Dp) {
     _list.Add(new ColoredText(format.Inject(cs.Combined)));
     _list.Add(new ColoredText(format.Inject(cs.Beam_Offense)));
     _list.Add(new ColoredText(format.Inject(cs.Beam_Defense)));
     _list.Add(new ColoredText(format.Inject(cs.Particle_Offense)));
     _list.Add(new ColoredText(format.Inject(cs.Particle_Defense)));
     _list.Add(new ColoredText(format.Inject(cs.Missile_Offense)));
     _list.Add(new ColoredText(format.Inject(cs.Missile_Defense)));
 }
예제 #5
0
 protected override void RecalcDefensiveValues() {
     List<ICountermeasure> allCountermeasures = new List<ICountermeasure>(PassiveCountermeasures.Cast<ICountermeasure>());
     allCountermeasures.AddRange(ActiveCountermeasures.Cast<ICountermeasure>());
     allCountermeasures.AddRange(ShieldGenerators.Cast<ICountermeasure>());
     var cmDamageMitigation = allCountermeasures.Where(cm => !cm.IsDamaged).Select(cm => cm.DamageMitigation).Aggregate(default(DamageStrength), (accum, cmDmgMit) => accum + cmDmgMit);
     DamageMitigation = HullEquipment.DamageMitigation + cmDamageMitigation;
     DefensiveStrength = new CombatStrength(allCountermeasures, HullEquipment.DamageMitigation);
 }
예제 #6
0
 private void RecalcOffensiveStrength() {
     OffensiveStrength = new CombatStrength(Weapons);
 }
예제 #7
0
 public override void TakeHit(CombatStrength attackerWeaponStrength) {
     float damage = Data.Strength - attackerWeaponStrength;
     if (damage == Constants.ZeroF) {
         D.Log("{0} has been hit but incurred no damage.", FullName);
         return;
     }
     D.Log("{0} has been hit. Distributing {1} damage.", FullName, damage);
     DistributeDamage(damage);
 }
예제 #8
0
 public override void TakeHit(CombatStrength attackerWeaponStrength) {
     float damage = Data.Strength - attackerWeaponStrength;
     bool isCmdAlive = ApplyDamage(damage);
     D.Assert(isCmdAlive, "{0} should never die as a result of being hit.".Inject(Data.Name));
 }
예제 #9
0
 /// <summary>
 /// Attempts to fire the provided weapon at a target within range.
 /// </summary>
 /// <param name="weapon">The weapon.</param>
 private void TryFireOnAnyTarget(AWeapon weapon) {
     if (_weaponRangeMonitorLookup[weapon.MonitorID].__TryGetRandomEnemyTarget(out _attackTarget)) {
         D.Log("{0}.{1} firing at {2} from State {3}.", FullName, weapon.Name, _attackTarget.FullName, CurrentState.GetValueName());
         //_attackDamage = weapon.Damage;
         _attackStrength = weapon.Strength;
         Call(FacilityState.Attacking);
     }
     else {
         D.Warn("{0}.{1} could not lockon to a target from State {2}.", FullName, weapon.Name, CurrentState.GetValueName());
     }
 }
예제 #10
0
 void Attacking_ExitState() {
     LogEvent();
     _attackTarget = null;
     _attackStrength = TempGameValues.NoCombatStrength;
 }
예제 #11
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CountermeasureStat" /> 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 physical size of the countermeasure.</param>
 /// <param name="pwrRqmt">The power required to operate the countermeasure.</param>
 /// <param name="strength">The combat strength of the countermeasure.</param>
 /// <param name="accuracy">The accuracy of the countermeasure.</param>
 public CountermeasureStat(string name, AtlasID imageAtlasID, string imageFilename, string description, float size, float pwrRqmt, CombatStrength strength, float accuracy)
     : base(name, imageAtlasID, imageFilename, description, size, pwrRqmt) {
     Strength = strength;
     Accuracy = accuracy;
 }
예제 #12
0
 public abstract void TakeHit(CombatStrength weaponStrength);
예제 #13
0
    public override void TakeHit(CombatStrength attackerWeaponStrength) {
        if (CurrentState == ShipState.Dead) {
            return;
        }
        float damage = Data.Strength - attackerWeaponStrength;
        if (damage == Constants.ZeroF) {
            D.Log("{0} has been hit but incurred no damage.", FullName);
            return;
        }
        D.Log("{0} has been hit. Taking {1} damage.", FullName, damage);
        bool isCmdHit = false;
        bool isElementAlive = ApplyDamage(damage);
        if (IsHQElement) {
            isCmdHit = Command.__CheckForDamage(isElementAlive);
        }
        if (!isElementAlive) {
            CurrentState = ShipState.Dead;
            return;
        }

        var hitAnimation = isCmdHit ? EffectID.CmdHit : EffectID.Hit;
        OnShowAnimation(hitAnimation);

        AssessNeedForRepair();
    }