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/XRadioDocument.cs | 254 +++++++++++++++++++++ 1 file changed, 254 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/XRadioDocument.cs (limited to 'Client/Assets/Scripts/XMainClient/XRadioDocument.cs') diff --git a/Client/Assets/Scripts/XMainClient/XRadioDocument.cs b/Client/Assets/Scripts/XMainClient/XRadioDocument.cs new file mode 100644 index 00000000..b13feaad --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/XRadioDocument.cs @@ -0,0 +1,254 @@ +using System; +using System.Collections.Generic; +using KKSG; +using XMainClient.UI; +using XMainClient.UI.UICommon; +using XUpdater; +using XUtliPoolLib; + +namespace XMainClient +{ + internal class XRadioDocument : XDocComponent + { + public override uint ID + { + get + { + return XRadioDocument.uuID; + } + } + + public new static readonly uint uuID = XSingleton.singleton.XHash("XRadioDocument"); + + public List hostlist = new List(); + + public List hostIDs = new List(); + + private bool mJoinBigRoomSucc = false; + + public bool isHost = false; + + public XRadioDocument.BigRoomState roomState = XRadioDocument.BigRoomState.OutRoom; + + private bool startLoop = false; + + private float acc_time = 0f; + + private float all_time = 0f; + + private int TimeOut = 8; + + private bool cacheRadioOpen = false; + + public enum BigRoomState + { + OutRoom, + Processing, + InRoom + } + + protected override void OnReconnected(XReconnectedEventArgs arg) + { + } + + public override void Update(float fDeltaT) + { + base.Update(fDeltaT); + bool flag = this.startLoop; + if (flag) + { + this.acc_time += fDeltaT; + this.all_time += fDeltaT; + bool flag2 = this.all_time > (float)this.TimeOut && !this.mJoinBigRoomSucc; + if (flag2) + { + this.startLoop = false; + this.mJoinBigRoomSucc = false; + this.roomState = XRadioDocument.BigRoomState.OutRoom; + DlgBase.singleton.Refresh(false); + XSingleton.singleton.AddGreenLog("join room timeout, Apollo error!", null, null, null, null, null); + XSingleton.singleton.ShowSystemTip(XSingleton.singleton.GetString("FM_ENTER_OVERTIME"), "fece00"); + } + bool flag3 = this.acc_time > 0.4f; + if (flag3) + { + bool flag4 = !this.mJoinBigRoomSucc; + if (flag4) + { + IApolloManager xapolloManager = XSingleton.singleton.XApolloManager; + bool joinRoomBigResult = xapolloManager.GetJoinRoomBigResult(); + if (joinRoomBigResult) + { + this.startLoop = false; + this.mJoinBigRoomSucc = true; + xapolloManager.openMusic = true; + xapolloManager.openSpeak = false; + this.roomState = XRadioDocument.BigRoomState.InRoom; + this.MuteSounds(false); + DlgBase.singleton.Refresh(true); + DlgBase.singleton.UpdateHostInfo(); + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("FM_ENTER_SUCCESS"), "fece00"); + XSingleton.singleton.StopAutoPlay(); + XSingleton.singleton.EnableAutoPlay(false); + } + } + this.acc_time = 0f; + } + } + } + + public override void OnDetachFromHost() + { + this.cacheRadioOpen = false; + this.QuitApolloBigRoom(); + base.OnDetachFromHost(); + } + + public override void OnEnterScene() + { + base.OnEnterScene(); + bool flag = XSingleton.singleton.CurrentStage.Stage == EXStage.World; + if (flag) + { + XChatDocument specificDocument = XDocuments.GetSpecificDocument(XChatDocument.uuID); + bool flag2 = specificDocument.GetBattleRaw().real > 0; + if (flag2) + { + bool flag3 = this.roomState == XRadioDocument.BigRoomState.InRoom; + if (flag3) + { + this.cacheRadioOpen = true; + } + this.QuitBigRoom(); + } + } + else + { + bool flag4 = XSingleton.singleton.CurrentStage.Stage == EXStage.Hall; + if (flag4) + { + bool flag5 = this.cacheRadioOpen; + if (flag5) + { + bool flag6 = this.roomState == XRadioDocument.BigRoomState.OutRoom; + if (flag6) + { + this.JoinBigRoom(); + this.cacheRadioOpen = false; + } + } + } + } + } + + public void UpdateHost(List names, List roles) + { + bool flag = names != null; + if (flag) + { + this.hostlist = names; + this.hostIDs = roles; + } + bool flag2 = DlgBase.singleton.IsVisible(); + if (flag2) + { + DlgBase.singleton.UpdateHostInfo(); + } + } + + public void MuteSounds(bool mute) + { + bool flag = this.roomState == XRadioDocument.BigRoomState.InRoom; + if (flag) + { + IApolloManager xapolloManager = XSingleton.singleton.XApolloManager; + if (mute) + { + xapolloManager.SetMusicVolum(0); + } + else + { + XOptionsDocument specificDocument = XDocuments.GetSpecificDocument(XOptionsDocument.uuID); + int @int = XSingleton.singleton.GetInt("SetSpeakerVolume"); + xapolloManager.SetMusicVolum((int)((float)@int * specificDocument.voiceVolme)); + } + } + } + + public void JoinBigRoom() + { + bool flag = !this.mJoinBigRoomSucc && !this.startLoop; + if (flag) + { + this.roomState = XRadioDocument.BigRoomState.Processing; + XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("FM_ENTERING"), "fece00"); + RpcC2M_JoinFmRoom rpc = new RpcC2M_JoinFmRoom(); + XSingleton.singleton.Send(rpc); + } + } + + public void ProcessJoinBigRoom(JoinLargeRoomReply reply) + { + this.acc_time = 0f; + this.all_time = 0f; + this.startLoop = true; + this.mJoinBigRoomSucc = false; + XSingleton.singleton.AddLog("url:", reply.url, " bussinessid:" + reply.bussniessid, " role:" + reply.key, null, null, XDebugColor.XDebug_None); + XSingleton.singleton.AddLog("roomid: ", reply.roomid.ToString(), " roomkey:", reply.roomkey.ToString(), null, null, XDebugColor.XDebug_None); + IApolloManager xapolloManager = XSingleton.singleton.XApolloManager; + xapolloManager.SetRealtimeMode(); + xapolloManager.JoinBigRoom(reply.url, (int)reply.key, reply.bussniessid, (long)reply.roomid, (long)reply.roomkey, (short)reply.memberid); + } + + public void ProcessTimeOut() + { + this.mJoinBigRoomSucc = false; + this.roomState = XRadioDocument.BigRoomState.OutRoom; + DlgBase.singleton.Refresh(false); + } + + public void QuitBigRoom() + { + this.QuitApolloBigRoom(); + PtcC2M_LeaveLargeRoom proto = new PtcC2M_LeaveLargeRoom(); + XSingleton.singleton.Send(proto); + } + + private void QuitApolloBigRoom() + { + try + { + this.startLoop = false; + this.mJoinBigRoomSucc = false; + bool flag = this.roomState == XRadioDocument.BigRoomState.InRoom; + if (flag) + { + IApolloManager xapolloManager = XSingleton.singleton.XApolloManager; + bool flag2 = xapolloManager != null; + if (flag2) + { + xapolloManager.openSpeak = false; + xapolloManager.QuitBigRoom(); + } + } + this.roomState = XRadioDocument.BigRoomState.OutRoom; + bool flag3 = XSingleton.singleton.CurrentStage.Stage == EXStage.Hall; + if (flag3) + { + XSingleton.singleton.EnableAutoPlay(true); + XSingleton.singleton.StartAutoPlay(true, true); + } + } + catch (Exception ex) + { + XSingleton.singleton.AddLog(ex.StackTrace.ToString(), null, null, null, null, null, XDebugColor.XDebug_None); + } + } + + public bool isHosting() + { + IApolloManager xapolloManager = XSingleton.singleton.XApolloManager; + return this.roomState != XRadioDocument.BigRoomState.OutRoom && this.isHost && xapolloManager.openSpeak; + } + } +} -- cgit v1.1-26-g67d0