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; } } }