1
This commit is contained in:
@@ -165,6 +165,7 @@ namespace Assets.MyGame.Scripts.Net
|
||||
dic_API[APIType.Hall_GetChessRoomPartitionCount] = "/api/Hall/GetChessRoomPartitionCount";
|
||||
dic_API[APIType.Hall_SendBroadcast] = "/api/Hall/SendBroadcast";
|
||||
dic_API[APIType.Room_Assign] = "/api/Room/Assign";
|
||||
dic_API[APIType.Room_QuickJoin] = "/api/Room/QuickJoin";
|
||||
dic_API[APIType.Hall_UseVipExp] = "/api/Hall/UseVipExp";
|
||||
|
||||
// ---------------- Customer ----------------
|
||||
|
||||
@@ -208,4 +208,12 @@ namespace Assets.MyGame.Scripts.Net.APIRequest.Params
|
||||
{
|
||||
public string roomId;
|
||||
}
|
||||
|
||||
/// <summary>快速加入房间(GET /api/Room/QuickJoin?gameType=&level=)</summary>
|
||||
[Serializable]
|
||||
public class RoomQuickJoinParam : RequestParamBase
|
||||
{
|
||||
public int gameType;
|
||||
public int level;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,6 +320,20 @@ namespace Assets.MyGame.Scripts.Net
|
||||
}, callback);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 快速加入房间(GET /api/Room/QuickJoin?gameType=&level=)
|
||||
/// 返回:QuickJoinResponse(roomId + url)
|
||||
/// 后端自动分配房间和座位,客户端拿到后用 url 连 socket,再调 JoinRoom(roomId, userId, -1)
|
||||
/// </summary>
|
||||
public static void RoomQuickJoin(int gameType, int level, Action<QuickJoinResponse> callback)
|
||||
{
|
||||
APIManager.Response<QuickJoinResponse>(APIType.Room_QuickJoin, new RoomQuickJoinParam
|
||||
{
|
||||
gameType = gameType,
|
||||
level = level
|
||||
}, callback);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用VIP经验包(GET /api/Hall/UseVipExp)
|
||||
/// 返回:string
|
||||
|
||||
@@ -304,4 +304,18 @@ namespace Assets.MyGame.Scripts.Net.APIResponses
|
||||
public long taskFinishTime;
|
||||
public int exp; // 奖励经验
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 快速加入房间返回数据
|
||||
/// /api/Room/QuickJoin?gameType=&level=
|
||||
/// 示例: {"data":{"roomId":"11107","webSocketUrl":"ws://8.137.163.153/fishinghub?instance=1"},"code":0,"info":null}
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class QuickJoinResponse
|
||||
{
|
||||
/// <summary>房间ID</summary>
|
||||
public string roomId;
|
||||
/// <summary>房间专属 socket 地址(如 ws://xxx/fishinghub?instance=1)</summary>
|
||||
public string webSocketUrl;
|
||||
}
|
||||
}
|
||||
@@ -342,6 +342,9 @@ namespace Assets.MyGame.Scripts.Net
|
||||
/// <summary>获取房间专属 socket 地址(GET /api/Room/Assign?roomId=)</summary>
|
||||
Room_Assign,
|
||||
|
||||
/// <summary>快速加入房间(GET /api/Room/QuickJoin?gameType=&level=)</summary>
|
||||
Room_QuickJoin,
|
||||
|
||||
/// <summary>使用VIP经验包(GET /api/Hall/UseVipExp)</summary>
|
||||
Hall_UseVipExp,
|
||||
|
||||
|
||||
@@ -51,7 +51,9 @@ namespace Assets.MyGame.Scripts.Net.WebResponses
|
||||
changeTurret=7,
|
||||
freezeFish=8,
|
||||
changeCannonMultiple=9,
|
||||
changeWing=10
|
||||
changeWing=10,
|
||||
/// <summary>新玩家资源加载完成,请求房主广播场上活鱼</summary>
|
||||
requestSyncFish=11
|
||||
}
|
||||
[Serializable]
|
||||
public class FireCannonSendData
|
||||
|
||||
@@ -443,29 +443,32 @@ namespace Assets.MyGame.Scripts.Net
|
||||
//WebSocketManager.Instance.Close(SocketType.game);
|
||||
break;
|
||||
case "ChangeControllerUser":
|
||||
var userId = JsonConvert.DeserializeObject<WebSocketResponseBase<string>>(msg).arguments[0];
|
||||
if (userId == GameManager.Instance.user.id)
|
||||
{
|
||||
// 本地玩家成为房主:开启出鱼 + 同步本地房主引用
|
||||
CreateFishManager.Instance.fangzhu = true;
|
||||
if (SitPosData.localPlayerSit != null)
|
||||
SitPosData.roomOwnerSit = SitPosData.localPlayerSit;
|
||||
}
|
||||
else if (userId != null && userId.StartsWith("bot_"))
|
||||
{
|
||||
// 房主是人机:人机无法真正发包,由本地首个非人机玩家代发
|
||||
SitPosData.TransferRoomOwner();
|
||||
CreateFishManager.Instance.fangzhu =
|
||||
SitPosData.roomOwnerSit != null &&
|
||||
SitPosData.roomOwnerSit.user == GameManager.Instance.user.id;
|
||||
}
|
||||
else
|
||||
{
|
||||
// ⭐ 只在 userId 非空且确实是真人玩家时才停止本地出鱼
|
||||
// userId 为空(异常情况)时保持原状,避免误关出鱼导致 bot 退出后不出鱼
|
||||
if (!string.IsNullOrEmpty(userId))
|
||||
CreateFishManager.Instance.fangzhu = false;
|
||||
var userId = JsonConvert.DeserializeObject<WebSocketResponseBase<string>>(msg).arguments[0];
|
||||
if (userId == GameManager.Instance.user.id)
|
||||
{
|
||||
// 本地玩家成为房主:开启出鱼 + 同步本地房主引用
|
||||
CreateFishManager.Instance.fangzhu = true;
|
||||
if (SitPosData.localPlayerSit != null)
|
||||
SitPosData.roomOwnerSit = SitPosData.localPlayerSit;
|
||||
}
|
||||
else if (userId != null && userId.StartsWith("bot_"))
|
||||
{
|
||||
// 房主是人机:人机无法真正发包,由本地首个非人机玩家代发
|
||||
SitPosData.TransferRoomOwner();
|
||||
CreateFishManager.Instance.fangzhu =
|
||||
SitPosData.roomOwnerSit != null &&
|
||||
SitPosData.roomOwnerSit.user == GameManager.Instance.user.id;
|
||||
}
|
||||
else
|
||||
{
|
||||
// ⭐ 只在 userId 非空且确实是真人玩家时才停止本地出鱼
|
||||
// userId 为空(异常情况)时保持原状,避免误关出鱼导致 bot 退出后不出鱼
|
||||
if (!string.IsNullOrEmpty(userId))
|
||||
CreateFishManager.Instance.fangzhu = false;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case "Exception":
|
||||
{
|
||||
@@ -567,8 +570,13 @@ namespace Assets.MyGame.Scripts.Net
|
||||
case "UsePropNotice":
|
||||
{
|
||||
var data = JsonConvert.DeserializeObject<WebSocketResponseBase<Dictionary<string, object>>>(msg).arguments[0];
|
||||
// { userId, propNumber }
|
||||
Debug.Log($"[FishGameHub] 使用道具: userId={data["userId"]}, prop={data["propNumber"]}");
|
||||
var userId = data["userId"]?.ToString();
|
||||
string propNumber = data["propNumber"]?.ToString();
|
||||
Debug.Log($"[FishGameHub] 使用道具: userId={userId}, prop={propNumber}");
|
||||
|
||||
var panel = CreateFishManager.Instance.currGameType;
|
||||
if (panel != null)
|
||||
panel.OnUsePropNotice(userId, propNumber);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -44,27 +44,11 @@ namespace Assets.MyGame.Scripts.Net
|
||||
|
||||
var selectRoomPanel = var1.subUIManager.Get<UIHome_BY_SelectRoomLevelPanel>(UIPanel.SelectRoomLeavePenel);
|
||||
if (selectRoomPanel != null && selectRoomPanel.isMySelectRoom)
|
||||
selectRoomPanel.panel_UIHome_BY_MySelectRoomPenel.Show(msg);
|
||||
|
||||
else
|
||||
{
|
||||
var v = JsonConvert.DeserializeObject<WebSocketResponseBase<List<GetRoomList>>>(msg).arguments[0];
|
||||
|
||||
|
||||
foreach (var item in v)
|
||||
{
|
||||
if (item.currentOnlinePlayerCount < item.maxPlayerCount)
|
||||
{
|
||||
WebSocketSendList.GetRoomInfo(item.roomId);
|
||||
break;
|
||||
//if (item)
|
||||
//{
|
||||
//UIHome_BY_SelectRoomLevelPanel.StartGame(item);
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
// 手动选座:显示房间列表给玩家选
|
||||
selectRoomPanel.panel_UIHome_BY_MySelectRoomPenel.Show(msg);
|
||||
}
|
||||
// 快速加入分支已迁移到 OnSelectRoom → /api/Room/QuickJoin,不再走 GetRoomList
|
||||
}
|
||||
/// <summary>
|
||||
/// 加入房间 room
|
||||
@@ -274,6 +258,9 @@ namespace Assets.MyGame.Scripts.Net
|
||||
case FrameDataType.changeWing:
|
||||
EventCenter.Instance.EventTrigger<SyncGameData>(ConstEventString.SyncGameData_ChangeWing, syncGameData);
|
||||
break;
|
||||
case FrameDataType.requestSyncFish:
|
||||
EventCenter.Instance.EventTrigger<SyncGameData>(ConstEventString.SyncGameData_RequestSyncFish, syncGameData);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -260,6 +260,11 @@ public partial class WebSocketSendList
|
||||
_syncLv2Append.Add(sgd);
|
||||
return;
|
||||
|
||||
case FrameDataType.requestSyncFish:
|
||||
// ⭐ 新玩家加载完成的"请求同步鱼":立即发送,房主尽快响应广播
|
||||
SendImmediate(BuildJson(sgd));
|
||||
return;
|
||||
|
||||
default:
|
||||
_syncLv3Append.Add(sgd);
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user