手柄槽位信息调整

This commit is contained in:
ALIENJACK\alien 2025-08-21 11:57:22 +08:00
parent b4ce028b44
commit 32a4d9dca9
6 changed files with 38 additions and 33 deletions

View File

@ -53,7 +53,7 @@ MonoBehaviour:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2371389415552619370}
m_Enabled: 1
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
@ -200,7 +200,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 1bfe4359a48b5c349b439e88eb53b8b1, type: 3}
m_Name:
m_EditorClassIdentifier:
m_controllerIndex: 0
m_slotIndex: 0
m_connectInfoNode: {fileID: 2371389415552619370}
m_indexIcon: {fileID: 4536003039670490184}
m_playerName: {fileID: 6617607173830585898}
@ -275,8 +275,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 30.93, y: -1.59}
m_SizeDelta: {x: 146.1, y: 30.63}
m_AnchoredPosition: {x: 6.225006, y: -1.59}
m_SizeDelta: {x: 238.55, y: 30.63}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &4464870872037843803
CanvasRenderer:
@ -308,12 +308,12 @@ MonoBehaviour:
m_Calls: []
m_FontData:
m_Font: {fileID: 12800000, guid: 33a3bdf8f6bd1ec4eba7c4bc58183212, type: 3}
m_FontSize: 20
m_FontSize: 24
m_FontStyle: 0
m_BestFit: 1
m_MinSize: 4
m_MaxSize: 20
m_Alignment: 4
m_MaxSize: 27
m_Alignment: 3
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0

View File

@ -408,27 +408,28 @@ namespace AxibugEmuOnline.Client.Manager
/// 发送修改玩家槽位,但是增量
/// </summary>
/// <param name="dictSlotIdx2LocalJoyIdx">玩家占用房间GamePlaySlot和LocalJoyIdx字典</param>
public void SendChangePlaySlotIdxWithJoyIdx(uint localJoyIndex, uint slotIndex, GamePadType localGamePadType)
public void SendChangePlaySlotIdxWithJoyIdx(uint localJoyIndex, uint slotIndex)
{
if (!App.roomMgr.InRoom) return;
Dictionary<uint, ValueTuple<uint, GamePadType>> temp = new Dictionary<uint, ValueTuple<uint, GamePadType>>();
Dictionary<uint, uint> temp = new Dictionary<uint, uint>();
for (int i = 0; i < App.roomMgr.mineRoomMiniInfo.GamePlaySlotList.Count; i++)
{
var item = App.roomMgr.mineRoomMiniInfo.GamePlaySlotList[i];
if (item.PlayerUID <= 0) continue;
if (item.PlayerUID != App.user.userdata.UID) return;
temp[(uint)i] = new ValueTuple<uint, GamePadType>((uint)item.PlayerLocalJoyIdx, item.PlayerLocalGamePadType);
temp[(uint)i] = (uint)item.PlayerLocalJoyIdx;
}
temp[slotIndex] = new ValueTuple<uint, GamePadType>(localJoyIndex, localGamePadType);
temp[slotIndex] = localJoyIndex;
SendChangePlaySlotIdxWithJoyIdx(temp);
}
/// <summary>
/// 发送修改玩家槽位,全量
/// </summary>
/// <param name="dictSlotIdx2LocalJoyIdx">玩家占用房间GamePlaySlot和LocalJoyIdx字典</param>
public void SendChangePlaySlotIdxWithJoyIdx(Dictionary<uint, ValueTuple<uint, GamePadType>> dictSlotIdx2LocalJoyIdx)
public void SendChangePlaySlotIdxWithJoyIdx(Dictionary<uint, uint> dictSlotIdx2LocalJoyIdx)
{
if (!InRoom)
return;
@ -440,8 +441,7 @@ namespace AxibugEmuOnline.Client.Manager
_Protobuf_Room_Change_PlaySlotWithJoy.SlotWithJoy.Add(new Protobuf_PlaySlotIdxWithJoyIdx()
{
PlayerSlotIdx = (int)slotdata.Key,
PlayerLocalJoyIdx = (int)slotdata.Value.Item1,
PlayerLocalGamePadType = slotdata.Value.Item2,
PlayerLocalJoyIdx = (int)slotdata.Value,
});
}

