Exemple #1
0
 public void HideCount(bool isHide = true)
 {
     if (_commonItemIcon != null)
     {
         _commonItemIcon.HideCount();
     }
 }
        private void RefreshMaterial()
        {
            TransformUtil.ClearChildren(materialRoot, true);

            materialPrefab.gameObject.SetActive(true);
            BlackMarketInfo    info     = BlackMarketProxy.instance.selectBlackMarketInfo;
            List <GameResData> material = null;

            if (info != null)
            {
                material = info.materials;
            }
            else
            {
                material = new List <GameResData>();
            }
            int         count = material.Count;
            GameResData resData;

            for (int i = 0; i < 4; i++)
            {
                Transform tran = Instantiate <Transform>(materialPrefab);
                tran.transform.SetParent(materialRoot, false);
                Text      textCount     = tran.Find("text_count").GetComponent <Text>();
                Transform material_root = tran.Find("materialRoot");
                if (i < count)
                {
                    resData = material[i];
                    CommonItemIcon icon = CommonItemIcon.Create(material_root);
                    icon.SetGameResData(resData);
                    icon.HideCount();
                    int ownCount = 0;
                    if (resData.type == BaseResType.Item)
                    {
                        ownCount = ItemProxy.instance.GetItemCountByItemID(resData.id);
                    }
                    else
                    {
                        ownCount = GameProxy.instance.BaseResourceDictionary.GetValue(resData.type);
                    }

                    string countString = string.Format(Localization.Get("common.value/max"), ownCount, resData.count);
                    textCount.text = ownCount >= resData.count ? UIUtil.FormatToGreenText(countString) : UIUtil.FormatToRedText(countString);
                }
                else
                {
                    textCount.text = string.Empty;
                }
            }
            materialPrefab.gameObject.SetActive(false);
        }