Esempio n. 1
0
    private void SetField(string key, string value)
    {
        PropertyInfo propertyInfo = this.GetType().GetProperty(key, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

        if (propertyInfo == null)
        {
            return;
        }

        if (propertyInfo.PropertyType == typeof(int))
        {
            propertyInfo.SetValue(this, int.Parse(value), null);
        }
        else if (propertyInfo.PropertyType == typeof(string))
        {
            propertyInfo.SetValue(this, value, null);
        }
        else if (propertyInfo.PropertyType == typeof(double))
        {
            propertyInfo.SetValue(this, double.Parse(value), null);
        }
        else if (propertyInfo.PropertyType == typeof(bool))
        {
            propertyInfo.SetValue(this, bool.Parse(value), null);
        }
        else if (propertyInfo.PropertyType == typeof(Attribute))
        {
            propertyInfo.SetValue(this, AttributeExtension.ToEnum(value), null);
        }
        else if (propertyInfo.PropertyType == typeof(Target))
        {
            propertyInfo.SetValue(this, TargetExtension.ToEnum(value), null);
        }
        else if (propertyInfo.PropertyType == typeof(Tribe))
        {
            propertyInfo.SetValue(this, TribeExtension.ToEnum(value), null);
        }
        else if (propertyInfo.PropertyType == typeof(EnemyTribe))
        {
            propertyInfo.SetValue(this, EnemyTribeExtension.ToEnum(value), null);
        }
        else if (propertyInfo.PropertyType == typeof(Job))
        {
            propertyInfo.SetValue(this, JobExtension.ToEnum(value), null);
        }
        else if (propertyInfo.PropertyType == typeof(WeaponType))
        {
            propertyInfo.SetValue(this, WeaponTypeExtension.ToEnum(value), null);
        }
        else if (propertyInfo.PropertyType == typeof(SelectType))
        {
            propertyInfo.SetValue(this, SelectTypeExtension.ToEnum(value), null);
        }
        // 他の型にも対応させたいときには適当にここに。enumとかもどうにかなりそう。
    }
Esempio n. 2
0
        static Equipment Create(JSONObject obj)
        {
            var equipment = new Equipment(
                (int)obj.GetField("code").i,
                (int)obj.GetField("lv").i,
                obj.GetField("name").str,
                (int)obj.GetField("strong").i,
                (int)obj.GetField("intelligence").i,
                (int)obj.GetField("mystery").i,
                (int)obj.GetField("agile").i,
                (int)obj.GetField("vital").i,
                (int)obj.GetField("luck").i,
                AttributeExtension.ToEnum(obj.GetField("attribute").str),
                TribeExtension.ToEnum(obj.GetField("regist_tribe_1").str),
                TribeExtension.ToEnum(obj.GetField("regist_tribe_2").str),
                TribeExtension.ToEnum(obj.GetField("regist_tribe_3").str)
                );

            return(equipment);
        }