Exemplo n.º 1
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_LimitedShopBuyResponse> jsonObject = JSONParser.parseJSONObject <WebAPI.JSON_BodyResponse <Json_LimitedShopBuyResponse> >(www.text);
                DebugUtility.Assert(jsonObject != null, "res == null");
                if (jsonObject.body == null)
                {
                    this.OnRetry();
                }
                else
                {
                    Network.RemoveAPI();
                    LimitedShopData shop = MonoSingleton <GameManager> .Instance.Player.GetLimitedShopData() ?? new LimitedShopData();

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

                        LimitedShopItem limitedShopItem = shop.items[GlobalVars.ShopBuyIndex];
                        ItemParam       itemParam       = MonoSingleton <GameManager> .Instance.GetItemParam(limitedShopItem.iname);

                        if (limitedShopItem.isSetSaleValue)
                        {
                            AnalyticsManager.TrackOriginalCurrencyUse(limitedShopItem.saleType, MonoSingleton <GameManager> .Instance.Player.GetShopUpdateCost(this.mShopType, true), "ShopBuy." + (object)this.mShopType);
                        }
                        else if ((!limitedShopItem.IsArtifact ? itemParam.GetBuyNum(limitedShopItem.saleType) * limitedShopItem.num : MonoSingleton <GameManager> .Instance.MasterParam.GetArtifactParam(limitedShopItem.iname).GetBuyNum(limitedShopItem.saleType) * limitedShopItem.num) > 0)
                        {
                            AnalyticsManager.TrackOriginalCurrencyUse(limitedShopItem.saleType, MonoSingleton <GameManager> .Instance.Player.GetShopUpdateCost(this.mShopType, true), "ShopBuy." + (object)this.mShopType);
                        }
                        this.Success();
                    }
                }
            }
        }
        public override void OnSuccess(WWWResult www)
        {
            if (Network.IsError)
            {
                if (Network.ErrCode == Network.EErrCode.LimitedShopOutOfPeriod)
                {
                    this.OnPeriod();
                }
                else
                {
                    this.OnRetry();
                }
            }
            else
            {
                WebAPI.JSON_BodyResponse <Json_LimitedShopResponse> jsonObject = JSONParser.parseJSONObject <WebAPI.JSON_BodyResponse <Json_LimitedShopResponse> >(www.text);
                DebugUtility.Assert(jsonObject != null, "res == null");
                if (jsonObject.body == null)
                {
                    this.OnRetry();
                }
                else
                {
                    List <JSON_LimitedShopItemListSet> limitedShopItemListSetList = new List <JSON_LimitedShopItemListSet>((IEnumerable <JSON_LimitedShopItemListSet>)jsonObject.body.shopitems);
                    jsonObject.body.shopitems = limitedShopItemListSetList.ToArray();
                    Network.RemoveAPI();
                    LimitedShopData shop = MonoSingleton <GameManager> .Instance.Player.GetLimitedShopData() ?? new LimitedShopData();

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

                        this.Success();
                    }
                }
            }
        }
Exemplo n.º 3
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.º 4
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_LimitedShopBuyResponse> jsonObject = JSONParser.parseJSONObject <WebAPI.JSON_BodyResponse <Json_LimitedShopBuyResponse> >(www.text);
                DebugUtility.Assert(jsonObject != null, "res == null");
                if (jsonObject.body == null)
                {
                    this.OnRetry();
                }
                else
                {
                    Network.RemoveAPI();
                    LimitedShopData shop = MonoSingleton <GameManager> .Instance.Player.GetLimitedShopData() ?? new LimitedShopData();

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

                        LimitedShopItem limitedShopItem = shop.items[GlobalVars.ShopBuyIndex];
                        ItemParam       itemParam       = MonoSingleton <GameManager> .Instance.GetItemParam(limitedShopItem.iname);

                        if (limitedShopItem.isSetSaleValue)
                        {
                            PlayerData player = MonoSingleton <GameManager> .Instance.Player;
                            AnalyticsManager.TrackSpendShop(limitedShopItem.saleType, this.mShopType, player.GetShopUpdateCost(this.mShopType, true));
                        }
                        else
                        {
                            int num = 0;
                            switch (limitedShopItem.saleType)
                            {
                            case ESaleType.Gold:
                                num = (int)itemParam.buy * limitedShopItem.num;
                                break;

                            case ESaleType.Coin:
                                num = (int)itemParam.coin * limitedShopItem.num;
                                break;

                            case ESaleType.TourCoin:
                                num = (int)itemParam.tour_coin * limitedShopItem.num;
                                break;

                            case ESaleType.ArenaCoin:
                                num = (int)itemParam.arena_coin * limitedShopItem.num;
                                break;

                            case ESaleType.PiecePoint:
                                num = (int)itemParam.piece_point * limitedShopItem.num;
                                break;

                            case ESaleType.MultiCoin:
                                num = (int)itemParam.multi_coin * limitedShopItem.num;
                                break;

                            case ESaleType.EventCoin:
                                num = 0;
                                break;

                            case ESaleType.Coin_P:
                                num = (int)itemParam.coin * limitedShopItem.num;
                                break;
                            }
                            if (num > 0)
                            {
                                PlayerData player = MonoSingleton <GameManager> .Instance.Player;
                                AnalyticsManager.TrackSpendShop(limitedShopItem.saleType, this.mShopType, player.GetShopUpdateCost(this.mShopType, true));
                            }
                        }
                        this.Success();
                    }
                }
            }
        }
Exemplo n.º 5
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;

                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_LimitedShopBuyResponse> jsonObject = JSONParser.parseJSONObject <WebAPI.JSON_BodyResponse <Json_LimitedShopBuyResponse> >(www.text);
                DebugUtility.Assert(jsonObject != null, "res == null");
                if (jsonObject.body == null)
                {
                    this.OnRetry();
                }
                else
                {
                    Network.RemoveAPI();
                    LimitedShopData shop = MonoSingleton <GameManager> .Instance.Player.GetLimitedShopData() ?? new LimitedShopData();

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

                        LimitedShopItem limitedShopItem = shop.items.FirstOrDefault <LimitedShopItem>((Func <LimitedShopItem, bool>)(item => item.id == GlobalVars.ShopBuyIndex));
                        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));
                                }
                            }
                        }
                        if (limitedShopItem.isSetSaleValue)
                        {
                            MyMetaps.TrackSpendShop(limitedShopItem.saleType, this.mShopType, limitedShopItem.saleValue);
                        }
                        else
                        {
                            int num = !limitedShopItem.IsArtifact ? (!limitedShopItem.IsConceptCard ? MonoSingleton <GameManager> .Instance.GetItemParam(limitedShopItem.iname).GetBuyNum(limitedShopItem.saleType) * limitedShopItem.num : limitedShopItem.saleValue) : MonoSingleton <GameManager> .Instance.MasterParam.GetArtifactParam(limitedShopItem.iname).GetBuyNum(limitedShopItem.saleType) * limitedShopItem.num;

                            if (num > 0)
                            {
                                MyMetaps.TrackSpendShop(limitedShopItem.saleType, this.mShopType, num);
                            }
                        }
                        this.Success();
                    }
                }
            }
        }