示例#1
0
 public override bool InitWithJson(JsonData data)
 {
     foreach (string key in data.Keys)
     {
         if (key == CampsiteDataKey.ID)
         {
             id = (int)data[key];
         }
         else if (key == CampsiteDataKey.POINTS)
         {
             var subJsonArr = data[key];
             points = new CampsitePointData[subJsonArr.Count];
             for (int i = 0; i < subJsonArr.Count; i++)
             {
                 points[i] = new CampsitePointData();
                 points[i].InitWithJson(subJsonArr[i]);
             }
         }
         else if (key == CampsiteDataKey.TOTAL_REWARD_VAL)
         {
             totalRewardVal = (double)data[key];
         }
         else if (key == CampsiteDataKey.LAST_RECORD_TIME)
         {
             lastRecordTime = PTUtil.JsonData2DateTime(data[key]);
         }
         else if (key == CampsiteDataKey.HAS_OFFLINE_REWARD)
         {
             hasOfflineReward = (bool)data[key];
         }
     }
     return(true);
 }
示例#2
0
 public override bool InitWithJson(JsonData data)
 {
     foreach (string key in data.Keys)
     {
         if (key == ServerTimeDataKey.LOCAL_TIME_SPAN)
         {
             localTimeSpan = PTUtil.JsonData2Timestamp(data[key]);
         }
         else if (key == ServerTimeDataKey.REFRESH_TIME_ONE_DAY)
         {
             refreshTime_OneDay = PTUtil.JsonData2DateTime(data[key]);
         }
         else if (key == ServerTimeDataKey.REFRESH_TIME_TWO_DAY)
         {
             refreshTime_TwoDay = PTUtil.JsonData2DateTime(data[key]);
         }
         else if (key == ServerTimeDataKey.REFRESH_TIME_ONE_WEEK)
         {
             refreshTime_OneWeek = PTUtil.JsonData2DateTime(data[key]);
         }
     }
     return(true);
 }
示例#3
0
        public override bool InitWithJson(JsonData data)
        {
            foreach (string key in data.Keys)
            {
                if (key == PlayerDataKey.CUR_STAGE_ID)
                {
                    curStageID = (int)data[key];
                }
                else if (key == PlayerDataKey.CUR_GUIDE_ID)
                {
                    curGuideID = (int)data[key];
                }
                else if (key == PlayerDataKey.CUR_GUIDE_STAGE_INDEX)
                {
                    curGuideStageIndex = (int)data[key];
                }
                else if (key == PlayerDataKey.CUR_BOX_ID)
                {
                    curBoxID = (int)data[key];
                }
                else if (key == PlayerDataKey.MAX_UNLOCK_STAGE_ID)
                {
                    maxUnlockStageID = (int)data[key];
                }
                else if (key == PlayerDataKey.GUID)
                {
                    guid = Guid.Parse((string)data[key]);
                }
                else if (key == PlayerDataKey.CREATE_TIME)
                {
                    createTime = PTUtil.JsonData2DateTime(data[key]);
                }
                else if (key == PlayerDataKey.REFRESH_TIME)
                {
                    refreshTime = PTUtil.JsonData2DateTime(data[key]);
                }
                else if (key == PlayerDataKey.USE_WEAPON_ID)
                {
                    useWeaponID = (int)data[key];
                }
                else if (key == PlayerDataKey.LEVEL)
                {
                    level = (int)data[key];
                }
                else if (key == PlayerDataKey.BOXDRAWCOUNT)
                {
                    boxDrawCount = (int)data[key];
                }
                else if (key == PlayerDataKey.CURRENCY_DIAMOND)
                {
                    currencys[CurrencyType.DIAMOND] = (int)data[key];
                }
                else if (key == PlayerDataKey.CURRENCY_GOLD)
                {
                    BigInteger gold;
                    if (BigInteger.TryParse(data[key].ToString(), out gold))
                    {
                        bigCurrencys[CurrencyType.GOLD] = gold;
                    }
                }
                else if (key == PlayerDataKey.CURRENCY_KEY)
                {
                    currencys[CurrencyType.KEY] = (int)data[key];
                }
                else if (key == PlayerDataKey.STAGE_DATAS)
                {
                    var subJson = data[key];
                    for (int i = 0; i < subJson.Count; ++i)
                    {
                        var c = new StageData();
                        c.InitWithJson(subJson[i]);
                        stageDatas[c.stageID] = c;
                    }
                }
                else if (key == PlayerDataKey.CARD_DATAS)
                {
                    var subJson = data[key];
                    for (int i = 0; i < subJson.Count; ++i)
                    {
                        var c = new GunCardData();
                        c.InitWithJson(subJson[i]);
                        cardDatas[c.cardID] = c;
                    }
                }
                else if (key == PlayerDataKey.FUSED_CARD_LIST)
                {
                    var subJson = data[key];
                    for (int i = 0; i < subJson.Count; ++i)
                    {
                        fusedCardList.Add((int)subJson[i]);
                    }
                }
                else if (key == PlayerDataKey.SERVER_TIME_DATA)
                {
                    serverTimeData = new ServerTimeData();
                    serverTimeData.InitWithJson(data[key]);
                }
                else if (key == PlayerDataKey.CAMPTASKDATA)
                {
                    campTaskData.InitWithJson(data[key]);
                }
                else if (key == PlayerDataKey.CAMPSITEDATA)
                {
                    campsiteData = new CampsiteData();
                    campsiteData.InitWithJson(data[key]);
                }
                else if (key == PlayerDataKey.IDLE_REWARD_DATA)
                {
                    idleRewardData.InitWithJson(data[key]);
                }
                else if (key == PlayerDataKey.SHOP_DATA)
                {
                    shopData.InitWithJson(data[key]);
                }
                else if (key == PlayerDataKey.CHAPTERDATA)
                {
                    chapterData.InitWithJson(data[key]);
                }
                else if (key == PlayerDataKey.BOXDRAWDIC)
                {
                    boxDrawDic.Clear();
                    var boxDrawDicJson = data[key];
                    foreach (var idStr in boxDrawDicJson.Keys)
                    {
                        int boxID;
                        if (int.TryParse(idStr, out boxID))
                        {
                            boxDrawDic[boxID] = (int)boxDrawDicJson[idStr];
                        }
                    }
                }
                else if (key == PlayerDataKey.OPEN_MODULES)
                {
                    openModules.Clear();
                    var subJson = data[key];
                    if (subJson.IsArray)
                    {
                        for (int i = 0; i < subJson.Count; i++)
                        {
                            openModules.Add((int)subJson[i]);
                        }
                    }
                }
                else if (key == PlayerDataKey.FINISH_DIALOGUE_LIST)
                {
                    finishDialogueList.Clear();
                    var subJson = data[key];
                    if (subJson.IsArray)
                    {
                        for (int i = 0; i < subJson.Count; i++)
                        {
                            finishDialogueList.Add((int)subJson[i]);
                        }
                    }
                }
            }

            return(true);
        }