public Weapon(DamageModifier prefix, DamageModifier suffix, WeaponType type, WeaponModifier[] extraModifiers)
 {
     _prefix         = prefix;
     _suffix         = suffix;
     _type           = type;
     _extraModifiers = extraModifiers;
 }
        DamageModifier find_damage_modifier(DamageType type)
        {
            if (fCard == null)
            {
                return(null);
            }

            List <DamageType> types = new List <DamageType>();

            types.Add(type);
            int value = fCard.GetDamageModifier(types, fData);

            if (value == 0)
            {
                // No modifier
                return(null);
            }

            if (value == int.MinValue)
            {
                // Immune
                value = 0;
            }

            DamageModifier mod = new DamageModifier();

            mod.Type  = type;
            mod.Value = value;

            return(mod);
        }
        private void AddDmgBtn_Click(object sender, EventArgs e)
        {
            if (fCreature != null)
            {
                DamageModifier dm = new DamageModifier();

                DamageModifierForm dlg = new DamageModifierForm(dm);
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    fModifiers.Add(dlg.Modifier);
                    update_damage_list();
                }
            }

            if (fTemplate != null)
            {
                DamageModifierTemplate dm = new DamageModifierTemplate();

                DamageModifierTemplateForm dlg = new DamageModifierTemplateForm(dm);
                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    fModifierTemplates.Add(dlg.Modifier);
                    update_damage_list();
                }
            }
        }
Beispiel #4
0
 public DamageModDesc(DamageModifier item)
 {
     Name          = item.Name;
     Icon          = item.Url;
     Description   = item.Tooltip;
     NonMultiplier = !item.Multiplier;
 }
Beispiel #5
0
 public void decrease(DamageModifier mod)
 {
     for (int i = 0; i < v.Length; i++)
     {
         v[i] *= 1 - mod.v[i];
     }
 }
Beispiel #6
0
 public void sub(DamageModifier mod)
 {
     for (int i = 0; i < v.Length; i++)
     {
         v[i] -= mod.v[i];
     }
 }
Beispiel #7
0
 public void ignore(DamageModifier resist, float mod = 1)        //Игнорирование защиты
 {
     for (int i = 0; i < v.Length; i++)
     {
         v[i] /= (1 - resist.v[i] * mod);
     }
 }
 public bool AddDamageModifier(DamageModifier modifier, int priority = 0)
 {
     if (modifier == null || _damageModifiers.Contains(modifier))
         return false;
     _damageModifiers.Add(modifier);
     return true;
 }
Beispiel #9
0
        public AttackSummary Shoot(IEnemy enemy, CombatStats combatStats)
        {
            ValidateShoot(enemy, combatStats);

            int hitRoll = Rng.Roll(RollType.d20);

            AttackSummary summary;

            if (ShotMisfired(hitRoll))
            {
                HandleMisfire();
                summary = GetMisfireAttackSummary();
            }
            else
            {
                IModifier finalHitMod = HitModifier.Add(combatStats.HitModifier);
                IModifier finalDmgMod = DamageModifier.Add(combatStats.DamageModifier);

                summary = HandleShoot(enemy,
                                      hitRoll,
                                      finalHitMod,
                                      finalDmgMod,
                                      combatStats.CritValue);
            }

            DecrementCurrentAmmo();

            return(summary);
        }
Beispiel #10
0
        /// <summary>
        /// Apply damage to the Health.
        /// </summary>
        /// <param name="dmg">The damage to apply.</param>
        /// <returns>The actual damage amount dealt.</returns>
        public virtual float Damage(Damage dmg)
        {
            if (enabled && dmg.amount > 0 && hitInvulnTimer.Use())
            {
                DamageModifier?.Invoke(ref dmg);

                float prevHealth = health;
                health    -= dmg.amount;
                health     = Mathf.Max(health, 0);
                dmg.amount = prevHealth - health;

                healthRegenTimer.Set();
                SendMessage("OnDamage", dmg, SendMessageOptions.DontRequireReceiver);
                Damaged?.Invoke(dmg);
                if (damageSound)
                {
                    damageSound.Play();
                }

                if (health == 0 && !dead)
                {
                    dead = true;
                    SendMessage("OnZeroHealth", SendMessageOptions.DontRequireReceiver);
                    ZeroHealth?.Invoke();
                }
            }
            else
            {
                dmg.amount = 0;
            }

            return(dmg.amount);
        }
