From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Scripts/XMainClient/PetSkillLearnHandler.cs | 149 +++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/PetSkillLearnHandler.cs (limited to 'Client/Assets/Scripts/XMainClient/PetSkillLearnHandler.cs') diff --git a/Client/Assets/Scripts/XMainClient/PetSkillLearnHandler.cs b/Client/Assets/Scripts/XMainClient/PetSkillLearnHandler.cs new file mode 100644 index 00000000..c632675d --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/PetSkillLearnHandler.cs @@ -0,0 +1,149 @@ +using System; +using UILib; +using UnityEngine; +using XMainClient.UI; +using XMainClient.UI.UICommon; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class PetSkillLearnHandler : DlgHandlerBase + { + protected override string FileName + { + get + { + return "GameSystem/PetSkillLearn"; + } + } + + private XPetDocument doc; + + private IXUIButton m_Close; + + private IXUIButton m_Help; + + private IXUIButton m_BtnGetSkillBook; + + private IXUIScrollView m_PetListScrollView; + + private IXUIWrapContent m_WrapContent; + + protected override void Init() + { + XSingleton.singleton.AddGreenLog("Init", null, null, null, null, null); + base.Init(); + this.doc = XDocuments.GetSpecificDocument(XPetDocument.uuID); + this.m_Close = (base.transform.Find("Bg/Close").GetComponent("XUIButton") as IXUIButton); + this.m_Help = (base.transform.Find("Bg/Help").GetComponent("XUIButton") as IXUIButton); + this.m_PetListScrollView = (base.transform.Find("Bg/SkillBookPanel").GetComponent("XUIScrollView") as IXUIScrollView); + this.m_WrapContent = (base.transform.Find("Bg/SkillBookPanel/WrapContent").GetComponent("XUIWrapContent") as IXUIWrapContent); + this.m_BtnGetSkillBook = (base.transform.Find("Bg/BtnGetSkillBook").GetComponent("XUIButton") as IXUIButton); + } + + public override void RegisterEvent() + { + base.RegisterEvent(); + this.m_Close.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCloseClicked)); + this.m_WrapContent.RegisterItemUpdateEventHandler(new WrapItemUpdateEventHandler(this.OnSkillBookListUpdated)); + this.m_Help.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnHelpClicked)); + this.m_BtnGetSkillBook.ID = ulong.Parse(XSingleton.singleton.GetValue("PetGoBuySkillBook")); + this.m_BtnGetSkillBook.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnGoClick)); + } + + public bool OnCloseClicked(IXUIButton btn) + { + base.SetVisible(false); + return true; + } + + private bool OnHelpClicked(IXUIButton btn) + { + DlgBase.singleton.ShowHelp(XSysDefine.XSys_Horse_LearnSkill); + return true; + } + + protected override void OnShow() + { + base.OnShow(); + this.RefreshList(true); + XSingleton.singleton.AddGreenLog("OnShow", null, null, null, null, null); + } + + protected override void OnHide() + { + XSingleton.singleton.AddGreenLog("OnHide", null, null, null, null, null); + base.OnHide(); + } + + public override void OnUnload() + { + XSingleton.singleton.AddGreenLog("OnUnload", null, null, null, null, null); + this.doc = null; + base.OnUnload(); + } + + public void RefreshList(bool bResetPosition = true) + { + int count = this.doc.GetSkillBook().Count; + this.m_WrapContent.SetContentCount(count, false); + if (bResetPosition) + { + this.m_PetListScrollView.ResetPosition(); + } + else + { + this.m_WrapContent.RefreshAllVisibleContents(); + } + } + + private void OnSkillBookListUpdated(Transform t, int index) + { + bool flag = index < 0 || index >= this.doc.SkillBookList.Count; + if (flag) + { + XSingleton.singleton.AddErrorLog("index:" + index, null, null, null, null, null); + } + else + { + Transform transform = t.Find("Item"); + IXUISprite ixuisprite = transform.Find("Icon").GetComponent("XUISprite") as IXUISprite; + IXUIButton ixuibutton = t.Find("BtnLearn").GetComponent("XUIButton") as IXUIButton; + XItem xitem = this.doc.SkillBookList[index]; + XSingleton.singleton.DrawItem(transform.gameObject, xitem); + ixuisprite.ID = (ulong)((long)xitem.itemID); + ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this._OnItemClick)); + ixuibutton.ID = xitem.uid; + ixuibutton.RegisterClickEventHandler(new ButtonClickEventHandler(this._OnLearnSkillClick)); + PetSkillBook.RowData petSkillBook = XPetDocument.GetPetSkillBook((uint)xitem.itemID); + IXUILabel ixuilabel = t.Find("Description").GetComponent("XUILabel") as IXUILabel; + ixuilabel.SetText(petSkillBook.Description); + } + } + + private void _OnItemClick(IXUISprite iSp) + { + XSingleton.singleton.ShowTooltipDialog((int)iSp.ID, null); + } + + private bool _OnLearnSkillClick(IXUIButton btn) + { + this.ReqRecentMount(btn.ID, this.doc.CurSelectedPet.UID); + return true; + } + + private bool OnGoClick(IXUIButton btn) + { + XSingleton.singleton.OpenSystem((XSysDefine)btn.ID, 0UL); + return true; + } + + public void ReqRecentMount(ulong itemuid, ulong petuid) + { + RpcC2G_UseItem rpcC2G_UseItem = new RpcC2G_UseItem(); + rpcC2G_UseItem.oArg.uid = itemuid; + rpcC2G_UseItem.oArg.petid = petuid; + XSingleton.singleton.Send(rpcC2G_UseItem); + } + } +} -- cgit v1.1-26-g67d0