Esempio n. 1
0
        public ShopData GetShopData()
        {
            ShopData shopData = new ShopData();

            shopData.items = new List <ShopItem>();
            for (int index = 0; index < shopData.items.Count; ++index)
            {
                shopData.items[index] = (ShopItem)this.items[index];
            }
            shopData.UpdateCount = this.UpdateCount;
            return(shopData);
        }
Esempio n. 2
0
        private void Refresh()
        {
            if (Object.op_Equality((Object)this.ItemTemplate, (Object)null))
            {
                return;
            }
            PlayerData player   = MonoSingleton <GameManager> .Instance.Player;
            ShopData   shopData = player.GetShopData(GlobalVars.ShopType);

            DebugUtility.Assert(shopData != null, "ショップ情報が存在しない");
            for (int index = 0; index < this.mBuyItems.Count; ++index)
            {
                this.mBuyItems[index].get_gameObject().SetActive(false);
            }
            int count = shopData.items.Count;

            for (int index = 0; index < count; ++index)
            {
                ShopItem data = shopData.items[index];
                if (index >= this.mBuyItems.Count)
                {
                    GameObject gameObject = (GameObject)Object.Instantiate <GameObject>((M0)this.ItemTemplate);
                    gameObject.get_transform().SetParent((Transform)this.ItemLayoutParent, false);
                    this.mBuyItems.Add(gameObject);
                }
                GameObject mBuyItem = this.mBuyItems[index];
                DataSource.Bind <ShopItem>(mBuyItem, data);
                ItemData itemDataByItemId = player.FindItemDataByItemID(data.iname);
                DataSource.Bind <ItemData>(mBuyItem, itemDataByItemId);
                DataSource.Bind <ItemParam>(mBuyItem, MonoSingleton <GameManager> .Instance.GetItemParam(data.iname));
                ListItemEvents component1 = (ListItemEvents)mBuyItem.GetComponent <ListItemEvents>();
                if (Object.op_Inequality((Object)component1, (Object)null))
                {
                    component1.OnSelect = new ListItemEvents.ListItemEvent(this.OnSelect);
                }
                Button component2 = (Button)mBuyItem.GetComponent <Button>();
                if (Object.op_Inequality((Object)component2, (Object)null))
                {
                    ((Selectable)component2).set_interactable(!data.is_soldout);
                }
                mBuyItem.SetActive(true);
            }
            GameParameter.UpdateAll(((Component)this).get_gameObject());
        }
Esempio n. 3
0
 public bool Deserialize(JSON_EventShopItemListSet json)
 {
     if (json == null || json.item == null || (string.IsNullOrEmpty(json.item.iname) || json.cost == null) || string.IsNullOrEmpty(json.cost.type))
     {
         return(false);
     }
     this.id         = json.id;
     this.iname      = json.item.iname;
     this.num        = json.item.num;
     this.max_num    = json.item.maxnum;
     this.bougthnum  = json.item.boughtnum;
     this.saleValue  = json.cost.value;
     this.saleType   = ShopData.String2SaleType(json.cost.type);
     this.cost_iname = json.cost.iname == null ? GlobalVars.EventShopItem.shop_cost_iname : json.cost.iname;
     if (this.saleType == ESaleType.EventCoin && this.cost_iname == null)
     {
         return(false);
     }
     this.is_reset   = json.isreset == 1;
     this.start      = json.start;
     this.end        = json.end;
     this.is_soldout = json.sold > 0;
     if (json.children != null)
     {
         this.children = json.children;
     }
     if (json.children != null)
     {
         this.shopItemType = EShopItemType.Set;
     }
     else
     {
         this.shopItemType = ShopData.String2ShopItemType(json.item.itype);
         if (this.shopItemType == EShopItemType.Unknown)
         {
             this.shopItemType = ShopData.Iname2ShopItemType(json.item.iname);
         }
     }
     if (this.IsConceptCard)
     {
         MonoSingleton <GameManager> .Instance.Player.SetConceptCardNum(this.iname, json.item.has_count);
     }
     return(true);
 }
