1
This commit is contained in:
@@ -178,6 +178,21 @@ namespace Assets.MyGame.Scripts.Net
|
||||
dic_API[APIType.Customer_Status] = "/customerapi/Customer/status";
|
||||
dic_API[APIType.Customer_ChatLog] = "/customerapi/Customer/chatlog/{conversationId}";
|
||||
dic_API[APIType.Customer_MyConversations] = "/customerapi/Customer/my-conversations";
|
||||
|
||||
// ---------------- 补充:暂未使用但已注册,方便后续接入 ----------------
|
||||
dic_API[APIType.Login_LoginByPassword] = "/api/Login/LoginByPassword";
|
||||
dic_API[APIType.User_GetUserAssets] = "/api/User/GetUserAssets";
|
||||
dic_API[APIType.User_GetFishingReturnInfo] = "/api/User/GetFishingReturnInfo";
|
||||
dic_API[APIType.User_ClaimFishingReturn] = "/api/User/ClaimFishingReturn";
|
||||
dic_API[APIType.ActivityConfig_LotteryConfig] = "/api/ActivityConfig/lotteryConfig";
|
||||
dic_API[APIType.Lottery_Config] = "/api/Lottery/Config";
|
||||
dic_API[APIType.Lottery_Draw] = "/api/Lottery/Draw";
|
||||
dic_API[APIType.Lottery_UserStatus] = "/api/Lottery/UserStatus";
|
||||
dic_API[APIType.Lottery_DrawnPrizes] = "/api/Lottery/DrawnPrizes";
|
||||
dic_API[APIType.SummonCard_Use] = "/api/SummonCard/use";
|
||||
dic_API[APIType.Dict_GetByCode] = "/api/Dict/GetByCode";
|
||||
dic_API[APIType.Dict_GetListByCode] = "/api/Dict/GetListByCode";
|
||||
dic_API[APIType.Hall_GetBattleOrderLevelStatus] = "/api/Hall/GetBattleOrderLevelStatus";
|
||||
}
|
||||
|
||||
// ---------------- GET ----------------
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
|
||||
namespace Assets.MyGame.Scripts.Net.APIRequest.Params
|
||||
{
|
||||
// ============================================================
|
||||
// 补充参数类:以下接口暂未接入业务,但已注册到 APIManager,
|
||||
// 方便后续快速接入。按 swagger 路径分组放置。
|
||||
// ============================================================
|
||||
|
||||
// ---------------- /api/Login/LoginByPassword(POST) ----------------
|
||||
/// <summary>密码登录请求体</summary>
|
||||
[Serializable]
|
||||
public class LoginByPasswordParam : RequestParamBase
|
||||
{
|
||||
/// <summary>账号(手机号/用户名)</summary>
|
||||
public string account;
|
||||
/// <summary>密码</summary>
|
||||
public string password;
|
||||
}
|
||||
|
||||
// ---------------- /api/User/GetFishingReturnInfo(GET) ----------------
|
||||
/// <summary>获取捕鱼返利信息参数</summary>
|
||||
[Serializable]
|
||||
public class GetFishingReturnInfoParam : RequestParamBase
|
||||
{
|
||||
// 后端文档未明确字段,预留 userId;按需补充
|
||||
public string userId;
|
||||
}
|
||||
|
||||
// ---------------- /api/User/ClaimFishingReturn(GET) ----------------
|
||||
/// <summary>领取捕鱼返利参数</summary>
|
||||
[Serializable]
|
||||
public class ClaimFishingReturnParam : RequestParamBase
|
||||
{
|
||||
public string userId;
|
||||
}
|
||||
|
||||
// ---------------- /api/Lottery/Draw(GET) ----------------
|
||||
/// <summary>抽奖参数</summary>
|
||||
[Serializable]
|
||||
public class LotteryDrawParam : RequestParamBase
|
||||
{
|
||||
/// <summary>抽奖活动 ID(按后端定义补充)</summary>
|
||||
public int lotteryId;
|
||||
}
|
||||
|
||||
// ---------------- /api/SummonCard/use(GET) ----------------
|
||||
/// <summary>使用召唤卡参数</summary>
|
||||
[Serializable]
|
||||
public class SummonCardUseParam : RequestParamBase
|
||||
{
|
||||
/// <summary>召唤卡编号</summary>
|
||||
public string cardNumber;
|
||||
}
|
||||
|
||||
// ---------------- /api/Dict/GetByCode(GET) ----------------
|
||||
/// <summary>字典查询参数(按 code 取单条)</summary>
|
||||
[Serializable]
|
||||
public class DictGetByCodeParam : RequestParamBase
|
||||
{
|
||||
public string code;
|
||||
}
|
||||
|
||||
// ---------------- /api/Dict/GetListByCode(GET) ----------------
|
||||
/// <summary>字典列表查询参数(按 code 取列表)</summary>
|
||||
[Serializable]
|
||||
public class DictGetListByCodeParam : RequestParamBase
|
||||
{
|
||||
public string code;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ba31229aeeedc2459e34f8417b52a88
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,117 @@
|
||||
using Assets.MyGame.Scripts.Net.API;
|
||||
using Assets.MyGame.Scripts.Net.APIRequest.Params;
|
||||
using Assets.MyGame.Scripts.Net.APIResponses;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Assets.MyGame.Scripts.Net
|
||||
{
|
||||
/// <summary>
|
||||
/// 补充请求方法:以下接口暂未接入业务,仅注册调用入口。
|
||||
/// 字段类型为推测,接入业务前请按后端实际返回再调整。
|
||||
/// </summary>
|
||||
public static partial class APIRequestList
|
||||
{
|
||||
// ---------------- Login ----------------
|
||||
|
||||
/// <summary>
|
||||
/// 密码登录(POST /api/Login/LoginByPassword)
|
||||
/// 当前用 LoginPhone 已够用,暂不接入。
|
||||
/// </summary>
|
||||
public static void LoginByPassword(LoginByPasswordParam req, Action<UserToken> callback)
|
||||
{
|
||||
APIManager.Response<UserToken>(APIType.Login_LoginByPassword, req, obj =>
|
||||
{
|
||||
GameManager.Instance.user = obj;
|
||||
callback?.Invoke(obj);
|
||||
});
|
||||
}
|
||||
|
||||
// ---------------- User ----------------
|
||||
|
||||
/// <summary>
|
||||
/// 获取当前用户资产 + 背包(GET /api/User/GetUserAssets)
|
||||
/// 当前直接用 GetUser 已够用,暂不接入。
|
||||
/// </summary>
|
||||
public static void GetUserAssets(Action<UserAssetsResponse> callback)
|
||||
{
|
||||
APIManager.Response<UserAssetsResponse>(APIType.User_GetUserAssets, callback);
|
||||
}
|
||||
|
||||
/// <summary>获取捕鱼返利信息(GET /api/User/GetFishingReturnInfo)</summary>
|
||||
public static void GetFishingReturnInfo(Action<FishingReturnInfoResponse> callback)
|
||||
{
|
||||
APIManager.Response<FishingReturnInfoResponse>(APIType.User_GetFishingReturnInfo, callback);
|
||||
}
|
||||
|
||||
/// <summary>领取捕鱼返利金币(GET /api/User/ClaimFishingReturn)</summary>
|
||||
public static void ClaimFishingReturn(Action<ClaimFishingReturnResponse> callback)
|
||||
{
|
||||
APIManager.Response<ClaimFishingReturnResponse>(APIType.User_ClaimFishingReturn, callback);
|
||||
}
|
||||
|
||||
// ---------------- ActivityConfig ----------------
|
||||
|
||||
/// <summary>奖池抽奖活动配置(GET /api/ActivityConfig/lotteryConfig)</summary>
|
||||
public static void GetLotteryActivityConfig(Action<LotteryConfigResponse> callback)
|
||||
{
|
||||
APIManager.Response<LotteryConfigResponse>(APIType.ActivityConfig_LotteryConfig, callback);
|
||||
}
|
||||
|
||||
// ---------------- Lottery ----------------
|
||||
|
||||
/// <summary>抽奖配置(GET /api/Lottery/Config)</summary>
|
||||
public static void GetLotteryConfig(Action<LotteryConfigResponse> callback)
|
||||
{
|
||||
APIManager.Response<LotteryConfigResponse>(APIType.Lottery_Config, callback);
|
||||
}
|
||||
|
||||
/// <summary>抽奖(GET /api/Lottery/Draw)</summary>
|
||||
public static void LotteryDraw(LotteryDrawParam req, Action<LotteryDrawResponse> callback)
|
||||
{
|
||||
APIManager.Response<LotteryDrawResponse>(APIType.Lottery_Draw, req, callback);
|
||||
}
|
||||
|
||||
/// <summary>用户抽奖状态(GET /api/Lottery/UserStatus)</summary>
|
||||
public static void GetLotteryUserStatus(Action<LotteryUserStatusResponse> callback)
|
||||
{
|
||||
APIManager.Response<LotteryUserStatusResponse>(APIType.Lottery_UserStatus, callback);
|
||||
}
|
||||
|
||||
/// <summary>已抽奖项(GET /api/Lottery/DrawnPrizes)</summary>
|
||||
public static void GetLotteryDrawnPrizes(Action<List<LotteryDrawnPrizeItem>> callback)
|
||||
{
|
||||
APIManager.Response<List<LotteryDrawnPrizeItem>>(APIType.Lottery_DrawnPrizes, callback);
|
||||
}
|
||||
|
||||
// ---------------- SummonCard ----------------
|
||||
|
||||
/// <summary>使用召唤卡(GET /api/SummonCard/use)</summary>
|
||||
public static void UseSummonCard(SummonCardUseParam req, Action<SummonCardUseResponse> callback)
|
||||
{
|
||||
APIManager.Response<SummonCardUseResponse>(APIType.SummonCard_Use, req, callback);
|
||||
}
|
||||
|
||||
// ---------------- Dict ----------------
|
||||
|
||||
/// <summary>字典单条查询(GET /api/Dict/GetByCode)</summary>
|
||||
public static void GetDictByCode(DictGetByCodeParam req, Action<DictItem> callback)
|
||||
{
|
||||
APIManager.Response<DictItem>(APIType.Dict_GetByCode, req, callback);
|
||||
}
|
||||
|
||||
/// <summary>字典列表查询(GET /api/Dict/GetListByCode)</summary>
|
||||
public static void GetDictListByCode(DictGetListByCodeParam req, Action<List<DictItem>> callback)
|
||||
{
|
||||
APIManager.Response<List<DictItem>>(APIType.Dict_GetListByCode, req, callback);
|
||||
}
|
||||
|
||||
// ---------------- Hall ----------------
|
||||
|
||||
/// <summary>获取战令各等级奖励领取状态(GET /api/Hall/GetBattleOrderLevelStatus)</summary>
|
||||
public static void GetBattleOrderLevelStatus(Action<BattleOrderLevelStatusResponse> callback)
|
||||
{
|
||||
APIManager.Response<BattleOrderLevelStatusResponse>(APIType.Hall_GetBattleOrderLevelStatus, callback);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 143eabfa275ff2d48bf4ca896d6d9d34
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,142 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Assets.MyGame.Scripts.Net.APIResponses
|
||||
{
|
||||
// ============================================================
|
||||
// 补充响应类:以下接口暂未接入业务,但已注册到 APIManager,
|
||||
// 方便后续快速接入。按 swagger 路径分组放置。
|
||||
// 字段类型为推测,接入业务前请按后端实际返回再调整。
|
||||
// ============================================================
|
||||
|
||||
// ---------------- /api/User/GetUserAssets ----------------
|
||||
/// <summary>用户资产 + 背包统一响应</summary>
|
||||
[Serializable]
|
||||
public class UserAssetsResponse
|
||||
{
|
||||
public string userId;
|
||||
public long gold;
|
||||
public int diamond;
|
||||
public long safeBoxGold;
|
||||
public int level;
|
||||
public long exp;
|
||||
public int vipLevel;
|
||||
public List<PropInfo> props;
|
||||
}
|
||||
|
||||
// ---------------- /api/User/GetFishingReturnInfo ----------------
|
||||
/// <summary>捕鱼返利信息</summary>
|
||||
[Serializable]
|
||||
public class FishingReturnInfoResponse
|
||||
{
|
||||
/// <summary>待领取返利金币</summary>
|
||||
public long pendingGold;
|
||||
/// <summary>累计返利金币</summary>
|
||||
public long totalGold;
|
||||
/// <summary>上次结算时间</summary>
|
||||
public long lastSettleTime;
|
||||
/// <summary>是否可领取</summary>
|
||||
public bool canClaim;
|
||||
}
|
||||
|
||||
// ---------------- /api/User/ClaimFishingReturn ----------------
|
||||
/// <summary>领取捕鱼返利响应</summary>
|
||||
[Serializable]
|
||||
public class ClaimFishingReturnResponse
|
||||
{
|
||||
/// <summary>本次领取金币</summary>
|
||||
public long claimedGold;
|
||||
/// <summary>领取时间</summary>
|
||||
public long claimTime;
|
||||
}
|
||||
|
||||
// ---------------- /api/ActivityConfig/lotteryConfig & /api/Lottery/Config ----------------
|
||||
/// <summary>抽奖活动配置</summary>
|
||||
[Serializable]
|
||||
public class LotteryConfigResponse
|
||||
{
|
||||
public int lotteryId;
|
||||
public string name;
|
||||
public long startTime;
|
||||
public long endTime;
|
||||
public List<LotteryPrizeInfo> prizes;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class LotteryPrizeInfo
|
||||
{
|
||||
public int prizeId;
|
||||
public string prizeName;
|
||||
public int prizeType; // 1=金币 2=钻石 3=道具
|
||||
public int count;
|
||||
public int weight; // 权重
|
||||
public string icon;
|
||||
}
|
||||
|
||||
// ---------------- /api/Lottery/Draw ----------------
|
||||
/// <summary>抽奖结果</summary>
|
||||
[Serializable]
|
||||
public class LotteryDrawResponse
|
||||
{
|
||||
public int prizeId;
|
||||
public string prizeName;
|
||||
public int prizeType;
|
||||
public int count;
|
||||
public long drawTime;
|
||||
}
|
||||
|
||||
// ---------------- /api/Lottery/UserStatus ----------------
|
||||
/// <summary>用户抽奖状态</summary>
|
||||
[Serializable]
|
||||
public class LotteryUserStatusResponse
|
||||
{
|
||||
public int lotteryId;
|
||||
public int freeCount; // 剩余免费次数
|
||||
public int paidCount; // 剩余付费次数
|
||||
public long lastDrawTime;
|
||||
}
|
||||
|
||||
// ---------------- /api/Lottery/DrawnPrizes ----------------
|
||||
/// <summary>已抽奖项记录</summary>
|
||||
[Serializable]
|
||||
public class LotteryDrawnPrizeItem
|
||||
{
|
||||
public int prizeId;
|
||||
public string prizeName;
|
||||
public int prizeType;
|
||||
public int count;
|
||||
public long drawTime;
|
||||
}
|
||||
|
||||
// ---------------- /api/SummonCard/use ----------------
|
||||
/// <summary>使用召唤卡响应</summary>
|
||||
[Serializable]
|
||||
public class SummonCardUseResponse
|
||||
{
|
||||
public bool success;
|
||||
public string message;
|
||||
public List<PropInfo> drops; // 掉落道具列表
|
||||
}
|
||||
|
||||
// ---------------- /api/Dict/GetByCode ----------------
|
||||
/// <summary>字典单条</summary>
|
||||
[Serializable]
|
||||
public class DictItem
|
||||
{
|
||||
public string code;
|
||||
public string name;
|
||||
public string value;
|
||||
public string remark;
|
||||
}
|
||||
|
||||
// ---------------- /api/Hall/GetBattleOrderLevelStatus ----------------
|
||||
/// <summary>战令各等级奖励领取状态</summary>
|
||||
[Serializable]
|
||||
public class BattleOrderLevelStatusResponse
|
||||
{
|
||||
public int currentLevel;
|
||||
public List<int> normalReceivedLevels; // 普通奖励已领取等级
|
||||
public List<int> luxuryReceivedLevels; // 豪华奖励已领取等级
|
||||
public List<int> supremeReceivedLevels; // 至尊奖励已领取等级
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1fcbfa8b86b09c347b35eb726285010c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -376,5 +376,46 @@ namespace Assets.MyGame.Scripts.Net
|
||||
|
||||
/// <summary>获取我的会话列表(含消息)GET</summary>
|
||||
Customer_MyConversations,
|
||||
|
||||
// ---------------- 补充:暂未使用但已注册,方便后续接入 ----------------
|
||||
|
||||
/// <summary>密码登录(POST /api/Login/LoginByPassword)</summary>
|
||||
Login_LoginByPassword,
|
||||
|
||||
/// <summary>获取当前用户资产和背包(GET /api/User/GetUserAssets)</summary>
|
||||
User_GetUserAssets,
|
||||
|
||||
/// <summary>获取捕鱼返利信息(GET /api/User/GetFishingReturnInfo)</summary>
|
||||
User_GetFishingReturnInfo,
|
||||
|
||||
/// <summary>领取捕鱼返利金币(GET /api/User/ClaimFishingReturn)</summary>
|
||||
User_ClaimFishingReturn,
|
||||
|
||||
/// <summary>奖池抽奖活动配置(GET /api/ActivityConfig/lotteryConfig)</summary>
|
||||
ActivityConfig_LotteryConfig,
|
||||
|
||||
/// <summary>抽奖配置(GET /api/Lottery/Config)</summary>
|
||||
Lottery_Config,
|
||||
|
||||
/// <summary>抽奖(GET /api/Lottery/Draw)</summary>
|
||||
Lottery_Draw,
|
||||
|
||||
/// <summary>用户抽奖状态(GET /api/Lottery/UserStatus)</summary>
|
||||
Lottery_UserStatus,
|
||||
|
||||
/// <summary>已抽奖项(GET /api/Lottery/DrawnPrizes)</summary>
|
||||
Lottery_DrawnPrizes,
|
||||
|
||||
/// <summary>使用召唤卡(GET /api/SummonCard/use)</summary>
|
||||
SummonCard_Use,
|
||||
|
||||
/// <summary>字典查询(GET /api/Dict/GetByCode)</summary>
|
||||
Dict_GetByCode,
|
||||
|
||||
/// <summary>字典列表查询(GET /api/Dict/GetListByCode)</summary>
|
||||
Dict_GetListByCode,
|
||||
|
||||
/// <summary>获取战令各等级奖励领取状态(GET /api/Hall/GetBattleOrderLevelStatus)</summary>
|
||||
Hall_GetBattleOrderLevelStatus,
|
||||
}
|
||||
}
|
||||
@@ -394,6 +394,9 @@ namespace Assets.MyGame.Scripts.Net
|
||||
case "KillAnnouncement":
|
||||
WebSocketReponseList.KillAnnouncement(msg);
|
||||
break;
|
||||
case "LevelChangedNEW":
|
||||
WebSocketReponseList.LevelChanged(msg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -609,6 +612,50 @@ namespace Assets.MyGame.Scripts.Net
|
||||
}
|
||||
break;
|
||||
|
||||
// ======== FishGameHub / FishRoomHub 补充事件 ========
|
||||
|
||||
case "BotLeaveRoomNoticeNEW":
|
||||
{
|
||||
// 机器人退出房间,数据 { userId }
|
||||
var data = JsonConvert.DeserializeObject<WebSocketResponseBase<Dictionary<string, object>>>(msg).arguments[0];
|
||||
string botUserId = data != null && data.TryGetValue("userId", out var buid) ? buid?.ToString() : "";
|
||||
Debug.Log($"[FishGameHub] 机器人退出: {botUserId}");
|
||||
WebSocketReponseList.BotLeaveRoom(botUserId);
|
||||
}
|
||||
break;
|
||||
|
||||
case "HostDisconnectNEW":
|
||||
{
|
||||
// 房主断线,其他玩家可接受机器人控制权
|
||||
Debug.Log("[FishGameHub] 房主断线,可接受机器人控制权");
|
||||
WebSocketReponseList.HostDisconnect();
|
||||
}
|
||||
break;
|
||||
|
||||
case "OnSeatChange":
|
||||
{
|
||||
// 座位变更 { type, userId, position, showWaiting? }
|
||||
var data = JsonConvert.DeserializeObject<WebSocketResponseBase<Dictionary<string, object>>>(msg).arguments[0];
|
||||
if (data != null)
|
||||
{
|
||||
int seatType = data.TryGetValue("type", out var t) ? Convert.ToInt32(t) : 0;
|
||||
string userId = data.TryGetValue("userId", out var u) ? u?.ToString() : "";
|
||||
int position = data.TryGetValue("position", out var p) ? Convert.ToInt32(p) : -1;
|
||||
bool showWaiting = data.TryGetValue("showWaiting", out var sw) && Convert.ToBoolean(sw);
|
||||
Debug.Log($"[FishGameHub] 座位变更: type={seatType}, userId={userId}, position={position}, showWaiting={showWaiting}");
|
||||
WebSocketReponseList.SeatChange(seatType, userId, position, showWaiting);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case "RoomChange":
|
||||
{
|
||||
// FishRoomHub 房间变化通知(人数/状态变更),更新房间列表
|
||||
Debug.Log("[FishRoomHub] 房间变化通知");
|
||||
WebSocketReponseList.RoomChangeNotice(msg);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -157,6 +157,26 @@ public partial class WebSocketSendList
|
||||
var sendObj = new WebSocketSendList("Bind", userId);
|
||||
WebSocketManager.Instance.Send(SocketType.login, JsonConvert.SerializeObject(sendObj));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 断线重连(必须先调用,重新加入房间前调用)
|
||||
/// 对应服务端 FishGameHub.Reconnect(string userId)
|
||||
/// </summary>
|
||||
public static void Reconnect(string userId)
|
||||
{
|
||||
var sendObj = new WebSocketSendList("Reconnect", userId);
|
||||
WebSocketManager.Instance.Send(SocketType.game, JsonConvert.SerializeObject(sendObj));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取玩家信息(结果通过 SendPlayerInfoResult 事件返回)
|
||||
/// 对应服务端 FishGameHub.GetPlayerInfo(string roomId, string userId)
|
||||
/// </summary>
|
||||
public static void GetPlayerInfo(string roomId, string userId)
|
||||
{
|
||||
var sendObj = new WebSocketSendList("GetPlayerInfo", roomId, userId);
|
||||
WebSocketManager.Instance.Send(SocketType.game, JsonConvert.SerializeObject(sendObj));
|
||||
}
|
||||
/// <summary>
|
||||
/// 加入房间
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user