コード例 #1
0
        public override IBaseData Create(string jsonString_)
        {
            //first override all simple type fields...
            PeriodImpactData data = DefaultJsonFactory.Create <PeriodImpactData>(jsonString_);

            //...and then more complex fields
            JSONObject jo = new JSONObject(jsonString_);

            //IMPACTS
            JSONObject arrayJo = jo["impact"];

            if (arrayJo != null)
            {
                int cnt = arrayJo.list.Count;
                data.impactInfos = new ImpactInfo[cnt];
                for (int i = 0; i < cnt; i++)
                {
                    ImpactInfo info = //JsonFactory.Instance.Create<ImpactInfo>(arrayJo.list[i].ToString());
                                      JsonUtility.FromJson <ImpactInfo>(arrayJo.list[i].ToString());
                    data.impactInfos[i] = info;
                }
            }
            //targetTypes
            data.targetTypes = GetStringArray(jo, "targetTypes");

            return(data);
        }
コード例 #2
0
        public override IBaseData Create(string jsonString_)
        {
            //first override all simple type fields...
            EnemyData data = DefaultJsonFactory.Create <EnemyData>(jsonString_);
            //...and then more complex fields
            JSONObject jo = new JSONObject(jsonString_);
            //SKILLS
            JSONObject arrayJo = jo["skills"];

            if (arrayJo != null)
            {
                int cnt = arrayJo.list.Count;
                data.skillInfos = new SkillInfo[cnt];
                for (int i = 0; i < cnt; i++)
                {
                    SkillInfo skillInfo = new SkillInfo();
                    JsonUtility.FromJsonOverwrite(arrayJo.list[i].ToString(), skillInfo);
                    data.skillInfos[i] = skillInfo;
                }
            }
            //BONUSES
            data.bonusIds = GetStringArray(jo, "bonusIds");
            //
            return(data);
        }
コード例 #3
0
        public override IBaseData Create(string jsonString_)
        {
            //first override all simple type fields...
            BehaviourImpactData data = DefaultJsonFactory.Create <BehaviourImpactData>(jsonString_);
            //...and then more complex fields
            JSONObject jo = new JSONObject(jsonString_);

            //targetTypes
            data.targetTypes = GetStringArray(jo, "targetTypes");
            return(data);
        }
コード例 #4
0
 public T Create <T>(string jsonString_) where T : IBaseData, new()
 {
     if (_factories.ContainsKey(typeof(T)))
     {
         return((T)_factories[typeof(T)].Create(jsonString_));
     }
     else
     {
         return(DefaultJsonFactory.Create <T>(jsonString_));
     }
 }
コード例 #5
0
        public override IBaseData Create(string jsonString_)
        {
            //first override all simple type fields...
            SkillImpactData data = DefaultJsonFactory.Create <SkillImpactData>(jsonString_);

            //...and then more complex fields
            JSONObject jo = new JSONObject(jsonString_);

            //skills
            data.skills = GetStringArray(jo, "skills");
            //strategy
            JSONObject strategy = jo["strategy"];

            if (strategy != null)
            {
                data.strategy = SkillModifyStrategy.Get(strategy.str);
            }
            //targetTypes
            data.targetTypes = GetStringArray(jo, "targetTypes");
            return(data);
        }
コード例 #6
0
        public override IBaseData Create(string jsonString_)
        {
            //first override all simple type fields...
            BulletData data = DefaultJsonFactory.Create <BulletData>(jsonString_);
            //...and then more complex fields
            JSONObject jo = new JSONObject(jsonString_);
            //IMPACTS
            JSONObject arrayJo = jo["impact"];

            if (arrayJo != null)
            {
                int cnt = arrayJo.list.Count;
                data.impactInfos = new ImpactInfo[cnt];
                for (int i = 0; i < cnt; i++)
                {
                    ImpactInfo impactInfo = new ImpactInfo();
                    JsonUtility.FromJsonOverwrite(arrayJo.list[i].ToString(), impactInfo);
                    data.impactInfos[i] = impactInfo;
                }
            }

            return(data);
        }