迁移数据表到 Luban,移除 JsonNet、EnumUtility
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SepCore.Definition
|
||||
{
|
||||
public sealed partial class modifier
|
||||
{
|
||||
public StatType StatType => Key;
|
||||
|
||||
/// <summary>
|
||||
/// 实际参与数值计算的浮点数值。
|
||||
/// 1. 百分比加成(IsPercent == true):表内千分比(如 200 代表 20%),转换为 0.2f。
|
||||
/// 2. 非百分比加成(IsPercent == false):移动速度原为 float 放大了 1000 倍(如 800 代表 0.8f),除以 1000f;其余(如生命+53、攻击+10)直接使用原值。
|
||||
/// </summary>
|
||||
public float RealValue
|
||||
{
|
||||
get
|
||||
{
|
||||
if (IsPercent)
|
||||
{
|
||||
return Value / 1000f;
|
||||
}
|
||||
|
||||
if (Key == StatType.MovementSpeed)
|
||||
{
|
||||
return Value / 1000f;
|
||||
}
|
||||
|
||||
return Value;
|
||||
}
|
||||
}
|
||||
|
||||
public modifier()
|
||||
{
|
||||
}
|
||||
|
||||
public modifier(StatType key, int value, bool isPercent)
|
||||
{
|
||||
Key = key;
|
||||
Value = value;
|
||||
IsPercent = isPercent;
|
||||
}
|
||||
|
||||
public modifier(StatType key, float value, bool isPercent)
|
||||
{
|
||||
Key = key;
|
||||
Value = (isPercent || key == StatType.MovementSpeed)
|
||||
? Mathf.RoundToInt(value * 1000f)
|
||||
: Mathf.RoundToInt(value);
|
||||
IsPercent = isPercent;
|
||||
}
|
||||
|
||||
public string ToDisplayString()
|
||||
{
|
||||
if (IsPercent)
|
||||
{
|
||||
float percent = Value / 10f;
|
||||
return $"{Key} +{percent:0.##}%";
|
||||
}
|
||||
|
||||
if (Key == StatType.MovementSpeed)
|
||||
{
|
||||
float speed = Value / 1000f;
|
||||
return $"{Key} +{speed:0.##}";
|
||||
}
|
||||
|
||||
return $"{Key} +{Value}";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user