Ejemplo n.º 1
0
        public virtual void LoadFromKeyValues(KeyValue kv)
        {
            PropertyInfo[] properties = this.GetType().GetProperties();

            ClassName = kv.Key;

            foreach(PropertyInfo info in properties)
            {
                if (info.Name == "ClassName") continue;
                if (info.Name == "WasModified") continue;

                KeyValue subkey = kv[info.Name];
                if (subkey == null)
                {
                    continue;
                }
                if (subkey.HasChildren) continue; //TODO parse children because this is AbilitySpecial

                object data = null;
                if(info.PropertyType == typeof(int))
                {
                    data = subkey.GetInt();
                }
                if(info.PropertyType == typeof(float))
                {
                    data = subkey.GetFloat();
                }
                if(info.PropertyType == typeof(bool))
                {
                    data = subkey.GetBool();
                }
                if(info.PropertyType == typeof(string))
                {
                    data = subkey.GetString();
                }
                if (typeof(Enum).IsAssignableFrom(info.PropertyType) && subkey.GetString() != "")
                {
                    if (info.PropertyType.GetCustomAttribute(typeof(FlagsAttribute)) != null)
                    {
                        string[] flags = subkey.GetString().Replace(" ", "").Split('|').Where(x => x != "").ToArray();
                        string p = String.Join(", ", flags);

                        data = Enum.Parse(info.PropertyType, p);
                    }
                    else
                    {
                        data = Enum.Parse(info.PropertyType, subkey.GetString());
                    }
                }
                if (info.PropertyType == typeof(PerLevel))
                {
                    data = new PerLevel(subkey.GetString().Trim());
                }
                if(data != null) info.SetMethod.Invoke(this, new object[] { data });

            }
        }
Ejemplo n.º 2
0
 public PerLevelPropertyDescriptor(PerLevel data, int index)
     : base("#" + index.ToString(), null)
 {
     this.item = data;
     this.index = index;
 }
Ejemplo n.º 3
0
 public PerLevelPropertyDescriptor(PerLevel data, int index)
     : base("#" + index.ToString(), null)
 {
     this.item  = data;
     this.index = index;
 }