第一批重构,主要是物理迁移脚本和部分命名空间的调整
- 结构上迁移文件,将脚本分成 Base/Runtime/Presentation/Procedure/Editor 五大文件夹 - 调整 DataTable 和 Definition 下脚本的命名空间 - 依据 UI-5层架构设计规范 拆分原先的 UI 到 Runtime 和 Presentation 下
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
using System;
|
||||
using SepCore.Definition;
|
||||
using CustomUtility;
|
||||
using UnityGameFramework.Runtime;
|
||||
|
||||
namespace SepCore.Definition
|
||||
{
|
||||
public class StatModifier
|
||||
{
|
||||
// None = 0,
|
||||
// MaxHealth = 1,
|
||||
// MovementSpeed = 2,
|
||||
// Attack = 3,
|
||||
// Defense = 4,
|
||||
// AttackSpeed = 5,
|
||||
// Critical = 6,
|
||||
// CriticalDamage = 7,
|
||||
// Dodge = 8,
|
||||
// AbsorbRange = 9
|
||||
|
||||
private readonly string[] _statTypeNames =
|
||||
{
|
||||
"无效",
|
||||
"最大生命",
|
||||
"移动速度",
|
||||
"伤害",
|
||||
"防御",
|
||||
"冷却",
|
||||
"暴击率",
|
||||
"暴击伤害",
|
||||
"闪避",
|
||||
"金币/经验吸收范围"
|
||||
};
|
||||
|
||||
public StatType StatType;
|
||||
public float Value;
|
||||
public bool IsPercent;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
if (IsPercent)
|
||||
{
|
||||
if (Value > 0)
|
||||
{
|
||||
return $"{_statTypeNames[(int)StatType]}: <color=green>+{Value * 100}%</color>";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"{_statTypeNames[(int)StatType]}: <color=red>+{Value * 100}%</color>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Value > 0)
|
||||
{
|
||||
return $"{_statTypeNames[(int)StatType]}: <color=green>+{Value}</color>";
|
||||
}
|
||||
else
|
||||
{
|
||||
return $"{_statTypeNames[(int)StatType]}: <color=red>+{Value}</color>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static StatModifier StringToModifier(string input)
|
||||
{
|
||||
if (string.IsNullOrEmpty(input))
|
||||
{
|
||||
Log.Warning("Invalid modifier: {0}", input);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!input.StartsWith('[') || !input.EndsWith(']'))
|
||||
{
|
||||
throw new ArgumentException("Input must be enclosed in square brackets.");
|
||||
}
|
||||
|
||||
string inner = input.Substring(1, input.Length - 2);
|
||||
|
||||
// 如果是空列表 "[]"
|
||||
if (inner.Length == 0) return null;
|
||||
|
||||
string[] property = inner.Split(",");
|
||||
int propertyIndex = 0;
|
||||
return new StatModifier
|
||||
{
|
||||
StatType = EnumUtility<StatType>.Get(property[propertyIndex++]),
|
||||
Value = float.Parse(property[propertyIndex++]),
|
||||
IsPercent = bool.Parse(property[propertyIndex++])
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user