Exemple #1
0
        public List <InventoryDisplayItem> GetInventoryList(List <Inventory> inventory, List <Inventory> inventoryStartingItems)
        {
            List <InventoryDisplayItem> displayItems = new List <InventoryDisplayItem>();
            InventoryDisplayItem        displayItem  = new InventoryDisplayItem();
            Inventory item = new Inventory();
            int       stock;

            string[] tempArray = inventoryStartingItems.Select(i => i.Name).ToArray();

            for (int i = 0; i < tempArray.Count(); i++)
            {
                displayItem.id    = i;
                displayItem.name  = tempArray[i];
                displayItem.value = GetItemValue(displayItem.name, inventory);
                item.Name         = displayItem.name;
                stock             = GetInventoryCount(item, inventory);
                if (stock == 0)
                {
                    displayItem.stock = "OUT OF STOCK";
                }
                else
                {
                    displayItem.stock = stock.ToString();
                }

                displayItems.Add(displayItem);
            }

            return(displayItems);
        }
    public void RefreshSelected()
    {
        this.itemData             = this;
        this.icon.overrideSprite  = this.category.icon;
        this.itemName.text        = this.category.catalogRef.DisplayName;
        this.itemDescription.text = this.category.catalogRef.Description;
        this.annotation.text      = this.category.inventory[0].Annotation;

        //		var kvp = item.category.catalogRef.VirtualCurrencyPrices.First();
        //		this.itemCost.text = string.Format(" x{0}", kvp.Value);
        //		this.currencyIcon.overrideSprite = GameController.Instance.iconManager.GetIconById(kvp.Key);

        if (this.category.catalogRef.Container != null && this.category.catalogRef.Container.ResultTableContents != null)
        {
            this.totalUses.gameObject.SetActive(true);
            this.totalUses.text = string.Format(" x{0}", this.category.count);
        }
        else if (this.category.isConsumable || this.category.totalUses > 0 || this.category.count > 1)
        {
            if (controller.activeFilter == DialogCanvasController.InventoryFilters.UsableInCombat)
            {
                //this.UseAction.gameObject.SetActive(true);
            }

            this.totalUses.text = string.Format(" x{0}", this.category.totalUses > this.category.count ? this.category.totalUses : this.category.count);
            this.totalUses.gameObject.SetActive(true);
        }
        else
        {
            this.totalUses.gameObject.SetActive(false);
        }
    }
Exemple #3
0
    public void ItemClicked(InventoryDisplayItem item)
    {
        if (this.selectedItem.itemData != null)
        {
            this.selectedItem.itemData.Deselect();
        }

        this.selectedItem.RefreshSelected(item);
        ShowSelectedItem();
    }
 public void CloseInventory()
 {
     GameController.Instance.soundManager.PlaySound(Vector3.zero, GlobalStrings.BUTTON_LEAVE_SOUND_EFFECT);
     // get this to close down and also close the tint.
     // get a confirmation here
     //DeselectButtons();
     if (selectedItem != null)
     {
         selectedItem.Deselect();
         selectedItem = null;
     }
     this.gameObject.SetActive(false);
 }
    public void ItemClicked(InventoryDisplayItem item)
    {
        //if (this.selectedItem.itemData != null)
        //{
        //    this.selectedItem.itemData.Deselect();
        //}

        //this.selectedItem.RefreshSelected(item);
        //ShowSelectedItem();
        if (this.selectedItem != null)
        {
            this.selectedItem.Deselect();
        }
        this.selectedItem = item;
        this.selectedItem.CheckIsUseable();
        Debug.Log(item.itemName.text + " Clicked");
    }
Exemple #6
0
    public void RefreshSelected(InventoryDisplayItem item)
    {
        if (item == null)
        {
            return;
        }

        var qty         = PF_PlayerData.GetItemQty(item.category.itemId);
        var isContainer = item.category.catalogRef.Container != null && item.category.catalogRef.Container.ResultTableContents != null;

        itemData             = item;
        icon.overrideSprite  = item.category.icon;
        itemName.text        = item.category.catalogRef.DisplayName;
        itemDescription.text = item.category.catalogRef.Description;
        annotation.text      = item.category.inventory[0].Annotation;
        totalUses.text       = " x" + qty;

        UnlockAction.gameObject.SetActive(isContainer);
        UseAction.gameObject.SetActive(!isContainer && controller.activeFilter == DialogCanvasController.InventoryFilters.UsableInCombat);
        totalUses.gameObject.SetActive(qty != 1);
    }
    public void Init(Action <string> callback = null, DialogCanvasController.InventoryFilters filter = DialogCanvasController.InventoryFilters.AllItems)
    {
        foreach (var slot in itemSlots)
        {
            slot.gameObject.SetActive(false);
        }

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

        this.activeFilter = filter;

        if (callback != null)
        {
            this.callbackAfterUse = callback;
        }

        //only displaying the main currencies (Gold & Gems) for now
        this.currenciesInUse.Clear();
        this.currenciesInUse.Add("NT");

        if (PF_PlayerData.inventoryByCategory != null && PF_PlayerData.virtualCurrency != null)
        {
            this.itemsToDisplay = PF_PlayerData.inventoryByCategory;
            //this.Currencies.Init(PF_PlayerData.virtualCurrency);
        }
        else
        {
            return;
        }

        string filterName;
        // GlobalStrings.INV_FILTER_DISPLAY_NAMES.TryGetValue(filter, out filterName);
        //this.StoreName.text = string.Format(GlobalStrings.INV_WINDOW_TITLE, filterName);
        int count = 0;

        foreach (var kvp in this.itemsToDisplay)
        {
            bool addItem = false;
            if (filter == DialogCanvasController.InventoryFilters.Containers)
            {
                if (string.Equals(kvp.Value.catalogRef.ItemClass, filter.ToString()))
                {
                    addItem = true;
                }
                else
                {
                    continue;
                }
            }
            else if (filter == DialogCanvasController.InventoryFilters.Keys)
            {
                if (string.Equals(kvp.Value.catalogRef.ItemClass, filter.ToString()))
                {
                    addItem = true;
                }
                else
                {
                    continue;
                }
            }
            else if (filter == DialogCanvasController.InventoryFilters.UsableInCombat)
            {
                if (string.Equals(kvp.Value.catalogRef.ItemClass, filter.ToString()))
                {
                    addItem = true;
                }
                else
                {
                    continue;
                }
            }
            else if (filter == DialogCanvasController.InventoryFilters.Material)
            {
                if (string.Equals(kvp.Value.catalogRef.ItemClass, filter.ToString()))
                {
                    addItem = true;
                }
                else
                {
                    continue;
                }
            }
            else if (filter == DialogCanvasController.InventoryFilters.AllItems)
            {
                addItem = true;
            }
            if (addItem == true)
            {
                itemSlots[count].gameObject.SetActive(true);
                itemSlots[count].Init();
                itemSlots[count].SetButton(kvp.Value.icon, kvp.Value);

                count++;
            }
        }
        this.gameObject.SetActive(true);
    }