Esempio n. 4
0
        public override void OnActivate(int pinID)
        {
            if (pinID != 1)
            {
                return;
            }
            PlayerData player = MonoSingleton <GameManager> .Instance.Player;

            ((Behaviour)this).set_enabled(false);
            ShopData shopData = player.GetShopData(GlobalVars.ShopType);

            if (shopData == null)
            {
                this.ActivateOutputLinks(104);
            }
            else
            {
                ShopItem shopitem = shopData.items.FirstOrDefault <ShopItem>((Func <ShopItem, bool>)(item => item.id == GlobalVars.ShopBuyIndex));
                if (shopitem.is_soldout)
                {
                    this.ActivateOutputLinks(105);
                }
                else
                {
                    int       buy       = 0;
                    ItemParam itemParam = (ItemParam)null;
                    if (shopitem.IsArtifact)
                    {
                        buy = MonoSingleton <GameManager> .Instance.MasterParam.GetArtifactParam(shopitem.iname).GetBuyNum(shopitem.saleType);
                    }
                    else if (shopitem.IsConceptCard)
                    {
                        if (!MonoSingleton <GameManager> .Instance.Player.CheckConceptCardCapacity(shopitem.num * GlobalVars.ShopBuyAmount))
                        {
                            ConceptCardParam conceptCardParam = MonoSingleton <GameManager> .Instance.MasterParam.GetConceptCardParam(shopitem.iname);

                            if (conceptCardParam != null && conceptCardParam.type == eCardType.Equipment)
                            {
                                this.ActivateOutputLinks(106);
                                return;
                            }
                        }
                    }
                    else
                    {
                        itemParam = MonoSingleton <GameManager> .Instance.GetItemParam(shopitem.iname);

                        if (!shopitem.IsSet && !player.CheckItemCapacity(itemParam, shopitem.num * GlobalVars.ShopBuyAmount))
                        {
                            this.ActivateOutputLinks(106);
                            return;
                        }
                        buy = itemParam.GetBuyNum(shopitem.saleType);
                    }
                    switch (shopitem.saleType)
                    {
                    case ESaleType.Gold:
                        if (!this.CheckCanBuy(shopitem, buy, player.Gold, 107))
                        {
                            return;
                        }
                        break;

                    case ESaleType.Coin:
                        if (!this.CheckCanBuy(shopitem, buy, player.Coin, 108))
                        {
                            return;
                        }
                        break;

                    case ESaleType.TourCoin:
                        if (!this.CheckCanBuy(shopitem, buy, player.TourCoin, 109))
                        {
                            return;
                        }
                        break;

                    case ESaleType.ArenaCoin:
                        if (!this.CheckCanBuy(shopitem, buy, player.ArenaCoin, 110))
                        {
                            return;
                        }
                        break;

                    case ESaleType.PiecePoint:
                        if (!this.CheckCanBuy(shopitem, buy, player.PiecePoint, 111))
                        {
                            return;
                        }
                        break;

                    case ESaleType.MultiCoin:
                        if (!this.CheckCanBuy(shopitem, buy, player.MultiCoin, 112))
                        {
                            return;
                        }
                        break;

                    case ESaleType.EventCoin:
                        DebugUtility.Assert("There is no common price in the event coin.");
                        this.ActivateOutputLinks(113);
                        return;

                    case ESaleType.Coin_P:
                        if (!this.CheckCanBuy(shopitem, buy, player.PaidCoin, 114))
                        {
                            return;
                        }
                        break;
                    }
                    this.mShopType = GlobalVars.ShopType;
                    int shopBuyIndex = GlobalVars.ShopBuyIndex;
                    if (Network.Mode == Network.EConnectMode.Offline)
                    {
                        if (itemParam == null)
                        {
                            return;
                        }
                        player.DEBUG_BUY_ITEM(this.mShopType, shopBuyIndex);
                        ShopParam shopParam = MonoSingleton <GameManager> .Instance.MasterParam.GetShopParam(this.mShopType);

                        player.OnBuyAtShop(shopParam.iname, itemParam.iname, shopitem.num);
                        this.Success();
                    }
                    else
                    {
                        if (this.mShopType == EShopType.Guerrilla)
                        {
                            this.ExecRequest((WebAPI) new ReqItemGuerrillaShopBuypaid(shopBuyIndex, GlobalVars.ShopBuyAmount, new Network.ResponseCallback(((FlowNode_Network)this).ResponseCallback)));
                        }
                        else
                        {
                            this.ExecRequest((WebAPI) new ReqItemShopBuypaid(this.mShopType.ToString(), shopBuyIndex, GlobalVars.ShopBuyAmount, new Network.ResponseCallback(((FlowNode_Network)this).ResponseCallback)));
                        }
                        ((Behaviour)this).set_enabled(true);
                    }
                }
            }
        }
