private void UpdateItemsToUI(List <Item> items, ItemUIType type, int itemCount)
    {
        ResetItemButtons();
        ItemDescription.text = "Select Item";

        for (int i = itemCount; i < itemButtons.Count; i++)
        {
            itemButtons[i].interactable = false;
            itemButtons[i].image.sprite = ItemButtonEmptySprite;
        }
        for (int i = 0; i < itemCount; i++)
        {
            Item   item   = items[i];
            Button button = itemButtons[i];
            Text   stack  = button.transform.GetChild(0).GetComponent <Text>();
            button.onClick.AddListener(() => ViewItem(item, type));
            button.interactable = true;

            if (item.sprite)
            {
                button.image.sprite = item.sprite;
            }
        }

        if (type == ItemUIType.Inventory || type == ItemUIType.Sell)
        {
            ShowStacks(items, itemCount);
            UpdateStacks(items, itemCount);
        }
        else
        {
            HideStacks();
        }
    }
Пример #2
0
    public GameObject spawn_item_UI_body(ItemUIType itemUIType, Vector3 pos, bool forCharacter)
    {
        /*
         * if (itemUIType == ItemUIType.ITEM_HEART_UI)
         * {
         *  Debug.Log("there is no heart UI");
         *  return null;
         * }*/

        for (int i = 0; i < itemUIList.Count; i++)
        {
            if (itemUIType == itemUIList[i].itemUIType)
            {
                GameObject UI_body = Instantiate(itemUIList[i].itemUIObject, pos, transform.rotation) as GameObject;
                if (forCharacter)                 //GameManager.Instance.sub_managers.uIManager.itemUIList.Add(UI_body);
                {
                    GameManager.Instance.sub_managers.uIManager.UIList_add(UI_body, itemUIType);
                }
                UI_body.AddComponent <CoroutineBox>();
                //GameManager.Instance.garbageBox.garbageList.Add(UI_body);
                return(UI_body);
            }
        }
        Debug.Log("no such itemUI");
        return(null);
    }
    public void ManualToggleItemUI(bool toggle, ItemUIType type)
    {
        itemUIChecker = type;
        SwitchItemUIDesign(type);
        ItemUI.SetActive(toggle);
        // HandleItemTutorialGuide(type);
        ToggleMainUI(!toggle);
        AudioManager.Instance.inventory.Play();
        if (EventManager.currentShopAnimator)
        {
            EventManager.currentShopAnimator.ResetTrigger("Bow");
            EventManager.currentShopAnimator.SetTrigger("Bow");
        }
        Blur(toggle);
        if (!toggle)
        {
            inventoryToggler = ItemUIType.Inventory;
            ResetItemViewer(type);
            EnableUseOrBuyButton(false);
            EnableStashOrSellButton(false);
            GameManager.Instance.NormalTime();

            if (GameManager.Instance.Tutorial && TutorialManager.Instance.inventoryTestDone)
            {
                TutorialDialog(preBaybayinUnlockTutorial, true);
            }
        }
        else
        {
            GameManager.Instance.FreezeTime();
        }

        SwitchItemButtonTexts(type);
        SetUIRamifications(toggle);
    }
    public void ToggleInventory(bool toggle)
    {
        itemUIChecker = ItemUIType.Inventory;
        SwitchItemUIDesign(ItemUIType.Inventory);
        ItemUI.SetActive(toggle);
        // HandleItemTutorialGuide(type);
        Blur(ItemUI.activeSelf);
        UpdateInventoryToUI();
        AudioManager.Instance.inventory.Play();
        if (!ItemUI.activeSelf)
        {
            ResetItemViewer(ItemUIType.Inventory);
            inventoryToggler = ItemUIType.Inventory;
            EnableUseOrBuyButton(false);
            EnableStashOrSellButton(false);
            GameManager.Instance.NormalTime();

            if (GameManager.Instance.Tutorial && TutorialManager.Instance.inventoryTestDone)
            {
                TutorialDialog(preBaybayinUnlockTutorial, true);
            }
        }
        else
        {
            GameManager.Instance.FreezeTime();
        }
        SwitchItemButtonTexts(ItemUIType.Inventory);
        SetUIRamifications(ItemUI.activeSelf);
    }
 public void UpdateShopToUI(List <Item> items)
 {
     itemUIChecker = ItemUIType.Buy;
     ResetItemViewer(ItemUIType.Inventory);
     inventoryToggler = ItemUIType.Inventory;
     UpdateItemsToUI(items, ItemUIType.Buy, items.Count);
     StashOrSell.onClick.AddListener(() => UpdateToSellUI());
     SwitchItemButtonTexts(ItemUIType.Buy);
     EnableUseOrBuyButton(false);
     EnableStashOrSellButton(true);
 }
