Ejemplo n.º 1
0
    void Awake()
    {
        m_potsImg = new PotSelectImg[5];

        m_potsImg[0] = GameObject.Find("Img1").GetComponent <PotSelectImg>();
        m_potsImg[1] = GameObject.Find("Img2").GetComponent <PotSelectImg>();
        m_potsImg[2] = GameObject.Find("Img3").GetComponent <PotSelectImg>();
        m_potsImg[3] = GameObject.Find("Img4").GetComponent <PotSelectImg>();
        m_potsImg[4] = GameObject.Find("Img5").GetComponent <PotSelectImg>();

        m_pots     = GameObject.FindGameObjectWithTag("Player").GetComponent <PotionBag>();
        m_potsList = m_pots.GetPotiosBag();

        m_initilized = false;
        m_alreadySet = false;
    }
Ejemplo n.º 2
0
    public void InitializePotionsImage()
    {
        m_potsList  = m_pots.GetPotiosBag();
        m_activeBag = m_pots.GetActivePot();

        if (m_potsList.Count > 0)
        {
            for (int i = 0; i < m_potsImg.Length; i++)
            {
                m_potsImg[i].gameObject.SetActive(true);
            }

            m_activeBag = m_pots.GetActivePot();
            int leftBag  = (m_activeBag - 1 < 0) ? m_potsList.Count - (0 - (m_activeBag - 1)) : m_activeBag - 1;
            int rightBag = (m_activeBag + 1 > m_potsList.Count - 1) ? 0 + ((m_activeBag + 1) - m_potsList.Count) : m_activeBag + 1;
            int auxBag   = (m_activeBag - 2 < 0) ? m_potsList.Count - (0 - (m_activeBag - 2)) : m_activeBag - 2;
            int auxBag2  = (m_activeBag + 2 > m_potsList.Count - 1) ? 0 + ((m_activeBag + 2) - m_potsList.Count) : m_activeBag + 2;

            if (m_potsList.Count <= 1)
            {
                auxBag  = 0;
                auxBag2 = 0;
            }

            for (int i = 0; i < m_potsImg.Length; i++)
            {
                switch (m_potsImg[i].GetPos())
                {
                case 1:
                    m_potsImg[i].SetImage(CraftingDataBase.GetPotionImage(m_potsList[m_activeBag][0]));
                    break;

                case 2:
                    m_potsImg[i].SetImage(CraftingDataBase.GetPotionImage(m_potsList[rightBag][0]));
                    break;

                case 3:
                    m_potsImg[i].SetImage(CraftingDataBase.GetPotionImage(m_potsList[auxBag2][0]));
                    break;

                case 4:
                    m_potsImg[i].SetImage(CraftingDataBase.GetPotionImage(m_potsList[auxBag][0]));
                    break;

                case 5:
                    m_potsImg[i].SetImage(CraftingDataBase.GetPotionImage(m_potsList[leftBag][0]));
                    break;

                default:
                    break;
                }
            }
        }
        else if (m_potsList.Count == 0)
        {
            for (int i = 0; i < m_potsImg.Length; i++)
            {
                m_potsImg[i].gameObject.SetActive(false);
            }
        }


        m_initilized = true;
        m_alreadySet = true;
    }