Esempio 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_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();
                    }
                }
            }
        }
        public override void OnActivate(int pinID)
        {
            if (pinID != 1 || ((Behaviour)this).get_enabled())
            {
                return;
            }
            this.mShopType = GlobalVars.ShopType;
            ShopData shopData = MonoSingleton <GameManager> .Instance.Player.GetShopData(this.mShopType);

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

            ((Behaviour)this).set_enabled(false);
            if (shopData == null || shopParam == null)
            {
                this.ActivateOutputLinks(101);
            }
            else
            {
                PlayerData player         = MonoSingleton <GameManager> .Instance.Player;
                int        shopUpdateCost = player.GetShopUpdateCost(this.mShopType, false);
                switch (shopParam.UpdateCostType)
                {
                case ESaleType.Gold:
                    if (player.Gold < shopUpdateCost)
                    {
                        this.ActivateOutputLinks(103);
                        return;
                    }
                    break;

                case ESaleType.Coin:
                    if (player.Coin < shopUpdateCost)
                    {
                        this.ActivateOutputLinks(104);
                        return;
                    }
                    break;

                case ESaleType.TourCoin:
                    if (player.TourCoin < shopUpdateCost)
                    {
                        this.ActivateOutputLinks(105);
                        return;
                    }
                    break;

                case ESaleType.ArenaCoin:
                    if (player.ArenaCoin < shopUpdateCost)
                    {
                        this.ActivateOutputLinks(106);
                        return;
                    }
                    break;

                case ESaleType.PiecePoint:
                    if (player.PiecePoint < shopUpdateCost)
                    {
                        this.ActivateOutputLinks(107);
                        return;
                    }
                    break;

                case ESaleType.MultiCoin:
                    if (player.MultiCoin < shopUpdateCost)
                    {
                        this.ActivateOutputLinks(108);
                        return;
                    }
                    break;

                case ESaleType.EventCoin:
                    if (player.EventCoinNum(GlobalVars.EventShopItem.shop_cost_iname) < shopUpdateCost)
                    {
                        this.ActivateOutputLinks(109);
                        return;
                    }
                    break;
                }
                if (Network.Mode == Network.EConnectMode.Online)
                {
                    if (this.mShopType != EShopType.Event)
                    {
                        this.ExecRequest((WebAPI) new ReqItemShopUpdate(this.mShopType.ToString(), new Network.ResponseCallback(((FlowNode_Network)this).ResponseCallback)));
                    }
                    else
                    {
                        this.ExecRequest((WebAPI) new ReqItemEventShopUpdate(GlobalVars.EventShopItem.shops.gname, GlobalVars.EventShopItem.shop_cost_iname, new Network.ResponseCallback(((FlowNode_Network)this).ResponseCallback)));
                    }
                    ((Behaviour)this).set_enabled(true);
                }
                else if (!player.CheckShopUpdateCost(GlobalVars.ShopType))
                {
                    this.ActivateOutputLinks(104);
                }
                else
                {
                    this.Success();
                }
            }
        }
        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
            {
                if (GlobalVars.ShopType != EShopType.Event)
                {
                    WebAPI.JSON_BodyResponse <Json_ShopUpdateResponse> jsonObject = JSONParser.parseJSONObject <WebAPI.JSON_BodyResponse <Json_ShopUpdateResponse> >(www.text);
                    DebugUtility.Assert(jsonObject != null, "res == null");
                    if (jsonObject.body == null)
                    {
                        this.OnRetry();
                        return;
                    }
                    Network.RemoveAPI();
                    ShopData shop = MonoSingleton <GameManager> .Instance.Player.GetShopData(this.mShopType) ?? new ShopData();

                    if (!shop.Deserialize(jsonObject.body))
                    {
                        this.OnFailed();
                        return;
                    }
                    MonoSingleton <GameManager> .Instance.Player.SetShopData(this.mShopType, shop);
                }
                else
                {
                    WebAPI.JSON_BodyResponse <Json_EventShopUpdateResponse> jsonObject = JSONParser.parseJSONObject <WebAPI.JSON_BodyResponse <Json_EventShopUpdateResponse> >(www.text);
                    DebugUtility.Assert(jsonObject != null, "res == null");
                    if (jsonObject.body == null)
                    {
                        this.OnRetry();
                        return;
                    }
                    List <JSON_EventShopItemListSet> eventShopItemListSetList = new List <JSON_EventShopItemListSet>((IEnumerable <JSON_EventShopItemListSet>)jsonObject.body.shopitems);
                    jsonObject.body.shopitems = eventShopItemListSetList.ToArray();
                    Network.RemoveAPI();
                    EventShopData shop = MonoSingleton <GameManager> .Instance.Player.GetEventShopData() ?? new EventShopData();

                    if (!shop.Deserialize(jsonObject.body))
                    {
                        this.OnFailed();
                        return;
                    }
                    MonoSingleton <GameManager> .Instance.Player.SetEventShopData(shop);
                }
                ShopParam shopParam = MonoSingleton <GameManager> .Instance.MasterParam.GetShopParam(this.mShopType);

                if (shopParam != null)
                {
                    PlayerData player = MonoSingleton <GameManager> .Instance.Player;
                    AnalyticsManager.TrackSpendShopUpdate(shopParam.UpdateCostType, this.mShopType, player.GetShopUpdateCost(this.mShopType, true));
                }
                this.Success();
            }
        }
        private void Refresh()
        {
            this.mShopitem = MonoSingleton <GameManager> .Instance.Player.GetEventShopData().items.FirstOrDefault <EventShopItem>((Func <EventShopItem, bool>)(item => item.id == GlobalVars.ShopBuyIndex));

            this.ItemWindow.SetActive(!this.mShopitem.IsArtifact);
            this.ArtifactWindow.SetActive(this.mShopitem.IsArtifact);
            if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.AmountNum, (UnityEngine.Object)null))
            {
                this.AmountNum.set_text(this.mShopitem.remaining_num.ToString());
            }
            if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.Sold, (UnityEngine.Object)null))
            {
                this.Sold.SetActive(!this.mShopitem.IsNotLimited);
            }
            if (this.mShopitem.IsArtifact)
            {
                ArtifactParam artifactParam = MonoSingleton <GameManager> .Instance.MasterParam.GetArtifactParam(this.mShopitem.iname);

                DataSource.Bind <ArtifactParam>(((Component)this).get_gameObject(), artifactParam);
                this.mArtifactParam = artifactParam;
                ArtifactData artifactData = new ArtifactData();
                artifactData.Deserialize(new Json_Artifact()
                {
                    iname = artifactParam.iname,
                    rare  = artifactParam.rareini
                });
                BaseStatus fixed_status = new BaseStatus();
                BaseStatus scale_status = new BaseStatus();
                artifactData.GetHomePassiveBuffStatus(ref fixed_status, ref scale_status, (UnitData)null, 0, true);
                this.ArtifactStatus.SetValues(fixed_status, scale_status, false);
                if (artifactParam.abil_inames != null && artifactParam.abil_inames.Length > 0)
                {
                    AbilityParam abilityParam = MonoSingleton <GameManager> .Instance.MasterParam.GetAbilityParam(artifactParam.abil_inames[0]);

                    List <AbilityData> learningAbilities = artifactData.LearningAbilities;
                    bool flag = false;
                    if (learningAbilities != null)
                    {
                        for (int index = 0; index < learningAbilities.Count; ++index)
                        {
                            AbilityData abilityData = learningAbilities[index];
                            if (abilityData != null && abilityParam.iname == abilityData.Param.iname)
                            {
                                flag = true;
                                break;
                            }
                        }
                    }
                    DataSource.Bind <AbilityParam>(this.ArtifactAbility, abilityParam);
                    if (flag)
                    {
                        this.ArtifactAbilityAnimation.SetInteger(this.AbilityListItemState, this.AbilityListItem_Unlocked);
                    }
                    else
                    {
                        this.ArtifactAbilityAnimation.SetInteger(this.AbilityListItemState, this.AbilityListItem_Hidden);
                    }
                }
                else
                {
                    this.ArtifactAbilityAnimation.SetInteger(this.AbilityListItemState, this.AbilityListItem_Hidden);
                }
                if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.m_SetEffectsButton, (UnityEngine.Object)null) && UnityEngine.Object.op_Inequality((UnityEngine.Object) this.m_SetEffectsButton, (UnityEngine.Object)null) && artifactParam != null)
                {
                    ((Selectable)this.m_SetEffectsButton).set_interactable(MonoSingleton <GameManager> .Instance.MasterParam.ExistSkillAbilityDeriveDataWithArtifact(artifactParam.iname));
                    if (((Selectable)this.m_SetEffectsButton).get_interactable())
                    {
                        ArtifactSetList.SetSelectedArtifactParam(artifactParam);
                    }
                }
            }
            else
            {
                ItemData itemDataByItemId = MonoSingleton <GameManager> .Instance.Player.FindItemDataByItemID(this.mShopitem.iname);

                this.event_shop_item_set_list.Clear();
                if (this.mShopitem.IsSet)
                {
                    for (int index = 0; index < this.mShopitem.children.Length; ++index)
                    {
                        GameObject gameObject = index >= this.event_shop_item_set_list.Count ? (GameObject)UnityEngine.Object.Instantiate <GameObject>((M0)this.ItemTemplate) : ((Component)this.event_shop_item_set_list[index]).get_gameObject();
                        if (UnityEngine.Object.op_Inequality((UnityEngine.Object)gameObject, (UnityEngine.Object)null))
                        {
                            gameObject.SetActive(true);
                            Vector3 localScale = gameObject.get_transform().get_localScale();
                            gameObject.get_transform().SetParent(this.ItemParent.get_transform());
                            gameObject.get_transform().set_localScale(localScale);
                            EventShopSetItemListElement component = (EventShopSetItemListElement)gameObject.GetComponent <EventShopSetItemListElement>();
                            StringBuilder stringBuilder           = GameUtility.GetStringBuilder();
                            if (this.mShopitem.children[index].IsArtifact)
                            {
                                ArtifactParam artifactParam = MonoSingleton <GameManager> .Instance.MasterParam.GetArtifactParam(this.mShopitem.children[index].iname);

                                if (artifactParam != null)
                                {
                                    stringBuilder.Append(artifactParam.name);
                                }
                                component.ArtifactParam = artifactParam;
                            }
                            else if (this.mShopitem.children[index].IsConceptCard)
                            {
                                ConceptCardData cardDataForDisplay = ConceptCardData.CreateConceptCardDataForDisplay(this.mShopitem.children[index].iname);
                                if (cardDataForDisplay != null)
                                {
                                    stringBuilder.Append(cardDataForDisplay.Param.name);
                                }
                                component.SetupConceptCard(cardDataForDisplay);
                            }
                            else
                            {
                                ItemData itemData = new ItemData();
                                itemData.Setup(0L, this.mShopitem.children[index].iname, this.mShopitem.children[index].num);
                                if (itemData != null)
                                {
                                    stringBuilder.Append(itemData.Param.name);
                                }
                                component.itemData = itemData;
                            }
                            stringBuilder.Append("×");
                            stringBuilder.Append(this.mShopitem.children[index].num.ToString());
                            component.itemName.set_text(stringBuilder.ToString());
                            component.SetShopItemDesc(this.mShopitem.children[index]);
                            this.event_shop_item_set_list.Add(component);
                        }
                    }
                }
                DataSource.Bind <ItemData>(((Component)this).get_gameObject(), itemDataByItemId);
                DataSource.Bind <ItemParam>(((Component)this).get_gameObject(), MonoSingleton <GameManager> .Instance.GetItemParam(this.mShopitem.iname));
            }
            if (this.mShopitem.IsArtifact)
            {
                this.AmountSliderHolder = this.ArtifactAmountSliderHolder;
                this.AmountSlider       = this.ArtifactAmountSlider;
                this.AmountSliderNum    = this.ArtifactAmountSliderNum;
                this.IncrementButton    = this.ArtifactIncrementButton;
                this.DecrementButton    = this.ArtifactDecrementButton;
            }
            else
            {
                this.AmountSliderHolder = this.ItemAmountSliderHolder;
                this.AmountSlider       = this.ItemAmountSlider;
                this.AmountSliderNum    = this.ItemAmountSliderNum;
                this.IncrementButton    = this.ItemIncrementButton;
                this.DecrementButton    = this.ItemDecrementButton;
            }
            this.mEnabledSlider = false;
            if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.AmountSliderHolder, (UnityEngine.Object)null) && UnityEngine.Object.op_Inequality((UnityEngine.Object) this.AmountSlider, (UnityEngine.Object)null) && UnityEngine.Object.op_Inequality((UnityEngine.Object) this.AmountSliderNum, (UnityEngine.Object)null))
            {
                if (!this.mShopitem.IsNotLimited && this.mShopitem.remaining_num > 1)
                {
                    this.mEnabledSlider = true;
                    GameParameter component = (GameParameter)((Component)this.LimitedItemPriceText).GetComponent <GameParameter>();
                    if (UnityEngine.Object.op_Inequality((UnityEngine.Object)component, (UnityEngine.Object)null))
                    {
                        ((Behaviour)component).set_enabled(false);
                    }
                    this.AmountSliderHolder.SetActive(true);
                    int remainingCurrency = ShopData.GetRemainingCurrency((ShopItem)this.mShopitem);
                    int buyPrice          = ShopData.GetBuyPrice((ShopItem)this.mShopitem);
                    int num1 = 1;
                    if (buyPrice > 0)
                    {
                        while (buyPrice * num1 <= remainingCurrency)
                        {
                            ++num1;
                        }
                    }
                    int num2 = Math.Max(Math.Min(num1 - 1, this.mShopitem.remaining_num), 1);
                    this.AmountSlider.set_minValue(1f);
                    this.AmountSlider.set_maxValue((float)num2);
                    this.SetSliderValue(1f);
                    // ISSUE: method pointer
                    ((UnityEvent <float>) this.AmountSlider.get_onValueChanged()).AddListener(new UnityAction <float>((object)this, __methodptr(OnSliderValueChanged)));
                }
                else
                {
                    this.mEnabledSlider = false;
                    this.AmountSliderHolder.SetActive(false);
                }
            }
            DataSource.Bind <EventShopItem>(((Component)this).get_gameObject(), this.mShopitem);
            GameParameter.UpdateAll(((Component)this).get_gameObject());
        }
        private void Refresh()
        {
            if (UnityEngine.Object.op_Equality((UnityEngine.Object) this.UnitTemplate, (UnityEngine.Object)null))
            {
                return;
            }
            List <UnitData> units = MonoSingleton <GameManager> .Instance.Player.Units;

            for (int index = 0; index < this.mUnits.Count; ++index)
            {
                this.mUnits[index].get_gameObject().SetActive(false);
            }
            this.mShopitem = MonoSingleton <GameManager> .Instance.Player.GetShopData(GlobalVars.ShopType).items.FirstOrDefault <ShopItem>((Func <ShopItem, bool>)(item => item.id == GlobalVars.ShopBuyIndex));

            bool flag1 = !this.mShopitem.IsNotLimited || this.mShopitem.saleType == ESaleType.Coin_P;

            if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.limited_item, (UnityEngine.Object)null))
            {
                this.limited_item.SetActive(flag1);
            }
            if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.no_limited_item, (UnityEngine.Object)null))
            {
                this.no_limited_item.SetActive(!flag1);
            }
            if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.Sold, (UnityEngine.Object)null))
            {
                this.Sold.SetActive(!this.mShopitem.IsNotLimited);
            }
            if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.SoldNum, (UnityEngine.Object)null))
            {
                this.SoldNum.set_text(this.mShopitem.remaining_num.ToString());
            }
            this.mEnabledSlider = false;
            if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.AmountSliderHolder, (UnityEngine.Object)null) && UnityEngine.Object.op_Inequality((UnityEngine.Object) this.AmountSlider, (UnityEngine.Object)null) && UnityEngine.Object.op_Inequality((UnityEngine.Object) this.AmountSliderNum, (UnityEngine.Object)null))
            {
                if (!this.mShopitem.IsNotLimited && this.mShopitem.remaining_num > 1)
                {
                    this.mEnabledSlider = true;
                    GameParameter component = (GameParameter)((Component)this.LimitedItemPriceText).GetComponent <GameParameter>();
                    if (UnityEngine.Object.op_Inequality((UnityEngine.Object)component, (UnityEngine.Object)null))
                    {
                        ((Behaviour)component).set_enabled(false);
                    }
                    this.AmountSliderHolder.SetActive(true);
                    int remainingCurrency = ShopData.GetRemainingCurrency(this.mShopitem);
                    int buyPrice          = ShopData.GetBuyPrice(this.mShopitem);
                    int num1 = 1;
                    if (buyPrice > 0)
                    {
                        while (buyPrice * num1 <= remainingCurrency)
                        {
                            ++num1;
                        }
                    }
                    int num2 = Math.Max(Math.Min(num1 - 1, this.mShopitem.remaining_num), 1);
                    this.AmountSlider.set_minValue(1f);
                    this.AmountSlider.set_maxValue((float)num2);
                    this.SetSliderValue(1f);
                    // ISSUE: method pointer
                    ((UnityEvent <float>) this.AmountSlider.get_onValueChanged()).AddListener(new UnityAction <float>((object)this, __methodptr(OnSliderValueChanged)));
                }
                else
                {
                    this.mEnabledSlider = false;
                    this.AmountSliderHolder.SetActive(false);
                }
            }
            if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.HasJem, (UnityEngine.Object)null) && UnityEngine.Object.op_Inequality((UnityEngine.Object) this.HasCoin, (UnityEngine.Object)null) && UnityEngine.Object.op_Inequality((UnityEngine.Object) this.HasZenny, (UnityEngine.Object)null))
            {
                switch (this.mShopitem.saleType)
                {
                case ESaleType.Gold:
                    this.HasJem.SetActive(false);
                    this.HasCoin.SetActive(false);
                    this.HasZenny.SetActive(true);
                    break;

                case ESaleType.Coin:
                case ESaleType.Coin_P:
                    this.HasJem.SetActive(true);
                    this.HasCoin.SetActive(false);
                    this.HasZenny.SetActive(false);
                    break;

                default:
                    this.HasJem.SetActive(false);
                    this.HasCoin.SetActive(true);
                    this.HasZenny.SetActive(false);
                    break;
                }
            }
            if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.EnableEquipUnitWindow, (UnityEngine.Object)null))
            {
                this.EnableEquipUnitWindow.get_gameObject().SetActive(false);
                int index1 = 0;
                for (int index2 = 0; index2 < units.Count; ++index2)
                {
                    UnitData data  = units[index2];
                    bool     flag2 = false;
                    for (int index3 = 0; index3 < data.Jobs.Length; ++index3)
                    {
                        JobData job = data.Jobs[index3];
                        if (job.IsActivated)
                        {
                            int equipSlotByItemId = job.FindEquipSlotByItemID(this.mShopitem.iname);
                            if (equipSlotByItemId != -1 && job.CheckEnableEquipSlot(equipSlotByItemId))
                            {
                                flag2 = true;
                                break;
                            }
                        }
                    }
                    if (flag2)
                    {
                        if (index1 >= this.mUnits.Count)
                        {
                            this.UnitTemplate.SetActive(true);
                            GameObject gameObject = (GameObject)UnityEngine.Object.Instantiate <GameObject>((M0)this.UnitTemplate);
                            gameObject.get_transform().SetParent((Transform)this.UnitLayoutParent, false);
                            this.mUnits.Add(gameObject);
                            this.UnitTemplate.SetActive(false);
                        }
                        GameObject gameObject1 = this.mUnits[index1].get_gameObject();
                        DataSource.Bind <UnitData>(gameObject1, data);
                        gameObject1.SetActive(true);
                        this.EnableEquipUnitWindow.get_gameObject().SetActive(true);
                        GameUtility.SetGameObjectActive(this.LayoutRight, true);
                        ++index1;
                    }
                }
            }
            DataSource.Bind <ShopItem>(((Component)this).get_gameObject(), this.mShopitem);
            if (this.mShopitem.IsArtifact)
            {
                DataSource.Bind <ArtifactParam>(((Component)this).get_gameObject(), MonoSingleton <GameManager> .Instance.MasterParam.GetArtifactParam(this.mShopitem.iname));
            }
            else if (this.mShopitem.IsConceptCard)
            {
                GameUtility.SetGameObjectActive(this.ItemIconRoot, false);
                GameUtility.SetGameObjectActive(this.ConceptCardIconRoot, true);
                if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.ConceptCardDetail, (UnityEngine.Object)null))
                {
                    ConceptCardData cardDataForDisplay = ConceptCardData.CreateConceptCardDataForDisplay(this.mShopitem.iname);
                    GlobalVars.SelectedConceptCardData.Set(cardDataForDisplay);
                    GameUtility.SetGameObjectActive(this.ConceptCardDetail, true);
                    GameUtility.SetGameObjectActive(this.LayoutRight, true);
                    if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.TextDesc, (UnityEngine.Object)null))
                    {
                        this.TextDesc.set_text(cardDataForDisplay.Param.expr);
                    }
                }
            }
            else
            {
                ItemData itemDataByItemId = MonoSingleton <GameManager> .Instance.Player.FindItemDataByItemID(this.mShopitem.iname);

                if (itemDataByItemId != null)
                {
                    DataSource.Bind <ItemData>(((Component)this).get_gameObject(), itemDataByItemId);
                    if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.TextDesc, (UnityEngine.Object)null))
                    {
                        this.TextDesc.set_text(itemDataByItemId.Param.Expr);
                    }
                }
                else
                {
                    ItemParam itemParam = MonoSingleton <GameManager> .Instance.GetItemParam(this.mShopitem.iname);

                    if (itemParam != null && UnityEngine.Object.op_Inequality((UnityEngine.Object) this.TextDesc, (UnityEngine.Object)null))
                    {
                        DataSource.Bind <ItemParam>(((Component)this).get_gameObject(), itemParam);
                        this.TextDesc.set_text(itemParam.Expr);
                    }
                }
            }
            GameParameter.UpdateAll(((Component)this).get_gameObject());
        }
