// *********************************************************************** // Assembly : Game // Author : Kimch // Created : 2020-09-12 // Description : // Last Modified By : // Last Modified On : // *********************************************************************** // // // *********************************************************************** using TMPro; using UnityEngine; using UnityEngine.UI; namespace G.UI { /// /// 广告费用 /// public class AdCostWidget : KUIWidget { #region Field #pragma warning disable CS0649 // 从未对字段赋值,字段将一直保持其默认值 null [KUIFlag] KUIImage _imgFrame; [KUIFlag] Image _imgIcon; [KUIFlag] TextMeshProUGUI _tmpCount; #pragma warning restore CS0649 // 从未对字段赋值,字段将一直保持其默认值 null private Color _oriColor; #endregion #region Method public void SetCount(int cur, int max) { bool enough = cur >= 0; _tmpCount.color = enough ? _oriColor : Color.red; _tmpCount.text = $"{cur}/{max}"; } /// /// /// /// /// public void SetPrice(int itemId, int count, bool enough = true) { var prop = ItemProxy.Instance.GetStaticItem(itemId); if (prop != null) { IconProxy.Instance.SetSprite(_imgIcon, prop.icon); if (_imgFrame) _imgFrame.ShowSprite(prop.quality); } _tmpCount.color = enough ? _oriColor : Color.red; _tmpCount.text = count.ToString(); } /// /// /// /// /// public void SetPrice(Item.ItemInfo itemInfo, bool enough = true) { SetPrice(itemInfo.id, itemInfo.count, enough); } /// /// 自己检测 /// /// /// public void SetPrice2(int itemId, int count) { var prop = ItemProxy.Instance.GetStaticItem(itemId); if (prop != null) { IconProxy.Instance.SetSprite(_imgIcon, prop.icon); if (_imgFrame) _imgFrame.ShowSprite(prop.quality); } _tmpCount.text = count.ToString(); _tmpCount.color = MoneyProxy.Instance.CheckMoney(itemId, count) ? _oriColor : Color.red; } #endregion #region Unity /// /// /// private void Awake() { SetViewData(); _oriColor = _tmpCount.color; } #endregion } }