1
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,4 @@
|
||||
using Assets.MyGame.Scripts.Net;
|
||||
using Assets.MyGame.Scripts.Net;
|
||||
using Assets.MyGame.Scripts.Net.API;
|
||||
using Assets.MyGame.Scripts.Net.API.GameConfig_SubClass;
|
||||
using CameraShake;
|
||||
@@ -241,39 +241,52 @@ public class GameManager : MonoSingleton<GameManager>
|
||||
UIManager.Instance.ShowAsync(UIPanel.MainGamePanelDefault);
|
||||
break;
|
||||
case GameType.FLZY:
|
||||
if (action != null)
|
||||
WebSocketManager.Instance.Connect(SocketType.game, action);
|
||||
//UIManager.Instance.ShowAsync(UIPanel.MainGamePanelFLZY);
|
||||
ConnectGameSocket(action);
|
||||
break;
|
||||
case GameType.YYSC:
|
||||
if (action != null)
|
||||
{
|
||||
WebSocketManager.Instance.Connect(SocketType.game, action);
|
||||
}
|
||||
ConnectGameSocket(action);
|
||||
break;
|
||||
case GameType.ZGXQ:
|
||||
//UIManager.Instance.ShowAsync(UIPanel.MainGamePanelZGXQ);
|
||||
//UIManager.Instance.ShowAsync(UIPanel.MainGamePanelZGXQ);
|
||||
//这里设置触发棋盘的初始化
|
||||
|
||||
break;
|
||||
case GameType.XJMH:
|
||||
if (action != null)
|
||||
{
|
||||
WebSocketManager.Instance.Connect(SocketType.game, action);
|
||||
}
|
||||
else
|
||||
WebSocketManager.Instance.Connect(SocketType.game);
|
||||
ConnectGameSocket(action);
|
||||
break;
|
||||
case GameType.HHWK:
|
||||
//UIManager.Instance.ShowAsync(UIPanel.MainGamePanelDefault);
|
||||
if (action != null)
|
||||
WebSocketManager.Instance.Connect(SocketType.game, action);
|
||||
ConnectGameSocket(action);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通过 /api/Room/Assign 获取房间专属 socket 地址后连接 game socket
|
||||
/// </summary>
|
||||
private void ConnectGameSocket(Action action)
|
||||
{
|
||||
string roomId = gameData.currRoomData?.roomId;
|
||||
if (string.IsNullOrEmpty(roomId))
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
Debug.LogWarning("[GameManager] currRoomData.roomId 为空,使用默认 game socket 地址");
|
||||
#endif
|
||||
WebSocketManager.Instance.Connect(SocketType.game, action);
|
||||
return;
|
||||
}
|
||||
APIRequestList.RoomAssign(roomId, url =>
|
||||
{
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
WebSocketManager.Instance.Connect(SocketType.game, url, action);
|
||||
else
|
||||
WebSocketManager.Instance.Connect(SocketType.game, action);
|
||||
});
|
||||
}
|
||||
// Start is called before the first frame update
|
||||
public Button btn_Skip;
|
||||
public VideoClip startVideoClip;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Assets.MyGame.Scripts.Net.API;
|
||||
using Assets.MyGame.Scripts.Net.API;
|
||||
using Assets.MyGame.Scripts.Net.APIRequest;
|
||||
using Best.HTTP.SecureProtocol.Org.BouncyCastle.Ocsp;
|
||||
using Newtonsoft.Json;
|
||||
@@ -165,6 +165,7 @@ namespace Assets.MyGame.Scripts.Net
|
||||
dic_API[APIType.Hall_GetRanking] = "/api/Hall/GetRanking";
|
||||
dic_API[APIType.Hall_GetChessRoomPartitionCount] = "/api/Hall/GetChessRoomPartitionCount";
|
||||
dic_API[APIType.Hall_SendBroadcast] = "/api/Hall/SendBroadcast";
|
||||
dic_API[APIType.Room_Assign] = "/api/Room/Assign";
|
||||
|
||||
// ---------------- Customer ----------------
|
||||
dic_API[APIType.Customer_Start] = "/customerapi/Customer/start";
|
||||
|
||||
@@ -3,26 +3,26 @@ using System;
|
||||
namespace Assets.MyGame.Scripts.Net.APIRequest.Params
|
||||
{
|
||||
/// <summary>
|
||||
/// 存入保险箱请求参数
|
||||
/// ���뱣�����������
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class SaveSafeBoxParam : RequestParamBase
|
||||
{
|
||||
|
||||
public int gold; // 存入金额
|
||||
public int gold; // ������
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置保险箱密码请求参数
|
||||
/// �����������������
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class SetSafeBoxPasswordParam : RequestParamBase
|
||||
{
|
||||
public string password; // 新密码
|
||||
public string password; // ������
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置保险箱密码请求参数(GET)
|
||||
/// �������������������GET��
|
||||
/// Swagger: /api/Hall/ResetSafeBoxPassword?password=&code=
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
@@ -33,7 +33,7 @@ namespace Assets.MyGame.Scripts.Net.APIRequest.Params
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 取出保险箱请求参数(GET)
|
||||
/// ȡ�����������������GET��
|
||||
/// Swagger: /api/Hall/GetSafeBox?gold=&password=
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
@@ -44,7 +44,7 @@ namespace Assets.MyGame.Scripts.Net.APIRequest.Params
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资产变动记录参数(GET)
|
||||
/// ��ȡ�ʲ��䶯��¼������GET��
|
||||
/// Swagger: /api/Hall/GetUserRewardList
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
@@ -54,151 +54,158 @@ namespace Assets.MyGame.Scripts.Net.APIRequest.Params
|
||||
public int pageIndex;
|
||||
public int pageSize;
|
||||
public string userId;
|
||||
public int type; // 1增加 2减少 0全部
|
||||
public int type; // 1���� 2���� 0ȫ��
|
||||
public int source;
|
||||
public int currencyType; // 1金币 2金币保险箱 3钻石 0全部
|
||||
public int currencyType; // 1��� 2��ұ����� 3��ʯ 0ȫ��
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 合成碎片请求参数
|
||||
/// �ϳ���Ƭ�������
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class SynthesisFragmentParam : RequestParamBase
|
||||
{
|
||||
public int fragmentId; // 碎片ID
|
||||
public int count; // 数量
|
||||
public int fragmentId; // ��ƬID
|
||||
public int count; // ����
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 购买月卡请求参数(GET)
|
||||
/// �����¿����������GET��
|
||||
/// Swagger: GET /api/Hall/BuyMonthCard
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class BuyMonthCardParam : RequestParamBase
|
||||
{
|
||||
/// <summary>月卡类型 1=周卡 2=月卡 3=年卡</summary>
|
||||
/// <summary>�¿����� 1=�ܿ� 2=�¿� 3=�꿨</summary>
|
||||
public int type;
|
||||
|
||||
/// <summary>金币价格(用于校验)</summary>
|
||||
/// <summary>��Ҽ۸�����У�飩</summary>
|
||||
public int gold;
|
||||
|
||||
/// <summary>现金价格</summary>
|
||||
/// <summary>�ֽ�۸�</summary>
|
||||
public double money;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 购买道具请求参数(GET)
|
||||
/// ����������������GET��
|
||||
/// Swagger: GET /api/Hall/BuyProp
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class BuyPropParam : RequestParamBase
|
||||
{
|
||||
/// <summary>道具编号</summary>
|
||||
/// <summary>���߱��</summary>
|
||||
public string propNumber;
|
||||
|
||||
/// <summary>购买数量</summary>
|
||||
/// <summary>��������</summary>
|
||||
public int count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 购买金币请求参数(GET)
|
||||
/// ���������������GET��
|
||||
/// Swagger: GET /api/Hall/BuyGold
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class BuyGoldParam : RequestParamBase
|
||||
{
|
||||
/// <summary>商品编号(GoldShopConfig.number)</summary>
|
||||
/// <summary>��Ʒ��ţ�GoldShopConfig.number��</summary>
|
||||
public string number;
|
||||
|
||||
/// <summary>购买数量</summary>
|
||||
/// <summary>��������</summary>
|
||||
public int count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 购买钻石请求参数(GET)
|
||||
/// ������ʯ���������GET��
|
||||
/// Swagger: GET /api/Hall/BuyDiamond
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class BuyDiamondParam : RequestParamBase
|
||||
{
|
||||
/// <summary>商品编号(DiamondShopConfig.number)</summary>
|
||||
/// <summary>��Ʒ��ţ�DiamondShopConfig.number��</summary>
|
||||
public string number;
|
||||
|
||||
/// <summary>购买数量</summary>
|
||||
/// <summary>��������</summary>
|
||||
public int count;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 切换炮台请求参数
|
||||
/// �л���̨�������
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class ChangeCannonParam : RequestParamBase
|
||||
{
|
||||
public string number; // 炮台编号
|
||||
public string number; // ��̨���
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 切换翅膀请求参数
|
||||
/// �����������
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class ChangeWingParam : RequestParamBase
|
||||
{
|
||||
public string number; // 翅膀编号
|
||||
public string number; // �����
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 切换战神请求参数
|
||||
/// �л�ս���������
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class ChangeGodWarParam : RequestParamBase
|
||||
{
|
||||
public string number; // 战神编号
|
||||
public string number; // ս����
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 发放奖励请求参数
|
||||
/// �������������
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class DistributeRewardsParam : RequestParamBase
|
||||
{
|
||||
public string id; // 奖励/任务 ID
|
||||
public string id; // ����/���� ID
|
||||
|
||||
}
|
||||
|
||||
/// <summary>领取战令等级奖励(GET)</summary>
|
||||
/// <summary>��ȡս��ȼ�������GET��</summary>
|
||||
[Serializable]
|
||||
public class ReceiveBattleOrderLevelRewardParam : RequestParamBase
|
||||
{
|
||||
public int level; // 等级
|
||||
public int level; // �ȼ�
|
||||
}
|
||||
|
||||
/// <summary>购买战令等级(GET)</summary>
|
||||
/// <summary>����ս��ȼ���GET��</summary>
|
||||
[Serializable]
|
||||
public class BuyBattleOrderLevelParam : RequestParamBase
|
||||
{
|
||||
public int levelCount; // 购买等级数
|
||||
public int levelCount; // ����ȼ���
|
||||
}
|
||||
|
||||
/// <summary>购买战令进阶(GET)</summary>
|
||||
/// <summary>����ս����ף�GET��</summary>
|
||||
[Serializable]
|
||||
public class BuyBattleOrderAdvanceParam : RequestParamBase
|
||||
{
|
||||
public int type; // 进阶类型 1=精英 2=至尊
|
||||
public int type; // �������� 1=��Ӣ 2=����
|
||||
}
|
||||
|
||||
/// <summary>获取用户任务列表(GET)</summary>
|
||||
/// <summary>��ȡ�û������б���GET��</summary>
|
||||
[Serializable]
|
||||
public class GetUserTaskListParam : RequestParamBase
|
||||
{
|
||||
public int taskType = -1; // -1=全部
|
||||
public int taskType = -1; // -1=ȫ��
|
||||
}
|
||||
|
||||
/// <summary>发送全服广播(GET)</summary>
|
||||
/// <summary>发送全服广播(GET)</summary>
|
||||
[Serializable]
|
||||
public class SendBroadcastParam : RequestParamBase
|
||||
{
|
||||
public string message;
|
||||
}
|
||||
|
||||
/// <summary>获取房间专属 socket 地址(GET /api/Room/Assign?roomId=)</summary>
|
||||
[Serializable]
|
||||
public class RoomAssignParam : RequestParamBase
|
||||
{
|
||||
public string roomId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,6 +308,18 @@ namespace Assets.MyGame.Scripts.Net
|
||||
}, callback);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取房间专属 socket 地址(GET /api/Room/Assign?roomId=xxx)
|
||||
/// 返回:string(如 ws://8.137.163.153/fishinghub?instance=1)
|
||||
/// </summary>
|
||||
public static void RoomAssign(string roomId, Action<string> callback)
|
||||
{
|
||||
APIManager.Response<string>(APIType.Room_Assign, new RoomAssignParam
|
||||
{
|
||||
roomId = roomId
|
||||
}, callback);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@@ -339,6 +339,9 @@ namespace Assets.MyGame.Scripts.Net
|
||||
/// <summary>发送全服广播(GET)</summary>
|
||||
Hall_SendBroadcast,
|
||||
|
||||
/// <summary>获取房间专属 socket 地址(GET /api/Room/Assign?roomId=)</summary>
|
||||
Room_Assign,
|
||||
|
||||
|
||||
// ---------------- Customer ----------------
|
||||
/// <summary>发起会话(POST)</summary>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
@@ -38,5 +38,26 @@ namespace Assets.MyGame.Scripts.Net.WebResponses
|
||||
public int fishScore;
|
||||
public object param;
|
||||
|
||||
/// <summary>
|
||||
/// 掉落道具(击杀 Boss 鱼时可能掉落,与 gold 一样仅占位,掉落道具弹窗逻辑暂未实现)
|
||||
/// </summary>
|
||||
public RoomKillNoticeDrop drop;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 击杀掉落道具信息
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class RoomKillNoticeDrop
|
||||
{
|
||||
/// <summary>掉落道具编号</summary>
|
||||
public string propNumber;
|
||||
|
||||
/// <summary>掉落道具名称</summary>
|
||||
public string propName;
|
||||
|
||||
/// <summary>掉落数量</summary>
|
||||
public int count;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,14 @@ namespace Assets.MyGame.Scripts.Net
|
||||
/// 创建或返回已存在的 WebSocket
|
||||
/// </summary>
|
||||
public WebSocket Connect(SocketType type,Action action=null)
|
||||
{
|
||||
return Connect(type, null, action);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建或返回已存在的 WebSocket(可指定动态 URL,用于 /api/Room/Assign 返回的房间专属地址)
|
||||
/// </summary>
|
||||
public WebSocket Connect(SocketType type, string url, Action action = null)
|
||||
{
|
||||
// 已存在则直接返回
|
||||
if (sockets.TryGetValue(type, out var exist))
|
||||
@@ -83,7 +91,9 @@ namespace Assets.MyGame.Scripts.Net
|
||||
}
|
||||
}
|
||||
|
||||
string url = baseUrl + socketPaths[type];
|
||||
// 未指定 url 时用默认 baseUrl + socketPaths
|
||||
if (string.IsNullOrEmpty(url))
|
||||
url = baseUrl + socketPaths[type];
|
||||
var ws = new WebSocket(new Uri(url));
|
||||
sockets[type] = ws;
|
||||
// 事件绑定
|
||||
|
||||
@@ -347,7 +347,7 @@ namespace Assets.MyGame.Scripts.Net
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LoginHub 消息处理(Broadcast / AssetUpdated / BackpackUpdated / NewEmail)
|
||||
/// LoginHub 消息处理(Broadcast / AssetUpdated / BackpackUpdated / NewEmail / KillAnnouncement)
|
||||
/// </summary>
|
||||
private static void LoginMSG(string msg, WebSocketResponseBase<object> v)
|
||||
{
|
||||
@@ -368,6 +368,9 @@ namespace Assets.MyGame.Scripts.Net
|
||||
case "NewEmail":
|
||||
WebSocketReponseList.NewEmail(msg);
|
||||
break;
|
||||
case "KillAnnouncement":
|
||||
WebSocketReponseList.KillAnnouncement(msg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Assets.MyGame.Scripts.Net.WebResponses;
|
||||
using Assets.MyGame.Scripts.Net.WebResponses;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -389,6 +389,17 @@ namespace Assets.MyGame.Scripts.Net
|
||||
UIManager.Instance.ShowBoardError($"收到新邮件:{data.title}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LoginHub KillAnnouncement — 全局击杀公告(特殊 Boss 击杀全服推送)
|
||||
/// </summary>
|
||||
public static void KillAnnouncement(string msg)
|
||||
{
|
||||
var data = JsonConvert.DeserializeObject<WebSocketResponseBase<KillAnnouncementData>>(msg).arguments[0];
|
||||
// 服务端已拼好 text(格式:恭喜玩家*****在风雷之渊 高级场捕获 人鱼公主*2000倍 150000000大奖)
|
||||
if (data != null && !string.IsNullOrEmpty(data.text))
|
||||
UIManager.Instance.ShowBoardGongGao(data.text);
|
||||
}
|
||||
|
||||
// ---------------- Customer ----------------
|
||||
|
||||
/// <summary>
|
||||
@@ -445,6 +456,30 @@ namespace Assets.MyGame.Scripts.Net
|
||||
public long time;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LoginHub KillAnnouncement 数据(全局击杀公告)
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class KillAnnouncementData
|
||||
{
|
||||
/// <summary>公告文本(服务端已拼接:恭喜玩家*****在风雷之渊 高级场捕获 人鱼公主*2000倍 150000000大奖)</summary>
|
||||
public string text;
|
||||
/// <summary>玩家名(已脱敏,全部替换为*)</summary>
|
||||
public string userName;
|
||||
/// <summary>游戏类型名(如:风雷之渊)</summary>
|
||||
public string gameTypeName;
|
||||
/// <summary>房间名(如:高级场)</summary>
|
||||
public string roomName;
|
||||
/// <summary>鱼名称(如:人鱼公主)</summary>
|
||||
public string fishName;
|
||||
/// <summary>炮台倍数</summary>
|
||||
public int multiple;
|
||||
/// <summary>获得金币</summary>
|
||||
public long gold;
|
||||
/// <summary>时间戳(Unix秒)</summary>
|
||||
public long time;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LoginHub AssetUpdated 数据
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user