예제 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AHullStat" /> 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 space available within this hull.</param>
 /// <param name="mass">The mass of this hull.</param>
 /// <param name="pwrRqmt">The power required to operate this hull.</param>
 /// <param name="expense">The expense consumed by this hull.</param>
 /// <param name="maxHitPts">The maximum hit points of this hull.</param>
 /// <param name="damageMitigation">The resistance to damage of this hull.</param>
 /// <param name="hullDimensions">The hull dimensions.</param>
 public AHullStat(string name, AtlasID imageAtlasID, string imageFilename, string description, float size, float mass,
     float pwrRqmt, float expense, float maxHitPts, DamageStrength damageMitigation, Vector3 hullDimensions)
     : base(name, imageAtlasID, imageFilename, description, size, mass, pwrRqmt, expense) {
     MaxHitPoints = maxHitPts;
     DamageMitigation = damageMitigation;
     HullDimensions = hullDimensions;
 }
    private int CalculateDamage(Troop troop)
    {
        int heroAttack = BattleData.main.GetHeroesAttack(troop.elementId);

        int damage = (int)(heroAttack * (1 + troop.attackBonus)) * 4;

        damage -= 2 * battler.GetDefence(level);
        damage  = Mathf.Max(0, damage);

        DamageStrength type         = DamageStrength.NORMAL;
        int            elementCount = Settings.main.elements.Length;
        int            totalDamage  = damage;

        if ((troop.elementId - 1) % elementCount == battler.elementId)
        {
            type        = DamageStrength.STRONG;
            totalDamage = 2 * damage;
        }
        else if ((troop.elementId + 1) % elementCount == battler.elementId)
        {
            type        = DamageStrength.WEAK;
            totalDamage = damage / 2;
        }
        totalDamage += Random.Range(-damage / 3, damage / 3 + 1);

        damageTextController.ShowDamage(totalDamage, type);
        return(totalDamage);
    }
예제 #3
0
파일: Saw.cs 프로젝트: tarsupin/Nexus
 private void AssignSubType(byte subType)
 {
     if (subType == (byte)SawSubType.Small)
     {
         this.SpriteName = "Saw/Small";
         this.AssignBoundsByAtlas(2, 2, -2, -2);
     }
     else if (subType == (byte)SawSubType.Large)
     {
         this.SpriteName = "Saw/Large";
         this.AssignBoundsByAtlas(2, 2, -2, -2);
     }
     else if (subType == (byte)SawSubType.LethalSmall)
     {
         this.Damage     = DamageStrength.InstantKill;
         this.SpriteName = "Saw/Lethal";
         this.AssignBoundsByAtlas(2, 2, -2, -2);
     }
     else if (subType == (byte)SawSubType.LethalLarge)
     {
         this.Damage     = DamageStrength.InstantKill;
         this.SpriteName = "Saw/LethalLarge";
         this.AssignBoundsByAtlas(2, 2, -2, -2);
     }
 }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FacilityHullStat" /> class.
 /// </summary>
 /// <param name="hullCategory">The hull category.</param>
 /// <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="maxHitPts">The maximum hit PTS.</param>
 /// <param name="damageMitigation">The damage mitigation.</param>
 /// <param name="hullDimensions">The hull dimensions.</param>
 /// <param name="science">The science generated by this hull, if any.</param>
 /// <param name="culture">The culture generated by this hull, if any.</param>
 /// <param name="income">The income generated by this hull, if any.</param>
 public FacilityHullStat(FacilityHullCategory hullCategory, string name, AtlasID imageAtlasID, string imageFilename, string description, float size, float mass,
     float pwrRqmt, float expense, float maxHitPts, DamageStrength damageMitigation, Vector3 hullDimensions, float science, float culture, float income)
     : base(name, imageAtlasID, imageFilename, description, size, mass, pwrRqmt, expense, maxHitPts, damageMitigation, hullDimensions) {
     HullCategory = hullCategory;
     Science = science;
     Culture = culture;
     Income = income;
 }
예제 #5
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;
 }
