public void UpdateItenIcon(int itenIndex)
    {
        /*indice 0 é bomba, 1 e shield */
        Transform itemUIRef = gameObject.transform.GetChild(0).transform.Find(Constantes.PLAYER_PANEL).transform.Find(Constantes.ITEM_UI);

        if (itemUIRef)
        {
            if (itenIndex == 0)
            {
                itemUIRef.Find(Constantes.ITEM_IMAGE).gameObject.GetComponent <Image>().sprite = bombIcon;
                amountText.text = "X " + PlayerGlobalStatus.GetPlayerBombsNumber().ToString();
            }
            else if (itenIndex == 1)
            {
                itemUIRef.Find(Constantes.ITEM_IMAGE).gameObject.GetComponent <Image>().sprite = shieldIcon;
                amountText.text = "X " + PlayerGlobalStatus.GetPlayerShieldsNumber().ToString();
            }
        }
        else
        {
            Debug.LogWarning(Constantes.MISSING_COMPONENT_NAME);
        }
    }
Esempio n. 2
0
 private void SetButtonsStatus(GameObject child, bool status, bool sellFlag = false)
 {
     if (item.CompareTag(Constantes.WEAPON))
     {
         if (PlayerHaveItem())
         {
             child.GetComponent <Button>().interactable = status;
         }
         else
         {
             child.GetComponent <Button>().interactable = !status;
         }
     }        //caso o item seja bomba ou shield, poderá comprar até 10
     else if (item.CompareTag(Constantes.BOMB))
     {
         //sellFlag serve apenas na tentativa de vender bombas ou shields
         if (!sellFlag)
         {
             if (PlayerGlobalStatus.GetPlayerBombsNumber() >= Constantes.MAX_ITEM_CAPACITY)
             {
                 child.GetComponent <Button>().interactable = status;
             }
             else
             {
                 child.GetComponent <Button>().interactable = !status;
             }
         }
         else
         {
             if (PlayerGlobalStatus.GetPlayerBombsNumber() > 0)
             {
                 child.GetComponent <Button>().interactable = status;
             }
             else
             {
                 child.GetComponent <Button>().interactable = !status;
             }
         }
     }
     else if (item.CompareTag(Constantes.SHIELD))
     {
         if (!sellFlag)
         {
             if (PlayerGlobalStatus.GetPlayerShieldsNumber() >= Constantes.MAX_ITEM_CAPACITY)
             {
                 child.GetComponent <Button>().interactable = status;
             }
             else
             {
                 child.GetComponent <Button>().interactable = !status;
             }
         }
         else
         {
             if (PlayerGlobalStatus.GetPlayerShieldsNumber() > 0)
             {
                 child.GetComponent <Button>().interactable = status;
             }
             else
             {
                 child.GetComponent <Button>().interactable = !status;
             }
         }
     }
     else
     {
         Debug.LogWarning(Constantes.NO_TAG_MATCHED);
     }
 }
    public void GeneratePanelOutput(List <GameObject> currentPanel, GameObject panelRef, GameObject parentPanelRef, bool showNextAtributes = false)
    {
        string itemType = GetItemTypeTag();

        if (itemType == Constantes.WEAPON)
        {
            foreach (Ammo ammo in ammoList)
            {
                string output = "";
                //ordem aqui é importante, instanciar antes de usar ( logico rs)
                currentPanel.Add(Instantiate(panelRef));

                //se tiver a municao habilitada
                if (ammo.GetAmmoStatus() || parentPanelRef.name == Constantes.UPGRADE_INFO_PANEL)
                {
                    output = SetPanelOutputText(ammo.getAmmoPrefab().name, ammo.GetAmmoFirePower().ToString("#.##"),
                                                (1 / ammo.GetFireDelay()).ToString("#.#"), ammo.GetAmmoType());
                }
                //se ainda nao tiver a municao habilitada
                else
                {
                    output = SetPanelOutputText("???", ammo.GetAmmoFirePower().ToString("#.##")
                                                , (1 / ammo.GetFireDelay()).ToString("#.#"), ammo.GetAmmoType());
                    var colorAlpha = Color.black;
                    colorAlpha.a = 0.75f;
                    currentPanel[currentPanel.Count - 1].transform.Find(Constantes.PANEL).transform.Find(Constantes.AMMOS_IMAGE).gameObject.GetComponent <Image>().color = colorAlpha;
                    currentPanel[currentPanel.Count - 1].GetComponent <Image>().color = colorAlpha;
                    currentPanel[currentPanel.Count - 1].transform.Find(Constantes.AMMOS_INFO_PANEL).gameObject.GetComponent <TextMeshProUGUI>().color = colorAlpha;
                }
                //formatacao padrao pra ambos os casos
                currentPanel[currentPanel.Count - 1].transform.SetParent(parentPanelRef.transform, false);
                currentPanel[currentPanel.Count - 1].transform.Find(Constantes.PANEL).transform.Find(Constantes.AMMOS_IMAGE).gameObject.GetComponent <Image>().sprite = ammo.GetAmmoSprite();
                currentPanel[currentPanel.Count - 1].transform.Find(Constantes.AMMOS_INFO_PANEL).gameObject.GetComponent <TextMeshProUGUI>().text = output;
            }
        }
        //se for uma bomba
        else if (itemType == Constantes.BOMB)
        {
            string output = "";
            //ordem aqui é importante, instanciar antes de usar ( logico rs)
            currentPanel.Add(Instantiate(panelRef));
            Bomb bombRef = itemReference.GetComponent <ItemManager>().GetItemPrefab().GetComponent <Bomb>();
            /* se for o painel de upgrade, mostrará o status do próximo level */
            if (parentPanelRef.name == Constantes.UPGRADE_INFO_PANEL)
            {
                output = SetPanelOutputText(bombRef.name, bombRef.GetBombPower().ToString("#.##"), bombRef.GetBombRadius().ToString("#.##"), bombRef, showNextAtributes);
            }
            /*bombas e shields sempre mostrarão a info, tendo o item ou nao */
            else
            {
                output = SetPanelOutputText(bombRef.name, bombRef.GetBombPower().ToString("#.##"), bombRef.GetBombRadius().ToString("#.##"), bombRef);
            }
            //formatacao padrao pra ambos os casos
            currentPanel[currentPanel.Count - 1].transform.SetParent(parentPanelRef.transform, false);
            currentPanel[currentPanel.Count - 1].transform.Find(Constantes.PANEL).transform.Find(Constantes.AMMOS_IMAGE).gameObject.GetComponent <Image>().sprite = bombRef.GetBombIcon();
            currentPanel[currentPanel.Count - 1].transform.Find(Constantes.AMMOS_INFO_PANEL).gameObject.GetComponent <TextMeshProUGUI>().text = output;

            /* PRINTA AS INFORMACOES DA QUANTIDADE */
            ShowItemAmountOnInfoPanel("BOMBS", PlayerGlobalStatus.GetPlayerBombsNumber());
        }
        //se for um shield
        else
        {
            string output = "";
            //ordem aqui é importante, instanciar antes de usar ( logico rs)
            currentPanel.Add(Instantiate(panelRef));
            Shield shieldRef = itemReference.GetComponent <ItemManager>().GetItemPrefab().GetComponent <Shield>();

            /* se for o painel de upgrade, mostrará o status do próximo level */
            if (parentPanelRef.name == Constantes.UPGRADE_INFO_PANEL)
            {
                output = SetPanelOutputText(shieldRef.name, shieldRef.GetshieldDuration().ToString("#.##"), shieldRef, showNextAtributes);
            }
            else
            {
                output = SetPanelOutputText(shieldRef.name, shieldRef.GetshieldDuration().ToString("#.##"), shieldRef);
            }
            //formatacao padrao pra ambos os casos
            currentPanel[currentPanel.Count - 1].transform.SetParent(parentPanelRef.transform, false);
            currentPanel[currentPanel.Count - 1].transform.Find(Constantes.PANEL).transform.Find(Constantes.AMMOS_IMAGE).gameObject.GetComponent <Image>().sprite = shieldRef.GetShieldIcon();
            currentPanel[currentPanel.Count - 1].transform.Find(Constantes.AMMOS_INFO_PANEL).gameObject.GetComponent <TextMeshProUGUI>().text = output;

            /* PRINTA AS INFORMACOES DA QUANTIDADE */
            ShowItemAmountOnInfoPanel("SHIELDS", PlayerGlobalStatus.GetPlayerShieldsNumber());
        }
    }