using System.Collections; using System.Collections.Generic; using System.Text; using TableConfig; using UnityEngine; using UnityEngine.UI; namespace Snxxz.UI { public class ViewPetHorseStoneCell : CellView { [SerializeField] ItemCell m_Item; [SerializeField] Slider m_Slider; [SerializeField] Text m_UseNum; [SerializeField] Text m_Property; static Dictionary propertyDict = new Dictionary(); static StringBuilder textBuilder = new StringBuilder(); public void Display(int itemId, int count) { var config = Config.Instance.Get(itemId); if (config == null) { return; } ItemCellModel cellModel = new ItemCellModel(itemId, true, (ulong)count); m_Item.Init(cellModel); m_Item.cellBtn.RemoveAllListeners(); m_Item.cellBtn.AddListener(() => { ItemAttrData itemAttrData = new ItemAttrData(itemId, true); ModelCenter.Instance.GetModel().SetItemTipsModel(itemAttrData); }); var stoneConfig = Config.Instance.Get(itemId); if (stoneConfig != null) { m_Slider.value = (float)count / stoneConfig.MaxUseCnt; m_UseNum.text = StringUtility.Contact(count, "/", stoneConfig.MaxUseCnt); } propertyDict.Clear(); if (config.Effect1 != 0) { propertyDict.Add(config.Effect1, config.EffectValueA1); } if (config.Effect2 != 0) { propertyDict.Add(config.Effect2, config.EffectValueA2); } if (config.Effect3 != 0) { propertyDict.Add(config.Effect3, config.EffectValueA3); } if (config.Effect4 != 0) { propertyDict.Add(config.Effect4, config.EffectValueA4); } if (config.Effect5 != 0) { propertyDict.Add(config.Effect5, config.EffectValueA5); } var index = 0; textBuilder.Length = 0; foreach (var key in propertyDict.Keys) { var propertyConfig = Config.Instance.Get(key); textBuilder.Append(propertyConfig == null ? string.Empty : propertyConfig.Name); textBuilder.Append(" +"); textBuilder.Append(UIHelper.ReplaceLargeNum(UIHelper.ReplacePercentage(count * propertyDict[key], propertyConfig == null ? 0 : propertyConfig.ISPercentage))); textBuilder.Append(""); index++; textBuilder.Append(index % 3 == 0 && index > 0 ? "\n" : " "); } m_Property.text = textBuilder.ToString(); } } }