This commit is contained in:
2026-07-20 22:32:52 +08:00
parent 61b9b9a3e6
commit 9977ce1fc9
17 changed files with 254 additions and 109 deletions
@@ -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;