优化武器商品描述文本、修复敌人子弹无法击中玩家的bug
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using SepCore.Definition;
|
||||
@@ -9,18 +8,9 @@ namespace SepCore.CustomUtility
|
||||
{
|
||||
public static class ItemDescUtility
|
||||
{
|
||||
private static readonly Dictionary<ParamType, string> _paramTypeNames = new()
|
||||
{
|
||||
{ ParamType.HitRadius, "攻击半宽" },
|
||||
{ ParamType.SectorAngle, "攻击角度" },
|
||||
{ ParamType.HitHalfWidth, "横向半宽" },
|
||||
{ ParamType.PierceLength, "前戳距离" },
|
||||
{ ParamType.HitHeight, "判定高度" },
|
||||
};
|
||||
|
||||
private static readonly string[] _statTypeNames =
|
||||
{
|
||||
"无效", // None = 0
|
||||
"无效", // None = 0
|
||||
"最大生命", // MaxHp = 1
|
||||
"生命恢复", // HpRegen = 2
|
||||
"生命窃取", // LifeSteal = 3
|
||||
@@ -35,8 +25,8 @@ namespace SepCore.CustomUtility
|
||||
"护甲", // Armor = 12
|
||||
"闪避率", // Dodge = 13
|
||||
"移动速度", // MoveSpeed = 14
|
||||
"收获", // Harvesting = 15
|
||||
"幸运" // Luck = 16
|
||||
"收获", // Harvesting = 15
|
||||
"幸运" // Luck = 16
|
||||
};
|
||||
|
||||
public static string Describe(StatModifierConfig statModifierConfig)
|
||||
@@ -110,80 +100,53 @@ namespace SepCore.CustomUtility
|
||||
|
||||
public static string CreateWeaponDescription(WeaponConfig weaponConfig)
|
||||
{
|
||||
if (weaponConfig == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return CreateWeaponDescription(weaponConfig.Attack, weaponConfig.Cooldown,
|
||||
weaponConfig.AttackRange, weaponConfig.StatModifierConfigs, weaponConfig.Parameters);
|
||||
weaponConfig.AttackRange, weaponConfig.StatModifierConfigs);
|
||||
}
|
||||
|
||||
public static string CreateWeaponDescription(WeaponBase weapon)
|
||||
{
|
||||
if (weapon == null || weapon.WeaponData == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return CreateWeaponDescription(weapon.WeaponData);
|
||||
}
|
||||
|
||||
|
||||
public static string CreateWeaponDescription(WeaponData weaponData)
|
||||
{
|
||||
if (weaponData == null)
|
||||
{
|
||||
return null;
|
||||
Log.Error("Weapon data is invalid.");
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return CreateWeaponDescription(weaponData.Attack, weaponData.Cooldown,
|
||||
weaponData.AttackRange, weaponData.Modifiers, weaponData.Parameters);
|
||||
weaponData.AttackRange, weaponData.Modifiers);
|
||||
}
|
||||
|
||||
public static string CreatePropDescription(PropItem prop)
|
||||
{
|
||||
if (prop == null)
|
||||
{
|
||||
return null;
|
||||
Log.Error("Prop is invalid.");
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
return CreatePropDescription(prop.Modifiers);
|
||||
}
|
||||
|
||||
private static string CreateWeaponDescription(int attack, float cooldown, float attackRange,
|
||||
IEnumerable<StatModifierConfig> modifiers, IReadOnlyDictionary<ParamType, float> parameters)
|
||||
public static string CreateWeaponDescription(int attack, float cooldown, float attackRange,
|
||||
IEnumerable<StatModifierConfig> modifiers = null)
|
||||
{
|
||||
float baseCrit = GameEntry.Luban.Global.WeaponBaseCrit;
|
||||
float critMult = GameEntry.Luban.Global.CritMultiplier;
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine($"攻击: {attack}");
|
||||
sb.AppendLine($"冷却: {cooldown}");
|
||||
sb.AppendLine($"范围: {attackRange}");
|
||||
sb.AppendLine($"伤害: {attack}");
|
||||
sb.AppendLine($"暴击: x{critMult:0.##} ({baseCrit * 100:0.##}%)");
|
||||
sb.AppendLine($"冷却: {cooldown:0.##}s");
|
||||
sb.AppendLine($"范围: {attackRange:0.##}");
|
||||
|
||||
string modifiersDesc = CreatePropDescription(modifiers);
|
||||
if (!string.IsNullOrEmpty(modifiersDesc))
|
||||
{
|
||||
sb.Append(modifiersDesc);
|
||||
sb.AppendLine();
|
||||
sb.Append(modifiersDesc.TrimEnd());
|
||||
}
|
||||
|
||||
if (parameters == null || parameters.Count == 0)
|
||||
{
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
foreach (var kvp in parameters)
|
||||
{
|
||||
if (!_paramTypeNames.TryGetValue(kvp.Key, out string paramName))
|
||||
{
|
||||
paramName = kvp.Key.ToString();
|
||||
}
|
||||
|
||||
string valStr = kvp.Key == ParamType.SectorAngle
|
||||
? kvp.Value.ToString()
|
||||
: kvp.Value.ToString("0.##");
|
||||
|
||||
sb.AppendLine($"{paramName}: {valStr}");
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
return sb.ToString().TrimEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user