From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../XMainClient/UI/ArtifactRecastHandler.cs | 255 +++++++++++++++++++++ 1 file changed, 255 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/UI/ArtifactRecastHandler.cs (limited to 'Client/Assets/Scripts/XMainClient/UI/ArtifactRecastHandler.cs') diff --git a/Client/Assets/Scripts/XMainClient/UI/ArtifactRecastHandler.cs b/Client/Assets/Scripts/XMainClient/UI/ArtifactRecastHandler.cs new file mode 100644 index 00000000..4be6b9c6 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/ArtifactRecastHandler.cs @@ -0,0 +1,255 @@ +using System; +using UILib; +using UnityEngine; +using XMainClient.UI.UICommon; +using XUtliPoolLib; + +namespace XMainClient.UI +{ + internal class ArtifactRecastHandler : DlgHandlerBase + { + protected override string FileName + { + get + { + return "ItemNew/ArtifactRecastHandler"; + } + } + + private ArtifactRecastDocument m_doc; + + private GameObject m_itemGoMain; + + private GameObject m_itemGoMet; + + private IXUISprite m_boxSprMain; + + private IXUIButton m_recastBtn; + + private bool m_bIsEnough = true; + + private int m_needItemId = 0; + + private float m_delayTime = 0.5f; + + private float m_fLastClickBtnTime = 0f; + + protected override void Init() + { + base.Init(); + this.m_doc = ArtifactRecastDocument.Doc; + this.m_doc.Handler = this; + Transform transform = base.PanelObject.transform.Find("Bg1"); + this.m_itemGoMain = transform.Find("item0").gameObject; + this.m_itemGoMet = transform.Find("item1").gameObject; + this.m_boxSprMain = (transform.Find("BgBox1").GetComponent("XUISprite") as IXUISprite); + this.m_recastBtn = (transform.Find("Get").GetComponent("XUIButton") as IXUIButton); + } + + public override void RegisterEvent() + { + base.RegisterEvent(); + this.m_boxSprMain.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnClickBox)); + this.m_recastBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnClickRecastBtn)); + } + + protected override void OnShow() + { + base.OnShow(); + } + + protected override void OnHide() + { + base.OnHide(); + } + + public override void StackRefresh() + { + base.StackRefresh(); + } + + public override void OnUnload() + { + base.OnUnload(); + this.m_doc.Handler = null; + } + + public void RefreshUi() + { + this.FillContent(); + } + + private void FillContent() + { + bool flag = this.m_doc.SelectUid == 0UL; + if (flag) + { + this.FillNull(); + } + else + { + XItem itemByUID = XBagDocument.BagDoc.GetItemByUID(this.m_doc.SelectUid); + bool flag2 = itemByUID == null; + if (flag2) + { + this.FillNull(); + } + else + { + XSingleton.singleton.DrawItem(this.m_itemGoMain, itemByUID); + IXUISprite ixuisprite = this.m_itemGoMain.transform.Find("Icon").GetComponent("XUISprite") as IXUISprite; + ixuisprite.ID = this.m_doc.SelectUid; + ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnClickTips)); + ArtifactListTable.RowData artifactListRowData = ArtifactDocument.GetArtifactListRowData((uint)itemByUID.itemID); + bool flag3 = artifactListRowData == null || artifactListRowData.RecastMaterials[0, 0] == 0u; + if (flag3) + { + XSingleton.singleton.DrawItem(this.m_itemGoMet, null); + } + else + { + this.m_needItemId = (int)artifactListRowData.RecastMaterials[0, 0]; + uint num = artifactListRowData.RecastMaterials[0, 1]; + XSingleton.singleton.normalItemDrawer.DrawItem(this.m_itemGoMet, this.m_needItemId, (int)num, false); + ixuisprite = (this.m_itemGoMet.transform.Find("Icon").GetComponent("XUISprite") as IXUISprite); + ixuisprite.ID = (ulong)((long)this.m_needItemId); + ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnClickTips)); + ulong itemCount = XBagDocument.BagDoc.GetItemCount(this.m_needItemId); + IXUILabel ixuilabel = this.m_itemGoMet.transform.Find("Num").GetComponent("XUILabel") as IXUILabel; + ixuilabel.gameObject.SetActive(true); + this.m_bIsEnough = (itemCount >= (ulong)num); + bool bIsEnough = this.m_bIsEnough; + if (bIsEnough) + { + ixuilabel.SetText(string.Format("[00ff00]{0}/{1}[-]", itemCount, num)); + } + else + { + ixuilabel.SetText(string.Format("[ff0000]{0}/{1}[-]", itemCount, num)); + } + } + } + } + } + + private void FillNull() + { + XSingleton.singleton.DrawItem(this.m_itemGoMain, null); + int @int = XSingleton.singleton.GetInt("RecastStoneItemId"); + XSingleton.singleton.normalItemDrawer.DrawItem(this.m_itemGoMet, @int, 2, false); + ulong itemCount = XBagDocument.BagDoc.GetItemCount(@int); + IXUILabel ixuilabel = this.m_itemGoMet.transform.Find("Num").GetComponent("XUILabel") as IXUILabel; + ixuilabel.SetText(string.Format("{0}/?", itemCount)); + IXUISprite ixuisprite = this.m_itemGoMet.transform.Find("Icon").GetComponent("XUISprite") as IXUISprite; + ixuisprite.ID = (ulong)((long)@int); + ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnClickTips)); + } + + private bool OnClickRecastBtn(IXUIButton btn) + { + bool flag = this.SetButtonCool(this.m_delayTime); + bool result; + if (flag) + { + result = true; + } + else + { + bool flag2 = this.m_doc.SelectUid == 0UL; + if (flag2) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("ArtifactRecastTips2"), "fece00"); + result = false; + } + else + { + bool flag3 = !this.m_bIsEnough; + if (flag3) + { + DlgBase.singleton.SetVisible(false, true); + XSingleton.singleton.ShowItemAccess(this.m_needItemId, null); + result = false; + } + else + { + XOptionsDocument specificDocument = XDocuments.GetSpecificDocument(XOptionsDocument.uuID); + bool flag4 = specificDocument.GetValue(XOptionsDefine.OD_NO_RECAST_CONFIRM) == 1; + if (flag4) + { + this.m_doc.ReqRecast(); + } + else + { + XSingleton.singleton.ShowModalDialog(XSingleton.singleton.GetString("RecastEnsureTips"), XStringDefineProxy.GetString(XStringDefine.COMMON_OK), XStringDefineProxy.GetString(XStringDefine.COMMON_CANCEL), new ButtonClickEventHandler(this.DoOK), new ButtonClickEventHandler(this.DoCancel), false, XTempTipDefine.OD_RECAST_CONFIRM, 50); + } + result = true; + } + } + } + return result; + } + + private bool DoOK(IXUIButton btn) + { + bool flag = DlgBase.singleton.IsVisible(); + if (flag) + { + XOptionsDocument specificDocument = XDocuments.GetSpecificDocument(XOptionsDocument.uuID); + specificDocument.SetValue(XOptionsDefine.OD_NO_RECAST_CONFIRM, DlgBase.singleton.GetTempTip(XTempTipDefine.OD_RECAST_CONFIRM) ? 1 : 0, false); + } + XSingleton.singleton.CloseModalDlg(); + this.m_doc.ReqRecast(); + return true; + } + + private bool DoCancel(IXUIButton btn) + { + XOptionsDocument specificDocument = XDocuments.GetSpecificDocument(XOptionsDocument.uuID); + specificDocument.SetValue(XOptionsDefine.OD_NO_RECAST_CONFIRM, DlgBase.singleton.GetTempTip(XTempTipDefine.OD_RECAST_CONFIRM) ? 1 : 0, false); + XSingleton.singleton.CloseModalDlg(); + return true; + } + + private void OnClickBox(IXUISprite spr) + { + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("ArtifactRecastTips1"), "fece00"); + } + + private void OnClickTips(IXUISprite spr) + { + XItem xitem = XBagDocument.BagDoc.GetItemByUID(spr.ID); + bool flag = xitem == null; + if (flag) + { + xitem = XBagDocument.MakeXItem((int)spr.ID, false); + } + bool flag2 = xitem == null; + if (!flag2) + { + bool flag3 = xitem.Type == ItemType.ARTIFACT; + if (flag3) + { + XSingleton.singleton.bShowTakeOutBtn = true; + } + XSingleton.singleton.ShowTooltipDialog(xitem, null, spr, true, 0u); + } + } + + private bool SetButtonCool(float time) + { + float num = Time.realtimeSinceStartup - this.m_fLastClickBtnTime; + bool flag = num < time; + bool result; + if (flag) + { + result = true; + } + else + { + this.m_fLastClickBtnTime = Time.realtimeSinceStartup; + result = false; + } + return result; + } + } +} -- cgit v1.1-26-g67d0