From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- Client/Assets/Scripts/XMainClient/NeedItemView.cs | 85 +++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/NeedItemView.cs (limited to 'Client/Assets/Scripts/XMainClient/NeedItemView.cs') diff --git a/Client/Assets/Scripts/XMainClient/NeedItemView.cs b/Client/Assets/Scripts/XMainClient/NeedItemView.cs new file mode 100644 index 00000000..3644bd8d --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/NeedItemView.cs @@ -0,0 +1,85 @@ +using System; +using UILib; +using UnityEngine; +using XMainClient.UI; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class NeedItemView + { + public GameObject goItem; + + public IXUISprite sprIcon; + + public IXUILabel lbNum; + + public bool bShowTotal; + + public int itemid; + + public int itemcount; + + public bool bIsEnough; + + public NeedItemView(bool showTotal = true) + { + this.bShowTotal = showTotal; + } + + public void FindFrom(Transform t) + { + bool flag = t != null; + if (flag) + { + this.goItem = t.gameObject; + this.lbNum = (t.Find("Num").GetComponent("XUILabel") as IXUILabel); + this.sprIcon = (t.Find("Icon").GetComponent("XUISprite") as IXUISprite); + } + } + + public void ResetItem() + { + XSingleton.singleton.DrawItem(this.goItem, null); + this.itemid = 0; + } + + public bool SetItem(int itemID, int needCount) + { + this.itemid = itemID; + this.itemcount = needCount; + XSingleton.singleton.normalItemDrawer.DrawItem(this.goItem, itemID, needCount, true); + this.sprIcon.ID = (ulong)((long)itemID); + ulong itemCount = XBagDocument.BagDoc.GetItemCount(itemID); + ulong num = (ulong)((long)needCount); + bool flag = itemCount >= num; + if (flag) + { + bool flag2 = this.bShowTotal; + if (flag2) + { + this.lbNum.SetText(string.Format(XStringDefineProxy.GetString("COMMON_COUNT_TOTAL_FMT"), XSingleton.singleton.NumberFormat(itemCount), XSingleton.singleton.NumberFormat(num))); + } + else + { + this.lbNum.SetText(string.Format("{0}", XSingleton.singleton.NumberFormat(num))); + } + this.bIsEnough = true; + } + else + { + bool flag3 = this.bShowTotal; + if (flag3) + { + this.lbNum.SetText(string.Format(XStringDefineProxy.GetString("COMMON_COUNT_TOTAL_NOTENOUGH_FMT"), XSingleton.singleton.NumberFormat(itemCount), XSingleton.singleton.NumberFormat(num))); + } + else + { + this.lbNum.SetText(string.Format("[FF0000]{0}[-]", XSingleton.singleton.NumberFormat(num))); + } + this.bIsEnough = false; + } + return this.bIsEnough; + } + } +} -- cgit v1.1-26-g67d0