using AxibugEmuOnline.Client; using AxibugEmuOnline.Client.ClientCore; using AxibugEmuOnline.Client.Event; using AxibugEmuOnline.Client.Manager; using System; using System.Collections.Generic; using UnityEngine; using VirtualNes.Core; public class ControllerInfoPanel : MonoBehaviour { private void OnEnable() { Eventer.Instance.RegisterEvent(EEvent.OnLocalJoyDesireInvert, OnLocalJoyDesireInvert); } private void OnDisable() { Eventer.Instance.UnregisterEvent(EEvent.OnLocalJoyDesireInvert, OnLocalJoyDesireInvert); } static List s_freeSlots = new List(4); private void OnLocalJoyDesireInvert(int joyIndex) { if (App.roomMgr.InRoom) { if (!App.roomMgr.mineRoomMiniInfo.GetFreeSlot(ref s_freeSlots)) return; //找到第一个空闲手柄插槽 var freeSlotIndex = s_freeSlots[0]; App.roomMgr.SendChangePlaySlotIdxWithJoyIdx((uint)joyIndex, (uint)freeSlotIndex); } else //不在房间中,直接设置 { if (App.emu.Core.IsNull()) return; var setuper = App.emu.Core.GetControllerSetuper(); if (setuper == null) return; var freeSlotIndex = setuper.GetFreeSlotIndex(); if (freeSlotIndex == null) return; setuper.LetControllerConnect(joyIndex, freeSlotIndex.Value); } } }