Ejemplo n.º 1
0
 void Filter(string itemClass)
 {
     for (int i = 0; i < itemGrid.GetComponentsInChildren <Transform>(true).Length; i++)
     {
         FMStoreItemUI item = itemGrid.GetComponentsInChildren <Transform>(true)[i].GetComponent <FMStoreItemUI>();
         if (item != null)
         {
             item.gameObject.SetActive(item.Item.ItemClass.Equals(itemClass));
         }
     }
     itemGrid.Reposition();
 }
Ejemplo n.º 2
0
    void DisplayItems()
    {
        for (int i = 0; i < ClientSessionData.Instance.CatalogItems.Count; i++)
        {
            CatalogItem   item       = ClientSessionData.Instance.CatalogItems[i];
            GameObject    itemPrefab = Instantiate(Resources.Load("Prefabs/FMStoreItemListUI")) as GameObject;
            FMStoreItemUI itemUI     = itemPrefab.GetComponent <FMStoreItemUI>();

            itemUI.SetData(item);
            itemUI.OnSelected = DisplaySelectedItemInfo;

            itemUI.gameObject.transform.parent     = itemGrid.transform;
            itemUI.gameObject.transform.localScale = Vector3.one;
        }

        itemGrid.Reposition();
        FilterByItem();
    }
Ejemplo n.º 3
0
    void DisplaySelectedItemInfo(FMStoreItemUI item)
    {
        buttonCO.isEnabled = true;
        buttonPC.isEnabled = true;

        if (selectedItem != null)
        {
            selectedItem.Unselect();
        }

        labItenName.text      = item.Item.DisplayName;
        itemSprite.spriteName = item.Item.ItemImageUrl;
        labDescription.text   = item.Item.Description;

        uint CO;
        uint PC;
        bool hasCO = item.Item.VirtualCurrencyPrices.TryGetValue("CO", out CO);
        bool hasPC = item.Item.VirtualCurrencyPrices.TryGetValue("PC", out PC);

        buttonCO.GetComponentInChildren <UILabel>().text = hasCO ? CO.ToString() : "--";
        buttonPC.GetComponentInChildren <UILabel>().text = hasPC ? PC.ToString() : "--";

        //disable buttons if there is no currency
        if (!hasCO)
        {
            buttonCO.isEnabled = false;
        }
        if (!hasPC)
        {
            buttonPC.isEnabled = false;
        }

        FMInventoryItem invItem = ClientSessionData.Instance.InventoryItems.Find(x => x.CatalogID.Equals(item.Item.ItemId));

        labOwned.text = invItem != null?invItem.Amount.ToString() : "0";

        selectedItem = item;
    }