Esempio n. 10
0
        private void Refresh()
        {
            GameUtility.DestroyGameObjects(this.mItems);
            this.mItems.Clear();
            ShopData shopData = MonoSingleton <GameManager> .Instance.Player.GetShopData(GlobalVars.ShopType);

            if (shopData == null || shopData.items.Count <= 0 || UnityEngine.Object.op_Equality((UnityEngine.Object) this.ItemTemplate, (UnityEngine.Object)null))
            {
                return;
            }
            int       shopdata_index = GlobalVars.ShopBuyIndex;
            Transform parent         = !UnityEngine.Object.op_Inequality((UnityEngine.Object) this.ItemParent, (UnityEngine.Object)null) ? this.ItemTemplate.get_transform().get_parent() : this.ItemParent.get_transform();
            ShopItem  shopItem       = shopData.items.FirstOrDefault <ShopItem>((Func <ShopItem, bool>)(item => item.id == shopdata_index));
            List <Json_ShopItemDesc> jsonShopItemDescList = new List <Json_ShopItemDesc>();

            if (shopItem.IsArtifact)
            {
                jsonShopItemDescList.Add(new Json_ShopItemDesc()
                {
                    iname = shopItem.iname,
                    itype = ShopData.ShopItemType2String(shopItem.ShopItemType),
                    num   = shopItem.num
                });
            }
            else if (shopItem.children != null && shopItem.children.Length > 0)
            {
                jsonShopItemDescList.AddRange((IEnumerable <Json_ShopItemDesc>)shopItem.children);
            }
            if (jsonShopItemDescList.Count > 0)
            {
                for (int index = 0; index < jsonShopItemDescList.Count; ++index)
                {
                    Json_ShopItemDesc shop_item_desc = jsonShopItemDescList[index];
                    string            empty          = string.Empty;
                    GameObject        gameObject;
                    string            name;
                    if (shop_item_desc.IsArtifact)
                    {
                        ArtifactParam artifactParam = MonoSingleton <GameManager> .Instance.MasterParam.GetArtifactParam(shop_item_desc.iname);

                        if (artifactParam != null)
                        {
                            gameObject = this.InstantiateItem <ArtifactParam>(this.ItemTemplate, parent, artifactParam);
                            name       = artifactParam.name;
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else if (shop_item_desc.IsConceptCard)
                    {
                        ConceptCardData cardDataForDisplay = ConceptCardData.CreateConceptCardDataForDisplay(shop_item_desc.iname);
                        if (cardDataForDisplay != null)
                        {
                            gameObject = this.InstantiateItem <ConceptCardData>(this.ItemTemplate, parent, cardDataForDisplay);
                            ConceptCardIcon componentInChildren = (ConceptCardIcon)gameObject.GetComponentInChildren <ConceptCardIcon>();
                            if (UnityEngine.Object.op_Inequality((UnityEngine.Object)componentInChildren, (UnityEngine.Object)null))
                            {
                                componentInChildren.Setup(cardDataForDisplay);
                            }
                            name = cardDataForDisplay.Param.name;
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else
                    {
                        ItemData itemData = new ItemData();
                        if (itemData.Setup(0L, shop_item_desc.iname, shop_item_desc.num))
                        {
                            gameObject = this.InstantiateItem <ItemData>(this.ItemTemplate, parent, itemData);
                            name       = itemData.Param.name;
                        }
                        else
                        {
                            continue;
                        }
                    }
                    ShopGiftItem component = (ShopGiftItem)gameObject.GetComponent <ShopGiftItem>();
                    if (UnityEngine.Object.op_Inequality((UnityEngine.Object)component, (UnityEngine.Object)null))
                    {
                        component.SetShopItemInfo(shop_item_desc, name, GlobalVars.ShopBuyAmount);
                    }
                }
            }
            GameParameter.UpdateAll(((Component)parent).get_gameObject());
        }
Esempio n. 11
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();
                    }
                }
            }
        }
