Beispiel #1
0
    public void InitItems(List <UpgradeCategory> upgradesCategories)
    {
        for (int i = 0; i < upgradesCategories.Count; i++)
        {
            GameObject    container          = Instantiate(categroryContainerPrefab, _transform, false) as GameObject;
            Transform     containerTransform = container.GetComponent <Transform>();
            RectTransform containerRectTrans = container.GetComponent <RectTransform>();
            containerRectTrans.anchorMin = Vector2.zero;
            containerRectTrans.anchorMax = new Vector2(1, 1);

            for (int j = 0; j < upgradesCategories[i].upgrades.Count; j++)
            {
                BaseUpgrade upgradePrefab = upgradesCategories[i].upgrades[j];
                GameObject  itemGO        = Instantiate(shopItemPrefab, containerTransform, false) as GameObject;
                ShopItemUI  item          = itemGO.GetComponent <ShopItemUI>();
                Instantiate(upgradePrefab, itemGO.transform, false);
                item.Init(upgradePrefab, upgradeShop);

                items.Add(item);
            }

            container.SetActive(false);
            categoriesContainers.Add(upgradesCategories[i], container);
        }
    }
Beispiel #2
0
    void InitShopItems()
    {
        int i = 0;

        foreach (var itemDefine in DataManager.Instance.ShopItems[shopID].Values)
        {
            GameObject obj = ResManager.Instance.Load <GameObject>(ResManager.ResourceType.Panel, "ShopItemUI");
            obj.transform.parent        = Content;
            obj.transform.localScale    = Vector3.one;
            obj.transform.localPosition = Vector3.zero;

            ShopItemUI itemUI = obj.GetComponent <ShopItemUI>();
            itemUI.Init(this, itemDefine, i++);
            items.Add(itemUI);
        }
    }
Beispiel #3
0
    private void SetupList()
    {
        // SKINS
        skinUiList = new ShopItemUI[purchaseableSkins.Length + achievementSkins.Length];

        for (int i = 0; i < skinUiList.Length; i++)
        {
            ShopItemUI skinUiInst = Instantiate(shopItemPrefab);
            skinUiList[i] = skinUiInst;

            skinUiInst.cachedTrans.parent        = skinListStart;
            skinUiInst.cachedTrans.localPosition = new Vector3(0f, -i * spacing, 0f);
            skinUiInst.cachedTrans.localScale    = Vector3.one;

            skinUiInst.Init(this, ShopItemUI.Type.FrogSkin, i, GetSkin(i));
        }

        // Automatically own default skin.
        skinUiList[0].SetStatus(ShopItemUI.Status.Owned);

        // MAP THEMES
        mapThemeGroupTrans.localPosition = new Vector3(0f, (-skinUiList.Length * spacing) + skinGroupTrans.localPosition.y + mapThemeListOffsetY, 0f);
        mapThemeUiList = new ShopItemUI[purchaseableMapThemes.Length + achievementMapThemes.Length];

        for (int i = 0; i < mapThemeUiList.Length; i++)
        {
            ShopItemUI mapThemeUiInst = Instantiate(shopItemPrefab);
            mapThemeUiList[i] = mapThemeUiInst;

            mapThemeUiInst.cachedTrans.parent        = mapThemeListStart;
            mapThemeUiInst.cachedTrans.localPosition = new Vector3(0f, -i * spacing, 0f);
            mapThemeUiInst.cachedTrans.localScale    = Vector3.one;

            mapThemeUiInst.Init(this, ShopItemUI.Type.MapTheme, i, GetMapTheme(i));
        }

        // Automatically own default map theme.
        mapThemeUiList[0].SetStatus(ShopItemUI.Status.Owned);
    }