using System.Collections;
|
using System.Collections.Generic;
|
using System.Text;
|
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
namespace vnxbqy.UI
|
{
|
public class ViewPetHorseStoneCell : CellView
|
{
|
[SerializeField] ItemCell m_Item;
|
[SerializeField] Slider m_Slider;
|
[SerializeField] Text m_UseNum;
|
[SerializeField] Text m_Property;
|
|
static Dictionary<int, int> propertyDict = new Dictionary<int, int>();
|
|
static StringBuilder textBuilder = new StringBuilder();
|
|
public void Display(int itemId, int count)
|
{
|
var config = ItemConfig.Get(itemId);
|
if (config == null)
|
{
|
return;
|
}
|
ItemCellModel cellModel = new ItemCellModel(itemId, true, (ulong)count);
|
m_Item.Init(cellModel);
|
|
m_Item.button.RemoveAllListeners();
|
m_Item.button.AddListener(() =>
|
{
|
ItemTipUtility.Show(itemId);
|
});
|
|
var stoneConfig = AttrFruitConfig.Get(itemId);
|
if (stoneConfig != null)
|
{
|
m_Slider.value = (float)count / stoneConfig.basicUseLimit;
|
m_UseNum.text = StringUtility.Contact(count, "/", stoneConfig.basicUseLimit);
|
}
|
|
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 = PlayerPropertyConfig.Get(key);
|
textBuilder.Append(propertyConfig == null ? string.Empty : propertyConfig.Name);
|
textBuilder.Append(" <color=#109d06>+");
|
textBuilder.Append(UIHelper.ReplaceLargeNum(UIHelper.ReplacePercentage(count * propertyDict[key], propertyConfig == null ? 0 : propertyConfig.ISPercentage)));
|
textBuilder.Append("</color>");
|
index++;
|
textBuilder.Append(index % 3 == 0 && index > 0 ? "\n" : " ");
|
}
|
m_Property.text = textBuilder.ToString();
|
}
|
}
|
}
|