summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XRadioDocument.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Client/Assets/Scripts/XMainClient/XRadioDocument.cs')
-rw-r--r--Client/Assets/Scripts/XMainClient/XRadioDocument.cs254
1 files changed, 254 insertions, 0 deletions
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<XCommon>.singleton.XHash("XRadioDocument");
+
+ public List<string> hostlist = new List<string>();
+
+ public List<ulong> hostIDs = new List<ulong>();
+
+ 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<RadioDlg, RadioBehaviour>.singleton.Refresh(false);
+ XSingleton<XDebug>.singleton.AddGreenLog("join room timeout, Apollo error!", null, null, null, null, null);
+ XSingleton<UiUtility>.singleton.ShowSystemTip(XSingleton<XStringTable>.singleton.GetString("FM_ENTER_OVERTIME"), "fece00");
+ }
+ bool flag3 = this.acc_time > 0.4f;
+ if (flag3)
+ {
+ bool flag4 = !this.mJoinBigRoomSucc;
+ if (flag4)
+ {
+ IApolloManager xapolloManager = XSingleton<XUpdater.XUpdater>.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<RadioDlg, RadioBehaviour>.singleton.Refresh(true);
+ DlgBase<RadioDlg, RadioBehaviour>.singleton.UpdateHostInfo();
+ XSingleton<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("FM_ENTER_SUCCESS"), "fece00");
+ XSingleton<XChatIFlyMgr>.singleton.StopAutoPlay();
+ XSingleton<XChatIFlyMgr>.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<XGame>.singleton.CurrentStage.Stage == EXStage.World;
+ if (flag)
+ {
+ XChatDocument specificDocument = XDocuments.GetSpecificDocument<XChatDocument>(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<XGame>.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<string> names, List<ulong> roles)
+ {
+ bool flag = names != null;
+ if (flag)
+ {
+ this.hostlist = names;
+ this.hostIDs = roles;
+ }
+ bool flag2 = DlgBase<RadioDlg, RadioBehaviour>.singleton.IsVisible();
+ if (flag2)
+ {
+ DlgBase<RadioDlg, RadioBehaviour>.singleton.UpdateHostInfo();
+ }
+ }
+
+ public void MuteSounds(bool mute)
+ {
+ bool flag = this.roomState == XRadioDocument.BigRoomState.InRoom;
+ if (flag)
+ {
+ IApolloManager xapolloManager = XSingleton<XUpdater.XUpdater>.singleton.XApolloManager;
+ if (mute)
+ {
+ xapolloManager.SetMusicVolum(0);
+ }
+ else
+ {
+ XOptionsDocument specificDocument = XDocuments.GetSpecificDocument<XOptionsDocument>(XOptionsDocument.uuID);
+ int @int = XSingleton<XGlobalConfig>.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<UiUtility>.singleton.ShowSystemTip(XStringDefineProxy.GetString("FM_ENTERING"), "fece00");
+ RpcC2M_JoinFmRoom rpc = new RpcC2M_JoinFmRoom();
+ XSingleton<XClientNetwork>.singleton.Send(rpc);
+ }
+ }
+
+ public void ProcessJoinBigRoom(JoinLargeRoomReply reply)
+ {
+ this.acc_time = 0f;
+ this.all_time = 0f;
+ this.startLoop = true;
+ this.mJoinBigRoomSucc = false;
+ XSingleton<XDebug>.singleton.AddLog("url:", reply.url, " bussinessid:" + reply.bussniessid, " role:" + reply.key, null, null, XDebugColor.XDebug_None);
+ XSingleton<XDebug>.singleton.AddLog("roomid: ", reply.roomid.ToString(), " roomkey:", reply.roomkey.ToString(), null, null, XDebugColor.XDebug_None);
+ IApolloManager xapolloManager = XSingleton<XUpdater.XUpdater>.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<RadioDlg, RadioBehaviour>.singleton.Refresh(false);
+ }
+
+ public void QuitBigRoom()
+ {
+ this.QuitApolloBigRoom();
+ PtcC2M_LeaveLargeRoom proto = new PtcC2M_LeaveLargeRoom();
+ XSingleton<XClientNetwork>.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<XUpdater.XUpdater>.singleton.XApolloManager;
+ bool flag2 = xapolloManager != null;
+ if (flag2)
+ {
+ xapolloManager.openSpeak = false;
+ xapolloManager.QuitBigRoom();
+ }
+ }
+ this.roomState = XRadioDocument.BigRoomState.OutRoom;
+ bool flag3 = XSingleton<XGame>.singleton.CurrentStage.Stage == EXStage.Hall;
+ if (flag3)
+ {
+ XSingleton<XChatIFlyMgr>.singleton.EnableAutoPlay(true);
+ XSingleton<XChatIFlyMgr>.singleton.StartAutoPlay(true, true);
+ }
+ }
+ catch (Exception ex)
+ {
+ XSingleton<XDebug>.singleton.AddLog(ex.StackTrace.ToString(), null, null, null, null, null, XDebugColor.XDebug_None);
+ }
+ }
+
+ public bool isHosting()
+ {
+ IApolloManager xapolloManager = XSingleton<XUpdater.XUpdater>.singleton.XApolloManager;
+ return this.roomState != XRadioDocument.BigRoomState.OutRoom && this.isHost && xapolloManager.openSpeak;
+ }
+ }
+}