forked from sin365/AxibugEmuOnline
客户端
This commit is contained in:
parent
9f3c8ea7c5
commit
7c5934bc6b
@ -67,6 +67,6 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当房间中手柄位信息发生任何变化时触发,进入房间后也应该触发
|
/// 当房间中手柄位信息发生任何变化时触发,进入房间后也应该触发
|
||||||
/// </summary>
|
/// </summary>
|
||||||
OnRoomSlotDataChanged, //todo : 实现这个事件
|
OnRoomSlotDataChanged,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -72,18 +72,5 @@ namespace AxibugEmuOnline.Client.Manager
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#region 测试
|
|
||||||
void TestCreate()
|
|
||||||
{
|
|
||||||
App.roomMgr.SendCreateRoom(1, 0, string.Empty);
|
|
||||||
}
|
|
||||||
long TestFrameID = 0;
|
|
||||||
void TestEmuUpdate()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,6 @@ namespace AxibugEmuOnline.Client.Manager
|
|||||||
public bool IsHost => mineRoomMiniInfo?.HostPlayerUID == App.user.userdata.UID;
|
public bool IsHost => mineRoomMiniInfo?.HostPlayerUID == App.user.userdata.UID;
|
||||||
public bool IsScreenProviderUID => mineRoomMiniInfo?.ScreenProviderUID == App.user.userdata.UID;
|
public bool IsScreenProviderUID => mineRoomMiniInfo?.ScreenProviderUID == App.user.userdata.UID;
|
||||||
public RoomGameState RoomState => mineRoomMiniInfo.GameState;
|
public RoomGameState RoomState => mineRoomMiniInfo.GameState;
|
||||||
public int MinePlayerIdx => GetMinePlayerIndex();
|
|
||||||
public int WaitStep { get; private set; } = -1;
|
public int WaitStep { get; private set; } = -1;
|
||||||
public byte[] RawData { get; private set; } = null;
|
public byte[] RawData { get; private set; } = null;
|
||||||
public NetReplay netReplay { get; private set; }
|
public NetReplay netReplay { get; private set; }
|
||||||
@ -110,64 +109,31 @@ namespace AxibugEmuOnline.Client.Manager
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 房间管理
|
#region 房间管理
|
||||||
int GetMinePlayerIndex()
|
List<Protobuf_Room_GamePlaySlot> GetMinePlayerSlotInfo()
|
||||||
{
|
{
|
||||||
if (mineRoomMiniInfo == null)
|
if (mineRoomMiniInfo == null)
|
||||||
return -1;
|
return null;
|
||||||
|
return mineRoomMiniInfo.GamePlaySlotList.Where(w => w.PlayerUID == App.user.userdata.UID).ToList();
|
||||||
if (mineRoomMiniInfo.Player1UID == App.user.userdata.UID)
|
|
||||||
return 0;
|
|
||||||
if (mineRoomMiniInfo.Player2UID == App.user.userdata.UID)
|
|
||||||
return 1;
|
|
||||||
if (mineRoomMiniInfo.Player3UID == App.user.userdata.UID)
|
|
||||||
return 2;
|
|
||||||
if (mineRoomMiniInfo.Player4UID == App.user.userdata.UID)
|
|
||||||
return 3;
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
long[] GetRoom4PlayerUIDs()
|
long[] GetRoom4PlayerUIDs()
|
||||||
{
|
{
|
||||||
if (mineRoomMiniInfo == null)
|
if (mineRoomMiniInfo == null)
|
||||||
return null;
|
return null;
|
||||||
long[] result = new long[4];
|
long[] result = new long[mineRoomMiniInfo.GamePlaySlotList.Count];
|
||||||
if (mineRoomMiniInfo.Player1UID > 0)
|
for (int i = 0; i < mineRoomMiniInfo.GamePlaySlotList.Count; i++)
|
||||||
result[0] = mineRoomMiniInfo.Player1UID;
|
{
|
||||||
if (mineRoomMiniInfo.Player2UID > 0)
|
if (mineRoomMiniInfo.GamePlaySlotList[i].PlayerUID > 0)
|
||||||
result[1] = mineRoomMiniInfo.Player2UID;
|
result[i] = mineRoomMiniInfo.GamePlaySlotList[i].PlayerUID;
|
||||||
if (mineRoomMiniInfo.Player3UID > 0)
|
}
|
||||||
result[2] = mineRoomMiniInfo.Player3UID;
|
|
||||||
if (mineRoomMiniInfo.Player4UID > 0)
|
|
||||||
result[3] = mineRoomMiniInfo.Player4UID;
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
S_PlayerMiniInfo[] GetRoom4PlayerMiniInfos()
|
Protobuf_Room_GamePlaySlot[] GetRoom4GameSlotMiniInfos()
|
||||||
{
|
{
|
||||||
if (mineRoomMiniInfo == null)
|
if (mineRoomMiniInfo == null)
|
||||||
return null;
|
return null;
|
||||||
S_PlayerMiniInfo[] result = new S_PlayerMiniInfo[4];
|
return mineRoomMiniInfo.GamePlaySlotList.ToArray();
|
||||||
if (mineRoomMiniInfo.Player1UID > 0)
|
|
||||||
{
|
|
||||||
result[0].UID = mineRoomMiniInfo.Player1UID;
|
|
||||||
result[0].NickName = mineRoomMiniInfo.Player1NickName;
|
|
||||||
}
|
|
||||||
if (mineRoomMiniInfo.Player2UID > 0)
|
|
||||||
{
|
|
||||||
result[1].UID = mineRoomMiniInfo.Player2UID;
|
|
||||||
result[1].NickName = mineRoomMiniInfo.Player2NickName;
|
|
||||||
}
|
|
||||||
if (mineRoomMiniInfo.Player3UID > 0)
|
|
||||||
{
|
|
||||||
result[2].UID = mineRoomMiniInfo.Player3UID;
|
|
||||||
result[2].NickName = mineRoomMiniInfo.Player3NickName;
|
|
||||||
}
|
|
||||||
if (mineRoomMiniInfo.Player4UID > 0)
|
|
||||||
{
|
|
||||||
result[3].UID = mineRoomMiniInfo.Player4UID;
|
|
||||||
result[3].NickName = mineRoomMiniInfo.Player4NickName;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -251,9 +217,8 @@ namespace AxibugEmuOnline.Client.Manager
|
|||||||
/// <param name="GameRomID"></param>
|
/// <param name="GameRomID"></param>
|
||||||
/// <param name="JoinPlayerIdx"></param>
|
/// <param name="JoinPlayerIdx"></param>
|
||||||
/// <param name="GameRomHash"></param>
|
/// <param name="GameRomHash"></param>
|
||||||
public void SendCreateRoom(int GameRomID, int JoinPlayerIdx, string GameRomHash = null)
|
public void SendCreateRoom(int GameRomID, string GameRomHash = null)
|
||||||
{
|
{
|
||||||
_Protobuf_Room_Create.JoinPlayerIdx = JoinPlayerIdx;
|
|
||||||
_Protobuf_Room_Create.GameRomID = GameRomID;
|
_Protobuf_Room_Create.GameRomID = GameRomID;
|
||||||
_Protobuf_Room_Create.GameRomHash = GameRomHash;
|
_Protobuf_Room_Create.GameRomHash = GameRomHash;
|
||||||
App.log.Info($"创建房间");
|
App.log.Info($"创建房间");
|
||||||
@ -278,13 +243,12 @@ namespace AxibugEmuOnline.Client.Manager
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建房间
|
/// 创建房间
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="GameRomID"></param>
|
/// <param name="RoomID"></param>
|
||||||
/// <param name="JoinPlayerIdx"></param>
|
/// <param name="JoinSlotIdx">加入时所在SlotIdx</param>
|
||||||
/// <param name="GameRomHash"></param>
|
/// <param name="LocalJoyIdx">加入时候本地对应JoyIdx</param>
|
||||||
public void SendJoinRoom(int RoomID, int JoinPlayerIdx)
|
public void SendJoinRoom(int RoomID)
|
||||||
{
|
{
|
||||||
_Protobuf_Room_Join.RoomID = RoomID;
|
_Protobuf_Room_Join.RoomID = RoomID;
|
||||||
_Protobuf_Room_Join.PlayerNum = JoinPlayerIdx;
|
|
||||||
App.log.Info($"加入房间");
|
App.log.Info($"加入房间");
|
||||||
App.network.SendToServer((int)CommandID.CmdRoomJoin, ProtoBufHelper.Serizlize(_Protobuf_Room_Join));
|
App.network.SendToServer((int)CommandID.CmdRoomJoin, ProtoBufHelper.Serizlize(_Protobuf_Room_Join));
|
||||||
}
|
}
|
||||||
@ -336,35 +300,105 @@ namespace AxibugEmuOnline.Client.Manager
|
|||||||
{
|
{
|
||||||
Protobuf_Room_MyRoom_State_Change msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_MyRoom_State_Change>(reqData);
|
Protobuf_Room_MyRoom_State_Change msg = ProtoBufHelper.DeSerizlize<Protobuf_Room_MyRoom_State_Change>(reqData);
|
||||||
long[] oldRoomPlayer = GetRoom4PlayerUIDs();
|
long[] oldRoomPlayer = GetRoom4PlayerUIDs();
|
||||||
|
Protobuf_Room_GamePlaySlot[] oldslotArr = GetRoom4GameSlotMiniInfos();
|
||||||
mineRoomMiniInfo = msg.RoomMiniInfo;
|
mineRoomMiniInfo = msg.RoomMiniInfo;
|
||||||
long[] newRoomPlayer = GetRoom4PlayerUIDs();
|
long[] newRoomPlayer = GetRoom4PlayerUIDs();
|
||||||
|
Protobuf_Room_GamePlaySlot[] newslotArr = GetRoom4GameSlotMiniInfos();
|
||||||
|
|
||||||
|
oldRoomPlayer = oldRoomPlayer.Where(w => w > 0).Distinct().ToArray();
|
||||||
|
newRoomPlayer = newRoomPlayer.Where(w => w > 0).Distinct().ToArray();
|
||||||
|
//离开用户
|
||||||
|
foreach (var leavn in oldRoomPlayer.Where(w => !newRoomPlayer.Contains(w)))
|
||||||
|
{
|
||||||
|
UserDataBase oldplayer = App.user.GetUserByUid(leavn);
|
||||||
|
string oldPlayName = oldplayer != null ? oldplayer.NickName : "Player";
|
||||||
|
OverlayManager.PopTip($"[{oldPlayName}]离开房间");
|
||||||
|
Eventer.Instance.PostEvent(EEvent.OnOtherPlayerLeavnRoom, leavn);
|
||||||
|
}
|
||||||
|
//新加入用户
|
||||||
|
foreach (var newJoin in newRoomPlayer.Where(w => !oldRoomPlayer.Contains(w)))
|
||||||
|
{
|
||||||
|
UserDataBase newplayer = App.user.GetUserByUid(newJoin);
|
||||||
|
string newplayerName = newplayer != null ? newplayer.NickName : "Player";
|
||||||
|
OverlayManager.PopTip($"[{newplayer}]进入房间");
|
||||||
|
Eventer.Instance.PostEvent(EEvent.OnOtherPlayerJoinRoom, newJoin);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool bChangeSlot = false;
|
||||||
for (int i = 0; i < 4; i++)
|
for (int i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
long OldPlayer = oldRoomPlayer[i];
|
var oldSlot = oldslotArr[i];
|
||||||
long NewPlayer = newRoomPlayer[i];
|
var newSlot = newslotArr[i];
|
||||||
if (OldPlayer == NewPlayer)
|
if (oldSlot.PlayerUID <= 0 && newSlot.PlayerUID <= 0)
|
||||||
continue;
|
continue;
|
||||||
//位置之前有人,但是离开了
|
if (
|
||||||
if (OldPlayer > 0)
|
oldSlot.PlayerUID != newSlot.PlayerUID
|
||||||
|
||
|
||||||
|
oldSlot.PlayerLocalJoyIdx != newSlot.PlayerLocalJoyIdx
|
||||||
|
)
|
||||||
{
|
{
|
||||||
Eventer.Instance.PostEvent(EEvent.OnOtherPlayerLeavnRoom, i, OldPlayer);
|
bChangeSlot = true;
|
||||||
UserDataBase oldplayer = App.user.GetUserByUid(OldPlayer);
|
if (newSlot.PlayerUID > 0)
|
||||||
string oldPlayName = oldplayer != null ? oldplayer.NickName : "Player";
|
|
||||||
OverlayManager.PopTip($"[{oldPlayName}]离开房间,手柄位:P{i}");
|
|
||||||
if (NewPlayer > 0)//而且害换了一个玩家
|
|
||||||
{
|
{
|
||||||
Eventer.Instance.PostEvent(EEvent.OnOtherPlayerJoinRoom, i, NewPlayer);
|
OverlayManager.PopTip($"[{newSlot.PlayerNickName}]使用:P{i}");
|
||||||
mineRoomMiniInfo.GetPlayerNameByPlayerIdx((uint)i, out string PlayerName);
|
|
||||||
OverlayManager.PopTip($"[{PlayerName}]进入房间,手柄位:P{i}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else //之前没人
|
|
||||||
{
|
|
||||||
Eventer.Instance.PostEvent(EEvent.OnOtherPlayerJoinRoom, i, NewPlayer);
|
|
||||||
mineRoomMiniInfo.GetPlayerNameByPlayerIdx((uint)i, out string PlayerName);
|
|
||||||
OverlayManager.PopTip($"[{PlayerName}]进入房间,手柄位:P{i}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bChangeSlot)
|
||||||
|
{
|
||||||
|
Eventer.Instance.PostEvent(EEvent.OnRoomSlotDataChanged);
|
||||||
|
}
|
||||||
|
|
||||||
|
//for (int i = 0; i < 4; i++)
|
||||||
|
//{
|
||||||
|
// long OldPlayer = oldRoomPlayer[i];
|
||||||
|
// long NewPlayer = newRoomPlayer[i];
|
||||||
|
// if (OldPlayer == NewPlayer)
|
||||||
|
// continue;
|
||||||
|
|
||||||
|
// //位置之前有人,但是离开了
|
||||||
|
// if (OldPlayer > 0)
|
||||||
|
// {
|
||||||
|
// Eventer.Instance.PostEvent(EEvent.OnOtherPlayerLeavnRoom, i, OldPlayer);
|
||||||
|
// UserDataBase oldplayer = App.user.GetUserByUid(OldPlayer);
|
||||||
|
// string oldPlayName = oldplayer != null ? oldplayer.NickName : "Player";
|
||||||
|
// OverlayManager.PopTip($"[{oldPlayName}]离开房间,手柄位:P{i}");
|
||||||
|
// if (NewPlayer > 0)//而且害换了一个玩家
|
||||||
|
// {
|
||||||
|
// Eventer.Instance.PostEvent(EEvent.OnOtherPlayerJoinRoom, i, NewPlayer);
|
||||||
|
// mineRoomMiniInfo.GetPlayerNameByPlayerIdx((uint)i, out string PlayerName);
|
||||||
|
// OverlayManager.PopTip($"[{PlayerName}]进入房间,手柄位:P{i}");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else //之前没人
|
||||||
|
// {
|
||||||
|
// Eventer.Instance.PostEvent(EEvent.OnOtherPlayerJoinRoom, i, NewPlayer);
|
||||||
|
// mineRoomMiniInfo.GetPlayerNameByPlayerIdx((uint)i, out string PlayerName);
|
||||||
|
// OverlayManager.PopTip($"[{PlayerName}]进入房间,手柄位:P{i}");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //位置之前有人,但是离开了
|
||||||
|
// if (OldPlayer > 0)
|
||||||
|
// {
|
||||||
|
// Eventer.Instance.PostEvent(EEvent.OnOtherPlayerLeavnRoom, i, OldPlayer);
|
||||||
|
// UserDataBase oldplayer = App.user.GetUserByUid(OldPlayer);
|
||||||
|
// string oldPlayName = oldplayer != null ? oldplayer.NickName : "Player";
|
||||||
|
// OverlayManager.PopTip($"[{oldPlayName}]离开房间,手柄位:P{i}");
|
||||||
|
// if (NewPlayer > 0)//而且害换了一个玩家
|
||||||
|
// {
|
||||||
|
// Eventer.Instance.PostEvent(EEvent.OnOtherPlayerJoinRoom, i, NewPlayer);
|
||||||
|
// mineRoomMiniInfo.GetPlayerNameByPlayerIdx((uint)i, out string PlayerName);
|
||||||
|
// OverlayManager.PopTip($"[{PlayerName}]进入房间,手柄位:P{i}");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else //之前没人
|
||||||
|
// {
|
||||||
|
// Eventer.Instance.PostEvent(EEvent.OnOtherPlayerJoinRoom, i, NewPlayer);
|
||||||
|
// mineRoomMiniInfo.GetPlayerNameByPlayerIdx((uint)i, out string PlayerName);
|
||||||
|
// OverlayManager.PopTip($"[{PlayerName}]进入房间,手柄位:P{i}");
|
||||||
|
// }
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -461,14 +495,11 @@ namespace AxibugEmuOnline.Client.Manager
|
|||||||
|
|
||||||
if (mineRoomMiniInfo == null)
|
if (mineRoomMiniInfo == null)
|
||||||
{
|
{
|
||||||
if (mineRoomMiniInfo.Player1UID == uid)
|
foreach (var gameslot in mineRoomMiniInfo.GamePlaySlotList)
|
||||||
mineRoomMiniInfo.Player1NickName = userdata.NickName;
|
{
|
||||||
else if (mineRoomMiniInfo.Player2UID == uid)
|
if (gameslot.PlayerUID == uid)
|
||||||
mineRoomMiniInfo.Player2NickName = userdata.NickName;
|
gameslot.PlayerNickName = userdata.NickName;
|
||||||
else if (mineRoomMiniInfo.Player3UID == uid)
|
}
|
||||||
mineRoomMiniInfo.Player3NickName = userdata.NickName;
|
|
||||||
else if (mineRoomMiniInfo.Player4UID == uid)
|
|
||||||
mineRoomMiniInfo.Player4NickName = userdata.NickName;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -484,34 +515,38 @@ namespace AxibugEmuOnline.Client.Manager
|
|||||||
public static bool GetFreeSlot(this Protobuf_Room_MiniInfo roomMiniInfo, out int[] freeSlots)
|
public static bool GetFreeSlot(this Protobuf_Room_MiniInfo roomMiniInfo, out int[] freeSlots)
|
||||||
{
|
{
|
||||||
List<int> temp = new List<int>();
|
List<int> temp = new List<int>();
|
||||||
if (roomMiniInfo.Player1UID <= 0) temp.Add(0);
|
for (int i = 0; i < roomMiniInfo.GamePlaySlotList.Count; i++)
|
||||||
if (roomMiniInfo.Player2UID <= 0) temp.Add(1);
|
{
|
||||||
if (roomMiniInfo.Player3UID <= 0) temp.Add(2);
|
if (roomMiniInfo.GamePlaySlotList[i].PlayerUID <= 0)
|
||||||
if (roomMiniInfo.Player4UID <= 0) temp.Add(3);
|
temp.Add(i);
|
||||||
|
}
|
||||||
freeSlots = temp.ToArray();
|
freeSlots = temp.ToArray();
|
||||||
return freeSlots.Length > 0;
|
return freeSlots.Length > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 指定uid和该uid的本地手柄序号,获取占用的手柄位
|
/// 指定uid和该uid的本地手柄序号,获取占用的手柄位
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool GetPlayerSlotIdxByUid(this Protobuf_Room_MiniInfo roomMiniInfo, long uid ,int controllerIndex, out uint? slotID)
|
public static bool GetPlayerSlotIdxByUid(this Protobuf_Room_MiniInfo roomMiniInfo, long uid, int joyIdx, out uint? slotIdx)
|
||||||
{
|
{
|
||||||
slotID = null;
|
slotIdx = null;
|
||||||
|
//joyIdx取值返回[0,3],这个序号代表玩家本地的手柄编号
|
||||||
//controllerIndex取值返回[0,3],这个序号代表玩家本地的手柄编号
|
|
||||||
//todo : 根据uid和controllerIndex 返回占用的位置
|
//todo : 根据uid和controllerIndex 返回占用的位置
|
||||||
|
|
||||||
//目前未实现,所有非0号位置的手柄,都返回false
|
//目前未实现,所有非0号位置的手柄,都返回false
|
||||||
if (controllerIndex != 0) return false;
|
|
||||||
|
|
||||||
if (roomMiniInfo.Player1UID == uid) slotID = 0;
|
for (int i = 0; i < roomMiniInfo.GamePlaySlotList.Count; i++)
|
||||||
if (roomMiniInfo.Player2UID == uid) slotID = 1;
|
{
|
||||||
if (roomMiniInfo.Player3UID == uid) slotID = 2;
|
if (roomMiniInfo.GamePlaySlotList[i].PlayerUID == uid)
|
||||||
if (roomMiniInfo.Player4UID == uid) slotID = 3;
|
{
|
||||||
return true;
|
slotIdx = (uint)i;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 按照房间玩家下标获取昵称
|
/// 按照房间玩家下标获取昵称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -519,16 +554,11 @@ namespace AxibugEmuOnline.Client.Manager
|
|||||||
/// <param name="PlayerIndex"></param>
|
/// <param name="PlayerIndex"></param>
|
||||||
/// <param name="PlayerName"></param>
|
/// <param name="PlayerName"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool GetPlayerNameByPlayerIdx(this Protobuf_Room_MiniInfo roomMiniInfo,uint PlayerIndex, out string PlayerName)
|
public static bool GetPlayerNameByPlayerIdx(this Protobuf_Room_MiniInfo roomMiniInfo, uint GameSlotIdx, out string PlayerName)
|
||||||
{
|
{
|
||||||
PlayerName = string.Empty;
|
PlayerName = string.Empty;
|
||||||
switch (PlayerIndex)
|
if (roomMiniInfo.GamePlaySlotList[(int)GameSlotIdx].PlayerUID > 0)
|
||||||
{
|
PlayerName = roomMiniInfo.GamePlaySlotList[(int)GameSlotIdx].PlayerNickName;
|
||||||
case 0: PlayerName = roomMiniInfo.Player1UID > 0 ? roomMiniInfo.Player1NickName : null; break;
|
|
||||||
case 1: PlayerName = roomMiniInfo.Player2UID > 0 ? roomMiniInfo.Player2NickName : null; break;
|
|
||||||
case 2: PlayerName = roomMiniInfo.Player3UID > 0 ? roomMiniInfo.Player3NickName : null; break;
|
|
||||||
case 3: PlayerName = roomMiniInfo.Player4UID > 0 ? roomMiniInfo.Player4NickName : null; break;
|
|
||||||
}
|
|
||||||
return string.IsNullOrEmpty(PlayerName);
|
return string.IsNullOrEmpty(PlayerName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using AxibugEmuOnline.Client.ClientCore;
|
using AxibugEmuOnline.Client.ClientCore;
|
||||||
|
using AxibugProtobuf;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
@ -83,6 +84,12 @@ namespace AxibugEmuOnline.Client.Network
|
|||||||
|
|
||||||
public void PostNetMsgEvent(int cmd, int ERRCODE, byte[] arg)
|
public void PostNetMsgEvent(int cmd, int ERRCODE, byte[] arg)
|
||||||
{
|
{
|
||||||
|
ErrorCode err = ((ErrorCode)ERRCODE);
|
||||||
|
if (err != ErrorCode.ErrorOk)
|
||||||
|
{
|
||||||
|
OverlayManager.PopTip("错误:"+err.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
List<Delegate> eventList = GetNetEventDicList(cmd);
|
List<Delegate> eventList = GetNetEventDicList(cmd);
|
||||||
if (eventList != null)
|
if (eventList != null)
|
||||||
{
|
{
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -83,7 +83,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
{
|
{
|
||||||
if (App.user.IsLoggedIn)
|
if (App.user.IsLoggedIn)
|
||||||
{
|
{
|
||||||
App.roomMgr.SendCreateRoom(RomFile.ID, 0, RomFile.Hash);
|
App.roomMgr.SendCreateRoom(RomFile.ID, RomFile.Hash);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -116,7 +116,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
private void OnLoggedIn()
|
private void OnLoggedIn()
|
||||||
{
|
{
|
||||||
if (m_delayCreateRoom) App.roomMgr.SendCreateRoom(RomFile.ID, 0, RomFile.Hash);
|
if (m_delayCreateRoom) App.roomMgr.SendCreateRoom(RomFile.ID, RomFile.Hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnServerStepUpdate(int step)
|
private void OnServerStepUpdate(int step)
|
||||||
|
@ -39,7 +39,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
public void SetData(object data)
|
public void SetData(object data)
|
||||||
{
|
{
|
||||||
Debug.Assert(data is Protobuf_Room_MiniInfo);
|
Debug.Assert(data is Protobuf_Room_MiniInfo);
|
||||||
|
|
||||||
var roomInfo = (Protobuf_Room_MiniInfo)data;
|
var roomInfo = (Protobuf_Room_MiniInfo)data;
|
||||||
RoomID = roomInfo.RoomID;
|
RoomID = roomInfo.RoomID;
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
App.roomMgr.SendJoinRoom(RoomID, freeSlots[0]);
|
App.roomMgr.SendJoinRoom(RoomID);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ using AxibugEmuOnline.Client.ClientCore;
|
|||||||
using AxibugProtobuf;
|
using AxibugProtobuf;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace AxibugEmuOnline.Client
|
namespace AxibugEmuOnline.Client
|
||||||
@ -19,21 +20,17 @@ namespace AxibugEmuOnline.Client
|
|||||||
public static string GetHostNickName(this Protobuf_Room_MiniInfo roomInfo)
|
public static string GetHostNickName(this Protobuf_Room_MiniInfo roomInfo)
|
||||||
{
|
{
|
||||||
var hostUID = roomInfo.HostPlayerUID;
|
var hostUID = roomInfo.HostPlayerUID;
|
||||||
if (hostUID == roomInfo.Player1UID) return roomInfo.Player1NickName;
|
Protobuf_Room_GamePlaySlot slotdata = roomInfo.GamePlaySlotList.FirstOrDefault(w => w.PlayerUID == hostUID);
|
||||||
else if (hostUID == roomInfo.Player2UID) return roomInfo.Player2NickName;
|
if (slotdata != null)
|
||||||
else if (hostUID == roomInfo.Player3UID) return roomInfo.Player3NickName;
|
return slotdata.PlayerNickName;
|
||||||
else if (hostUID == roomInfo.Player4UID) return roomInfo.Player4NickName;
|
else
|
||||||
else return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void GetRoomPlayers(this Protobuf_Room_MiniInfo roomInfo, out int current, out int max)
|
public static void GetRoomPlayers(this Protobuf_Room_MiniInfo roomInfo, out int current, out int max)
|
||||||
{
|
{
|
||||||
current = 0; max = 4;
|
current = 0; max = 4;
|
||||||
|
current = roomInfo.GamePlaySlotList.Count(w => w.PlayerUID > 0);
|
||||||
if (roomInfo.Player1UID > 0) current++;
|
|
||||||
if (roomInfo.Player2UID > 0) current++;
|
|
||||||
if (roomInfo.Player3UID > 0) current++;
|
|
||||||
if (roomInfo.Player4UID > 0) current++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Dictionary<int, RomFile> s_RomFileCahcesInRoomInfo = new Dictionary<int, RomFile>();
|
private static Dictionary<int, RomFile> s_RomFileCahcesInRoomInfo = new Dictionary<int, RomFile>();
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -300,8 +300,6 @@ message Protobuf_Room_Create
|
|||||||
{
|
{
|
||||||
int32 GameRomID = 1;
|
int32 GameRomID = 1;
|
||||||
string GameRomHash = 2;
|
string GameRomHash = 2;
|
||||||
int32 PlayerSlotIdx = 3;//创建时的P1~P4编号
|
|
||||||
int32 PlayerLocalJoyIdx = 4;//创建时的客户端Joy编号
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message Protobuf_Room_Create_RESP
|
message Protobuf_Room_Create_RESP
|
||||||
@ -312,8 +310,6 @@ message Protobuf_Room_Create_RESP
|
|||||||
message Protobuf_Room_Join
|
message Protobuf_Room_Join
|
||||||
{
|
{
|
||||||
int32 RoomID = 1;//房间ID
|
int32 RoomID = 1;//房间ID
|
||||||
int32 PlayerSlotIdx = 2;//P1~P4编号
|
|
||||||
int32 PlayerLocalJoyIdx = 3;//客户端Joy编号
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message Protobuf_Room_Join_RESP
|
message Protobuf_Room_Join_RESP
|
||||||
|
Loading…
Reference in New Issue
Block a user