引入属性、伤害管线
This commit is contained in:
@@ -20,46 +20,52 @@ namespace SepCore.CustomUtility
|
||||
|
||||
private static readonly string[] _statTypeNames =
|
||||
{
|
||||
"无效",
|
||||
"最大生命",
|
||||
"移动速度",
|
||||
"伤害",
|
||||
"防御",
|
||||
"冷却",
|
||||
"暴击率",
|
||||
"暴击伤害",
|
||||
"闪避",
|
||||
"金币/经验吸收范围"
|
||||
"无效", // None = 0
|
||||
"最大生命", // MaxHp = 1
|
||||
"生命恢复", // HpRegen = 2
|
||||
"生命窃取", // LifeSteal = 3
|
||||
"伤害加成", // DamagePercent = 4
|
||||
"近战伤害", // MeleeDamage = 5
|
||||
"远程伤害", // RangedDamage = 6
|
||||
"元素伤害", // ElementalDamage = 7
|
||||
"攻击速度", // AttackSpeed = 8
|
||||
"暴击率", // CritChance = 9
|
||||
"工程学", // Engineering = 10
|
||||
"攻击范围", // Range = 11
|
||||
"护甲", // Armor = 12
|
||||
"闪避率", // Dodge = 13
|
||||
"移动速度", // MoveSpeed = 14
|
||||
"收获", // Harvesting = 15
|
||||
"幸运" // Luck = 16
|
||||
};
|
||||
|
||||
public static string Describe(modifier modifier)
|
||||
public static string Describe(StatModifierConfig statModifierConfig)
|
||||
{
|
||||
if (modifier == null)
|
||||
if (statModifierConfig == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
string name = _statTypeNames[(int)modifier.Key];
|
||||
string colorTag = modifier.Value > 0 ? "green" : "red";
|
||||
string suffix = modifier.IsPercent ? "%" : string.Empty;
|
||||
float displayValue;
|
||||
if (modifier.IsPercent)
|
||||
int index = (int)statModifierConfig.StatType;
|
||||
string name = (index >= 0 && index < _statTypeNames.Length) ? _statTypeNames[index] : statModifierConfig.StatType.ToString();
|
||||
string colorTag = statModifierConfig.Value >= 0 ? "green" : "red";
|
||||
string sign = statModifierConfig.Value >= 0 ? "+" : "";
|
||||
|
||||
if (statModifierConfig.ModifierType == ModifierType.PercentAdd)
|
||||
{
|
||||
displayValue = modifier.Value / 10f;
|
||||
}
|
||||
else if (modifier.Key == StatType.MovementSpeed)
|
||||
{
|
||||
displayValue = modifier.Value / 1000f;
|
||||
}
|
||||
else
|
||||
{
|
||||
displayValue = modifier.Value;
|
||||
float displayPercent = statModifierConfig.Value * 100f;
|
||||
return $"{name}: <color={colorTag}>{sign}{displayPercent:0.##}%</color>";
|
||||
}
|
||||
|
||||
return $"{name}: <color={colorTag}>+{displayValue:0.##}{suffix}</color>";
|
||||
if (statModifierConfig.ModifierType == ModifierType.PercentMult)
|
||||
{
|
||||
return $"{name}: <color={colorTag}>x{statModifierConfig.Value:0.##}</color>";
|
||||
}
|
||||
|
||||
return $"{name}: <color={colorTag}>{sign}{statModifierConfig.Value:0.##}</color>";
|
||||
}
|
||||
|
||||
public static string CreatePropDescription(IEnumerable<modifier> modifiers)
|
||||
public static string CreatePropDescription(IEnumerable<StatModifierConfig> modifiers)
|
||||
{
|
||||
if (modifiers == null)
|
||||
{
|
||||
@@ -67,7 +73,7 @@ namespace SepCore.CustomUtility
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach (modifier modifier in modifiers)
|
||||
foreach (StatModifierConfig modifier in modifiers)
|
||||
{
|
||||
sb.Append(Describe(modifier));
|
||||
sb.Append('\n');
|
||||
@@ -84,7 +90,7 @@ namespace SepCore.CustomUtility
|
||||
}
|
||||
|
||||
return CreateWeaponDescription(weaponConfig.Attack, weaponConfig.Cooldown / 1000f,
|
||||
weaponConfig.AttackRange / 1000f, weaponConfig.Modifiers, weaponConfig.Parameters);
|
||||
weaponConfig.AttackRange / 1000f, weaponConfig.StatModifierConfigs, weaponConfig.Parameters);
|
||||
}
|
||||
|
||||
public static string CreateWeaponDescription(WeaponBase weapon)
|
||||
@@ -119,7 +125,7 @@ namespace SepCore.CustomUtility
|
||||
}
|
||||
|
||||
private static string CreateWeaponDescription(int attack, float cooldown, float attackRange,
|
||||
IEnumerable<modifier> modifiers, IReadOnlyDictionary<ParamType, int> parameters)
|
||||
IEnumerable<StatModifierConfig> modifiers, IReadOnlyDictionary<ParamType, int> parameters)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine($"攻击: {attack}");
|
||||
|
||||
Reference in New Issue
Block a user