View File

@ -12,6 +12,13 @@ public interface IControllerSetuper
uint? con2ToSlot = null,
uint? con3ToSlot = null);
/// <summary>
/// 增量式的修改一个手柄和一个槽位的连接关系
/// </summary>
/// <param name="conIndex"></param>
/// <param name="slotIndex"></param>
void LetControllerConnect(int conIndex, uint slotIndex);
/// <summary>
/// 指定手柄插槽位,获取当前槽位连接的本地手柄序号
/// </summary>
@ -26,12 +33,7 @@ public interface IControllerSetuper
/// <returns></returns>
uint? GetFreeSlotIndex();
/// <summary>
/// 增量式的修改一个手柄和一个槽位的连接关系
/// </summary>
/// <param name="conIndex"></param>
/// <param name="slotIndex"></param>
void LetControllerConnect(int conIndex, uint slotIndex);
}
public interface IController
{

View File

@ -125,16 +125,13 @@ namespace AxibugEmuOnline.Client
{
m_delayCreateRoom = false;
//延迟创建房间成功后,同步本地手柄连接状态
Dictionary<uint, ValueTuple<uint, GamePadType>> temp = new Dictionary<uint, ValueTuple<uint, GamePadType>>();
Dictionary<uint, uint> temp = new Dictionary<uint, uint>();
var setuper = App.emu.Core.GetControllerSetuper();
for (int i = 0; i < 4; i++)
for (uint i = 0; i < 4; i++)
{
var joyIndex = setuper.GetSlotConnectingControllerIndex(i);
var joyIndex = setuper.GetSlotConnectingControllerIndex((int)i);
//TODO 手柄类型
GamePadType gpType = GamePadType.GlobalGamePad;
if (joyIndex != null) temp[(uint)i] = new ValueTuple<uint, GamePadType>((uint)joyIndex.Value, gpType);
if (joyIndex != null) temp[i] = (uint)joyIndex.Value;
}
App.roomMgr.SendChangePlaySlotIdxWithJoyIdx(temp);
}

View File

@ -18,6 +18,7 @@ public class ControllerInfo : MonoBehaviour
[SerializeField]
Text m_playerName;
private bool m_islocal;
private Tweener m_tween;
public int SlotIndex
{
@ -67,7 +68,16 @@ public class ControllerInfo : MonoBehaviour
if (controller == null) return;
if (!controller.AnyButtonDown()) return;
m_indexIcon.rectTransform.DOShakePosition(0.1f);
if (m_tween != null)
{
m_indexIcon.rectTransform.anchoredPosition = Vector2.zero;
m_tween.Kill();
m_tween = null;
}
m_tween = m_indexIcon.rectTransform.DOShakePosition(0.1f).SetLink(gameObject).OnComplete(() =>
{
m_tween = null;
});
}
}
@ -94,7 +104,6 @@ public class ControllerInfo : MonoBehaviour
{
SetDisconnect();
return;
}
var connecter = App.emu.Core.GetControllerSetuper();

View File

@ -28,10 +28,7 @@ public class ControllerInfoPanel : MonoBehaviour
//找到第一个空闲手柄插槽
var freeSlotIndex = s_freeSlots[0];
//TODO 手柄类型
GamePadType gpType = GamePadType.GlobalGamePad;
App.roomMgr.SendChangePlaySlotIdxWithJoyIdx((uint)joyIndex, (uint)freeSlotIndex, gpType);
App.roomMgr.SendChangePlaySlotIdxWithJoyIdx((uint)joyIndex, (uint)freeSlotIndex);
}
else //不在房间中,直接设置
{