diff options
Diffstat (limited to 'Client/Assets/Scripts/XMainClient/XChatMaqueeView.cs')
-rw-r--r-- | Client/Assets/Scripts/XMainClient/XChatMaqueeView.cs | 245 |
1 files changed, 245 insertions, 0 deletions
diff --git a/Client/Assets/Scripts/XMainClient/XChatMaqueeView.cs b/Client/Assets/Scripts/XMainClient/XChatMaqueeView.cs new file mode 100644 index 00000000..9eaf8290 --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XChatMaqueeView.cs @@ -0,0 +1,245 @@ +using System;
+using System.Collections.Generic;
+using KKSG;
+using UnityEngine;
+using XMainClient.UI.UICommon;
+using XUtliPoolLib;
+
+namespace XMainClient
+{
+ internal class XChatMaqueeView : DlgBase<XChatMaqueeView, XChatMaqueeBehaviour>
+ {
+ public override string fileName
+ {
+ get
+ {
+ return "GameSystem/ChatMaqueeDlg";
+ }
+ }
+
+ public override bool isHideChat
+ {
+ get
+ {
+ return false;
+ }
+ }
+
+ public override int group
+ {
+ get
+ {
+ return 1;
+ }
+ }
+
+ public override bool autoload
+ {
+ get
+ {
+ return true;
+ }
+ }
+
+ public override bool needOnTop
+ {
+ get
+ {
+ return true;
+ }
+ }
+
+ private XChatDocument _doc = null;
+
+ private bool m_IsPlaying;
+
+ private List<MaqueeInfo> m_MaqueeFirst = new List<MaqueeInfo>();
+
+ private List<MaqueeInfo> m_MaqueeSecond = new List<MaqueeInfo>();
+
+ private List<MaqueeInfo> m_MaqueeThird = new List<MaqueeInfo>();
+
+ private int m_OffsetStart = 0;
+
+ private int m_OffsetEnd = 0;
+
+ private int m_CurOffset = 0;
+
+ private float m_CurShowTime = 0f;
+
+ private bool m_MaqueeSwitch = true;
+
+ private MaqueeInfo m_PlayingMaquee;
+
+ protected override void Init()
+ {
+ this._doc = XDocuments.GetSpecificDocument<XChatDocument>(XChatDocument.uuID);
+ this._doc.ChatMaqueeView = this;
+ }
+
+ public override void RegisterEvent()
+ {
+ }
+
+ protected override void OnShow()
+ {
+ base.OnShow();
+ }
+
+ protected override void OnUnload()
+ {
+ this._doc = null;
+ this.m_IsPlaying = false;
+ this.m_MaqueeThird.Clear();
+ base.OnUnload();
+ }
+
+ public void ShowMaquee()
+ {
+ this.SetVisible(true, true);
+ }
+
+ public void HideMaquee()
+ {
+ this.SetVisible(false, true);
+ }
+
+ public void SetMaqueeSwitch(bool enable)
+ {
+ this.m_MaqueeSwitch = enable;
+ bool flag = !base.IsLoaded();
+ if (!flag)
+ {
+ bool flag2 = !enable;
+ if (flag2)
+ {
+ this.m_IsPlaying = false;
+ this.SetVisible(false, true);
+ }
+ else
+ {
+ this.PlayFinished();
+ }
+ }
+ }
+
+ public void ReceiveChatInfo(KKSG.ChatInfo chatinfo)
+ {
+ SceneType sceneType = XSingleton<XScene>.singleton.SceneType;
+ bool flag = sceneType != SceneType.SCENE_HALL && sceneType != SceneType.SCENE_GUILD_HALL && sceneType != SceneType.SCENE_BATTLE && sceneType != SceneType.SCENE_FAMILYGARDEN && sceneType != SceneType.SCENE_ABYSSS && sceneType != SceneType.SCENE_TOWER && sceneType != SceneType.SCENE_NEST && sceneType != SceneType.SCENE_LEISURE;
+ if (!flag)
+ {
+ bool flag2 = !this.m_MaqueeSwitch;
+ if (!flag2)
+ {
+ bool flag3 = chatinfo.level <= XSingleton<XAttributeMgr>.singleton.XPlayerData.Level;
+ if (flag3)
+ {
+ bool flag4 = chatinfo.channel == 5u;
+ if (flag4)
+ {
+ this.AddMaqueeNormalInfo(chatinfo.info, 0f);
+ }
+ else
+ {
+ this.AddMaqueeNormalInfo(chatinfo.info, 5f);
+ }
+ }
+ }
+ }
+ }
+
+ public void AddMaqueeNormalInfo(string info, float stopTime)
+ {
+ bool flag = info == null;
+ if (!flag)
+ {
+ this.ShowMaquee();
+ MaqueeInfo maqueeInfo = new MaqueeInfo();
+ maqueeInfo.content = info;
+ maqueeInfo.playTimes = 1;
+ maqueeInfo.showTime = stopTime;
+ maqueeInfo.playSpeed = XSingleton<XGlobalConfig>.singleton.GetInt("MaqueeSpeed");
+ this.m_MaqueeThird.Add(maqueeInfo);
+ bool flag2 = !this.m_IsPlaying;
+ if (flag2)
+ {
+ this.StartPlayMaquee(maqueeInfo);
+ }
+ }
+ }
+
+ public void StartPlayMaquee(MaqueeInfo maquee)
+ {
+ string text = XLabelSymbolHelper.RemoveFormatInfo(maquee.content);
+ bool flag = !base.IsVisible();
+ if (flag)
+ {
+ this.SetVisible(true, true);
+ }
+ base.uiBehaviour.m_MaqueeText.SetText(text);
+ Vector2 printSize = base.uiBehaviour.m_MaqueeText.GetPrintSize();
+ base.uiBehaviour.m_MaqueeTextSymbol.InputText = text;
+ this.m_PlayingMaquee = maquee;
+ this.m_IsPlaying = true;
+ this.m_CurShowTime = maquee.showTime;
+ this.m_OffsetStart = (int)(printSize.x / 2f) + base.uiBehaviour.m_MaqueeBoard.spriteWidth / 2 + 20;
+ this.m_OffsetEnd = -1 * this.m_OffsetStart;
+ this.m_CurOffset = this.m_OffsetStart;
+ base.uiBehaviour.m_MaqueeTween.PlayTween(true, -1f);
+ }
+
+ public void UpdateMaquee(float delta)
+ {
+ bool flag = !this.m_IsPlaying || !base.IsVisible();
+ if (!flag)
+ {
+ bool flag2 = this.m_CurOffset <= 0 && this.m_CurShowTime > 0f;
+ if (flag2)
+ {
+ this.m_CurShowTime -= delta;
+ }
+ else
+ {
+ this.m_CurOffset -= (int)(delta * (float)this.m_PlayingMaquee.playSpeed);
+ base.uiBehaviour.m_MaqueeText.gameObject.transform.localPosition = new Vector3((float)this.m_CurOffset, base.uiBehaviour.m_MaqueeText.gameObject.transform.localPosition.y, base.uiBehaviour.m_MaqueeText.gameObject.transform.localPosition.z);
+ bool flag3 = this.m_CurOffset <= this.m_OffsetEnd;
+ if (flag3)
+ {
+ this.PlayFinished();
+ }
+ }
+ }
+ }
+
+ public void PlayFinished()
+ {
+ bool flag = this.m_PlayingMaquee == null;
+ if (!flag)
+ {
+ bool flag2 = this.m_PlayingMaquee.playTimes > 1;
+ if (flag2)
+ {
+ this.m_CurOffset = this.m_OffsetStart;
+ this.m_PlayingMaquee.playTimes--;
+ this.m_CurShowTime = this.m_PlayingMaquee.showTime;
+ }
+ else
+ {
+ this.m_MaqueeThird.RemoveAt(0);
+ bool flag3 = this.m_MaqueeThird.Count > 0;
+ if (flag3)
+ {
+ this.StartPlayMaquee(this.m_MaqueeThird[0]);
+ }
+ else
+ {
+ this.m_IsPlaying = false;
+ base.uiBehaviour.m_MaqueeTween.PlayTween(false, -1f);
+ base.UnLoad(false);
+ }
+ }
+ }
+ }
+ }
+}
|