Пример #6
0
 public void UIList_add(GameObject UI_body, ItemUIType itemUIType)
 {
     if (itemUIType == ItemUIType.ITEM_HEART_UI || itemUIType == ItemUIType.ITEM_BLUEHEART_UI || itemUIType == ItemUIType.ITEM_BAG_HEART_UI)
     {
         GameManager.Instance.sub_managers.uIManager.heartUIList.Add(UI_body);
     }
     else
     {
         GameManager.Instance.sub_managers.uIManager.itemUIList.Add(UI_body);
     }
 }
 public void UpdateToSellUI()
 {
     itemUIChecker = ItemUIType.Sell;
     ResetItemViewer(ItemUIType.Inventory);
     inventoryToggler = ItemUIType.Sell;
     HandleItemTutorialGuide(ItemUIType.Sell);
     UseOrBuy.onClick.AddListener(() => UpdateShopToUI(GameManager.Instance.currentShopItems));
     SwitchItemButtonTexts(ItemUIType.Sell);
     UpdateItemsToUI(
         InventoryManager.Instance.inventory.items,
         ItemUIType.Sell,
         InventoryManager.Instance.GetItemCount()
         );
     EnableUseOrBuyButton(true);
     EnableStashOrSellButton(false);
 }
    private void SwitchItemUIDesign(ItemUIType type)
    {
        bool isInventory = type == ItemUIType.Inventory;

        ItemUI.GetComponent <Image>().sprite            = isInventory ? inventoryBG : shopBG;
        ConfirmationPanel.GetComponent <Image>().sprite = isInventory ? inventoryBG : shopBG;
        proceed.image.sprite      = isInventory ? inventoryButton : shopButton;
        deleteCancel.image.sprite = isInventory ? inventoryButton : shopButton;
        ItemUIClose.image.sprite  = isInventory ? inventoryButton : shopButton;
        UseOrBuy.image.sprite     = isInventory ? inventoryButton : shopButton;
        StashOrSell.image.sprite  = isInventory ? inventoryButton : shopButton;

        foreach (Image i in itemButtonBackgrounds)
        {
            i.sprite = isInventory ? inventoryStuff : shopStuff;
        }
    }
    public void ResetItemViewer(ItemUIType type)
    {
        ItemName.text        = "";
        CostOrSellPrice.text = "";
        switch (type)
        {
        case ItemUIType.Inventory:
            UseOrBuy.onClick.RemoveAllListeners();
            StashOrSell.onClick.RemoveAllListeners();
            break;

        case ItemUIType.Buy:
            UseOrBuy.onClick.RemoveAllListeners();
            break;

        case ItemUIType.Sell:
            StashOrSell.onClick.RemoveAllListeners();
            break;
        }
    }
    private void SwitchItemButtonTexts(ItemUIType type)
    {
        switch (type)
        {
        case ItemUIType.Inventory:
            UseOrBuy.GetComponentInChildren <Text>().text    = useButtonText;
            StashOrSell.GetComponentInChildren <Text>().text = stashButtonText;
            break;

        case ItemUIType.Buy:
            UseOrBuy.GetComponentInChildren <Text>().text    = buyButtonText;
            StashOrSell.GetComponentInChildren <Text>().text = sellButtonText;
            break;

        case ItemUIType.Sell:
            UseOrBuy.GetComponentInChildren <Text>().text    = returnText;
            StashOrSell.GetComponentInChildren <Text>().text = sellButtonText;
            break;
        }
    }
    // Tutorial
    private void HandleItemTutorialGuide(ItemUIType type)
    {
        if (GameManager.Instance.AreAllItemTutorialsDone())
        {
            return;
        }

        switch (type)
        {
        case ItemUIType.Inventory:
            if (!GameManager.Instance.inventoryTutorialMode)
            {
                return;
            }

            TutorialDialog(inventoryTutorial, GameManager.Instance.inventoryTutorialMode);
            GameManager.Instance.inventoryTutorialMode = false;
            break;

        case ItemUIType.Buy:
            if (!GameManager.Instance.shopTutorialMode)
            {
                return;
            }

            TutorialDialog(shopTutorial, GameManager.Instance.shopTutorialMode);
            GameManager.Instance.shopTutorialMode = false;
            break;

        case ItemUIType.Sell:
            if (!GameManager.Instance.sellTutorialMode)
            {
                return;
            }

            TutorialDialog(sellTutorial, GameManager.Instance.sellTutorialMode);
            GameManager.Instance.sellTutorialMode = false;
            break;
        }
    }
    void Start()
    {
        notEnoughManaTimer  = 0f;
        Player              = GameManager.Instance.Player;
        inventoryToggler    = ItemUIType.Inventory;
        previousDeleteCount = (int)toDeleteItemCount.value;

        ResetItemViewer(ItemUIType.Inventory);
        ResetBaybayinCharacterViewer();
        ResetSpellShardViewer();
        ResetSpellViewer();

        UpdateSpellsToArchive();
        UpdateSpellShardsToUI();
        UpdateInventoryToUI();
        UpdatePlayerHealth();
        UpdatePlayerMana();

        if (GameManager.Instance.Tutorial)
        {
            TutorialDialog(movementTutorial, !TutorialManager.Instance.movementTestDone);
        }
    }
