Beispiel #1
0
        private void Deserialize(Json_TrophyConceptCards json)
        {
            if (json == null)
            {
                return;
            }
            if (json.mail != null && json.mail.Length > 0)
            {
                RewardData rewardData = GlobalVars.LastReward.Get();
                if (rewardData != null)
                {
                    rewardData.IsOverLimit = true;
                }
                foreach (Json_TrophyConceptCard trophyConceptCard in json.mail)
                {
                    if (!string.IsNullOrEmpty(trophyConceptCard.unit))
                    {
                        if (rewardData != null)
                        {
                            ItemParam itemParam = MonoSingleton <GameManager> .Instance.MasterParam.GetItemParam(trophyConceptCard.unit);

                            rewardData.AddReward(itemParam, 1);
                        }
                        FlowNode_ConceptCardGetUnit.AddConceptCardData(ConceptCardData.CreateConceptCardDataForDisplay(trophyConceptCard.iname));
                    }
                }
            }
            if (json.direct == null)
            {
                return;
            }
            RewardData rewardData1 = GlobalVars.LastReward.Get();

            foreach (Json_TrophyConceptCard trophyConceptCard in json.direct)
            {
                GlobalVars.IsDirtyConceptCardData.Set(true);
                if (!string.IsNullOrEmpty(trophyConceptCard.unit))
                {
                    if (rewardData1 != null)
                    {
                        ItemParam itemParam = MonoSingleton <GameManager> .Instance.MasterParam.GetItemParam(trophyConceptCard.unit);

                        rewardData1.AddReward(itemParam, 1);
                    }
                    FlowNode_ConceptCardGetUnit.AddConceptCardData(ConceptCardData.CreateConceptCardDataForDisplay(trophyConceptCard.iname));
                }
            }
        }
        public override void OnSuccess(WWWResult www)
        {
            if (Network.IsError)
            {
                switch (Network.ErrCode)
                {
                case Network.EErrCode.ShopSoldOut:
                case Network.EErrCode.ShopBuyCostShort:
                case Network.EErrCode.ShopBuyLvShort:
                case Network.EErrCode.ShopBuyNotFound:
                case Network.EErrCode.ShopBuyItemNotFound:
                    this.OnBack();
                    break;

                case Network.EErrCode.ShopRefreshItemList:
                    UIUtility.SystemMessage((string)null, Network.ErrMsg, (UIUtility.DialogResultEvent)(go => this.ActivateOutputLinks(121)), (GameObject)null, false, -1);
                    ((Behaviour)this).set_enabled(false);
                    Network.RemoveAPI();
                    Network.ResetError();
                    break;

                case Network.EErrCode.ShopBuyOutofItemPeriod:
                    UIUtility.SystemMessage((string)null, Network.ErrMsg, (UIUtility.DialogResultEvent)(go => this.ActivateOutputLinks(120)), (GameObject)null, false, -1);
                    ((Behaviour)this).set_enabled(false);
                    Network.RemoveAPI();
                    Network.ResetError();
                    break;

                case Network.EErrCode.ShopBuyOutofPeriod:
                    UIUtility.SystemMessage((string)null, Network.ErrMsg, (UIUtility.DialogResultEvent)(go => this.ActivateOutputLinks(122)), (GameObject)null, false, -1);
                    ((Behaviour)this).set_enabled(false);
                    Network.RemoveAPI();
                    Network.ResetError();
                    break;

                default:
                    this.OnRetry();
                    break;
                }
            }
            else
            {
                WebAPI.JSON_BodyResponse <Json_ShopBuyResponse> jsonObject = JSONParser.parseJSONObject <WebAPI.JSON_BodyResponse <Json_ShopBuyResponse> >(www.text);
                DebugUtility.Assert(jsonObject != null, "res == null");
                if (jsonObject.body == null)
                {
                    this.OnRetry();
                }
                else
                {
                    Network.RemoveAPI();
                    ShopData shop = MonoSingleton <GameManager> .Instance.Player.GetShopData(this.mShopType) ?? new ShopData();

                    if (!shop.Deserialize(jsonObject.body))
                    {
                        this.OnFailed();
                    }
                    else
                    {
                        MonoSingleton <GameManager> .Instance.Player.SetShopData(this.mShopType, shop);

                        if (jsonObject.body.cards != null && jsonObject.body.cards.Length > 0)
                        {
                            GlobalVars.IsDirtyConceptCardData.Set(true);
                            Json_ShopBuyConceptCard[] cards = jsonObject.body.cards;
                            for (int index = 0; index < cards.Length; ++index)
                            {
                                if (cards[index] != null && cards[index].IsGetConceptCardUnit)
                                {
                                    FlowNode_ConceptCardGetUnit.AddConceptCardData(ConceptCardData.CreateConceptCardDataForDisplay(cards[index].iname));
                                }
                            }
                        }
                        ShopParam shopParam = MonoSingleton <GameManager> .Instance.MasterParam.GetShopParam(this.mShopType);

                        if (shopParam != null)
                        {
                            PlayerData player   = MonoSingleton <GameManager> .Instance.Player;
                            ShopItem   shopItem = shop.items.FirstOrDefault <ShopItem>((Func <ShopItem, bool>)(item => item.id == GlobalVars.ShopBuyIndex));
                            string     iname    = shopItem.iname;
                            if (shopItem.isSetSaleValue)
                            {
                                MyMetaps.TrackSpendShop(shopItem.saleType, this.mShopType, shopItem.saleValue);
                            }
                            else
                            {
                                int num = !shopItem.IsArtifact ? (!shopItem.IsConceptCard ? MonoSingleton <GameManager> .Instance.GetItemParam(shopItem.iname).GetBuyNum(shopItem.saleType) * shopItem.num : shopItem.saleValue) : MonoSingleton <GameManager> .Instance.MasterParam.GetArtifactParam(shopItem.iname).GetBuyNum(shopItem.saleType) * shopItem.num;

                                if (num > 0)
                                {
                                    MyMetaps.TrackSpendShop(shopItem.saleType, this.mShopType, num);
                                }
                            }
                            player.OnBuyAtShop(shopParam.iname, iname, shopItem.num);
                        }
                        this.Success();
                    }
                }
            }
        }
