迁移数据表到 Luban,移除 JsonNet、EnumUtility
This commit is contained in:
@@ -1,29 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using SepCore.DataTable;
|
||||
using SepCore.Definition;
|
||||
using SepCore.Entity;
|
||||
using SepCore.Entity.Weapon;
|
||||
using System;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.CustomUtility
|
||||
{
|
||||
public static class ItemDescUtility
|
||||
{
|
||||
private static readonly Dictionary<string, string> _paramsDict = new(StringComparer.OrdinalIgnoreCase)
|
||||
private static readonly Dictionary<ParamType, string> _paramTypeNames = new()
|
||||
{
|
||||
{"hitHalfWidth", "横向半宽"},
|
||||
{"hitRadius", "攻击半宽"},
|
||||
{"hitHeight", "判定高度"},
|
||||
{"hitCenterYOffset", "判定高度偏移"},
|
||||
{"sectorAngle", "攻击角度"},
|
||||
{"pierceLength", "前戳距离"},
|
||||
{"thrustDistance", "前戳距离(旧)"},
|
||||
{"forwardOffset", "前置偏移"},
|
||||
{"rotateSpeed", "转向速度"},
|
||||
{"attackDuration", "突刺时长"},
|
||||
{"returnDuration", "收枪时长"}
|
||||
{ ParamType.HitRadius, "攻击半宽" },
|
||||
{ ParamType.SectorAngle, "攻击角度" },
|
||||
{ ParamType.HitHalfWidth, "横向半宽" },
|
||||
{ ParamType.PierceLength, "前戳距离" },
|
||||
{ ParamType.HitHeight, "判定高度" },
|
||||
};
|
||||
|
||||
private static readonly string[] _statTypeNames =
|
||||
@@ -39,30 +32,43 @@ namespace SepCore.CustomUtility
|
||||
"闪避",
|
||||
"金币/经验吸收范围"
|
||||
};
|
||||
|
||||
public static string Describe(StatModifier modifier)
|
||||
|
||||
public static string Describe(modifier modifier)
|
||||
{
|
||||
if (modifier == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
string name = _statTypeNames[(int)modifier.StatType];
|
||||
string name = _statTypeNames[(int)modifier.Key];
|
||||
string colorTag = modifier.Value > 0 ? "green" : "red";
|
||||
string suffix = modifier.IsPercent ? "%" : string.Empty;
|
||||
float displayValue = modifier.IsPercent ? modifier.Value * 100 : modifier.Value;
|
||||
return $"{name}: <color={colorTag}>+{displayValue}{suffix}</color>";
|
||||
}
|
||||
float displayValue;
|
||||
if (modifier.IsPercent)
|
||||
{
|
||||
displayValue = modifier.Value / 10f;
|
||||
}
|
||||
else if (modifier.Key == StatType.MovementSpeed)
|
||||
{
|
||||
displayValue = modifier.Value / 1000f;
|
||||
}
|
||||
else
|
||||
{
|
||||
displayValue = modifier.Value;
|
||||
}
|
||||
|
||||
public static string CreatePropDescription(StatModifier[] modifiers)
|
||||
return $"{name}: <color={colorTag}>+{displayValue:0.##}{suffix}</color>";
|
||||
}
|
||||
|
||||
public static string CreatePropDescription(IEnumerable<modifier> modifiers)
|
||||
{
|
||||
if (modifiers == null || modifiers.Length == 0)
|
||||
if (modifiers == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
foreach (StatModifier modifier in modifiers)
|
||||
foreach (modifier modifier in modifiers)
|
||||
{
|
||||
sb.Append(Describe(modifier));
|
||||
sb.Append('\n');
|
||||
@@ -71,15 +77,15 @@ namespace SepCore.CustomUtility
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static string CreateWeaponDescription(DRWeapon drWeapon)
|
||||
public static string CreateWeaponDescription(WeaponConfig weaponConfig)
|
||||
{
|
||||
if (drWeapon == null)
|
||||
if (weaponConfig == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return CreateWeaponDescription(drWeapon.Attack, drWeapon.Cooldown, drWeapon.AttackRange, drWeapon.Modifiers,
|
||||
drWeapon.Pramas);
|
||||
return CreateWeaponDescription(weaponConfig.Attack, weaponConfig.Cooldown / 1000f,
|
||||
weaponConfig.AttackRange / 1000f, weaponConfig.Modifiers, weaponConfig.Parameters);
|
||||
}
|
||||
|
||||
public static string CreateWeaponDescription(WeaponBase weapon)
|
||||
@@ -100,7 +106,7 @@ namespace SepCore.CustomUtility
|
||||
}
|
||||
|
||||
return CreateWeaponDescription(weaponData.Attack, weaponData.Cooldown,
|
||||
weaponData.AttackRange, weaponData.Modifiers, weaponData.Params);
|
||||
weaponData.AttackRange, weaponData.Modifiers, weaponData.Parameters);
|
||||
}
|
||||
|
||||
public static string CreatePropDescription(PropItem prop)
|
||||
@@ -114,7 +120,7 @@ namespace SepCore.CustomUtility
|
||||
}
|
||||
|
||||
private static string CreateWeaponDescription(int attack, float cooldown, float attackRange,
|
||||
StatModifier[] modifiers, Dictionary<string, string> @params)
|
||||
IEnumerable<modifier> modifiers, IReadOnlyDictionary<ParamType, int> parameters)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine($"攻击: {attack}");
|
||||
@@ -127,19 +133,23 @@ namespace SepCore.CustomUtility
|
||||
sb.Append(modifiersDesc);
|
||||
}
|
||||
|
||||
if (@params == null || @params.Count == 0)
|
||||
if (parameters == null || parameters.Count == 0)
|
||||
{
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
foreach (var kvp in @params)
|
||||
foreach (var kvp in parameters)
|
||||
{
|
||||
if (!_paramsDict.TryGetValue(kvp.Key, out string value))
|
||||
if (!_paramTypeNames.TryGetValue(kvp.Key, out string paramName))
|
||||
{
|
||||
value = kvp.Key;
|
||||
Log.Warning($"{kvp.Key} is not defined.");
|
||||
paramName = kvp.Key.ToString();
|
||||
}
|
||||
sb.AppendLine($"{value}: {kvp.Value}");
|
||||
|
||||
string valStr = kvp.Key == ParamType.SectorAngle
|
||||
? kvp.Value.ToString()
|
||||
: (kvp.Value / 1000f).ToString("0.##");
|
||||
|
||||
sb.AppendLine($"{paramName}: {valStr}");
|
||||
}
|
||||
|
||||
return sb.ToString();
|
||||
|
||||
Reference in New Issue
Block a user