public UnitWeaponCombiner(UnitData unit, WeaponData weapon) { if (weapon == null || unit == null) { return; } canUse = unit.Attributes.Strength >= weapon.StrRequired && unit.Attributes.Dexterity >= weapon.DexRequired && unit.Attributes.Intelligence >= weapon.IntRequired; bonusStr = (int)Mathf.Max(0, unit.Attributes.Strength - weapon.StrRequired); bonusDex = (int)Mathf.Max(0, unit.Attributes.Dexterity - weapon.DexRequired); bonusInt = (int)Mathf.Max(0, unit.Attributes.Intelligence - weapon.IntRequired); damageBonus = new DamageBonus(weapon, bonusStr, bonusDex, bonusInt); speedBonus = new SpeedBonus(weapon, bonusStr, bonusDex, bonusInt, weapon.TotalAttackTime); reachBonus = new ReachBonus(weapon, bonusStr, bonusDex, bonusInt); minDamage = (int)weapon.MinDamage + (int)damageBonus.Value; maxDamage = (int)weapon.MaxDamage + (int)damageBonus.Value; weaponReach = weapon.Reach + reachBonus.Value; totalReach = weaponReach + Main.StaticData.Game.Skills.GetValue(unit.MainAttack).Data.Reach; attackSpeedModifier = weapon.SpeedModifier / speedBonus.Multiplier; attacksPerSecond = weapon.AttacksPerSecond / speedBonus.Multiplier; damagePerSecond = AverageDamage * AttacksPerSecond; }
public string ToString(int quantity, ItemStringOptions options) { StringBuilder builder = new StringBuilder(); // show the quantity if (options.IsSet(ItemStringOptions.ShowQuantity)) { if (quantity > 1) { builder.Append(quantity.ToString()); builder.Append(" "); } else { builder.Append("a "); } } // show the prefix power if ((mPower != null) && mPower.Type.IsPrefix) { builder.Append(mPower.Name); builder.Append(" "); } // show the name if (options.IsSet(ItemStringOptions.ShowQuantity)) { if (quantity > 1) { builder.Append(Type.Noun.Plural); } else { builder.Append(Type.Noun.Singular); } } else { builder.Append(Type.Noun.Singular); } // show the suffix power if ((mPower != null) && !mPower.Type.IsPrefix) { builder.Append(" "); builder.Append(mPower.Name); } if (options.IsSet(ItemStringOptions.ShowBonuses)) { // show the weapon stats if ((Type.Attack != null) || (StrikeBonus != 0) || (DamageBonus != 1.0f)) { bool needsSpace = false; builder.Append(" ^k(^m"); if (Type.Attack != null) { builder.Append(Type.Attack.Damage.ToString()); needsSpace = true; } if (StrikeBonus != 0) { if (needsSpace) { builder.Append(" "); } builder.Append(StrikeBonus.ToString("+##;-##;0")); needsSpace = true; } if (DamageBonus != 1.0f) { if (needsSpace) { builder.Append(" "); } builder.AppendFormat("x{0}", DamageBonus); } builder.Append("^k)^-"); } // show the armor stats if ((Type.Armor != 0) || (ArmorBonus != 0)) { bool needsSpace = false; builder.Append(" ^k[^m"); if (Type.Armor != 0) { builder.Append(Type.Armor.ToString()); needsSpace = true; } if (ArmorBonus != 0) { if (needsSpace) { builder.Append(" "); } builder.Append(ArmorBonus.ToString("+##;-##;0")); } builder.Append("^k]^-"); } // show the stat bonus if (StatBonus != 0) { builder.Append(" ^k(^m"); builder.Append(StatBonus.ToString("+##;-##;0")); builder.Append("^k)^-"); } // show the speed bonus if (SpeedBonus != 0) { builder.Append(" ^k(^m"); builder.Append(SpeedBonus.ToString("+##;-##;0")); builder.Append(" speed^k)^-"); } } if (options.IsSet(ItemStringOptions.ShowCharges)) { switch (Type.ChargeType) { case ChargeType.Light: if (mCharges == 0) { builder.Append(" ^k(^mempty^k)^-"); } else if (mCharges > 0) { builder.AppendFormat(" ^k(^ylit^m {0} left^k)^-", mCharges); } else { builder.AppendFormat(" ^k(^m{0} left^k)^-", -mCharges); } break; case ChargeType.Multi: if (mCharges == 0) { builder.Append(" ^k(^mempty^k)^-"); } else { builder.AppendFormat(" ^k(^m{0} charges^k)^-", mCharges); } break; } } return(builder.ToString()); }