Esempio n. 1
0
        public override JsonData GetJsonData()
        {
            JsonData ret = new JsonData()
            {
                [PlayerDataKey.GUID]                  = guid.ToString(),
                [PlayerDataKey.CREATE_TIME]           = PTUtil.DateTime2Timestamp(createTime),
                [PlayerDataKey.REFRESH_TIME]          = PTUtil.DateTime2Timestamp(refreshTime),
                [PlayerDataKey.CUR_GUIDE_ID]          = curGuideID,
                [PlayerDataKey.CUR_STAGE_ID]          = curStageID,
                [PlayerDataKey.MAX_UNLOCK_STAGE_ID]   = maxUnlockStageID,
                [PlayerDataKey.CUR_GUIDE_STAGE_INDEX] = curGuideStageIndex,
                [PlayerDataKey.CUR_BOX_ID]            = curBoxID,
                [PlayerDataKey.USE_WEAPON_ID]         = useWeaponID,
                [PlayerDataKey.CURRENCY_DIAMOND]      = currencys[CurrencyType.DIAMOND],
                [PlayerDataKey.CURRENCY_GOLD]         = bigCurrencys[CurrencyType.GOLD].ToString(),
                [PlayerDataKey.CURRENCY_KEY]          = currencys[CurrencyType.KEY],
                [PlayerDataKey.BOXDRAWCOUNT]          = boxDrawCount,
                [PlayerDataKey.LEVEL]                 = level,

                [PlayerDataKey.CAMPTASKDATA]     = campTaskData.GetJsonData(),
                [PlayerDataKey.IDLE_REWARD_DATA] = idleRewardData.GetJsonData(),

                [PlayerDataKey.SHOP_DATA]   = shopData.GetJsonData(),
                [PlayerDataKey.CHAPTERDATA] = chapterData.GetJsonData(),
            };

            if (serverTimeData != null)
            {
                ret[PlayerDataKey.SERVER_TIME_DATA] = serverTimeData.GetJsonData();
            }
            //JsonData currencysJson = new JsonData();
            //currencysJson.SetJsonType(JsonType.Array);
            //foreach (var key in currencys.Keys)
            //{
            //    currencysJson[key.ToString()] = currencys[key];
            //}
            //ret[PlayerDataKey.CURRENCYS] = currencysJson;

            //JsonData currencyRegtimesJson = new JsonData();
            //currencyRegtimesJson.SetJsonType(JsonType.Array);
            //foreach (var key in currencyRegtimes.Keys)
            //{
            //    currencyRegtimesJson[key.ToString()] = currencyRegtimes[key].ToString();
            //}
            //ret[PlayerDataKey.CURRENCY_REGTIMES] = currencyRegtimesJson;

            JsonData stageDatasJson = new JsonData();

            stageDatasJson.SetJsonType(JsonType.Array);
            foreach (var key in stageDatas.Keys)
            {
                stageDatasJson.Add(stageDatas[key].GetJsonData());
            }
            ret[PlayerDataKey.STAGE_DATAS] = stageDatasJson;

            JsonData cardDatasJson = new JsonData();

            cardDatasJson.SetJsonType(JsonType.Array);
            foreach (var key in cardDatas.Keys)
            {
                cardDatasJson.Add(cardDatas[key].GetJsonData());
            }
            ret[PlayerDataKey.CARD_DATAS] = cardDatasJson;

            JsonData fusedCardListJson = new JsonData();

            fusedCardListJson.SetJsonType(JsonType.Array);
            foreach (var value in fusedCardList)
            {
                fusedCardListJson.Add(value);
            }
            ret[PlayerDataKey.FUSED_CARD_LIST] = fusedCardListJson;

            if (campsiteData != null)
            {
                ret[PlayerDataKey.CAMPSITEDATA] = campsiteData.GetJsonData();
            }

            if (boxDrawDic.Count > 0)
            {
                JsonData boxDrawDicJson = new JsonData();
                //stageDatasJson.SetJsonType(JsonType.Array);
                foreach (var item in boxDrawDic)
                {
                    boxDrawDicJson[item.Key.ToString()] = item.Value;
                }

                ret[PlayerDataKey.BOXDRAWDIC] = boxDrawDicJson;
            }

            if (openModules.Count > 0)
            {
                JsonData openModulesJson = new JsonData();
                openModulesJson.SetJsonType(JsonType.Array);
                for (int i = 0; i < openModules.Count; i++)
                {
                    openModulesJson.Add(openModules[i]);
                }
                ret[PlayerDataKey.OPEN_MODULES] = openModulesJson;
            }

            if (finishDialogueList.Count > 0)
            {
                JsonData finishDialogueListJson = new JsonData();
                finishDialogueListJson.SetJsonType(JsonType.Array);
                for (int i = 0; i < finishDialogueList.Count; i++)
                {
                    finishDialogueListJson.Add(finishDialogueList[i]);
                }
                ret[PlayerDataKey.FINISH_DIALOGUE_LIST] = finishDialogueListJson;
            }

            return(ret);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        private void ShowCardInfo()
        {
            NameTxt.text.text    = LanguageMgr.GetText(gunCardRes.tid_name);;
            RarityTxt.text.text  = TableMgr.singleton.ValueTable.GetQualityName(gunCardRes.rarity);
            IconBtn.image.sprite = Resources.Load(gunCardRes.icon, typeof(Sprite)) as Sprite;
            Frame.image.sprite   = Resources.Load(TableMgr.singleton.ValueTable.GetCardQualityFrame(gunCardRes.rarity),
                                                  typeof(Sprite)) as Sprite;

            var gunTypeRes = TableMgr.singleton.GunTypeTable.GetItemByID(gunCardRes.gunType);

            if (gunTypeRes == null)
            {
                return;
            }

            TypeTxt.text.text     = LanguageMgr.GetText(gunTypeRes.tid_type);
            TypeIcon.image.sprite = Resources.Load(gunTypeRes.icon, typeof(Sprite)) as Sprite;

            cardData = PlayerDataMgr.singleton.GetGunCardData(gunCardRes.id);
            if (cardData == null)
            {
                return;
            }

            ChipCount.text.text = cardData.count.ToString();

            var gunStarRes = TableMgr.singleton.CardStarTable.GetItemByID(cardData.star);

            if (gunStarRes == null)
            {
                return;
            }

            if (cardData.level >= gunStarRes.maxLevel)
            {
                LevelTxt.text.text = string.Format("Lv.{0}(Max)", cardData.level);
            }
            else
            {
                LevelTxt.text.text = string.Format("Lv.{0}/{1}", cardData.level, gunStarRes.maxLevel);
            }
            if (cardData.level <= 1)
            {
                ResetBtn.gameObject.SetActive(false);
            }
            else
            {
                ResetBtn.gameObject.SetActive(true);
            }

            for (int i = 0; i < starList.Count; ++i)
            {
                if (i < gunStarRes.star)
                {
                    starList[i].SetActive(true);
                }
                else
                {
                    starList[i].SetActive(false);
                }
            }

            var maxStar = PlayerDataMgr.GetCardMaxStarCount(gunCardRes.rarity, gunStarRes.starRarity);

            for (int i = 0; i < starFrameList.Count; ++i)
            {
                if (i < maxStar)
                {
                    starFrameList[i].SetActive(true);
                }
                else
                {
                    starFrameList[i].SetActive(false);
                }
            }

            if (cardData.star >= PlayerDataMgr.GetCardMaxStar(gunCardRes.rarity))
            {
                StarUpBtn.gameObject.SetActive(false);
            }
            else
            {
                StarUpBtn.gameObject.SetActive(true);
                if (PlayerDataMgr.singleton.CanCardStarUp(gunCardRes.id))
                {
                    RedPoint.gameObject.SetActive(true);
                }
                else
                {
                    RedPoint.gameObject.SetActive(false);
                }
            }

            CurAtk.text.text = ((int)cardData.GetAtk()).ToString();
            //NextAtk.text.text = cardData.GetAtk(cardData.level + 1, cardData.star).ToString();
            CurAtkSpeed.text.text = cardData.GetAtkSpeed().ToString();
            //NextAtkSpeed.text.text = cardData.GetAtkSpeed(cardData.level + 1, cardData.star).ToString();

            ProductionBonus.text.text = cardData.GetCampRewardFactor().ToString();
            FirePower.text.text       = (cardData.DPS() / TableMgr.singleton.ValueTable.combat_capability).ToString("f0");

            var fuseSkillRes = TableMgr.singleton.FuseGunSkillTable.GetItemByID(cardData.fuseSkillID);

            if (fuseSkillRes == null)
            {
                return;
            }

            FuseSkillName.text.text  = LanguageMgr.GetText(fuseSkillRes.tid_name);
            FuseSkillLevel.text.text = string.Format("Lv.{0}", fuseSkillRes.level);

            var campSkillRes = TableMgr.singleton.CampGunSkillTable.GetItemByID(cardData.campSkillID);

            if (campSkillRes == null)
            {
                return;
            }

            CampSkillName.text.text  = LanguageMgr.GetText(campSkillRes.tid_name);
            CampSkillLevel.text.text = string.Format("Lv.{0}", campSkillRes.level);

            LvUpCost.text.text = PlayerDataMgr.singleton.GetCardLvUpCost(cardData.level + 1).ToSymbolString();
            var offset = -(PTUtil.CalculateLengthOfText(LvUpCost.text.text, LvUpCost.text)) / 2;

            if (offset < -80)
            {
                offset = -80;
            }
            GoldIcon.rectTransform.localPosition = new Vector3(offset, 0.0f, 0.0f);
        }