Exemplo n.º 1
0
        public override void OnSuccess(WWWResult www)
        {
            if (Network.IsError)
            {
                Network.EErrCode errCode = Network.ErrCode;
                this.OnRetry();
            }
            else
            {
                WebAPI.JSON_BodyResponse <Json_ShopResponse> jsonObject = JSONParser.parseJSONObject <WebAPI.JSON_BodyResponse <Json_ShopResponse> >(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);

                        this.Success();
                    }
                }
            }
        }
Exemplo n.º 2
0
        public override void OnSuccess(WWWResult www)
        {
            if (Network.IsError)
            {
                switch (Network.ErrCode)
                {
                case Network.EErrCode.ShopRefreshCostShort:
                case Network.EErrCode.ShopRefreshLvSort:
                    this.OnBack();
                    break;

                default:
                    this.OnRetry();
                    break;
                }
            }
            else
            {
                switch (GlobalVars.ShopType)
                {
                case EShopType.Event:
                    WebAPI.JSON_BodyResponse <Json_EventShopUpdateResponse> jsonObject1 = JSONParser.parseJSONObject <WebAPI.JSON_BodyResponse <Json_EventShopUpdateResponse> >(www.text);
                    DebugUtility.Assert(jsonObject1 != null, "res == null");
                    if (jsonObject1.body == null)
                    {
                        this.OnRetry();
                        return;
                    }
                    List <JSON_EventShopItemListSet> eventShopItemListSetList = new List <JSON_EventShopItemListSet>((IEnumerable <JSON_EventShopItemListSet>)jsonObject1.body.shopitems);
                    jsonObject1.body.shopitems = eventShopItemListSetList.ToArray();
                    Network.RemoveAPI();
                    EventShopData shop1 = MonoSingleton <GameManager> .Instance.Player.GetEventShopData() ?? new EventShopData();

                    if (!shop1.Deserialize(jsonObject1.body))
                    {
                        this.OnFailed();
                        return;
                    }
                    MonoSingleton <GameManager> .Instance.Player.SetEventShopData(shop1);

                    break;

                case EShopType.Limited:
                    WebAPI.JSON_BodyResponse <Json_LimitedShopUpdateResponse> jsonObject2 = JSONParser.parseJSONObject <WebAPI.JSON_BodyResponse <Json_LimitedShopUpdateResponse> >(www.text);
                    DebugUtility.Assert(jsonObject2 != null, "res == null");
                    if (jsonObject2.body == null)
                    {
                        this.OnRetry();
                        return;
                    }
                    List <JSON_LimitedShopItemListSet> limitedShopItemListSetList = new List <JSON_LimitedShopItemListSet>((IEnumerable <JSON_LimitedShopItemListSet>)jsonObject2.body.shopitems);
                    jsonObject2.body.shopitems = limitedShopItemListSetList.ToArray();
                    Network.RemoveAPI();
                    LimitedShopData shop2 = MonoSingleton <GameManager> .Instance.Player.GetLimitedShopData() ?? new LimitedShopData();

                    if (!shop2.Deserialize(jsonObject2.body))
                    {
                        this.OnFailed();
                        return;
                    }
                    MonoSingleton <GameManager> .Instance.Player.SetLimitedShopData(shop2);

                    break;

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

                    if (!shop3.Deserialize(jsonObject3.body))
                    {
                        this.OnFailed();
                        return;
                    }
                    MonoSingleton <GameManager> .Instance.Player.SetShopData(this.mShopType, shop3);

                    break;
                }
                ShopParam shopParam = MonoSingleton <GameManager> .Instance.MasterParam.GetShopParam(this.mShopType);

                if (shopParam != null)
                {
                    AnalyticsManager.TrackOriginalCurrencyUse(shopParam.UpdateCostType, MonoSingleton <GameManager> .Instance.Player.GetShopUpdateCost(this.mShopType, true), "ShopUpdate." + (object)this.mShopType);
                }
                this.Success();
            }
        }
Exemplo n.º 3
0
        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;

                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);

                        ShopParam shopParam = MonoSingleton <GameManager> .Instance.MasterParam.GetShopParam(this.mShopType);

                        if (shopParam != null)
                        {
                            PlayerData player   = MonoSingleton <GameManager> .Instance.Player;
                            ShopItem   shopItem = shop.items[GlobalVars.ShopBuyIndex];
                            string     iname    = shopItem.iname;
                            if (shopItem.isSetSaleValue)
                            {
                                MyMetaps.TrackSpendShop(shopItem.saleType, this.mShopType, shopItem.saleValue);
                            }
                            else
                            {
                                int num = !shopItem.IsArtifact ? MonoSingleton <GameManager> .Instance.GetItemParam(shopItem.iname).GetBuyNum(shopItem.saleType) * shopItem.num : 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();
                    }
                }
            }
        }