Beispiel #11
0
 public DamageModDesc(DamageModifier item)
 {
     Name          = item.Name;
     Icon          = item.Icon;
     Description   = item.Tooltip;
     NonMultiplier = !item.Multiplier;
     SkillBased    = item.SkillBased;
 }
Beispiel #12
0
 private void Start()
 {
     animator                        = GetComponentInChildren <Animator>();
     pickupable                      = GetComponent <Pickupable>();
     closedDamageModifier            = gameObject.EnsureComponent <DamageModifier>();
     closedDamageModifier.multiplier = 0.5f;
     closedDamageModifier.damageType = DamageType.Normal;
     surface = GetComponent <VFXSurface>();
 }
 public bool AddDamageModifier(DamageModifier modifier, int priority = 0)
 {
     if (modifier == null || _damageModifiers.Contains(modifier))
     {
         return(false);
     }
     _damageModifiers.Add(modifier);
     return(true);
 }
Beispiel #14
0
 public MeleeAttack(OffenseStats offenseAbilities,
                    AbilityScore strength,
                    CharacterSize size,
                    IWeaponAttackStatistics weapon) : base(offenseAbilities, size, weapon)
 {
     this.strength = strength;
     AttackBonus.AddModifier(new StatisticStatModifier("Melee Attack Bonus", offenseAbilities.MeleeAttackBonus));
     DamageModifier.AddModifier(this.strength.UniversalStatModifier);
     this.AttackType = AttackTypes.Melee;
 }
Beispiel #15
0
    void OnDisable()
    {
        Damageable t = GetComponent <Damageable>();

        if (t != null && this.mod != null)
        {
            t.RemoveModifier(this.mod);
            this.mod = null;
        }
    }
Beispiel #16
0
    public float getModifier(DamageModifier resist)             //расчет итогового множителя
    {
        float mod = 0;

        for (int i = 0; i < v.Length; i++)
        {
            mod += v[i] * (1 - resist.v[i]);
        }
        return(mod);
    }
    public void ApplyDamageReduction(float rawDamage, evoTypes attackerType, DamageModifier attacker)
    {
        processedDamage = rawDamage;
        evoTypes myType = GetComponent <UISelectionDescription>().GetMyType();

        ApplyStatusEffect(attacker);
        ProcessChangeForStatusEffect(processedDamage);
        ProcessChangeForType(processedDamage, attackerType, myType);
        GetComponent <Health>().TakeDamage(Mathf.RoundToInt(processedDamage));
    }
Beispiel #18
0
    void Start()
    {
        Damageable t = GetComponent <Damageable>();

        if (t != null)
        {
            this.mod = new DamageModReduction(this.armorStrength);
            t.AddModifier(this.mod);
        }
    }
        public float CalculateAppliedValue(DamageModifier stat)
        {
            if (stat.modifierType == DamageModType.Resistance)
            {
                if (effectType != EffectTypes.Instant)
                {
                    switch (valueTarget)
                    {
                    case EffectValueTarget.Value:
                        return(Mathf.Clamp(GetSustainedValue(stat.CurrentValue, stat), 0, 1) - stat.CurrentValue);

                    default:
                        return(0);
                    }
                }
                else
                {
                    switch (valueTarget)
                    {
                    case EffectValueTarget.Value:
                        return(Mathf.Clamp(GetSustainedValue(stat.CurrentValue, stat), 0, 1));

                    default:
                        return(0);
                    }
                }
            }
            else
            {
                if (effectType != EffectTypes.Instant)
                {
                    switch (valueTarget)
                    {
                    case EffectValueTarget.MaximumValue:
                        return(GetSustainedValue(stat.CurrentMaximum, stat) - stat.CurrentMaximum);

                    case EffectValueTarget.Value:
                        return(Mathf.Clamp(GetSustainedValue(stat.CurrentValue, stat), 0, stat.CurrentMaximum) - stat.CurrentValue);
                    }
                }
                else
                {
                    switch (valueTarget)
                    {
                    case EffectValueTarget.MaximumValue:
                        return(GetSustainedValue(stat.CurrentMaximum, stat));

                    case EffectValueTarget.Value:
                        return(Mathf.Clamp(GetSustainedValue(stat.CurrentValue, stat), 0, stat.CurrentMaximum));
                    }
                }

                return(0);
            }
        }
        public override void GetProperties(ObjectPropertyList list)
        {
            base.GetProperties(list);

            AddElementalDamageProperties(list);

            if (DamageModifier != 0)
            {
                list.Add(1074762, DamageModifier.ToString());                   // Damage Modifier: ~1_PERCENT~%
            }
        }
