Esempio n. 1
0
    public void ItemAdded(Item item)
    {
        InventoryUIItem emptyItem = Instantiate(ItemContainer); /* The instantiation of the item containers. */

        emptyItem.SetItem(item);                                /* Now since item is instantiated, we pass in the item that it receieved via the event. */
        emptyItem.transform.SetParent(scrollViewContent);
    }
Esempio n. 2
0
    public void ItemAdded(Item item)
    {
        InventoryUIItem emptyItem = Instantiate(itemContainer);

        emptyItem.SetItem(item);
        emptyItem.transform.SetParent(scrollViewContent);
    }
Esempio n. 3
0
    void ItemAddToCharacterViewer(Item item)
    {
        InventoryUIItem emptyItem = Instantiate(itemContainer);

        emptyItem.SetItem(item);
        if (item.TwoHanded)
        {
            characterViewer.Find("Equipment").Find("Equip_Blank").gameObject.SetActive(true);
            characterViewer.Find("Equipment").Find("Equip_Left").gameObject.SetActive(false);
        }
        switch (item.ObjectSlug)
        {
        case "sword":
            emptyItem.transform.SetParent(characterViewer.Find("Equipment").Find("Equip_Right").GetComponent <RectTransform>());
            break;

        case "staff":
            emptyItem.transform.SetParent(characterViewer.Find("Equipment").Find("Equip_Right").GetComponent <RectTransform>());
            break;

        default:
            Debug.Log("no");
            break;
        }
    }
Esempio n. 4
0
    void LootItem(List <Item> items)
    {
        CleanUp(lootWindow);
        looting = items;
        if (looting.Count == 0)
        {
            isLootingOn = false;
            lootPanel.gameObject.SetActive(isLootingOn);
            UIEventHandler.ItemLooted();
        }
        foreach (Item item in looting)
        {
            isLootingOn = true;
            lootPanel.gameObject.SetActive(isLootingOn);
            if (viewerVisible)
            {
                ToggleViewer();
            }

            itemName.text = item.ItemName;
            InventoryUIItem emptyItem = Instantiate(lootItemContainer);
            currentSelectedItem = item;
            emptyItem.SetItem(item);
            emptyItem.transform.SetParent(lootWindow);
        }
    }
Esempio n. 5
0
    void ItemAdded(ItemMeta item)
    {
        InventoryUIItem empty = Instantiate(itemContainer);

        empty.Item = item;
        empty.transform.SetParent(scrollViewContent);
    }
    public void ItemAdded(Item item)
    {
        Debug.Log("Adding Item: " + item.ItemName);
        InventoryUIItem emptyItem = Instantiate(itemContainer);

        emptyItem.SetItem(item);
        emptyItem.transform.SetParent(scrollViewContent);
    }
Esempio n. 7
0
    private void AddItemRepresentation(Item item)
    {
        //Debug.Log("Inventory UI adding item with uuid: " + item.Uuid + "Items in map: " + uuidToPrefab.Count);
        InventoryUIItem emptyItem = Instantiate(itemContainer);

        emptyItem.SetItem(item);
        emptyItem.transform.SetParent(scrollViewContent, false);
        uuidToPrefab[item.Uuid] = emptyItem.gameObject;
        UpdateItemNumbersUI();
    }
Esempio n. 8
0
    public void ItemAdded(Item item)
    {
        InventoryUIItem emptyItem = Instantiate(itemContainer, scrollViewContent);

        emptyItem.transform.localPosition = new Vector3(1, 1, 1);
        emptyItem.SetItem(item);
        // emptyItem.transform.SetParent(scrollViewContent);
        scrollViewContent.sizeDelta = new Vector2(scrollViewContent.rect.width, scrollViewContent.rect.height + itemContainer.GetComponent <RectTransform>().rect.height);
        emptyItem.GetComponent <RectTransform>().localScale = new Vector3(1, 1, 1);
    }
Esempio n. 9
0
    //Seperate system for quests
    public void questAdded(Quest quest)
    {
        //Creates a new item container which holds item information as UI element
        InventoryUIItem emptyItem = Instantiate(itemContainer);

        //Set quest information for UI
        emptyItem.setQuest(quest);

        //Assign quest container to correct tab
        emptyItem.transform.SetParent(questScrollViewContent, false);
    }
Esempio n. 10
0
    void Start()
    {
        //Loads item container prefab for inventory slots
        itemContainer = Resources.Load <InventoryUIItem>("InventoryUI/ItemContainer");

        //Helps UI know which item added to inventory. Event is known
        UIEventHandler.OnItemAddedToInventory += itemAdded;

        //Add quest to event system like above
        UIEventHandler.OnQuestAddedToInventory += questAdded;
    }
