using System; using SepCore.Definition; using SepCore.CustomUtility; using UnityGameFramework.Runtime; namespace SepCore.Definition { public class StatModifier { public StatType StatType; public float Value; public bool IsPercent; 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.Get(property[propertyIndex++]), Value = float.Parse(property[propertyIndex++]), IsPercent = bool.Parse(property[propertyIndex++]) }; } } }