From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Scripts/XMainClient/UI/BattleDramaDlg.cs | 259 +++++++++++++++++++++ 1 file changed, 259 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/UI/BattleDramaDlg.cs (limited to 'Client/Assets/Scripts/XMainClient/UI/BattleDramaDlg.cs') diff --git a/Client/Assets/Scripts/XMainClient/UI/BattleDramaDlg.cs b/Client/Assets/Scripts/XMainClient/UI/BattleDramaDlg.cs new file mode 100644 index 00000000..c4295a64 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/BattleDramaDlg.cs @@ -0,0 +1,259 @@ +using System; +using UILib; +using XMainClient.UI.UICommon; +using XUpdater; +using XUtliPoolLib; + +namespace XMainClient.UI +{ + internal class BattleDramaDlg : DlgBase + { + public override string fileName + { + get + { + return "Battle/BattleDramaDlg"; + } + } + + public override int layer + { + get + { + return 1; + } + } + + public override bool exclusive + { + get + { + return true; + } + } + + public override bool autoload + { + get + { + return true; + } + } + + private string leftTalker = ""; + + private string rightTalker = ""; + + private XDummy m_rightDummy; + + private XDummy m_leftDummy; + + private uint _close_timer = 0u; + + public override void RegisterEvent() + { + IXUISprite ixuisprite = base.uiBehaviour.m_TaskArea.GetComponent("XUISprite") as IXUISprite; + ixuisprite.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.GotoNextTalk)); + } + + protected override void OnShow() + { + base.OnShow(); + base.Alloc3DAvatarPool("BattleDramaDlg"); + XSingleton.singleton.EnableAllAI(false); + bool autoPlayOn = XSingleton.singleton.Player.PlayerAttributes.AutoPlayOn; + if (autoPlayOn) + { + float interval = float.Parse(XSingleton.singleton.GetValue("CloseDramaDlgTime")); + this._close_timer = XSingleton.singleton.SetTimer(interval, new XTimerMgr.ElapsedEventHandler(this.AutoClose), null); + } + } + + protected override void OnHide() + { + base.OnHide(); + XSingleton.singleton.ClearDummy(this.m_dummPool); + XSingleton.singleton.BattleNPCTalkEnd = true; + XSingleton.singleton.EnableAllAI(true); + this.leftTalker = ""; + this.rightTalker = ""; + XSingleton.singleton.EnableMainDummy(false, null); + bool flag = base.uiBehaviour.m_rightSnapshot != null; + if (flag) + { + base.uiBehaviour.m_rightSnapshot.RefreshRenderQueue = null; + } + bool flag2 = base.uiBehaviour.m_leftSnapshot != null; + if (flag2) + { + base.uiBehaviour.m_leftSnapshot.RefreshRenderQueue = null; + } + this.m_leftDummy = null; + this.m_rightDummy = null; + bool flag3 = this._close_timer > 0u; + if (flag3) + { + XSingleton.singleton.KillTimer(this._close_timer); + this._close_timer = 0u; + } + } + + protected override void OnUnload() + { + XSingleton.singleton.Pause = false; + this.leftTalker = ""; + this.rightTalker = ""; + base.Return3DAvatarPool(); + this.m_leftDummy = null; + this.m_rightDummy = null; + base.OnUnload(); + } + + private void AutoClose(object obj) + { + bool flag = base.IsVisible(); + if (flag) + { + this.GotoNextTalk(null); + this._close_timer = XSingleton.singleton.SetTimer(0.5f, new XTimerMgr.ElapsedEventHandler(this.AutoClose), null); + } + } + + protected void GotoNextTalk(IXUISprite sp) + { + XSingleton.singleton.ExecuteNextCmd(); + } + + public void SetRightAvatar(string talker, string content, string voice) + { + bool onReconnect = XSingleton.singleton.XConnect.OnReconnect; + if (!onReconnect) + { + XSingleton.singleton.Cancel(); + bool flag = DlgBase.singleton.IsLoaded(); + if (flag) + { + DlgBase.singleton.SkillHandler.ResetPressState(); + } + this.SetVisible(true, true); + base.uiBehaviour.m_RightText.gameObject.SetActive(true); + base.uiBehaviour.m_name.gameObject.SetActive(true); + base.uiBehaviour.m_LeftText.gameObject.SetActive(false); + base.uiBehaviour.m_rightSnapshot.transform.localPosition = base.uiBehaviour.m_rightDummyPos; + base.uiBehaviour.m_leftSnapshot.transform.localPosition = XGameUI.Far_Far_Away; + string text = ""; + bool flag2 = talker == "[player]"; + if (flag2) + { + XSingleton.singleton.EnableMainDummy(false, null); + XSingleton.singleton.EnableMainDummy(true, base.uiBehaviour.m_rightSnapshot); + XEntityPresentation.RowData byPresentID = XSingleton.singleton.EntityInfo.GetByPresentID(XSingleton.singleton.XPlayerData.PresentID); + bool flag3 = byPresentID != null && byPresentID.AvatarPos != null; + if (flag3) + { + int num = XSingleton.singleton.RandomInt(0, byPresentID.AvatarPos.Length); + XSingleton.singleton.SetMainAnimation(byPresentID.AvatarPos[num]); + } + } + else + { + uint key = uint.Parse(talker); + XNpcInfo.RowData byNPCID = XSingleton.singleton.NpcInfo.GetByNPCID(key); + text = byNPCID.Name; + this.m_rightDummy = XSingleton.singleton.CreateCommonEntityDummy(this.m_dummPool, byNPCID.PresentID, base.uiBehaviour.m_rightSnapshot, this.m_rightDummy, 1f); + XEntityPresentation.RowData byPresentID2 = XSingleton.singleton.EntityInfo.GetByPresentID(byNPCID.PresentID); + bool flag4 = byPresentID2 != null && byPresentID2.AvatarPos != null; + if (flag4) + { + int num2 = XSingleton.singleton.RandomInt(0, byPresentID2.AvatarPos.Length); + this.m_rightDummy.SetAnimation(byPresentID2.AvatarPos[num2]); + } + } + base.uiBehaviour.m_name.SetText(text); + base.uiBehaviour.m_RightText.SetText(content); + bool flag5 = !string.IsNullOrEmpty(voice); + if (flag5) + { + XSingleton.singleton.PlayUISound(this.GetProfVoice(voice), true, AudioChannel.Action); + } + this.rightTalker = talker; + } + } + + public void SetLeftAvatar(string talker, string content, string voice) + { + bool onReconnect = XSingleton.singleton.XConnect.OnReconnect; + if (!onReconnect) + { + XSingleton.singleton.Cancel(); + bool flag = DlgBase.singleton.IsLoaded(); + if (flag) + { + DlgBase.singleton.SkillHandler.ResetPressState(); + } + this.SetVisible(true, true); + base.uiBehaviour.m_RightText.gameObject.SetActive(false); + base.uiBehaviour.m_name.gameObject.SetActive(false); + base.uiBehaviour.m_LeftText.gameObject.SetActive(true); + base.uiBehaviour.m_rightSnapshot.transform.localPosition = XGameUI.Far_Far_Away; + base.uiBehaviour.m_leftSnapshot.transform.localPosition = base.uiBehaviour.m_leftDummyPos; + string text = ""; + bool flag2 = talker == "[player]"; + if (flag2) + { + XSingleton.singleton.EnableMainDummy(false, null); + XSingleton.singleton.EnableMainDummy(true, base.uiBehaviour.m_leftSnapshot); + XEntityPresentation.RowData byPresentID = XSingleton.singleton.EntityInfo.GetByPresentID(XSingleton.singleton.XPlayerData.PresentID); + bool flag3 = byPresentID != null && byPresentID.AvatarPos != null; + if (flag3) + { + int num = XSingleton.singleton.RandomInt(0, byPresentID.AvatarPos.Length); + XSingleton.singleton.SetMainAnimation(byPresentID.AvatarPos[num]); + } + } + else + { + uint key = uint.Parse(talker); + XNpcInfo.RowData byNPCID = XSingleton.singleton.NpcInfo.GetByNPCID(key); + text = byNPCID.Name; + this.m_leftDummy = XSingleton.singleton.CreateCommonEntityDummy(this.m_dummPool, byNPCID.PresentID, base.uiBehaviour.m_leftSnapshot, this.m_leftDummy, 1f); + XEntityPresentation.RowData byPresentID2 = XSingleton.singleton.EntityInfo.GetByPresentID(byNPCID.PresentID); + bool flag4 = byPresentID2 != null && byPresentID2.AvatarPos != null; + if (flag4) + { + int num2 = XSingleton.singleton.RandomInt(0, byPresentID2.AvatarPos.Length); + this.m_leftDummy.SetAnimation(byPresentID2.AvatarPos[num2]); + } + } + base.uiBehaviour.m_name.SetText(text); + base.uiBehaviour.m_LeftText.SetText(content); + bool flag5 = !string.IsNullOrEmpty(voice); + if (flag5) + { + XSingleton.singleton.PlayUISound(this.GetProfVoice(voice), true, AudioChannel.Action); + } + this.leftTalker = talker; + } + } + + protected string GetProfVoice(string voice) + { + string[] array = voice.Split(new char[] + { + '|' + }); + uint basicTypeID = XSingleton.singleton.XPlayerData.BasicTypeID; + bool flag = (ulong)basicTypeID <= (ulong)((long)array.Length); + string result; + if (flag) + { + result = array[(int)(basicTypeID - 1u)]; + } + else + { + result = array[0]; + } + return result; + } + } +} -- cgit v1.1-26-g67d0