2026-07-17 17:50:31 +08:00
|
|
|
using Assets.MyGame.Scripts.Net.API.GameConfig_SubClass;
|
2026-03-09 09:25:01 +08:00
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using System;
|
2026-02-03 11:35:19 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2026-04-25 18:53:04 +08:00
|
|
|
using UnityEngine;
|
2026-02-03 11:35:19 +08:00
|
|
|
|
|
|
|
|
namespace Assets.MyGame.Scripts.Net.WebResponses
|
|
|
|
|
{
|
2026-05-01 06:26:50 +08:00
|
|
|
|
|
|
|
|
public static class FrameDataParser
|
|
|
|
|
{
|
|
|
|
|
public static T Parse<T>(object frameData) where T : class, new()
|
|
|
|
|
{
|
|
|
|
|
if (frameData == null) return null;
|
|
|
|
|
|
|
|
|
|
// 如果已经是目标类型,直接返回
|
|
|
|
|
if (frameData is T typed) return typed;
|
|
|
|
|
|
|
|
|
|
// 如果是字符串,直接反序列化
|
|
|
|
|
if (frameData is string str)
|
|
|
|
|
return JsonConvert.DeserializeObject<T>(str);
|
|
|
|
|
|
|
|
|
|
// 如果是 JObject,轻量解析
|
|
|
|
|
if (frameData is JObject jObj)
|
|
|
|
|
return jObj.ToObject<T>();
|
|
|
|
|
|
|
|
|
|
// 兜底:调用 ToString 再反序列化
|
|
|
|
|
return JsonConvert.DeserializeObject<T>(frameData.ToString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2026-03-09 09:25:01 +08:00
|
|
|
[Serializable]
|
|
|
|
|
public enum FrameDataType
|
|
|
|
|
{
|
2026-04-22 16:22:28 +08:00
|
|
|
none = 0,
|
2026-04-24 22:51:34 +08:00
|
|
|
rotateTurrect=1,
|
|
|
|
|
fireBullet=2,
|
2026-07-25 23:05:24 +08:00
|
|
|
// createFish=3 已废弃:鱼创建改由服务端 OnFishSpawn 事件下发
|
2026-04-24 22:51:34 +08:00
|
|
|
changeAutoTarget=4,
|
|
|
|
|
randomDieFish=5,
|
2026-05-04 17:21:52 +08:00
|
|
|
changeTurretState=6,
|
2026-05-28 18:16:45 +08:00
|
|
|
changeTurret=7,
|
2026-06-19 18:18:04 +08:00
|
|
|
freezeFish=8,
|
2026-06-30 01:31:53 +08:00
|
|
|
changeCannonMultiple=9,
|
2026-07-20 22:32:52 +08:00
|
|
|
changeWing=10,
|
2026-07-25 23:05:24 +08:00
|
|
|
// requestSyncFish=11 已废弃:鱼同步改由服务端 OnFishSpawn(type=sync) 事件下发
|
2026-03-09 09:25:01 +08:00
|
|
|
}
|
2026-05-27 19:47:06 +08:00
|
|
|
[Serializable]
|
|
|
|
|
public class FireCannonSendData
|
|
|
|
|
{
|
2026-07-17 17:50:31 +08:00
|
|
|
public string roomId;
|
2026-05-27 19:47:06 +08:00
|
|
|
public string userId;
|
|
|
|
|
public long gold;
|
|
|
|
|
public int count;
|
2026-07-17 17:50:31 +08:00
|
|
|
public List<string> bulletIds;
|
2026-05-27 19:47:06 +08:00
|
|
|
public SyncGameData extra;
|
2026-07-17 17:50:31 +08:00
|
|
|
public bool isBot;
|
2026-05-27 19:47:06 +08:00
|
|
|
}
|
2026-02-03 11:35:19 +08:00
|
|
|
/// <summary>
|
|
|
|
|
/// 同步游戏数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable]
|
|
|
|
|
public class SyncGameData
|
|
|
|
|
{
|
2026-04-22 16:22:28 +08:00
|
|
|
public int sitPos;
|
2026-03-09 09:25:01 +08:00
|
|
|
public FrameDataType frameType;
|
2026-03-18 17:26:14 +08:00
|
|
|
public long time;
|
2026-04-25 18:53:04 +08:00
|
|
|
public object frameData;
|
2026-02-03 11:35:19 +08:00
|
|
|
|
|
|
|
|
}
|
2026-03-09 09:25:01 +08:00
|
|
|
[Serializable]
|
2026-02-03 11:35:19 +08:00
|
|
|
public class FrameData
|
|
|
|
|
{
|
2026-04-22 16:22:28 +08:00
|
|
|
|
2026-03-09 09:25:01 +08:00
|
|
|
}
|
|
|
|
|
[Serializable]
|
|
|
|
|
public class FrameData_Rotate : FrameData
|
|
|
|
|
{
|
|
|
|
|
public float angle;
|
|
|
|
|
}
|
|
|
|
|
[Serializable]
|
2026-06-16 19:12:37 +08:00
|
|
|
public class FrameData_FireBullet : FrameData
|
2026-03-09 09:25:01 +08:00
|
|
|
{
|
|
|
|
|
public float angle;
|
|
|
|
|
public long gold;
|
|
|
|
|
public bool isSanShe;
|
|
|
|
|
public bool isSuoDing;
|
|
|
|
|
public bool auto;
|
|
|
|
|
public bool twoRTruuect;
|
|
|
|
|
public string monsterID;
|
2026-05-18 18:39:11 +08:00
|
|
|
public bool isZuanTou;
|
2026-05-28 18:16:45 +08:00
|
|
|
/// <summary>三发锁定时每个子弹对应的鱼 GUID(3个),按优先级排序</summary>
|
|
|
|
|
public List<string> monsterIDs;
|
2026-03-09 09:25:01 +08:00
|
|
|
}
|
|
|
|
|
[Serializable]
|
|
|
|
|
public class FrameData_CreateFish : FrameData
|
|
|
|
|
{
|
2026-03-18 17:26:14 +08:00
|
|
|
public string fishNumber;
|
2026-03-10 15:36:10 +08:00
|
|
|
public string guid;
|
2026-03-18 17:26:14 +08:00
|
|
|
public string moveLineId;
|
2026-03-09 09:25:01 +08:00
|
|
|
}
|
|
|
|
|
[Serializable]
|
|
|
|
|
public class FrameData_ChangeAutoTarget : FrameData
|
|
|
|
|
{
|
2026-05-27 19:47:06 +08:00
|
|
|
public List< string> targetGuid;
|
|
|
|
|
public int colliderIndex;
|
2026-02-03 11:35:19 +08:00
|
|
|
}
|
2026-04-22 16:22:28 +08:00
|
|
|
[Serializable]
|
|
|
|
|
public class FrameData_RandomDieFish : FrameData
|
|
|
|
|
{
|
2026-04-25 18:53:04 +08:00
|
|
|
public float x;
|
|
|
|
|
public float y;
|
|
|
|
|
public float z;
|
2026-04-22 18:15:22 +08:00
|
|
|
public List<string> guids=new List<string>();
|
2026-04-25 00:12:55 +08:00
|
|
|
public List<RedPacketRecord> coinNum=new List<RedPacketRecord>();
|
2026-04-24 22:51:34 +08:00
|
|
|
public int count;
|
2026-04-22 16:22:28 +08:00
|
|
|
}
|
2026-05-04 17:21:52 +08:00
|
|
|
[Serializable]
|
|
|
|
|
public class FrameData_TurretState : FrameData
|
|
|
|
|
{
|
|
|
|
|
public TurretState state;
|
|
|
|
|
}
|
|
|
|
|
[Serializable]
|
|
|
|
|
public class FrameData_ChangeTurret : FrameData
|
|
|
|
|
{
|
|
|
|
|
public int turretIndex;
|
|
|
|
|
}
|
2026-05-28 18:16:45 +08:00
|
|
|
[Serializable]
|
|
|
|
|
public class FrameData_FreezeFish : FrameData
|
|
|
|
|
{
|
2026-06-21 00:07:26 +08:00
|
|
|
public bool isFreeze;
|
2026-05-28 18:16:45 +08:00
|
|
|
}
|
2026-06-19 18:18:04 +08:00
|
|
|
[Serializable]
|
|
|
|
|
public class FrameData_ChangeCannonMultiple : FrameData
|
|
|
|
|
{
|
|
|
|
|
public int cannonMultiple;
|
|
|
|
|
}
|
2026-07-25 23:05:24 +08:00
|
|
|
|
|
|
|
|
// ================================================================
|
|
|
|
|
// OnFishSpawn 事件数据结构 (服务端出鱼,破坏性替代 createFish 帧同步)
|
|
|
|
|
// ================================================================
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 服务端出鱼事件 OnFishSpawn 的数据载体。
|
|
|
|
|
/// type:
|
|
|
|
|
/// "init" - 首次出鱼(玩家进入房间后服务端推送初始鱼)
|
|
|
|
|
/// "spawn" - 定时出鱼(游戏中持续刷怪)
|
|
|
|
|
/// "sync" - 重连/取消挂机同步(把当前场上活鱼推送给回归玩家)
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable]
|
|
|
|
|
public class OnFishSpawnData
|
|
|
|
|
{
|
|
|
|
|
/// <summary>"init" | "spawn" | "sync"</summary>
|
|
|
|
|
public string type;
|
|
|
|
|
/// <summary>服务器当前时间戳(毫秒)</summary>
|
|
|
|
|
public long timestamp;
|
|
|
|
|
/// <summary>本批次出鱼列表</summary>
|
|
|
|
|
public List<OnFishSpawnFishItem> fish;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// OnFishSpawn 单条鱼描述。
|
|
|
|
|
/// 客户端据此调用 SpawnFishMainThread 生成鱼实例。
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable]
|
|
|
|
|
public class OnFishSpawnFishItem
|
|
|
|
|
{
|
|
|
|
|
/// <summary>服务端分配的全局唯一鱼 ID(作为 guid 使用)</summary>
|
|
|
|
|
public long fishId;
|
|
|
|
|
/// <summary>鱼编号(配置 fishNumber)</summary>
|
|
|
|
|
public string fishNumber;
|
|
|
|
|
/// <summary>路径编号</summary>
|
|
|
|
|
public int routeId;
|
|
|
|
|
/// <summary>鱼阵编号(非鱼阵时为空字符串)</summary>
|
|
|
|
|
public string fishArrayNumber;
|
|
|
|
|
/// <summary>鱼阵的 Boss 鱼编号</summary>
|
|
|
|
|
public string bossFishNumber;
|
|
|
|
|
/// <summary>鱼阵普通鱼数量</summary>
|
|
|
|
|
public int fishCount;
|
|
|
|
|
/// <summary>鱼阵 Boss 数量</summary>
|
|
|
|
|
public int bossCount;
|
|
|
|
|
/// <summary>鱼过期时间戳(毫秒),到期自动移除</summary>
|
|
|
|
|
public long expireAt;
|
|
|
|
|
/// <summary>鱼剩余存活秒数(客户端做倒计时用)</summary>
|
|
|
|
|
public int remainingSeconds;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 机器人退出房间通知数据 BotLeaveRoomNotice: { userId }
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable]
|
|
|
|
|
public class BotLeaveRoomNoticeData
|
|
|
|
|
{
|
|
|
|
|
public string userId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 玩家挂机/取消挂机通知数据: { userId }
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable]
|
|
|
|
|
public class PlayerAfkNoticeData
|
|
|
|
|
{
|
|
|
|
|
public string userId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 全局击杀公告 KillNotice 数据。
|
|
|
|
|
/// 真人击杀时只填基础字段;机器人模拟时额外填 fishName/multiplier/sceneName。
|
|
|
|
|
/// </summary>
|
|
|
|
|
[Serializable]
|
|
|
|
|
public class KillNoticeData
|
|
|
|
|
{
|
|
|
|
|
/// <summary>鱼编号</summary>
|
|
|
|
|
public string FishId;
|
|
|
|
|
/// <summary>玩家名</summary>
|
|
|
|
|
public string userName;
|
|
|
|
|
/// <summary>金币</summary>
|
|
|
|
|
public long gold;
|
|
|
|
|
// —— 机器人模拟时额外字段 ——
|
|
|
|
|
/// <summary>鱼名(机器人模拟时填充)</summary>
|
|
|
|
|
public string fishName;
|
|
|
|
|
/// <summary>倍数(机器人模拟时填充)</summary>
|
|
|
|
|
public int? multiplier;
|
|
|
|
|
/// <summary>场景名(机器人模拟时填充)</summary>
|
|
|
|
|
public string sceneName;
|
|
|
|
|
}
|
2026-02-03 11:35:19 +08:00
|
|
|
}
|