Esempio n. 11
0
    public void ItemAdded(Item item)
    {
        InventoryUIItem emptyItem = Instantiate(itemContainer);

        emptyItem.SetItem(item);
        if (item.TwoHanded && InventoryController.isEquipped)
        {
            characterViewer.Find("Equipment").Find("Equip_Blank").gameObject.SetActive(false);
            characterViewer.Find("Equipment").Find("Equip_Left").gameObject.SetActive(true);
        }
        emptyItem.transform.SetParent(scrollViewContent);
    }
 public void AddUIItem(PIckUp p)
 {
     if (!uiItems.Contains(p))
     {
         Transform       t = Instantiate(UIItemPrefab, transform);
         InventoryUIItem i = t.GetComponent <InventoryUIItem>();
         if (i != null)
         {
             i.registerPickUp(p.item.name, p.InventoryIcon);
             uiItems.Add(p);
         }
     }
 }
    public void OnItemInteract()
    {
        InventoryUIItem itemUI = selectedItemButton.GetComponent <InventoryUIItem>();

        if (item.ItemTypes == Item.ItemType.Consumable)
        {
            if (item.Stackable)
            {
                if (itemUI.Amount > 1)
                {
                    itemUI.UpdateCountConsume();
                    InventoryController.Instance.consumable.ConsumeItem(item);
                }
                else

                {
                    InventoryController.Instance.RemoveItem(item);
                    InventoryController.Instance.consumable.ConsumeItem(item);
                    Destroy(selectedItemButton.gameObject);
                    uiControl.ItemRemoved(selectedItemButton);
                    RemoveItemDetails();
                }
            }

            else
            {
                InventoryController.Instance.RemoveItem(item);
                InventoryController.Instance.consumable.ConsumeItem(item);
                Destroy(selectedItemButton.gameObject);
                uiControl.ItemRemoved(selectedItemButton);
                RemoveItemDetails(); //Remember to copy this to other types of Items.
            }
        }
        else if (item.ItemTypes == Item.ItemType.Craftables)
        {
            Debug.Log("Crafting Item Cant Do Anything");
        }

        else if (item.ItemTypes == Item.ItemType.QuestItem)
        {
            Debug.Log("Questing Item");
        }
        else
        {
            item = null;
        }
    }
Esempio n. 14
0
    private void UpdateInventory(Item item)
    {
        int itemCount = PlayerInventory.Instance.GetItemCount(item.GetItemID());

        if (itemCount > 1)
        {
            viewContent.Find("item_id:" + item.GetItemID()).GetComponent <InventoryUIItem>().number.text = itemCount.ToString();
        }
        else
        {
            InventoryUIItem emptyItem = Instantiate(itemContainer);
            emptyItem.SetItem(item);
            emptyItem.name = "item_id:" + item.GetItemID().ToString();
            emptyItem.transform.SetParent(viewContent);
        }
        UpdateInventorySize();
    }
Esempio n. 15
0
    void Awake()
    {
        if (Instance != null && Instance != this)
        {
            Destroy(gameObject);
        }
        else
        {
            Instance = this;
        }
        //Events
        UIEventHandler.OnItemAddedToInventory += ItemAdded;
        UIEventHandler.OnItemEquipped         += ItemAddToCharacterViewer;
        UIEventHandler.OnItemEquipped         += ShowStats;
        UIEventHandler.OnItemAddedToInventory += ShowStats;
        UIEventHandler.OnLootOpen             += LootItem;

        //Resource loading
        itemContainer     = Resources.Load <InventoryUIItem>("UI/ItemContainer");
        lootItemContainer = Resources.Load <InventoryUIItem>("UI/LootItem");
        characterStat     = Resources.Load <CharacterStatItem>("UI/CharacterStat");

        //Defining
        backpackInfoText   = backpackInfo.transform.Find("PlayerName").GetComponent <Text>();
        characterTab       = characterViewerPanel.transform.Find("ToggleTab").transform.Find("CharacterTab").GetComponent <Toggle>();
        skillsTab          = characterViewerPanel.transform.Find("ToggleTab").transform.Find("SkillsTab").GetComponent <Toggle>();
        characterStatPanel = characterViewer.Find("CharacterStats").GetComponent <RectTransform>();
        loot       = lootPanel.Find("Loot").GetComponent <Button>();
        lootWindow = lootPanel.Find("LootWindow").GetComponent <RectTransform>();
        lootAll    = lootPanel.Find("LootAll").GetComponent <Button>();
        itemName   = lootItemContainer.transform.Find("Text").GetComponent <Text>();

        //Button setups
        loot.onClick.AddListener(delegate { LootCurrentItem(); });
        characterTab.onValueChanged.AddListener(delegate { ToggleCharacterViewerTab(); });
        skillsTab.onValueChanged.AddListener(delegate { ToggleSkillsViewerTab(); });
        lootAll.onClick.AddListener(delegate { LootAll(); });


        //Additional things
        characterViewerPanel.SetActive(false);
        lootPanel.gameObject.SetActive(false);
        loot.gameObject.SetActive(false);
        inventoryPanel.gameObject.SetActive(false);
    }
