Пример #1
0
 public bool Deserialize(JSON_TrophyParam json)
 {
     if (json == null)
     {
         return(false);
     }
     if (json.flg_quests == null)
     {
         this.RequiredTrophies = new string[0];
     }
     else
     {
         this.RequiredTrophies = new string[json.flg_quests.Length];
         for (int index = 0; index < json.flg_quests.Length; ++index)
         {
             this.RequiredTrophies[index] = json.flg_quests[index];
         }
     }
     this.Objectives = new TrophyObjective[1];
     for (int index = 0; index < 1; ++index)
     {
         this.Objectives[index]       = new TrophyObjective();
         this.Objectives[index].Param = this;
         this.Objectives[index].index = index;
         this.Objectives[index].type  = (TrophyConditionTypes)json.type;
         this.Objectives[index].ival  = json.ival;
         if (json.sval != null)
         {
             this.Objectives[index].sval = new List <string>((IEnumerable <string>)json.sval);
         }
     }
     this.iname        = json.iname;
     this.Name         = json.name;
     this.Expr         = json.expr;
     this.Gold         = json.reward_gold;
     this.Coin         = json.reward_coin;
     this.Exp          = json.reward_exp;
     this.Stamina      = json.reward_stamina;
     this.ParentTrophy = json.parent_iname;
     this.help         = json.help;
     if (!string.IsNullOrEmpty(json.category))
     {
         this.category_hash_code    = json.category.GetHashCode();
         this.is_none_category_hash = false;
     }
     this.Category     = json.category;
     this.DispType     = (TrophyDispType)json.disp;
     this.Items        = TrophyParam.InitializeItems(json);
     this.Artifacts    = TrophyParam.InitializeArtifacts(json);
     this.ConceptCards = TrophyParam.InitializeConceptCards(json);
     return(true);
 }
Пример #2
0
        public bool Deserialize(JSON_TrophyParam json)
        {
            if (json == null || json.objective == null)
            {
                return(false);
            }
            if (json.flg_quests == null)
            {
                this.RequiredTrophies = new string[0];
            }
            else
            {
                this.RequiredTrophies = new string[json.flg_quests.Length];
                for (int index = 0; index < json.flg_quests.Length; ++index)
                {
                    this.RequiredTrophies[index] = json.flg_quests[index];
                }
            }
            this.Objectives = new TrophyObjective[json.objective.Length];
            for (int index = 0; index < json.objective.Length; ++index)
            {
                this.Objectives[index]       = new TrophyObjective();
                this.Objectives[index].Param = this;
                this.Objectives[index].index = index;
                if (!this.Objectives[index].Deserialize(json.objective[index]))
                {
                    return(false);
                }
            }
            this.iname    = json.iname;
            this.begin_at = json.begin_at;
            this.end_at   = json.end_at;
            this.Name     = json.name;
            this.Expr     = json.expr;
            this.Gold     = json.reward_gold;
            this.Coin     = json.reward_coin;
            this.Exp      = json.reward_exp;
            this.Stamina  = json.reward_stamina;
            this.Days     = json.day_reset & 1;
            this.ConvertDayRepeat(json.day_reset);
            this.Beginner     = json.bgnr;
            this.ParentTrophy = json.parent_iname;
            this.help         = json.help;
            this.Category     = json.category == 0 ? TrophyCategorys.Other : (TrophyCategorys)json.category;
            this.DispType     = (TrophyDispType)json.disp;
            int length = 0;

            if (!string.IsNullOrEmpty(json.reward_item1_iname) && json.reward_item1_num > 0)
            {
                ++length;
            }
            if (!string.IsNullOrEmpty(json.reward_item2_iname) && json.reward_item2_num > 0)
            {
                ++length;
            }
            if (!string.IsNullOrEmpty(json.reward_item3_iname) && json.reward_item3_num > 0)
            {
                ++length;
            }
            this.Items = new TrophyParam.RewardItem[length];
            int index1 = 0;

            if (!string.IsNullOrEmpty(json.reward_item1_iname) && json.reward_item1_num > 0)
            {
                this.Items[index1].iname = json.reward_item1_iname;
                this.Items[index1].Num   = json.reward_item1_num;
                ++index1;
            }
            if (!string.IsNullOrEmpty(json.reward_item2_iname) && json.reward_item2_num > 0)
            {
                this.Items[index1].iname = json.reward_item2_iname;
                this.Items[index1].Num   = json.reward_item2_num;
                ++index1;
            }
            if (!string.IsNullOrEmpty(json.reward_item3_iname) && json.reward_item3_num > 0)
            {
                this.Items[index1].iname = json.reward_item3_iname;
                this.Items[index1].Num   = json.reward_item3_num;
                int num = index1 + 1;
            }
            return(true);
        }