예제 #1
0
        public void UpdateIncome()
        {
            float price = 0f;

            if (m_Product.IsSellingWorld)
            {
                price = m_Product.m_PriceWorld;
            }
            else
            {
                price = m_Product.m_PriceLocal;
            }
            m_Income.text = UIManager.ConvertFloatToStringPrice(Inventory.Instance.m_SellingAmount[m_Product] * price);
        }
        public void Init(ProductionBuilding _pb)
        {
            m_PB               = _pb;
            m_Title.text       = m_PB.m_UIName;
            m_Cost.text        = UIManager.ConvertFloatToStringPrice(_pb.m_Cost);
            m_Balance.text     = UIManager.ConvertFloatToStringPriceWithSign(_pb.m_OperatingCost, out Color c);
            m_Balance.color    = c;
            m_Btn.interactable = false;
            m_UnlockBG.color   = Color.red;
            m_Conditions       = _pb.m_Production.m_Conditions;

            foreach (ProductionStat ps in m_PB.m_Production.m_Output)
            {
                GameObject obj = Instantiate(Output_Prefab, transform);
                obj.transform.SetSiblingIndex(1);
                m_Rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, m_Rect.rect.height + 50f);
                TextMeshProUGUI t = null;
                foreach (Transform child in obj.transform)
                {
                    if (child.gameObject.tag == "EditText")
                    {
                        t = child.GetComponent <TextMeshProUGUI>();
                        break;
                    }
                }
                if (t == null)
                {
                    Debug.LogError("No EditText Tag found in: " + obj);
                    return;
                }
                t.text = ps.m_Amount.ToString() + " " + ps.m_Product.m_UI_Name;
                if (ps.m_Product.m_UI_Sprit != null)
                {
                    Image i = obj.GetComponentInChildren <Image>();
                    i.sprite = ps.m_Product.m_UI_Sprit;
                }
            }

            foreach (ProductionStat ps in m_PB.m_Production.m_Input)
            {
                GameObject obj = Instantiate(Input_Prefab, transform);
                obj.transform.SetSiblingIndex(1);
                m_Rect.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, m_Rect.rect.height + 50f);
                TextMeshProUGUI t = null;
                foreach (Transform child in obj.transform)
                {
                    if (child.gameObject.tag == "EditText")
                    {
                        t = child.GetComponent <TextMeshProUGUI>();
                        break;
                    }
                }
                if (t == null)
                {
                    Debug.LogError("No EditText Tag found in: " + obj);
                    return;
                }
                t.text = ps.m_Amount.ToString() + " " + ps.m_Product.m_UI_Name;
                if (ps.m_Product.m_UI_Sprit != null)
                {
                    Image i = obj.GetComponentInChildren <Image>();
                    i.sprite = ps.m_Product.m_UI_Sprit;
                }
            }
        }
예제 #3
0
 private void SetCurrPrice(float _amount)
 {
     m_CurrPrice.text = UIManager.ConvertFloatToStringPrice(_amount);
 }