Esempio n. 12
0
        private void Refresh()
        {
            GameUtility.DestroyGameObjects(this.mItems);
            this.mItems.Clear();
            ShopData shopData = MonoSingleton <GameManager> .Instance.Player.GetShopData(GlobalVars.ShopType);

            if (shopData == null || shopData.items.Count <= 0 || Object.op_Equality((Object)this.ItemTemplate, (Object)null))
            {
                return;
            }
            int       shopBuyIndex = GlobalVars.ShopBuyIndex;
            Transform parent       = !Object.op_Inequality((Object)this.ItemParent, (Object)null) ? this.ItemTemplate.get_transform().get_parent() : this.ItemParent.get_transform();
            ShopItem  shopItem     = shopData.items[shopBuyIndex];

            if (shopItem.IsArtifact)
            {
                shopItem.children          = new Json_ShopItemDesc[1];
                shopItem.children[0]       = new Json_ShopItemDesc();
                shopItem.children[0].iname = shopItem.iname;
                shopItem.children[0].num   = shopItem.num;
            }
            if (shopItem.children != null && shopItem.children.Length > 0)
            {
                foreach (Json_ShopItemDesc child in shopItem.children)
                {
                    string     empty = string.Empty;
                    GameObject gameObject;
                    string     name;
                    if (child.IsArtifact)
                    {
                        ArtifactParam artifactParam = MonoSingleton <GameManager> .Instance.MasterParam.GetArtifactParam(child.iname);

                        if (artifactParam != null)
                        {
                            gameObject = this.InstantiateItem <ArtifactParam>(this.ItemTemplate, parent, artifactParam);
                            name       = artifactParam.name;
                        }
                        else
                        {
                            continue;
                        }
                    }
                    else
                    {
                        ItemData itemData = new ItemData();
                        if (itemData.Setup(0L, child.iname, child.num))
                        {
                            gameObject = this.InstantiateItem <ItemData>(this.ItemTemplate, parent, itemData);
                            name       = itemData.Param.name;
                        }
                        else
                        {
                            continue;
                        }
                    }
                    ShopGiftItem component = (ShopGiftItem)gameObject.GetComponent <ShopGiftItem>();
                    if (Object.op_Inequality((Object)component, (Object)null))
                    {
                        component.SetShopItemInfo(child, name);
                    }
                }
            }
            GameParameter.UpdateAll(((Component)parent).get_gameObject());
        }