Beispiel #3
0
        public override void OnSuccess(WWWResult www)
        {
            if (Network.IsError)
            {
                GlobalVars.UnitGetReward = (UnitGetParam)null;
                switch (Network.ErrCode)
                {
                case Network.EErrCode.NoMail:
                    this.OnBack();
                    break;

                case Network.EErrCode.MailReadable:
                    this.OnBack();
                    break;

                case Network.EErrCode.Gift_ConceptCardBoxLimit:
                    this.OnBack();
                    break;

                default:
                    this.OnRetry();
                    break;
                }
            }
            else
            {
                WebAPI.JSON_BodyResponse <FlowNode_ReadMail2.Json_MailRead> jsonObject = JSONParser.parseJSONObject <WebAPI.JSON_BodyResponse <FlowNode_ReadMail2.Json_MailRead> >(www.text);
                DebugUtility.Assert(jsonObject != null, "res == null");
                Network.RemoveAPI();
                try
                {
                    MonoSingleton <GameManager> .Instance.Deserialize(jsonObject.body.player);

                    MonoSingleton <GameManager> .Instance.Deserialize(jsonObject.body.items);

                    MonoSingleton <GameManager> .Instance.Deserialize(jsonObject.body.units);

                    MonoSingleton <GameManager> .Instance.Player.Deserialize(jsonObject.body.mails);

                    if (jsonObject.body.artifacts != null)
                    {
                        MonoSingleton <GameManager> .Instance.Deserialize(jsonObject.body.artifacts, true);
                    }
                    if (jsonObject.body.mails != null)
                    {
                        GlobalVars.ConceptCardNum.Set(jsonObject.body.mails.concept_count);
                    }
                    if (jsonObject.body.processed != null)
                    {
                        if (jsonObject.body.processed.Length > 0)
                        {
                            MailData[] mail_datas = new MailData[jsonObject.body.processed.Length];
                            for (int index1 = 0; index1 < mail_datas.Length; ++index1)
                            {
                                mail_datas[index1] = new MailData();
                                mail_datas[index1].Deserialize(jsonObject.body.processed[index1]);
                                if (mail_datas[index1].Contains(GiftTypes.ConceptCard))
                                {
                                    GlobalVars.IsDirtyConceptCardData.Set(true);
                                    for (int index2 = 0; index2 < mail_datas[index1].gifts.Length; ++index2)
                                    {
                                        string conceptCardIname = mail_datas[index1].gifts[index2].ConceptCardIname;
                                        if (mail_datas[index1].gifts[index2].IsGetConceptCardUnit)
                                        {
                                            FlowNode_ConceptCardGetUnit.AddConceptCardData(ConceptCardData.CreateConceptCardDataForDisplay(conceptCardIname));
                                        }
                                    }
                                }
                            }
                            this.SetRewordData(mail_datas);
                        }
                    }
                }
                catch (Exception ex)
                {
                    GlobalVars.UnitGetReward = (UnitGetParam)null;
                    DebugUtility.LogException(ex);
                    return;
                }
                if (GlobalVars.LastReward != null && GlobalVars.LastReward.Get() != null)
                {
                    MonoSingleton <GameManager> .Instance.Player.OnGoldChange(GlobalVars.LastReward.Get().Gold);
                }
                ((Behaviour)this).set_enabled(false);
                this.Success();
            }
        }