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/XSystemTipView.cs | 136 +++++++++++++++++++++ 1 file changed, 136 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XSystemTipView.cs (limited to 'Client/Assets/Scripts/XMainClient/XSystemTipView.cs') diff --git a/Client/Assets/Scripts/XMainClient/XSystemTipView.cs b/Client/Assets/Scripts/XMainClient/XSystemTipView.cs new file mode 100644 index 00000000..ae7bbdf9 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XSystemTipView.cs @@ -0,0 +1,136 @@ +using System; +using UILib; +using UnityEngine; +using XMainClient.UI.UICommon; + +namespace XMainClient +{ + internal class XSystemTipView : DlgBase + { + public override string fileName + { + get + { + return "GameSystem/SystemTip"; + } + } + + public override bool autoload + { + get + { + return true; + } + } + + public override bool isHideChat + { + get + { + return false; + } + } + + public override bool needOnTop + { + get + { + return true; + } + } + + private XSystemTipDocument _doc; + + private int _showCount; + + private GameObject _preTip = null; + + private int _count; + + private readonly float DEFAULT_INTERVAL = 0.4f; + + private float m_Time; + + private float m_Interval; + + protected override void Init() + { + base.Init(); + this._doc = XDocuments.GetSpecificDocument(XSystemTipDocument.uuID); + } + + protected override void OnShow() + { + base.uiBehaviour.m_TipPool.ReturnAll(false); + this._showCount = 0; + this._count = 0; + this.m_Time = 0f; + this._preTip = null; + this.m_Interval = this.DEFAULT_INTERVAL; + } + + public void ShowTip(string text) + { + GameObject gameObject = base.uiBehaviour.m_TipPool.FetchGameObject(false); + gameObject.transform.localPosition = base.uiBehaviour.m_TipPool.TplPos; + IXUISprite ixuisprite = gameObject.transform.GetComponent("XUISprite") as IXUISprite; + ixuisprite.spriteDepth = this._count; + IXUILabel ixuilabel = gameObject.transform.Find("Text").GetComponent("XUILabel") as IXUILabel; + ixuilabel.SetText(text); + ixuilabel.spriteDepth = this._count + 1; + bool flag = this._preTip != null; + if (flag) + { + bool activeSelf = this._preTip.activeSelf; + if (activeSelf) + { + this._preTip.transform.parent = gameObject.transform; + } + } + this._preTip = gameObject; + IXUITweenTool ixuitweenTool = gameObject.transform.GetComponent("XUIPlayTween") as IXUITweenTool; + ixuitweenTool.SetTargetGameObject(gameObject); + ixuitweenTool.RegisterOnFinishEventHandler(new OnTweenFinishEventHandler(this.OnPlayTweenFinish)); + ixuitweenTool.PlayTween(true, -1f); + this._showCount++; + this._count += 2; + } + + private void OnPlayTweenFinish(IXUITweenTool iPlayTween) + { + bool flag = !base.IsVisible(); + if (!flag) + { + base.uiBehaviour.m_TipPool.ReturnInstance(iPlayTween.gameObject, true); + this._showCount--; + bool flag2 = this._showCount == 0; + if (flag2) + { + this.SetVisible(false, true); + } + } + } + + public override void OnUpdate() + { + base.OnUpdate(); + bool flag = Time.time - this.m_Time > this.m_Interval; + if (flag) + { + string empty = string.Empty; + bool flag2 = this._doc.TryGetTip(ref empty); + if (flag2) + { + this.ShowTip(empty); + int leftCount = this._doc.LeftCount; + bool flag3 = leftCount > 3; + if (flag3) + { + this.m_Interval = this.DEFAULT_INTERVAL - 0.1f * (float)(leftCount - 3); + } + this.m_Time = Time.time; + } + } + } + } +} -- cgit v1.1-26-g67d0