From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Assets/Scripts/XMainClient/TitleItemDisplay.cs | 148 +++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/TitleItemDisplay.cs (limited to 'Client/Assets/Scripts/XMainClient/TitleItemDisplay.cs') diff --git a/Client/Assets/Scripts/XMainClient/TitleItemDisplay.cs b/Client/Assets/Scripts/XMainClient/TitleItemDisplay.cs new file mode 100644 index 00000000..fd57cb57 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/TitleItemDisplay.cs @@ -0,0 +1,148 @@ +using System; +using UILib; +using UnityEngine; +using XMainClient; +using XMainClient.UI; +using XMainClient.UI.UICommon; +using XUtliPoolLib; + +public class TitleItemDisplay +{ + public Transform transform { get; private set; } + + public GameObject gameObject + { + get + { + return this.transform.gameObject; + } + } + + private Transform m_ItemGo; + + private IXUILabel m_PPTLabel; + + private IXUILabel m_RunLabel; + + private IXUILabel m_itemNum; + + private IXUILabel m_itemName; + + private Transform m_ItemIcon; + + public void Init(Transform go) + { + this.transform = go; + this.m_ItemGo = this.transform.Find("Item"); + this.m_ItemIcon = this.transform.Find("Item/Icon"); + this.m_itemNum = (this.transform.Find("Item/Num").GetComponent("XUILabel") as IXUILabel); + this.m_itemName = (this.transform.Find("Item/ItemName").GetComponent("XUILabel") as IXUILabel); + this.m_PPTLabel = (this.transform.Find("PPT").GetComponent("XUILabel") as IXUILabel); + this.m_RunLabel = (this.transform.Find("Leave").GetComponent("XUILabel") as IXUILabel); + this.m_RunLabel.RegisterLabelClickEventHandler(new LabelClickEventHandler(this.OnClickLableHandler)); + } + + private void OnClickLableHandler(IXUILabel label) + { + bool flag = label.ID == 0UL; + if (flag) + { + DlgBase.singleton.ShowContent(FunctionDef.ZHANLI); + } + else + { + XSingleton.singleton.ShowItemAccess((int)label.ID, null); + } + DlgBase.singleton.SetVisibleWithAnimation(false, null); + } + + public void SetVisible(bool visible) + { + this.gameObject.SetActive(visible); + } + + public void Set(uint data0, uint data1, string desc) + { + this.m_RunLabel.ID = (ulong)data0; + bool flag = data0 == 0u; + if (flag) + { + this.SetFightValue(data1); + } + else + { + this.SetItemValue(data0, data1, desc); + } + } + + private void SetFightValue(uint value) + { + this.m_ItemGo.gameObject.SetActive(false); + this.m_PPTLabel.gameObject.SetActive(true); + double attr = XSingleton.singleton.XPlayerData.GetAttr(XAttributeDefine.XAttr_POWER_POINT_Basic); + int num = (int)(value - (uint)((int)attr)); + bool flag = value <= attr; + if (flag) + { + this.m_RunLabel.Alpha = 0f; + this.m_PPTLabel.SetText(XStringDefineProxy.GetString("COMMON_COUNT_TOTAL_FMT", new object[] + { + (int)attr, + value + })); + } + else + { + this.m_RunLabel.Alpha = 1f; + this.m_RunLabel.SetText(XStringDefineProxy.GetString("TITLE_RUN_LABEL_1")); + this.m_PPTLabel.SetText(XStringDefineProxy.GetString("COMMON_COUNT_TOTAL_NOTENOUGH_FMT", new object[] + { + (int)attr, + value + })); + } + } + + private void ShowTooltipDialog(IXUISprite sprite) + { + bool flag = sprite.ID > 0UL; + if (flag) + { + XSingleton.singleton.ShowTooltipDialog((int)sprite.ID, null, 0u); + } + } + + private void SetItemValue(uint itemID, uint value, string desc) + { + this.m_ItemGo.gameObject.SetActive(true); + this.m_PPTLabel.gameObject.SetActive(false); + ItemList.RowData itemConf = XBagDocument.GetItemConf((int)itemID); + int num = (int)XBagDocument.BagDoc.GetItemCount((int)itemID); + this.m_itemName.SetText(desc); + XItemDrawerMgr.Param.IconType = 1u; + XSingleton.singleton.normalItemDrawer.DrawItem(this.m_ItemIcon.gameObject, itemConf, 0, false); + IXUISprite ixuisprite = this.m_ItemIcon.Find("Icon").GetComponent("XUISprite") as IXUISprite; + ixuisprite.ID = (ulong)((long)itemConf.ItemID); + ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.ShowTooltipDialog)); + bool flag = (long)num < (long)((ulong)value); + if (flag) + { + this.m_RunLabel.Alpha = 1f; + this.m_RunLabel.SetText(XStringDefineProxy.GetString("TITLE_RUN_LABEL_1")); + this.m_itemNum.SetText(XStringDefineProxy.GetString("COMMON_COUNT_TOTAL_NOTENOUGH_FMT", new object[] + { + num, + value + })); + } + else + { + this.m_RunLabel.Alpha = 0f; + this.m_itemNum.SetText(XStringDefineProxy.GetString("COMMON_COUNT_TOTAL_FMT", new object[] + { + num, + value + })); + } + } +} -- cgit v1.1-26-g67d0