diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppEmu.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppEmu.cs index 6ed55dd..02c9302 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppEmu.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/Manager/AppEmu.cs @@ -63,39 +63,29 @@ namespace AxibugEmuOnline.Client.Manager m_emuCore.SetupScheme(); - m_controllerSetuper = Supporter.GetControllerSetuper(); - - SetupController(); + m_controllerSetuper = Supporter.GetControllerSetuper(); + + //自动分配0号手柄到0号手柄位 + m_controllerSetuper.SetConnect(con0ToSlot: 0); + Eventer.Instance.PostEvent(EEvent.OnControllerConnectChanged); Eventer.Instance.RegisterEvent(EEvent.OnRoomSlotDataChanged, OnSlotDataChanged); } private void OnSlotDataChanged() { - SetupController(); - } - - private void SetupController() - { - if (!App.roomMgr.InRoom) //不在房间中,自动分配0号手柄到0号手柄位 - { - m_controllerSetuper.SetConnect(con0ToSlot: 0); - } - else //在房间中则使用服务器下发的手柄槽位信息分配本地手柄 - { - long selfUID = App.user.userdata.UID; - uint? con0Slot; - uint? con1Slot; - uint? con2Slot; - uint? con3Slot; - - App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 0, out con0Slot); - App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 1, out con1Slot); - App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 2, out con2Slot); - App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 3, out con3Slot); - - m_controllerSetuper.SetConnect(con0Slot, con1Slot, con2Slot, con3Slot); - } + long selfUID = App.user.userdata.UID; + uint? con0Slot; + uint? con1Slot; + uint? con2Slot; + uint? con3Slot; + + App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 0, out con0Slot); + App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 1, out con1Slot); + App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 2, out con2Slot); + App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 3, out con3Slot); + + m_controllerSetuper.SetConnect(con0Slot, con1Slot, con2Slot, con3Slot); Eventer.Instance.PostEvent(EEvent.OnControllerConnectChanged); } diff --git a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI.cs b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI.cs index dc772b0..17eeb8c 100644 --- a/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI.cs +++ b/AxibugEmuOnline.Client/Assets/Script/AppMain/UI/InGameUI/InGameUI.cs @@ -2,6 +2,7 @@ using AxibugEmuOnline.Client.ClientCore; using AxibugEmuOnline.Client.Event; using AxibugProtobuf; +using VirtualNes.Core; namespace AxibugEmuOnline.Client { @@ -111,7 +112,19 @@ namespace AxibugEmuOnline.Client private void OnRoomCreated() { - m_delayCreateRoom = false; + if (m_delayCreateRoom) + { + m_delayCreateRoom = false; + //延迟创建房间成功后,同步本地手柄连接状态 + Dictionary temp = new Dictionary(); + var setuper = Supporter.GetControllerSetuper(); + for (int i = 0; i < 4; i++) + { + var joyIndex = setuper.GetSlotConnectingController(i); + if (joyIndex != null) temp[(uint)i] = (uint)joyIndex.Value; + } + App.roomMgr.SendChangePlaySlotIdxWithJoyIdx(temp); + } } private void OnLoggedIn()