예제 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ShieldGeneratorStat"/> 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="maximumCharge">The maximum charge.</param>
 /// <param name="trickleChargeRate">The trickle charge rate.</param>
 /// <param name="reloadPeriod">The reload period.</param>
 /// <param name="damageMitigation">The damage mitigation.</param>
 public ShieldGeneratorStat(string name, AtlasID imageAtlasID, string imageFilename, string description, float size, float mass,
     float pwrRqmt, float expense, RangeCategory rangeCat, float maximumCharge, float trickleChargeRate, float reloadPeriod, DamageStrength damageMitigation)
     : base(name, imageAtlasID, imageFilename, description, size, mass, pwrRqmt, expense, rangeCat) {
     MaximumCharge = maximumCharge;
     TrickleChargeRate = trickleChargeRate;
     ReloadPeriod = reloadPeriod;
     DamageMitigation = damageMitigation;
 }
예제 #7
0
        public bool ReceiveWoundDamage(DamageStrength damageStrength, bool forceDmg = false)
        {
            // If insufficient damage was created.
            if (damageStrength < DamageStrength.Trivial)
            {
                return(false);
            }

            // If the Character took Instant-Kill Wounds:
            if ((byte)damageStrength > (byte)DamageStrength.Lethal)
            {
                return(this.Death());
            }

            // If the Character is Invincible, no damage taken.
            if (this.IsInvincible && forceDmg == false)
            {
                return(false);
            }

            // Wound Sound
            this.character.room.PlaySound(Systems.sounds.wound, 1f, this.character.posX + 16, this.character.posY + 16);

            // Damage will be soaked by Armor, if available. Occurs before damaging equipment (e.g. Suit, Hat, etc.)
            if (this.Armor > 0)
            {
                this.Armor--;
                this.SetInvincible(this.InvincibleDuration);
                return(true);
            }

            // Damage will be soaked by destroying Hat, if one is available.
            if (this.character.hat is Hat && this.character.hat.IsPowerHat)
            {
                this.SetInvincible(this.InvincibleDuration);
                this.character.hat.DestroyHat(this.character, true);
                return(true);
            }

            // Damage will be soaked by destroying Suit, if one is available.
            if (this.character.suit is Suit && this.character.suit.IsPowerSuit)
            {
                this.SetInvincible(this.InvincibleDuration);
                this.character.suit.DestroySuit(this.character, true);
                return(true);
            }

            // Damage will be soaked by Health, if available. Last attempt to soak damage.
            if (this.Health > 0)
            {
                this.Health--;
                this.SetInvincible(this.InvincibleDuration);
                return(true);
            }

            // Damage could not be soaked. The character dies.
            return(this.Death());
        }
예제 #8
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;
        }
예제 #9
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;
 }
예제 #10
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();
 }
 /// <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;
 }
예제 #12
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;
 }
예제 #13
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;
        }
예제 #14
0
파일: Saw.cs 프로젝트: tarsupin/Nexus
        public Saw(RoomScene room, byte subType, FVector pos, Dictionary <string, short> paramList) : base(room, subType, pos, paramList)
        {
            this.Meta = Systems.mapper.ObjectMetaData[(byte)ObjectEnum.Saw].meta;

            // Physics, Collisions, etc.
            this.physics = new Physics(this);
            this.SetCollide(CollideEnum.NoTileCollide);

            // Assign Flight Behavior
            this.behavior = FlightBehavior.AssignFlightMotion(this, paramList);

            this.Damage = DamageStrength.Standard;

            this.AssignSubType(subType);
        }
