From 13cadd90a0877b3dc78417f7aa8f5e38db464f48 Mon Sep 17 00:00:00 2001 From: "ALIENJACK\\alien" Date: Wed, 25 Dec 2024 19:56:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=88=BF=E4=B8=BB=E5=88=9B?= =?UTF-8?q?=E5=BB=BA=E6=88=BF=E9=97=B4=E6=88=90=E5=8A=9F=E5=90=8E,?= =?UTF-8?q?=E5=B0=86=E6=9C=AC=E5=9C=B0=E7=9A=84=E6=89=8B=E6=9F=84=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E8=AE=BE=E7=BD=AE=E5=90=8C=E6=AD=A5=E5=88=B0=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1=E5=99=A8=E7=9A=84=E6=9C=BA=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Assets/Script/AppMain/Manager/AppEmu.cs | 44 +++++++------------ .../Script/AppMain/UI/InGameUI/InGameUI.cs | 15 ++++++- 2 files changed, 31 insertions(+), 28 deletions(-) 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()