Exemplo n.º 1
0
    //------------------------------------------------------------------------------------------------------------------------
    //                                                  AddItemToView()
    //------------------------------------------------------------------------------------------------------------------------
    //Adds a new item container to the view, each view can have its way of displaying items
    protected override void addItemToView(Item item)
    {
        GameObject newItemInstance = GameObject.Instantiate(itemPrefab);

        newItemInstance.transform.SetParent(itemLayoutGroup.transform);
        newItemInstance.transform.localScale = Vector3.one;//The scale would automatically change in Unity so we set it back to Vector3.one.

        GridViewItemContainer itemContainer = newItemInstance.GetComponent <GridViewItemContainer>();

        Debug.Assert(itemContainer != null);
        itemContainer.Initialize(item);

        _itemList.Add(newItemInstance);
    }
Exemplo n.º 2
0
    public override void UpdateObservers(ISubject pSubject)
    {
        if (pSubject.SubjectState == (int)ShopActions.PURCHASED)
        {
            updateItemList();
        }

        if (pSubject.SubjectState == (int)ShopActions.SOLD)
        {
            updateItemList();
        }

        if (pSubject.SubjectState == (int)ShopActions.UPGRADED)
        {
            GameObject itemInstance = _itemList[ShopCreator.Instance.inventoryModel.GetSelectedItemIndex()];

            GridViewItemContainer itemContainer = itemInstance.GetComponent <GridViewItemContainer>();
            itemContainer.UpdateItemDetailsUI();
        }

        updateMoneyPanel();
    }