Beispiel #21
0
        private void GetDamageModifierText(ref string description, DamageModifier damageModifier, string afflictionIdentifier)
        {
            int roundedValue = (int)Math.Round((1 - damageModifier.DamageMultiplier * damageModifier.ProbabilityMultiplier) * 100);

            if (roundedValue == 0)
            {
                return;
            }
            string colorStr = XMLExtensions.ColorToString(GUI.Style.Green);

            description += $"\n  ‖color:{colorStr}‖{roundedValue.ToString("-0;+#")}%‖color:end‖ {AfflictionPrefab.List.FirstOrDefault(ap => ap.Identifier.Equals(afflictionIdentifier, StringComparison.OrdinalIgnoreCase))?.Name ?? afflictionIdentifier}";
        }
Beispiel #22
0
        private void AddDmgBtn_Click(object sender, EventArgs e)
        {
            DamageModifier dm = new DamageModifier();

            DamageModifierForm dlg = new DamageModifierForm(dm);

            if (dlg.ShowDialog() == DialogResult.OK)
            {
                fNPC.DamageModifiers.Add(dlg.Modifier);
                update_damage_list();
            }
        }
Beispiel #23
0
    void Awake()
    {
        // 需要初始化 collider 和 rigid 设置 layer 以及 collider 属性等
        m_UnitAttached = GetComponentInParent <Unit>();
        DamageModifier dm = GetComponent <DamageModifier>();

        if (dm != null)
        {
            m_dmgDelegate = dm.GetRealDmg;
        }
        gameObject.layer = LayerMask.NameToLayer("OnHitBox");
    }