예제 #15
0
    public override void ShowDamage(int damage, DamageStrength type = DamageStrength.NORMAL)
    {
        Vector3 randomPosition = transform.position + new Vector3(
            Random.Range(textGenerationBounds.min.x, textGenerationBounds.max.x),
            Random.Range(textGenerationBounds.min.y, textGenerationBounds.max.x));
        GameObject indicator = Instantiate(Settings.main.damageTextSettings.prefab,
                                           randomPosition, Quaternion.identity, transform);

        Text    damageText = indicator.GetComponentInChildren <Text>();
        Outline outline    = indicator.GetComponentInChildren <Outline>();

        damageIndicators.Add(damageText);
        damageText.text = damage.ToString();

        switch (type)
        {
        case DamageStrength.WEAK:
            damageText.fontSize = weakFontSize;
            damageText.color    = weakFillColor;
            outline.effectColor = weakOutlineColor;
            if (!isWeak)
            {
                weakDamageText.enabled = true;
                weakTextAnimation.Play();
                isWeak = true;
            }
            break;

        case DamageStrength.STRONG:
            damageText.fontStyle = FontStyle.Bold;
            damageText.fontSize  = strongFontSize;
            damageText.color     = strongFillColor;
            outline.effectColor  = strongOutlineColor;
            if (!isStrong)
            {
                strongDamageText.enabled = true;
                strongTextAnimation.Play();
                isStrong = true;
            }
            break;

        default:
            damageText.fontSize = normalFontSize;
            damageText.color    = normalFillColor;
            outline.effectColor = normalOutlineColor;
            break;
        }
    }
 /// <summary>
 /// Initializes a new instance of the <see cref="PassiveCountermeasureStat"/> 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="damageMitigation">The damage mitigation.</param>
 public PassiveCountermeasureStat(string name, AtlasID imageAtlasID, string imageFilename, string description, float size, float mass, float pwrRqmt, float expense, DamageStrength damageMitigation)
     : base(name, imageAtlasID, imageFilename, description, size, mass, pwrRqmt, expense) {
     DamageMitigation = damageMitigation;
 }
예제 #17
0
파일: Enemy.cs 프로젝트: tarsupin/Nexus
 public bool CanResistDamage(DamageStrength damage)
 {
     return(this.ProjectileResist >= damage);
 }
예제 #18
0
 abstract public void ShowDamage(int damage, DamageStrength type);
    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;
    }
예제 #20
0
    public override void TakeHit(DamageStrength damagePotential) {
        LogEvent();
        if (_debugSettings.AllPlayersInvulnerable) {
            return;
        }
        D.Assert(IsOperational);
        DamageStrength damage = damagePotential - Data.DamageMitigation;
        if (damage.Total == Constants.ZeroF) {
            //D.Log("{0} has been hit but incurred no damage.", DebugName);
            return;
        }
        D.Log(ShowDebugLog, "{0} has been hit. Taking {1:0.#} damage.", DebugName, damage.Total);

        bool isCmdHit = false;
        float damageSeverity;
        bool isElementAlive = ApplyDamage(damage, out damageSeverity);
        if (!isElementAlive) {
            IsOperational = false;  // should immediately propagate thru to Cmd's alive status
        }
        if (IsHQ && Command.IsOperational) {
            isCmdHit = Command.__CheckForDamage(isElementAlive, damage, damageSeverity);
        }

        if (isElementAlive) {
            var hitAnimation = isCmdHit ? EffectSequenceID.CmdHit : EffectSequenceID.Hit;
            StartEffectSequence(hitAnimation);
            UponDamageIncurred();
        }
    }
