Ejemplo n.º 1
0
        private void Refresh()
        {
            GameUtility.DestroyGameObjects(this.mItems);
            this.mItems.Clear();
            EventShopData eventShopData = MonoSingleton <GameManager> .Instance.Player.GetEventShopData();

            if (eventShopData == null || eventShopData.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();
            EventShopItem eventShopItem = eventShopData.items[shopBuyIndex];

            if (eventShopItem.IsArtifact)
            {
                eventShopItem.children          = new Json_ShopItemDesc[1];
                eventShopItem.children[0]       = new Json_ShopItemDesc();
                eventShopItem.children[0].iname = eventShopItem.iname;
                eventShopItem.children[0].num   = eventShopItem.num;
            }
            if (eventShopItem.children != null && eventShopItem.children.Length > 0)
            {
                foreach (Json_ShopItemDesc child in eventShopItem.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;
                        }
                    }
                    EventShopGiftItem component = (EventShopGiftItem)gameObject.GetComponent <EventShopGiftItem>();
                    if (Object.op_Inequality((Object)component, (Object)null))
                    {
                        component.SetShopItemInfo(child, name);
                    }
                }
            }
            GameParameter.UpdateAll(((Component)parent).get_gameObject());
        }
Ejemplo n.º 2
0
        private void Refresh()
        {
            GameUtility.DestroyGameObjects(this.mItems);
            this.mItems.Clear();
            EventShopData eventShopData = MonoSingleton <GameManager> .Instance.Player.GetEventShopData();

            if (eventShopData == null || eventShopData.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();
            EventShopItem            eventShopItem        = eventShopData.items.FirstOrDefault <EventShopItem>((Func <EventShopItem, bool>)(item => item.id == shopdata_index));
            List <Json_ShopItemDesc> jsonShopItemDescList = new List <Json_ShopItemDesc>();

            if (eventShopItem.IsArtifact)
            {
                jsonShopItemDescList.Add(new Json_ShopItemDesc()
                {
                    iname = eventShopItem.iname,
                    itype = ShopData.ShopItemType2String(eventShopItem.ShopItemType),
                    num   = eventShopItem.num
                });
            }
            else if (eventShopItem.children != null && eventShopItem.children.Length > 0)
            {
                jsonShopItemDescList.AddRange((IEnumerable <Json_ShopItemDesc>)eventShopItem.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;
                        }
                    }
                    EventShopGiftItem component = (EventShopGiftItem)gameObject.GetComponent <EventShopGiftItem>();
                    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());
        }