Beispiel #24
0
 private void AreDamageEqual(List <DamageModifier> mp, List <DamageModifier> ddi)
 {
     Assert.AreEqual(mp.Count, ddi.Count);
     foreach (DamageModifier dMP in mp)
     {
         DamageModifier dDDI = ddi.SingleOrDefault(x => x.Type == dMP.Type);
         Assert.IsNotNull(dDDI);
         Assert.AreEqual(dMP.Value, dDDI.Value);
         Assert.AreEqual(dMP.Type, dDDI.Type);
         Assert.AreEqual(dMP.ToString(), dDDI.ToString());
     }
 }
        internal static DamageModDesc BuildDamageModDesc(DamageModifier item)
        {
            var damageModDesc = new DamageModDesc();

            damageModDesc.Name          = item.Name;
            damageModDesc.Icon          = item.Icon;
            damageModDesc.Description   = item.Tooltip;
            damageModDesc.NonMultiplier = !item.Multiplier;
            damageModDesc.SkillBased    = item.SkillBased;
            damageModDesc.Approximate   = item.Approximate;
            return(damageModDesc);
        }
 public void Initialize(DamageModifier modifier)
 {
     if (modifier.modifierType == DamageModType.Resistance)
     {
         AppliedValue = CalculateAppliedValue(modifier);
     }
     else
     {
         AppliedValue = CalculateAppliedValue(modifier);
     }
     Initialized = true;
 }
        internal static DamageModDesc BuildDamageModDesc(DamageModifier item)
        {
            var damageModDesc = new DamageModDesc
            {
                Name          = item.Name,
                Icon          = item.Icon,
                Description   = item.Tooltip,
                NonMultiplier = !item.Multiplier,
                SkillBased    = item.SkillBased,
                Approximate   = item.Approximate
            };

            return(damageModDesc);
        }
        private void update_list()
        {
            DamageList.Items.Clear();
            fTotalDamage = 0;

            foreach (OngoingCondition oc in fData.Conditions)
            {
                if (oc.Type != OngoingType.Damage)
                {
                    continue;
                }

                int            value = oc.Value;
                DamageModifier dm    = find_damage_modifier(oc.DamageType);
                if (dm != null)
                {
                    if (dm.Value == 0)
                    {
                        value = 0;
                    }
                    else
                    {
                        value += dm.Value;
                        value  = Math.Max(value, 0);
                    }
                }

                ListViewItem lvi = DamageList.Items.Add(oc.ToString(fEncounter, false));
                lvi.SubItems.Add((dm != null) ? dm.ToString() : "");
                lvi.SubItems.Add(value.ToString());
                lvi.Tag   = oc;
                lvi.Group = DamageList.Groups[0];

                fTotalDamage += value;
            }

            ListViewItem lvi_total = DamageList.Items.Add("Total");

            lvi_total.SubItems.Add("");
            lvi_total.SubItems.Add(fTotalDamage.ToString());
            lvi_total.Group = DamageList.Groups[1];
            lvi_total.Font  = new Font(Font, Font.Style | FontStyle.Bold);

            if (fData.Conditions.Count == 0)
            {
                ListViewItem lvi = DamageList.Items.Add("(no damage)");
                lvi.ForeColor = SystemColors.GrayText;
            }
        }
 private void ProcessChangeForBlessing(int rawDamage)
 {
     foreach (statusEffects effect in GetComponent <Tower>().GetActiveStatusEffects())
     {
         if (effect == statusEffects.Blessing)
         {
             DamageModifier damageModifier = GetComponent <Tower>().GetMyBuffGiver().GetComponent <DamageModifier>();
             foreach (AbilitiesAndStatusEffects ability in damageModifier.GetActiveAbilities())
             {
                 if (ability.GetStatusEffect() == statusEffects.Blessing)
                 {
                     processedDamage += rawDamage * ability.GetDamageMultiplier();
                 }
             }
         }
     }
 }
Beispiel #30
0
    public void AddModifier(DamageModifier mod)
    {
        int modPriority = mod.GetPriority();

        if (this.modifiers.Count > 0)
        {
            int insertPoint = this.modifiers.FindLastIndex((DamageModifier m) =>
            {
                return(m.GetPriority() == modPriority);
            });
            this.modifiers.Insert(insertPoint, mod);
        }
        else
        {
            this.modifiers.Add(mod);
        }
    }
Beispiel #31
0
        private void Version1_4_Load(Stream stream)
        {
            int    i, count;
            string effectName;

            // Remove all current effects
            foreach (StatEffect effect in Effects)
            {
                onEffectRemoved?.Invoke(effect);
            }

            foreach (StatValue stat in Stats)
            {
                stat.Load(stream, 1.4f);
            }

            damageModifiers.Clear();
            count = stream.ReadInt();
            for (i = 0; i < count; i++)
            {
                DamageModifier instance = ScriptableObject.CreateInstance <DamageModifier>();
                instance.Load(stream, 1.4f);
                damageModifiers.Add(instance);
            }

            Effects.Clear();
            count = stream.ReadInt();
            for (i = 0; i < count; i++)
            {
                effectName = stream.ReadStringPacket();
                foreach (StatEffect effect in effectList.availableEffects)
                {
                    if (effect.name == effectName)
                    {
                        StatEffect instance = InstanceStatEffect(effect);
                        instance.RemainingTime = stream.ReadFloat();
                        Effects.Add(instance);
                        onEffectAdded?.Invoke(instance);

                        break;
                    }
                }
            }
        }
 public bool RemoveDamageModifier(DamageModifier modifier)
 {
     return _damageModifiers.Remove(modifier);
 }