Esempio n. 13
0
 public void SetShopData(ShopData shopData)
 {
     this.mShopData = shopData;
 }
Esempio n. 14
0
 public EShopItemType GetShopItemTypeWithIType()
 {
     return(ShopData.String2ShopItemType(this.itype));
 }
Esempio n. 15
0
        private void Refresh()
        {
            if (UnityEngine.Object.op_Equality((UnityEngine.Object) this.ItemTemplate, (UnityEngine.Object)null))
            {
                return;
            }
            ShopData shopData = MonoSingleton <GameManager> .Instance.Player.GetShopData(GlobalVars.ShopType);

            DebugUtility.Assert(shopData != null, "ショップ情報が存在しない");
            if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.Updated, (UnityEngine.Object)null))
            {
                this.Updated.SetActive(shopData.btn_update);
            }
            if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.Update, (UnityEngine.Object)null))
            {
                this.Update.SetActive(shopData.btn_update);
            }
            if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.Lineup, (UnityEngine.Object)null))
            {
                this.Lineup.SetActive(shopData.btn_update);
            }
            for (int index = 0; index < this.mBuyItems.Count; ++index)
            {
                this.mBuyItems[index].get_gameObject().SetActive(false);
            }
            int count = shopData.items.Count;

            for (int index = 0; index < count; ++index)
            {
                ShopItem data1 = shopData.items[index];
                if (index >= this.mBuyItems.Count)
                {
                    GameObject gameObject = (GameObject)UnityEngine.Object.Instantiate <GameObject>((M0)this.ItemTemplate);
                    gameObject.get_transform().SetParent((Transform)this.ItemLayoutParent, false);
                    this.mBuyItems.Add(gameObject);
                }
                GameObject  mBuyItem            = this.mBuyItems[index];
                ShopBuyList componentInChildren = (ShopBuyList)mBuyItem.GetComponentInChildren <ShopBuyList>();
                componentInChildren.ShopItem = data1;
                componentInChildren.SetupDiscountUI();
                DataSource.Bind <ShopItem>(mBuyItem, data1);
                if (data1.IsArtifact)
                {
                    ArtifactParam artifactParam = MonoSingleton <GameManager> .Instance.MasterParam.GetArtifactParam(data1.iname);

                    DataSource.Bind <ArtifactParam>(mBuyItem, artifactParam);
                }
                else if (data1.IsConceptCard)
                {
                    ConceptCardData cardDataForDisplay = ConceptCardData.CreateConceptCardDataForDisplay(data1.iname);
                    componentInChildren.SetupConceptCard(cardDataForDisplay);
                }
                else if (data1.IsItem || data1.IsSet)
                {
                    ItemData data2 = new ItemData();
                    data2.Setup(0L, data1.iname, data1.num);
                    DataSource.Bind <ItemData>(mBuyItem, data2);
                    DataSource.Bind <ItemParam>(mBuyItem, MonoSingleton <GameManager> .Instance.GetItemParam(data1.iname));
                }
                else
                {
                    DebugUtility.LogError(string.Format("不明な商品タイプが設定されています (shopitem.iname({0}) => {1})", (object)data1.iname, (object)data1.ShopItemType));
                }
                ListItemEvents component1 = (ListItemEvents)mBuyItem.GetComponent <ListItemEvents>();
                if (UnityEngine.Object.op_Inequality((UnityEngine.Object)component1, (UnityEngine.Object)null))
                {
                    component1.OnSelect = new ListItemEvents.ListItemEvent(this.OnSelect);
                }
                Button component2 = (Button)mBuyItem.GetComponent <Button>();
                if (UnityEngine.Object.op_Inequality((UnityEngine.Object)component2, (UnityEngine.Object)null))
                {
                    ((Selectable)component2).set_interactable(!data1.is_soldout);
                }
                mBuyItem.SetActive(true);
            }
            GameParameter.UpdateAll(((Component)this).get_gameObject());
            if (GlobalVars.ShopType == EShopType.AwakePiece)
            {
                GameParameter.UpdateValuesOfType(GameParameter.ParameterTypes.GLOBAL_PLAYER_PIECEPOINT);
            }
            FlowNode_GameObject.ActivateOutputLinks((Component)this, 2);
        }
