示例#1
0
文件: Buff.cs 项目: pb0/ID0_Test
    public static Buff ToBuff(Stat stat)
    {
        var members = EnumTool.GetNames(stat.KeyType);
        Dictionary<Enum, float> values = new Dictionary<Enum, float>();
        for (int i = 1; true; i++)
        {
            string form1 = string.Format("Stat{0}Type", i);
            string form2 = string.Format("Stat{0}Value", i);
            if (members.Contains(form1) && members.Contains(form2))
            {
                Enum statType = stat.GetRawValue(EnumTool.Parse(stat.KeyType.Name, form1) as Enum) as Enum;
                float value = stat.Get(EnumTool.Parse(stat.KeyType.Name, form2) as Enum);
                if (statType.ToString() != "None")
                {
                    values.Add(statType, value);
                }
            }
            else
            {
                break;
            }
        }

        string name = stat.KeyType.ToString() + stat.Get(EnumTool.Parse(stat.KeyType, "ID") as Enum);
        float duration = float.MaxValue;
        return new Buff(name, duration, values);
    }