1
This commit is contained in:
@@ -449,6 +449,156 @@ namespace Assets.MyGame.Scripts.Net
|
||||
UIManager.Instance.ShowBoardGongGao(data.text);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LoginHub LevelChangedNEW — 后台修改玩家等级
|
||||
/// 直接调用 GetUser 刷新用户数据,触发 OnUserDataChanged 同步 UI
|
||||
/// </summary>
|
||||
public static void LevelChanged(string msg)
|
||||
{
|
||||
var data = JsonConvert.DeserializeObject<WebSocketResponseBase<LevelChangedData>>(msg).arguments[0];
|
||||
var userId = GameManager.Instance?.user?.id;
|
||||
if (!string.IsNullOrEmpty(userId))
|
||||
APIRequestList.GetUser(userId, a => GameManager.Instance.UpdataUserData(a));
|
||||
}
|
||||
|
||||
// ---------------- FishGameHub 补充 ----------------
|
||||
|
||||
/// <summary>
|
||||
/// FishGameHub BotLeaveRoomNoticeNEW — 机器人退出房间
|
||||
/// 仅触发对应座位显示等待,不影响本地玩家(自己退出走 LeaveRoomResult)
|
||||
/// </summary>
|
||||
public static void BotLeaveRoom(string botUserId)
|
||||
{
|
||||
if (string.IsNullOrEmpty(botUserId)) return;
|
||||
switch (GameManager.Instance.gameData.currGameType)
|
||||
{
|
||||
case GameType.FLZY:
|
||||
ReleaseBotSit(UIPanel.MainGamePanelFLZY, botUserId);
|
||||
break;
|
||||
case GameType.YYSC:
|
||||
ReleaseBotSit(UIPanel.MainGamePanelYYSC, botUserId);
|
||||
break;
|
||||
case GameType.XJMH:
|
||||
ReleaseBotSit(UIPanel.MainGamePanelXJMH, botUserId);
|
||||
break;
|
||||
case GameType.HHWK:
|
||||
ReleaseBotSit(UIPanel.MainGamePanelHHWK, botUserId);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>释放机器人座位(显示等待界面,标记为 bot)</summary>
|
||||
private static void ReleaseBotSit(UIPanel panelName, string botUserId)
|
||||
{
|
||||
var panel = UIManager.Instance.Get<GameMainPanel_FishBase>(panelName);
|
||||
if (panel == null) return;
|
||||
foreach (var sit in panel.list_Sits)
|
||||
{
|
||||
if (sit.user == botUserId)
|
||||
{
|
||||
sit.isBot = true;
|
||||
sit.ShowWaiting();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// FishGameHub HostDisconnectNEW — 房主断线
|
||||
/// 其他玩家可接受机器人控制权。本地房主引用若已断线则转移给本地首个非人机玩家。
|
||||
/// </summary>
|
||||
public static void HostDisconnect()
|
||||
{
|
||||
// 房主断线 → 触发房主转移(SitPosData 已封装好转移逻辑)
|
||||
SitPosData.TransferRoomOwner();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// FishGameHub OnSeatChange — 座位变更
|
||||
/// { type, userId, position, showWaiting? }
|
||||
/// type 字段后端未明确定义,先按 showWaiting 决定显示状态
|
||||
/// </summary>
|
||||
public static void SeatChange(int seatType, string userId, int position, bool showWaiting)
|
||||
{
|
||||
if (string.IsNullOrEmpty(userId) || position < 0) return;
|
||||
|
||||
GameMainPanel_FishBase panel = null;
|
||||
switch (GameManager.Instance.gameData.currGameType)
|
||||
{
|
||||
case GameType.FLZY:
|
||||
panel = UIManager.Instance.Get<GameMainPanel_FishBase>(UIPanel.MainGamePanelFLZY);
|
||||
break;
|
||||
case GameType.YYSC:
|
||||
panel = UIManager.Instance.Get<GameMainPanel_FishBase>(UIPanel.MainGamePanelYYSC);
|
||||
break;
|
||||
case GameType.XJMH:
|
||||
panel = UIManager.Instance.Get<GameMainPanel_FishBase>(UIPanel.MainGamePanelXJMH);
|
||||
break;
|
||||
case GameType.HHWK:
|
||||
panel = UIManager.Instance.Get<GameMainPanel_FishBase>(UIPanel.MainGamePanelHHWK);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (panel == null) return;
|
||||
|
||||
var targetSit = panel.list_Sits.Find(s => s.posID == position);
|
||||
if (targetSit == null) return;
|
||||
|
||||
if (showWaiting)
|
||||
{
|
||||
// 显示等待界面(玩家离开该座位)
|
||||
targetSit.ShowWaiting();
|
||||
}
|
||||
else
|
||||
{
|
||||
// 玩家进入该座位
|
||||
targetSit.isBot = !string.IsNullOrEmpty(userId) && userId.StartsWith("bot_");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// FishRoomHub RoomChange — 房间变化通知
|
||||
/// 房间列表界面收到时刷新显示。当前仅在房间列表 UI 开启时更新数据,
|
||||
/// 具体刷新逻辑由 UIHome_BY_SelectRoomLevelPanel / 手动选座面板按需实现。
|
||||
/// </summary>
|
||||
public static void RoomChangeNotice(string msg)
|
||||
{
|
||||
try
|
||||
{
|
||||
var roomData = JsonConvert.DeserializeObject<WebSocketResponseBase<RoomChangeResponse>>(msg).arguments[0];
|
||||
if (roomData == null) return;
|
||||
// 通知手动选座面板刷新(若开启)
|
||||
var homeMain = UIManager.Instance.Get<UIHomeMain>(UIPanel.HomeMainPanel);
|
||||
if (homeMain == null) return;
|
||||
var selectRoomPanel = homeMain.subUIManager.Get<UIHome_BY_SelectRoomLevelPanel>(UIPanel.SelectRoomLeavePenel);
|
||||
if (selectRoomPanel != null && selectRoomPanel.isMySelectRoom)
|
||||
{
|
||||
selectRoomPanel.panel_UIHome_BY_MySelectRoomPenel?.OnRoomChange(roomData);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogWarning("[RoomChangeNotice] 解析失败: " + e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LoginHub LevelChangedNEW 数据
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class LevelChangedData
|
||||
{
|
||||
public int newLevel;
|
||||
public long newExp;
|
||||
public long newGold;
|
||||
public int newDiamond;
|
||||
public string source;
|
||||
public string remark;
|
||||
}
|
||||
|
||||
// ---------------- Customer ----------------
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user