예제 #21
0
 public override void TakeHit(DamageStrength elementDamageSustained) {
     if (_debugSettings.AllPlayersInvulnerable) {
         return;
     }
     DamageStrength damageToCmd = elementDamageSustained - Data.DamageMitigation;
     float unusedDamageSeverity;
     bool isCmdAlive = ApplyDamage(damageToCmd, out unusedDamageSeverity);
     D.Assert(isCmdAlive, Data.DebugName);
 }
 private IList<PassiveCountermeasureStat> MakeAvailablePassiveCountermeasureStats(int quantity) {
     IList<PassiveCountermeasureStat> statsList = new List<PassiveCountermeasureStat>(quantity);
     for (int i = 0; i < quantity; i++) {
         string name = string.Empty;
         DamageStrength damageMitigation;
         var damageMitigationCategory = Enums<DamageCategory>.GetRandom(excludeDefault: false);
         float damageMitigationValue;
         switch (damageMitigationCategory) {
             case DamageCategory.Thermal:
                 name = "HighVaporAtmosphere";
                 damageMitigationValue = UnityEngine.Random.Range(3F, 8F);
                 damageMitigation = new DamageStrength(damageMitigationCategory, damageMitigationValue);
                 break;
             case DamageCategory.Atomic:
                 name = "HighAcidAtmosphere";
                 damageMitigationValue = UnityEngine.Random.Range(3F, 8F);
                 damageMitigation = new DamageStrength(damageMitigationCategory, damageMitigationValue);
                 break;
             case DamageCategory.Kinetic:
                 name = "HighParticulateAtmosphere";
                 damageMitigationValue = UnityEngine.Random.Range(3F, 8F);
                 damageMitigation = new DamageStrength(damageMitigationCategory, damageMitigationValue);
                 break;
             case DamageCategory.None:
                 name = "NoAtmosphere";
                 damageMitigation = new DamageStrength(1F, 1F, 1F);
                 break;
             default:
                 throw new NotImplementedException(ErrorMessages.UnanticipatedSwitchValue.Inject(damageMitigationCategory));
         }
         var countermeasureStat = new PassiveCountermeasureStat(name, AtlasID.MyGui, TempGameValues.AnImageFilename, "Description...", 0F, 0F, 0F, 0F, 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;
    }
예제 #25
0
 /// <summary>
 /// Checks for damage to this Command when its HQElement takes a hit. Returns true if 
 /// the Command takes damage.
 /// </summary>
 /// <param name="isHQElementAlive">if set to <c>true</c> the command's HQ element is still alive.</param>
 /// <param name="elementDamageSustained">The damage sustained by the HQ Element.</param>
 /// <param name="elementDamageSeverity">The severity of the damage sustained by the HQ Element.</param>
 /// <returns></returns>
 public bool __CheckForDamage(bool isHQElementAlive, DamageStrength elementDamageSustained, float elementDamageSeverity) {
     //D.Log(ShowDebugLog, "{0}.__CheckForDamage() called. IsHQElementAlive = {1}, ElementDamageSustained = {2}, ElementDamageSeverity = {3}.",
     //DebugName, isHQElementAlive, elementDamageSustained, elementDamageSeverity);
     var cmdMissedChance = Constants.OneHundredPercent - elementDamageSeverity;
     bool missed = (isHQElementAlive) ? RandomExtended.Chance(cmdMissedChance) : false;
     if (missed) {
         //D.Log(ShowDebugLog, "{0} avoided a hit.", DebugName);
     }
     else {
         TakeHit(elementDamageSustained);
     }
     return !missed;
 }
예제 #26
0
    public override void TakeHit(DamageStrength damagePotential) {
        if (_debugSettings.AllPlayersInvulnerable) {
            return;
        }
        D.Assert(IsOperational);
        LogEvent();
        DamageStrength damage = damagePotential - Data.DamageMitigation;
        if (damage.Total == Constants.ZeroF) {
            D.Log(ShowDebugLog, "{0} has been hit but incurred no damage.", DebugName);
            return;
        }
        D.Log(ShowDebugLog, "{0} has been hit. Taking {1:0.#} damage.", DebugName, damage.Total);

        float unusedDamageSeverity;
        bool isAlive = ApplyDamage(damage, out unusedDamageSeverity);
        if (!isAlive) {
            IsOperational = false;
            return;
        }
        StartEffectSequence(EffectSequenceID.Hit);
    }
예제 #27
0
 public void SetDamage(DamageStrength damage)
 {
     this.Damage = damage;
 }
 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;
 }
예제 #29
0
    /// <summary>
    /// Applies the damage to the command and returns true if the command survived the hit.
    /// </summary>
    /// <param name="damageToCmd">The damage sustained.</param>
    /// <param name="damageSeverity">The damage severity.</param>
    /// <returns>
    ///   <c>true</c> if the command survived.
    /// </returns>
    protected override bool ApplyDamage(DamageStrength damageToCmd, out float damageSeverity) {
        var __combinedDmgToCmd = damageToCmd.Total;
        var minAllowedCurrentHitPoints = 0.5F * Data.MaxHitPoints;
        var proposedCurrentHitPts = Data.CurrentHitPoints - __combinedDmgToCmd;
        if (proposedCurrentHitPts < minAllowedCurrentHitPoints) {
            Data.CurrentHitPoints = minAllowedCurrentHitPoints;
        }
        else {
            Data.CurrentHitPoints -= __combinedDmgToCmd;
        }
        D.Assert(Data.Health > Constants.ZeroPercent, "Should never fail as Commands can't die directly from a hit on the command");

        damageSeverity = Mathf.Clamp01(__combinedDmgToCmd / Data.CurrentHitPoints);
        AssessCripplingDamageToEquipment(damageSeverity);
        return true;
    }