예제 #1
0
    void ShowStoreItem()
    {
        HideItems();
        List <CityShopRef> rankList = CurShowItems;

        for (int i = 0, max = rankList.Count; i < max; i++)
        {
            ShopItemUI item = null;
            if (!allItemList.TryGetValue(i, out item))
            {
                GameObject go = Instantiate(exResources.GetResource(ResourceType.GUI, "GuildActivity/CityShopItem")) as GameObject;
                if (go != null)
                {
                    item = go.GetComponent <ShopItemUI>();
                    if (panelStore != null)
                    {
                        go.transform.parent = panelStore.transform;
                    }
                    go.transform.localScale = Vector3.one;
                }
                go             = null;
                allItemList[i] = item;
            }
            item = allItemList[i];
            if (item != null)
            {
                item.gameObject.SetActive(true);
                item.transform.localPosition = new Vector3(positionInfo.x + positionInfo.z * (i % 3), positionInfo.y + positionInfo.w * (i / 3), 0f);
                item.FillInfo(rankList[i]);
            }
        }
    }
예제 #2
0
    /// <summary>
    /// 刷新表现
    /// </summary>
    public void RefreshItems()
    {
        Object shopItemprefab = null;

        if (shopItemprefab == null)
        {
            shopItemprefab = exResources.GetResource(ResourceType.GUI, "Shop/ShopItem");
        }
        if (shopItemprefab == null)
        {
            GameSys.LogError("找不到预制:Shop/ShopItem");
            return;
        }
        Vector3 V3 = Vector3.zero;

        for (int i = 0; i < shopItemList.Count; i++)
        {
            if (!ShopItemContainers.ContainsKey(i))
            {
                GameObject obj          = Instantiate(shopItemprefab) as GameObject;
                Transform  parentTransf = this.gameObject.transform;
                obj.transform.parent        = parentTransf;
                obj.transform.localPosition = V3;
                obj.transform.localScale    = Vector3.one;
                if ((i + 1) % 2 == 0)
                {
                    V3 = new Vector3(0, V3.y - 140, V3.z);
                }
                else
                {
                    V3 = new Vector3(V3.x + 220, V3.y, V3.z);
                }


                ShopItemUI shopItemUI = obj.GetComponent <ShopItemUI>();
                shopItemUI.FillInfo(shopItemList[i]);
                shopItemUI.OnSelectEvent += OnSelectSkillUI;
                ShopItemContainers[i]     = shopItemUI;
                //                if (firstRun && skillList[i].SkillLv>0)
                //                {
                //                    firstRun = false;
                //                    selectSkillUI = skillUI;
                //                    UIToggle tog = obj.GetComponent<UIToggle>();
                //                    tog.value = true;
                //                    if (OnSelectItemEvent != null)
                //                    {
                //                        OnSelectItemEvent(selectSkillUI);
                //                    }
                //                }
            }
        }
    }