Esempio n. 16
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];
                            ItemParam  itemParam = MonoSingleton <GameManager> .Instance.GetItemParam(shopItem.iname);

                            int num = 0;
                            switch (shopItem.saleType)
                            {
                            case ESaleType.Gold:
                                num = (int)itemParam.buy * shopItem.num;
                                break;

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

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

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

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

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

                            case ESaleType.EventCoin:
                                num = 0;
                                DebugUtility.Assert("There is no common price in the event coin.");
                                break;
                            }
                            player.OnBuyAtShop(shopParam.iname, itemParam.iname, shopItem.num);
                            AnalyticsManager.TrackCurrencyObtain((AnalyticsManager.CurrencyType)(itemParam.type != EItemType.Ticket ? 4 : 2), AnalyticsManager.CurrencySubType.FREE, (long)shopItem.num, "Shop", new Dictionary <string, object>()
                            {
                                {
                                    "item_id",
                                    (object)shopItem.iname
                                }
                            });
                        }
                        this.Success();
                    }
                }
            }
        }
Esempio n. 17
0
        public override void OnActivate(int pinID)
        {
            if (pinID != 1)
            {
                return;
            }
            PlayerData player = MonoSingleton <GameManager> .Instance.Player;

            ((Behaviour)this).set_enabled(false);
            ShopData shopData = player.GetShopData(GlobalVars.ShopType);

            if (shopData == null)
            {
                this.ActivateOutputLinks(104);
            }
            else
            {
                ShopItem shopItem = shopData.items[GlobalVars.ShopBuyIndex];
                if (shopItem.is_soldout)
                {
                    this.ActivateOutputLinks(105);
                }
                else
                {
                    ItemParam itemParam = MonoSingleton <GameManager> .Instance.GetItemParam(shopItem.iname);

                    if (!player.CheckItemCapacity(itemParam, shopItem.num))
                    {
                        this.ActivateOutputLinks(106);
                    }
                    else
                    {
                        switch (shopItem.saleType)
                        {
                        case ESaleType.Gold:
                            if (player.Gold < (int)itemParam.buy * shopItem.num)
                            {
                                this.ActivateOutputLinks(107);
                                return;
                            }
                            break;

                        case ESaleType.Coin:
                            if (player.Coin < (int)itemParam.coin * shopItem.num)
                            {
                                this.ActivateOutputLinks(108);
                                return;
                            }
                            break;

                        case ESaleType.TourCoin:
                            if (player.TourCoin < (int)itemParam.tour_coin * shopItem.num)
                            {
                                this.ActivateOutputLinks(109);
                                return;
                            }
                            break;

                        case ESaleType.ArenaCoin:
                            if (player.ArenaCoin < (int)itemParam.arena_coin * shopItem.num)
                            {
                                this.ActivateOutputLinks(110);
                                return;
                            }
                            break;

                        case ESaleType.PiecePoint:
                            if (player.PiecePoint < (int)itemParam.piece_point * shopItem.num)
                            {
                                this.ActivateOutputLinks(111);
                                return;
                            }
                            break;

                        case ESaleType.MultiCoin:
                            if (player.MultiCoin < (int)itemParam.multi_coin * shopItem.num)
                            {
                                this.ActivateOutputLinks(112);
                                return;
                            }
                            break;

                        case ESaleType.EventCoin:
                            DebugUtility.Assert("There is no common price in the event coin.");
                            this.ActivateOutputLinks(113);
                            return;
                        }
                        this.mShopType = GlobalVars.ShopType;
                        int shopBuyIndex = GlobalVars.ShopBuyIndex;
                        if (Network.Mode == Network.EConnectMode.Offline)
                        {
                            player.DEBUG_BUY_ITEM(this.mShopType, shopBuyIndex);
                            ShopParam shopParam = MonoSingleton <GameManager> .Instance.MasterParam.GetShopParam(this.mShopType);

                            player.OnBuyAtShop(shopParam.iname, itemParam.iname, shopItem.num);
                            this.Success();
                        }
                        else
                        {
                            this.ExecRequest((WebAPI) new ReqItemShopBuypaid(this.mShopType.ToString(), shopBuyIndex, new Network.ResponseCallback(((FlowNode_Network)this).ResponseCallback)));
                            ((Behaviour)this).set_enabled(true);
                        }
                    }
                }
            }
        }
Esempio n. 18
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();
            }
        }