Пример #13
0
 public GameObject get_body(ItemUIType itemUIType, Vector3 pos, bool forCharacter) //itemUI
 {
     return(bodyPools.itemBodyPool.spawn_item_UI_body(itemUIType, pos, forCharacter));
 }
    private void ViewItem(Item item, ItemUIType type)
    {
        ItemDescription.text = item.description;
        ResetItemViewer(type);

        ItemName.text = item.Name.ToString();
        switch (type)
        {
        case ItemUIType.Inventory:
            if (!UseOrBuy.interactable)
            {
                EnableUseOrBuyButton(true);
            }
            if (!StashOrSell.interactable)
            {
                EnableStashOrSellButton(true);
            }

            if (item.Useable)
            {
                UseOrBuy.onClick.AddListener(() => ItemManager.Instance.Use(item));
            }

            StashOrSell.onClick.AddListener(() =>
                                            ShowConfirmationPanel(
                                                InventoryManager.Instance.RemoveItems,
                                                "Are you sure you want to discard this item?",
                                                item
                                                )
                                            );
            break;

        case ItemUIType.Buy:
            if (GameManager.Instance.Gold < item.BuyPrice)
            {
                UseOrBuy.interactable = false;
                return;
            }

            if (!UseOrBuy.interactable)
            {
                EnableUseOrBuyButton(true);
            }

            CostOrSellPrice.text = "Cost: " + item.BuyPrice.ToString();
            UseOrBuy.onClick.AddListener(() => Shop.Buy(item));
            break;

        case ItemUIType.Sell:
            if (!StashOrSell.interactable)
            {
                StashOrSell.interactable = true;
            }

            CostOrSellPrice.text = "Sell Price: " + item.SellPrice.ToString();
            StashOrSell.onClick.AddListener(() =>
                                            ShowConfirmationPanel(
                                                Shop.SellByStacks,
                                                "Are you sure you want to sell this item?",
                                                item
                                                )
                                            );
            break;
        }
    }