Esempio n. 16
0
    void Start()
    {
        if (Instance != null && Instance != this)
        {
            Destroy(gameObject);
        }
        else
        {
            Instance = this;
        }

        itemContainer = Resources.Load <InventoryUIItem>("UI/Item_Container");

        EventHandler.OnItemAdded   += UpdateInventory;
        EventHandler.OnItemRemoved += RemoveItem;

        inventoryToggle = false;
        itemSelected    = false;
        inventoryUI.gameObject.SetActive(inventoryToggle);
        inventorySize.text = "0/49";
    }
 public void ItemAdded(Item item)
 {
     if (item.Stackable && CheckIfItemIsInInventory(item))
     {
         for (int i = 0; i < itemUIList.Count; i++)
         {
             if (itemUIList[i].item == item)
             {
                 itemUIList[i].UpdateCount();
             }
         }
     }
     else if (!item.Stackable || !CheckIfItemIsInInventory(item))
     {
         InventoryUIItem emptyItem = Instantiate(ItemContainer);
         emptyItem.SetItem(item);
         itemUIList.Add(emptyItem);
         emptyItem.transform.SetParent(itemHolder);
         emptyItem.transform.localScale = new Vector3(1f, 1f, 1f);
         inventoryButtons.Add(emptyItem.GetComponent <Button>());
     }
 }
Esempio n. 18
0
    //So UI knows is added
    public void itemAdded(Item item)
    {
        //Updates Inventory UI to add more items
        //Because of event system, adds these

        if (item.quantity < 0)
        {
            return;
        }

        //This means an item was removed and no more are in inv
        if (item.quantity == 0)
        {
            if (item.itemType == Item.ItemType.Resource)
            {
                foreach (Transform child in resourcesScrollViewContent)
                {
                    if (child.transform.Find("ItemName").GetComponent <Text>().text == item.name)
                    {
                        Destroy(child.gameObject);
                    }
                }
            }
            else if (item.itemType == Item.ItemType.Consumable)
            {
                foreach (Transform child in consumablesScrollViewContent)
                {
                    if (child.transform.Find("ItemName").GetComponent <Text>().text == item.name)
                    {
                        Destroy(child.gameObject);
                    }
                }
            }
            else if (item.itemType == Item.ItemType.Weapon)
            {
                foreach (Transform child in weaponsScrollViewContent)
                {
                    if (child.transform.Find("ItemName").GetComponent <Text>().text == item.name)
                    {
                        Destroy(child.gameObject);
                    }
                }
            }

            return;
        }

        //Creates a new item container which holds item information as UI element
        InventoryUIItem emptyItem = Instantiate(itemContainer);

        //This deals with item stacking, if resources already has UI element with given item, delete current item UI and create a new one with updated quantity
        if (item.itemType == Item.ItemType.Resource)
        {
            foreach (Transform child in resourcesScrollViewContent)
            {
                if (child.transform.Find("ItemName").GetComponent <Text>().text == item.name)
                {
                    Destroy(child.gameObject);
                }
            }
        }
        else if (item.itemType == Item.ItemType.Consumable)
        {
            foreach (Transform child in consumablesScrollViewContent)
            {
                if (child.transform.Find("ItemName").GetComponent <Text>().text == item.name)
                {
                    Destroy(child.gameObject);
                }
            }
        }
        else if (item.itemType == Item.ItemType.Weapon)
        {
            foreach (Transform child in weaponsScrollViewContent)
            {
                if (child.transform.Find("ItemName").GetComponent <Text>().text == item.name)
                {
                    Destroy(child.gameObject);
                }
            }
        }

        //Set item information for UI
        emptyItem.setItem(item);

        //Assign item container to correct tab
        if (item.itemType == Item.ItemType.Resource)
        {
            emptyItem.transform.SetParent(resourcesScrollViewContent, false);
        }
        if (item.itemType == Item.ItemType.Consumable)
        {
            emptyItem.transform.SetParent(consumablesScrollViewContent, false);
        }
        if (item.itemType == Item.ItemType.Weapon)
        {
            emptyItem.transform.SetParent(weaponsScrollViewContent, false);
        }
        if (item.itemType == Item.ItemType.Craftable)
        {
            emptyItem.transform.SetParent(craftablesScrollViewContent, false);
        }
    }
Esempio n. 19
0
 private void Awake()
 {
     instance = this;
 }
Esempio n. 20
0
 // Use this for initialization
 void Start()
 {
     itemContainer             = Resources.Load <InventoryUIItem>("UI/ItemContainer");
     UIEventHandler.OnAddItem += ItemAdded;
     panel.gameObject.SetActive(false);
 }