甘艺伟 hace 2 semanas
padre
commit
eb240b8e42
Se han modificado 51 ficheros con 1790 adiciones y 3 borrados
  1. 27 0
      assets/script/network/GameServerConfig.ts
  2. 10 0
      assets/script/network/GameServerConfig.ts.meta
  3. 58 0
      assets/script/network/Security.ts
  4. 10 0
      assets/script/network/Security.ts.meta
  5. 16 0
      assets/script/network/ShareConfig.ts
  6. 10 0
      assets/script/network/ShareConfig.ts.meta
  7. 130 0
      assets/script/network/TsrpcNet.ts
  8. 10 0
      assets/script/network/TsrpcNet.ts.meta
  9. 26 0
      assets/script/network/base.ts
  10. 10 0
      assets/script/network/base.ts.meta
  11. 13 0
      assets/script/shared.meta
  12. 13 0
      assets/script/shared/game.meta
  13. 13 0
      assets/script/shared/game/state.meta
  14. 4 0
      assets/script/shared/game/state/OnlineState.ts
  15. 10 0
      assets/script/shared/game/state/OnlineState.ts.meta
  16. 31 0
      assets/script/shared/game/state/PlayerState.ts
  17. 10 0
      assets/script/shared/game/state/PlayerState.ts.meta
  18. 9 0
      assets/script/shared/game/state/RoomState.ts
  19. 10 0
      assets/script/shared/game/state/RoomState.ts.meta
  20. 13 0
      assets/script/shared/protocols.meta
  21. 918 0
      assets/script/shared/protocols/ServiceProtoRoom.ts
  22. 10 0
      assets/script/shared/protocols/ServiceProtoRoom.ts.meta
  23. 13 0
      assets/script/shared/protocols/match.meta
  24. 25 0
      assets/script/shared/protocols/match/PtlDoMatch.ts
  25. 10 0
      assets/script/shared/protocols/match/PtlDoMatch.ts.meta
  26. 13 0
      assets/script/shared/protocols/room.meta
  27. 25 0
      assets/script/shared/protocols/room/PtlRoomJoin.ts
  28. 10 0
      assets/script/shared/protocols/room/PtlRoomJoin.ts.meta
  29. 14 0
      assets/script/shared/protocols/room/PtlRoomLeave.ts
  30. 10 0
      assets/script/shared/protocols/room/PtlRoomLeave.ts.meta
  31. 13 0
      assets/script/shared/protocols/room/client.meta
  32. 6 0
      assets/script/shared/protocols/room/client/MsgAck.ts
  33. 10 0
      assets/script/shared/protocols/room/client/MsgAck.ts.meta
  34. 5 0
      assets/script/shared/protocols/room/client/MsgGameAction.ts
  35. 10 0
      assets/script/shared/protocols/room/client/MsgGameAction.ts.meta
  36. 16 0
      assets/script/shared/protocols/room/client/MsgSyncMap.ts
  37. 10 0
      assets/script/shared/protocols/room/client/MsgSyncMap.ts.meta
  38. 13 0
      assets/script/shared/protocols/room/server.meta
  39. 6 0
      assets/script/shared/protocols/room/server/MsgActionAck.ts
  40. 10 0
      assets/script/shared/protocols/room/server/MsgActionAck.ts.meta
  41. 9 0
      assets/script/shared/protocols/room/server/MsgGameAction.ts
  42. 10 0
      assets/script/shared/protocols/room/server/MsgGameAction.ts.meta
  43. 5 0
      assets/script/shared/protocols/room/server/MsgNotifySync.ts
  44. 10 0
      assets/script/shared/protocols/room/server/MsgNotifySync.ts.meta
  45. 12 0
      assets/script/shared/protocols/room/server/MsgPlayerJoin.ts
  46. 10 0
      assets/script/shared/protocols/room/server/MsgPlayerJoin.ts.meta
  47. 13 0
      assets/script/shared/types.meta
  48. 22 0
      assets/script/shared/types/GameAction.ts
  49. 10 0
      assets/script/shared/types/GameAction.ts.meta
  50. 106 2
      package-lock.json
  51. 3 1
      package.json

+ 27 - 0
assets/script/network/GameServerConfig.ts

@@ -0,0 +1,27 @@
+
+
+/** 游戏服务器配置,给客户端读取使用 */
+export class GameServerConfig {
+    public static isLocalServer: boolean = false;
+    /** 匹配服服务器地址 */
+    public static MATCH_SERVER = 'http://192.168.30.105:3001';
+    /** 游戏服务器地址 */
+    public static ROOM_SERVER = 'ws://192.168.30.105:3000';
+    // public static ROOM_SERVER = 'ws://118.190.242.151';
+    // public static ROOM_SERVER = location.hostname;
+    /** 两个心跳数据包之间的间隔时间(单位:毫秒) */
+    static heartbeat_interval: number = 1000;
+    /** 如果在此期间心跳数据包没有得到回复,连接将被关闭(单位:毫秒) */
+    static heartbeat_timeout: number = 3000;
+    /** 客户端发送玩家状态信息的频率 */
+    static player_state_update_rate: number = 0.066;
+
+    /**竞技服版本号 */
+    public static clientVersion: number = 1;
+    /** 客户端同步版本号 */
+    public static syncVersion: number = 1;
+    /** 客户端版本号 */
+    public static appVersion: number = 220;
+
+
+}

+ 10 - 0
assets/script/network/GameServerConfig.ts.meta

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "b01cb798-3dec-432c-82ee-32e8f96d9248",
+  "importer": "typescript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 58 - 0
assets/script/network/Security.ts

@@ -0,0 +1,58 @@
+
+
+import { ShareConfig } from './ShareConfig';
+// import TextEncodingPolyfill from 'text-encoding';
+/** 数据传输加密 */
+export class Security {
+
+    static repeatArray(arr: Array<number>, size: number): Array<number> {
+        let repeatedArray = arr.slice(); // 复制原数组
+        while (repeatedArray.length < size) {
+            // 如果数组长度小于指定大小,就复制一份原数组内容并追加到末尾
+            repeatedArray = repeatedArray.concat(arr.slice(0, size - repeatedArray.length));
+        }
+        return repeatedArray.slice(0, size); // 返回指定长度的数组
+    }
+
+    static mapKey(size: number): Array<number> {
+
+        const seed = Number('905010410038421001031011063552115');
+        // const seed = Number(new TextEncodingPolyfill.TextEncoder().encode(ShareConfig.securityKey).join(''));
+        const dict = new Array(256);
+
+        for (let i = 0; i < 256; i++) {
+            const temp = dict[i] || i;
+            const rand = (seed % (i + 1) + i) % 256;
+            dict[i] = dict[rand] || rand;
+            dict[rand] = temp;
+        }
+
+        if (size > 256) {
+            return Security.repeatArray(dict, size);
+        } else {
+            return dict;
+        }
+    }
+
+    static byteIn(keyMap: Array<number>, val: number, index: number): number {
+        for (let i = 0; i < keyMap.length; i++) {
+            if (keyMap[i] === val) return (i + keyMap[index]) % 256;
+        }
+        return 0;
+    }
+
+    static byteOut(keyMap: Array<number>, val: number, index: number): number {
+        const diff = val - keyMap[index];
+        return keyMap[(diff < 0) ? 256 + diff : diff];
+    }
+
+    /** 加密 */
+    static encrypt(buf: Uint8Array): Uint8Array {
+        return buf.map(Security.byteIn.bind(null, Security.mapKey(buf.length)));
+    }
+
+    /** 解密 */
+    static decrypt(buf: Uint8Array): Uint8Array {
+        return buf.map(Security.byteOut.bind(null, Security.mapKey(buf.length)));
+    }
+}

+ 10 - 0
assets/script/network/Security.ts.meta

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "aa378c83-5302-436d-a71f-61fce071a286",
+  "importer": "typescript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 16 - 0
assets/script/network/ShareConfig.ts

@@ -0,0 +1,16 @@
+/*
+ * @Author: dgflash
+ * @Date: 2022-06-29 16:39:42
+ * @LastEditors: dgflash
+ * @LastEditTime: 2022-11-14 10:57:00
+ */
+export class ShareConfig {
+    /** 强制HTTPS */
+    static https: boolean = false;
+    /** 传输协议是否使用加密功能 */
+    static security: boolean = true;
+    /** 传输加密key */
+    static securityKey: string = 'Z1hd&*dgej#2s';
+    /** 是否用JSON协议,否则用二进制 */
+    static json: boolean = false;
+}

+ 10 - 0
assets/script/network/ShareConfig.ts.meta

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "764d5a07-3858-4c16-8095-04e8c581c80a",
+  "importer": "typescript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 130 - 0
assets/script/network/TsrpcNet.ts

@@ -0,0 +1,130 @@
+/**
+ * tsrpc连接管理
+ */
+
+import { HttpClient as HttpClient_Browser, WsClient as WsClient_Browser } from 'tsrpc-browser';
+import { HttpClient as HttpClient_Miniapp, WsClient as WsClient_Miniapp } from 'tsrpc-miniapp';
+import { serviceProto as ServiceProtoRoom, ServiceType, ServiceType as ServiceTypeRoom } from "../shared/protocols/ServiceProtoRoom";
+import { GameServerConfig } from './GameServerConfig';
+import { ShareConfig } from './ShareConfig';
+import { Security } from './Security';
+import { BaseResponse } from './base';
+
+
+/** TSRPC网络模块 */
+export class TsrpcNet {
+
+    /** 连接房间服务器 Websocket 客户端 */
+    wscRoom: WsClient_Browser<ServiceTypeRoom> = null!;
+
+    private static instance: TsrpcNet;
+
+    static getInstance(): TsrpcNet {
+        if (this.instance == null) {
+            this.instance = new TsrpcNet();
+            //@ts-ignore
+            window.TsrpcNet = this;
+        }
+        return this.instance;
+    }
+    constructor() {
+    }
+
+
+    /**
+     *  创建连接房间服务器 Websocket 客户端
+     * @param serverUrl 服务器地址
+     * @returns WsClient
+     */
+    createWscRoom(serverUrl: string) {
+        // 创建客户端与房间服务器的 WebSocket 连接
+        serverUrl = serverUrl.replace(/[\u0000\x00]/g, "");
+        this.wscRoom = new (cc.sys.platform == cc.sys.WECHAT_GAME ? WsClient_Miniapp : WsClient_Browser)(ServiceProtoRoom, {
+            // server: serverUrl + "?" + Date.now(),
+            server: serverUrl,
+            heartbeat: {
+                interval: GameServerConfig.heartbeat_interval,
+                timeout: GameServerConfig.heartbeat_timeout
+            },
+            json: ShareConfig.json,
+            // logger: console,
+            logMsg: true,
+        });
+        this.flowClientApi(this.wscRoom);
+        this.flowAuth(this.wscRoom);
+
+        return this.wscRoom;
+    }
+
+    /** HTTP 客户端协议数据加密、解密 */
+    private flowClientApi(hc: any) {
+        if (!ShareConfig.security) return;
+
+        hc.flows.preSendDataFlow.push(v => {
+            if (v.data instanceof Uint8Array) {
+                v.data = Security.encrypt(v.data);
+            }
+            return v;
+        });
+
+        // 在处理接收到的数据之前,通常要进行加密/解密
+        hc.flows.preRecvDataFlow.push(v => {
+            if (v.data instanceof Uint8Array) {
+                v.data = Security.decrypt(v.data);
+            }
+            return v;
+        });
+    }
+
+    /** 帐号登录令牌验证是否逻辑(帐号中加入登录令牌,服务器通过令牌解析玩家数据,如果存在就是已登录) */
+    private flowAuth(client: any) {              // HttpClient WsClient
+        // 执行 callApi 之前协议中插入登录令牌
+        client.flows.preCallApiFlow.push(v => {
+            // 请求前插入登录令牌
+            let ssoToken = cc.sys.localStorage.getItem('SSO_TOKEN');
+            if (ssoToken) {
+                v.req.__ssoToken = ssoToken;
+            }
+            return v;
+        })
+
+        // 将 callApi 的结果返回给调用方之后将登录令牌存到本地(收到协议时将登录令牌存到本地)
+        client.flows.postApiReturnFlow.push(v => {
+            if (v.return.isSucc) {
+                let res = v.return.res as BaseResponse;
+
+                // 请求成功后刷新登录令牌
+                if (res.__ssoToken !== undefined) {
+                    cc.sys.localStorage.setItem('SSO_TOKEN', res.__ssoToken);
+                }
+            }
+            // 登录令牌过期时删除客户端登录令牌(可跳转到登录界面)
+            else if (v.return.err.code === 'NEED_LOGIN') {
+                cc.sys.localStorage.setItem('SSO_TOKEN', '');
+            }
+            return v;
+        });
+    }
+
+
+    /** http请求api */
+    public async callApi<T extends string & keyof ServiceType['api']>(apiName: T, req: ServiceType['api'][T]['req']) {
+        let ret = await this.wscRoom.callApi('RoomJoin', req);
+        return ret;
+    }
+
+
+    /** ws发送消息 */
+    public sendMsg<T extends string & keyof ServiceType['msg']>(msgName: T, msg: ServiceType['msg'][T]) {
+        this.wscRoom.sendMsg(msgName, msg);
+    }
+
+
+    /** 监听消息 */
+    public listenMsg<T extends keyof ServiceType['msg']>(msgName: T | RegExp, callback: Function) {
+        this.wscRoom.listenMsg(msgName, v => {
+            callback(v);
+        });
+    }
+
+}

+ 10 - 0
assets/script/network/TsrpcNet.ts.meta

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "d07dd4cf-c6f1-4cae-ae11-240554f10eac",
+  "importer": "typescript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 26 - 0
assets/script/network/base.ts

@@ -0,0 +1,26 @@
+
+/** HTTP 基础请求数据 */
+export interface BaseRequest {
+    /** 通行证 */
+    __ssoToken?: string;
+}
+
+/** HTTP 基础返回数据 */
+export interface BaseResponse {
+    /** 通行证 */
+    __ssoToken?: string;
+}
+
+/** 基础配置数据 */
+export interface BaseConf {
+    /** 是否必须登录 */
+    needLogin?: boolean
+    /** 是否验证客户端请求地址在白名单中 */
+    needCheckAddress?: boolean
+}
+
+/** 长链接基础消息数据 */
+export interface BaseMessage {
+    /** 是否必须登录 */
+    needLogin?: boolean
+}

+ 10 - 0
assets/script/network/base.ts.meta

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "12e02a70-8080-44cd-ae1d-b6804a4c13c8",
+  "importer": "typescript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 13 - 0
assets/script/shared.meta

@@ -0,0 +1,13 @@
+{
+  "ver": "1.1.3",
+  "uuid": "6123d76a-abc5-4af9-8d66-8ee9c8b77254",
+  "importer": "folder",
+  "isBundle": false,
+  "bundleName": "",
+  "priority": 1,
+  "compressionType": {},
+  "optimizeHotUpdate": {},
+  "inlineSpriteFrames": {},
+  "isRemoteBundle": {},
+  "subMetas": {}
+}

+ 13 - 0
assets/script/shared/game.meta

@@ -0,0 +1,13 @@
+{
+  "ver": "1.1.3",
+  "uuid": "930fc2e2-6bab-4f7a-89e3-382715ab5ef8",
+  "importer": "directory",
+  "isBundle": false,
+  "bundleName": "",
+  "priority": 1,
+  "compressionType": {},
+  "optimizeHotUpdate": {},
+  "inlineSpriteFrames": {},
+  "isRemoteBundle": {},
+  "subMetas": {}
+}

+ 13 - 0
assets/script/shared/game/state.meta

@@ -0,0 +1,13 @@
+{
+  "ver": "1.1.3",
+  "uuid": "8231aa97-6122-4f3d-b6a1-63aebe4cc4bc",
+  "importer": "directory",
+  "isBundle": false,
+  "bundleName": "",
+  "priority": 1,
+  "compressionType": {},
+  "optimizeHotUpdate": {},
+  "inlineSpriteFrames": {},
+  "isRemoteBundle": {},
+  "subMetas": {}
+}

+ 4 - 0
assets/script/shared/game/state/OnlineState.ts

@@ -0,0 +1,4 @@
+export enum OnlineState {
+    Online = 1,
+    Offline = 2
+}

+ 10 - 0
assets/script/shared/game/state/OnlineState.ts.meta

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "5bde4bf4-ed22-49c7-99e7-411a73ed6237",
+  "importer": "typescript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 31 - 0
assets/script/shared/game/state/PlayerState.ts

@@ -0,0 +1,31 @@
+export interface PlayerState {
+    id: string,
+    seatId: number,
+    score: number,
+    pre_score: number,
+    power: number,
+    avatar: number,
+    avatarFrame: number,
+    nickName: string,
+    cardId: number,
+    //是否准备就绪
+    ready: number,
+    //已使用道具
+    useProps: Array<number>
+    /** 奖杯 */
+    cup: number;
+    //在线状态
+    online: number,
+    //机器人难度id
+    robotId?: string,
+    /** 消除棋子 */
+    pre_cubes: number,
+    /**剩余步数 */
+    step?: number,
+    // vip等级
+    vip?: number,
+    data?: any
+}
+
+export type MatchPlayerState = Pick<PlayerState, "id" | "robotId" | "seatId" | "cardId" | "cup" | "nickName" | "avatar" | "avatarFrame" | "vip" | "data">
+export type RoomPlayerState = Pick<PlayerState, "id" | "score" | "useProps" | "step" | "power">

+ 10 - 0
assets/script/shared/game/state/PlayerState.ts.meta

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "b20ddf49-2d12-4ccc-8f7a-e9ad9655d0ae",
+  "importer": "typescript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 9 - 0
assets/script/shared/game/state/RoomState.ts

@@ -0,0 +1,9 @@
+import { PlayerState } from "./PlayerState";
+
+export interface RoomState {
+    id: string,
+    roomType: number,
+    server: string,
+    players: Array<PlayerState>,
+    startTime?: number,
+}

+ 10 - 0
assets/script/shared/game/state/RoomState.ts.meta

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "b3295a5c-3fec-4b6c-a053-d3278b56a23f",
+  "importer": "typescript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 13 - 0
assets/script/shared/protocols.meta

@@ -0,0 +1,13 @@
+{
+  "ver": "1.1.3",
+  "uuid": "cf0eccb1-8038-4327-817d-8dc9ee8b682e",
+  "importer": "directory",
+  "isBundle": false,
+  "bundleName": "",
+  "priority": 1,
+  "compressionType": {},
+  "optimizeHotUpdate": {},
+  "inlineSpriteFrames": {},
+  "isRemoteBundle": {},
+  "subMetas": {}
+}

+ 918 - 0
assets/script/shared/protocols/ServiceProtoRoom.ts

@@ -0,0 +1,918 @@
+import { ServiceProto } from 'tsrpc-proto';
+import { ReqRoomJoin, ResRoomJoin } from './room/PtlRoomJoin';
+import { MsgAck } from './room/client/MsgAck';
+
+export interface ServiceType {
+    api: {
+        "RoomJoin": {
+            req: ReqRoomJoin,
+            res: ResRoomJoin
+        }
+    },
+    msg: {
+        "msg/client/Ack": MsgAck,
+    }
+}
+
+export const serviceProto: ServiceProto<ServiceType> = {
+    "version": 36,
+    "services": [
+        {
+            "id": 25,
+            "name": "msg/client/Ack",
+            "type": "msg"
+        },
+        {
+            "id": 13,
+            "name": "msg/client/GameAction",
+            "type": "msg"
+        },
+        {
+            "id": 18,
+            "name": "msg/client/SyncMap",
+            "type": "msg"
+        },
+        {
+            "id": 24,
+            "name": "msg/server/ActionAck",
+            "type": "msg"
+        },
+        {
+            "id": 14,
+            "name": "msg/server/GameAction",
+            "type": "msg"
+        },
+        {
+            "id": 19,
+            "name": "msg/server/NotifySync",
+            "type": "msg"
+        },
+        {
+            "id": 15,
+            "name": "msg/server/PlayerJoin",
+            "type": "msg"
+        },
+        {
+            "id": 16,
+            "name": "msg/server/PlayerLeave",
+            "type": "msg"
+        },
+        {
+            "id": 22,
+            "name": "msg/server/PlayerStateChange",
+            "type": "msg"
+        },
+        {
+            "id": 23,
+            "name": "msg/server/SyncMapServer",
+            "type": "msg"
+        },
+        {
+            "id": 26,
+            "name": "GetMsg",
+            "type": "api"
+        },
+        {
+            "id": 5,
+            "name": "RoomJoin",
+            "type": "api"
+        },
+        {
+            "id": 6,
+            "name": "RoomLeave",
+            "type": "api"
+        },
+        {
+            "id": 11,
+            "name": "TestMatch",
+            "type": "api",
+            "conf": {
+                "needLogin": true
+            }
+        }
+    ],
+    "types": {
+        "msg/client/MsgAck/MsgAck": {
+            "type": "Interface",
+            "properties": [
+                {
+                    "id": 0,
+                    "name": "sns",
+                    "type": {
+                        "type": "Array",
+                        "elementType": {
+                            "type": "Number"
+                        }
+                    }
+                }
+            ]
+        },
+        "msg/client/MsgGameAction/MsgGameAction": {
+            "type": "Reference",
+            "target": "../../shared/types/GameAction/GameAction"
+        },
+        "../../shared/types/GameAction/GameAction": {
+            "type": "Interface",
+            "properties": [
+                {
+                    "id": 0,
+                    "name": "type",
+                    "type": {
+                        "type": "Literal",
+                        "literal": "GameAction"
+                    }
+                },
+                {
+                    "id": 1,
+                    "name": "playerId",
+                    "type": {
+                        "type": "String"
+                    },
+                    "optional": true
+                },
+                {
+                    "id": 2,
+                    "name": "actionName",
+                    "type": {
+                        "type": "String"
+                    }
+                },
+                {
+                    "id": 3,
+                    "name": "data",
+                    "type": {
+                        "type": "Any"
+                    }
+                },
+                {
+                    "id": 4,
+                    "name": "creatorQueue",
+                    "type": {
+                        "type": "Array",
+                        "elementType": {
+                            "type": "Interface",
+                            "properties": [
+                                {
+                                    "id": 0,
+                                    "name": "key",
+                                    "type": {
+                                        "type": "String"
+                                    }
+                                },
+                                {
+                                    "id": 1,
+                                    "name": "ids",
+                                    "type": {
+                                        "type": "Array",
+                                        "elementType": {
+                                            "type": "String"
+                                        }
+                                    }
+                                }
+                            ]
+                        }
+                    },
+                    "optional": true
+                },
+                {
+                    "id": 6,
+                    "name": "time",
+                    "type": {
+                        "type": "Number"
+                    },
+                    "optional": true
+                },
+                {
+                    "id": 5,
+                    "name": "sendTag",
+                    "type": {
+                        "type": "Number"
+                    },
+                    "optional": true
+                }
+            ]
+        },
+        "msg/client/MsgSyncMap/MsgSyncMap": {
+            "type": "Interface",
+            "properties": [
+                {
+                    "id": 17,
+                    "name": "data",
+                    "type": {
+                        "type": "Any"
+                    }
+                }
+            ]
+        },
+        "msg/server/MsgActionAck/MsgActionAck": {
+            "type": "Interface",
+            "properties": [
+                {
+                    "id": 1,
+                    "name": "sendTag",
+                    "type": {
+                        "type": "Number"
+                    }
+                },
+                {
+                    "id": 2,
+                    "name": "players",
+                    "type": {
+                        "type": "Any"
+                    }
+                }
+            ]
+        },
+        "msg/server/MsgGameAction/MsgGameAction": {
+            "type": "Interface",
+            "properties": [
+                {
+                    "id": 0,
+                    "name": "state",
+                    "type": {
+                        "type": "Any"
+                    }
+                },
+                {
+                    "id": 2,
+                    "name": "players",
+                    "type": {
+                        "type": "Any"
+                    }
+                },
+                {
+                    "id": 1,
+                    "name": "sn",
+                    "type": {
+                        "type": "Number"
+                    }
+                }
+            ]
+        },
+        "msg/server/MsgNotifySync/MsgNotifySync": {
+            "type": "Interface",
+            "properties": [
+                {
+                    "id": 0,
+                    "name": "playerId",
+                    "type": {
+                        "type": "String"
+                    }
+                }
+            ]
+        },
+        "msg/server/MsgPlayerJoin/MsgPlayerJoin": {
+            "type": "Interface",
+            "properties": [
+                {
+                    "id": 0,
+                    "name": "player",
+                    "type": {
+                        "type": "Reference",
+                        "target": "../../shared/game/state/PlayerState/PlayerState"
+                    }
+                },
+                {
+                    "id": 1,
+                    "name": "time",
+                    "type": {
+                        "type": "Number"
+                    }
+                },
+                {
+                    "id": 2,
+                    "name": "mapData",
+                    "type": {
+                        "type": "String"
+                    },
+                    "optional": true
+                }
+            ]
+        },
+        "../../shared/game/state/PlayerState/PlayerState": {
+            "type": "Interface",
+            "properties": [
+                {
+                    "id": 0,
+                    "name": "id",
+                    "type": {
+                        "type": "String"
+                    }
+                },
+                {
+                    "id": 1,
+                    "name": "seatId",
+                    "type": {
+                        "type": "Number"
+                    }
+                },
+                {
+                    "id": 2,
+                    "name": "score",
+                    "type": {
+                        "type": "Number"
+                    }
+                },
+                {
+                    "id": 3,
+                    "name": "pre_score",
+                    "type": {
+                        "type": "Number"
+                    }
+                },
+                {
+                    "id": 4,
+                    "name": "power",
+                    "type": {
+                        "type": "Number"
+                    }
+                },
+                {
+                    "id": 5,
+                    "name": "avatar",
+                    "type": {
+                        "type": "Number"
+                    }
+                },
+                {
+                    "id": 6,
+                    "name": "avatarFrame",
+                    "type": {
+                        "type": "Number"
+                    }
+                },
+                {
+                    "id": 7,
+                    "name": "nickName",
+                    "type": {
+                        "type": "String"
+                    }
+                },
+                {
+                    "id": 8,
+                    "name": "cardId",
+                    "type": {
+                        "type": "Number"
+                    }
+                },
+                {
+                    "id": 9,
+                    "name": "ready",
+                    "type": {
+                        "type": "Number"
+                    }
+                },
+                {
+                    "id": 10,
+                    "name": "useProps",
+                    "type": {
+                        "type": "Array",
+                        "elementType": {
+                            "type": "Number"
+                        }
+                    }
+                },
+                {
+                    "id": 11,
+                    "name": "cup",
+                    "type": {
+                        "type": "Number"
+                    }
+                },
+                {
+                    "id": 12,
+                    "name": "online",
+                    "type": {
+                        "type": "Number"
+                    }
+                },
+                {
+                    "id": 13,
+                    "name": "robotId",
+                    "type": {
+                        "type": "String"
+                    },
+                    "optional": true
+                },
+                {
+                    "id": 15,
+                    "name": "pre_cubes",
+                    "type": {
+                        "type": "Number"
+                    }
+                },
+                {
+                    "id": 16,
+                    "name": "step",
+                    "type": {
+                        "type": "Number"
+                    },
+                    "optional": true
+                },
+                {
+                    "id": 17,
+                    "name": "vip",
+                    "type": {
+                        "type": "Number"
+                    },
+                    "optional": true
+                },
+                {
+                    "id": 18,
+                    "name": "data",
+                    "type": {
+                        "type": "Any"
+                    },
+                    "optional": true
+                }
+            ]
+        },
+        "msg/server/MsgPlayerLeave/MsgPlayerLeave": {
+            "type": "Interface",
+            "properties": [
+                {
+                    "id": 0,
+                    "name": "playerId",
+                    "type": {
+                        "type": "String"
+                    }
+                }
+            ]
+        },
+        "msg/server/MsgPlayerStateChange/MsgPlayerStateChange": {
+            "type": "Interface",
+            "properties": [
+                {
+                    "id": 0,
+                    "name": "playerId",
+                    "type": {
+                        "type": "String"
+                    }
+                },
+                {
+                    "id": 1,
+                    "name": "state",
+                    "type": {
+                        "type": "Reference",
+                        "target": "../../shared/game/state/OnlineState/OnlineState"
+                    }
+                }
+            ]
+        },
+        "../../shared/game/state/OnlineState/OnlineState": {
+            "type": "Enum",
+            "members": [
+                {
+                    "id": 0,
+                    "value": 1
+                },
+                {
+                    "id": 1,
+                    "value": 2
+                }
+            ]
+        },
+        "msg/server/MsgSyncMapServer/MsgSyncMapServer": {
+            "type": "Interface",
+            "properties": [
+                {
+                    "id": 0,
+                    "name": "playerId",
+                    "type": {
+                        "type": "String"
+                    }
+                },
+                {
+                    "id": 1,
+                    "name": "state",
+                    "type": {
+                        "type": "Reference",
+                        "target": "../../shared/game/state/OnlineState/OnlineState"
+                    }
+                },
+                {
+                    "id": 2,
+                    "name": "data",
+                    "type": {
+                        "type": "Any"
+                    }
+                }
+            ]
+        },
+        "PtlGetMsg/ReqGetMsg": {
+            "type": "Interface",
+            "extends": [
+                {
+                    "id": 0,
+                    "type": {
+                        "type": "Reference",
+                        "target": "../../shared/base/BaseRequest"
+                    }
+                }
+            ],
+            "properties": [
+                {
+                    "id": 0,
+                    "name": "playerId",
+                    "type": {
+                        "type": "String"
+                    }
+                },
+                {
+                    "id": 1,
+                    "name": "roomId",
+                    "type": {
+                        "type": "String"
+                    }
+                }
+            ]
+        },
+        "../../shared/base/BaseRequest": {
+            "type": "Interface",
+            "properties": [
+                {
+                    "id": 0,
+                    "name": "__ssoToken",
+                    "type": {
+                        "type": "String"
+                    },
+                    "optional": true
+                }
+            ]
+        },
+        "PtlGetMsg/ResGetMsg": {
+            "type": "Interface",
+            "extends": [
+                {
+                    "id": 0,
+                    "type": {
+                        "type": "Reference",
+                        "target": "../../shared/base/BaseResponse"
+                    }
+                }
+            ],
+            "properties": [
+                {
+                    "id": 0,
+                    "name": "data",
+                    "type": {
+                        "type": "Any"
+                    }
+                },
+                {
+                    "id": 1,
+                    "name": "players",
+                    "type": {
+                        "type": "Any"
+                    }
+                }
+            ]
+        },
+        "../../shared/base/BaseResponse": {
+            "type": "Interface",
+            "properties": [
+                {
+                    "id": 0,
+                    "name": "__ssoToken",
+                    "type": {
+                        "type": "String"
+                    },
+                    "optional": true
+                }
+            ]
+        },
+        "PtlRoomJoin/ReqRoomJoin": {
+            "type": "Interface",
+            "extends": [
+                {
+                    "id": 1,
+                    "type": {
+                        "type": "Reference",
+                        "target": "../../shared/base/BaseRequest"
+                    }
+                }
+            ],
+            "properties": [
+                {
+                    "id": 0,
+                    "name": "playerId",
+                    "type": {
+                        "type": "String"
+                    }
+                },
+                {
+                    "id": 1,
+                    "name": "roomId",
+                    "type": {
+                        "type": "String"
+                    }
+                },
+                {
+                    "id": 2,
+                    "name": "mapData",
+                    "type": {
+                        "type": "String"
+                    },
+                    "optional": true
+                },
+                {
+                    "id": 3,
+                    "name": "sn",
+                    "type": {
+                        "type": "Number"
+                    },
+                    "optional": true
+                }
+            ]
+        },
+        "PtlRoomJoin/ResRoomJoin": {
+            "type": "Interface",
+            "extends": [
+                {
+                    "id": 1,
+                    "type": {
+                        "type": "Reference",
+                        "target": "../../shared/base/BaseResponse"
+                    }
+                }
+            ],
+            "properties": [
+                {
+                    "id": 0,
+                    "name": "playerId",
+                    "type": {
+                        "type": "String"
+                    }
+                },
+                {
+                    "id": 3,
+                    "name": "players",
+                    "type": {
+                        "type": "Array",
+                        "elementType": {
+                            "type": "Reference",
+                            "target": "../../shared/game/state/PlayerState/PlayerState"
+                        }
+                    }
+                },
+                {
+                    "id": 2,
+                    "name": "mapData",
+                    "type": {
+                        "type": "String"
+                    },
+                    "optional": true
+                },
+                {
+                    "id": 4,
+                    "name": "sn",
+                    "type": {
+                        "type": "Number"
+                    },
+                    "optional": true
+                },
+                {
+                    "id": 5,
+                    "name": "startTime",
+                    "type": {
+                        "type": "Number"
+                    },
+                    "optional": true
+                }
+            ]
+        },
+        "PtlRoomLeave/ReqRoomLeave": {
+            "type": "Interface",
+            "extends": [
+                {
+                    "id": 1,
+                    "type": {
+                        "type": "Reference",
+                        "target": "../../shared/base/BaseRequest"
+                    }
+                }
+            ],
+            "properties": [
+                {
+                    "id": 0,
+                    "name": "playerId",
+                    "type": {
+                        "type": "String"
+                    }
+                },
+                {
+                    "id": 1,
+                    "name": "roomId",
+                    "type": {
+                        "type": "String"
+                    }
+                }
+            ]
+        },
+        "PtlRoomLeave/ResRoomLeave": {
+            "type": "Interface",
+            "extends": [
+                {
+                    "id": 1,
+                    "type": {
+                        "type": "Reference",
+                        "target": "../../shared/base/BaseResponse"
+                    }
+                }
+            ],
+            "properties": [
+                {
+                    "id": 0,
+                    "name": "playerId",
+                    "type": {
+                        "type": "String"
+                    }
+                }
+            ]
+        },
+        "PtlTestMatch/ReqTestMatch": {
+            "type": "Interface",
+            "extends": [
+                {
+                    "id": 1,
+                    "type": {
+                        "type": "Reference",
+                        "target": "../../shared/base/BaseRequest"
+                    }
+                }
+            ],
+            "properties": [
+                {
+                    "id": 0,
+                    "name": "playerId",
+                    "type": {
+                        "type": "String"
+                    }
+                },
+                {
+                    "id": 1,
+                    "name": "roomType",
+                    "type": {
+                        "type": "Number"
+                    }
+                },
+                {
+                    "id": 2,
+                    "name": "cardId",
+                    "type": {
+                        "type": "Number"
+                    }
+                },
+                {
+                    "id": 3,
+                    "name": "cup",
+                    "type": {
+                        "type": "Number"
+                    }
+                },
+                {
+                    "id": 4,
+                    "name": "roomId",
+                    "type": {
+                        "type": "String"
+                    }
+                },
+                {
+                    "id": 5,
+                    "name": "nickName",
+                    "type": {
+                        "type": "String"
+                    }
+                },
+                {
+                    "id": 6,
+                    "name": "avatar",
+                    "type": {
+                        "type": "Number"
+                    }
+                },
+                {
+                    "id": 7,
+                    "name": "version",
+                    "type": {
+                        "type": "Number"
+                    }
+                }
+            ]
+        },
+        "PtlTestMatch/ResTestMatch": {
+            "type": "Interface",
+            "extends": [
+                {
+                    "id": 1,
+                    "type": {
+                        "type": "Reference",
+                        "target": "../../shared/base/BaseResponse"
+                    }
+                }
+            ],
+            "properties": [
+                {
+                    "id": 0,
+                    "name": "roomState",
+                    "type": {
+                        "type": "Reference",
+                        "target": "../../shared/game/state/RoomState/RoomState"
+                    }
+                },
+                {
+                    "id": 1,
+                    "name": "isRobot",
+                    "type": {
+                        "type": "Number"
+                    }
+                },
+                {
+                    "id": 2,
+                    "name": "version",
+                    "type": {
+                        "type": "Number"
+                    }
+                }
+            ]
+        },
+        "../../shared/game/state/RoomState/RoomState": {
+            "type": "Interface",
+            "properties": [
+                {
+                    "id": 0,
+                    "name": "id",
+                    "type": {
+                        "type": "String"
+                    }
+                },
+                {
+                    "id": 1,
+                    "name": "roomType",
+                    "type": {
+                        "type": "Number"
+                    }
+                },
+                {
+                    "id": 2,
+                    "name": "server",
+                    "type": {
+                        "type": "String"
+                    }
+                },
+                {
+                    "id": 3,
+                    "name": "players",
+                    "type": {
+                        "type": "Array",
+                        "elementType": {
+                            "type": "Reference",
+                            "target": "../../shared/game/state/PlayerState/PlayerState"
+                        }
+                    }
+                },
+                {
+                    "id": 4,
+                    "name": "sn",
+                    "type": {
+                        "type": "Number"
+                    }
+                },
+                {
+                    "id": 8,
+                    "name": "sendTag",
+                    "type": {
+                        "type": "Any"
+                    }
+                },
+                {
+                    "id": 7,
+                    "name": "startTime",
+                    "type": {
+                        "type": "Number"
+                    },
+                    "optional": true
+                },
+                {
+                    "id": 5,
+                    "name": "conns",
+                    "type": {
+                        "type": "Array",
+                        "elementType": {
+                            "type": "Any"
+                        }
+                    },
+                    "optional": true
+                },
+                {
+                    "id": 9,
+                    "name": "mapData",
+                    "type": {
+                        "type": "Any"
+                    },
+                    "optional": true
+                }
+            ]
+        }
+    }
+};

+ 10 - 0
assets/script/shared/protocols/ServiceProtoRoom.ts.meta

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "dfce188a-75d9-499e-ae9a-ecf16c52a06d",
+  "importer": "typescript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 13 - 0
assets/script/shared/protocols/match.meta

@@ -0,0 +1,13 @@
+{
+  "ver": "1.1.3",
+  "uuid": "6d24baea-7f9c-4ebe-8d10-f13eea6dcc50",
+  "importer": "directory",
+  "isBundle": false,
+  "bundleName": "",
+  "priority": 1,
+  "compressionType": {},
+  "optimizeHotUpdate": {},
+  "inlineSpriteFrames": {},
+  "isRemoteBundle": {},
+  "subMetas": {}
+}

+ 25 - 0
assets/script/shared/protocols/match/PtlDoMatch.ts

@@ -0,0 +1,25 @@
+
+
+import { BaseConf, BaseRequest, BaseResponse } from "../../../CookingScript/Logic/Room/base";
+import { MatchPlayerState } from "../../game/state/PlayerState";
+
+/** 开始匹配请求信息 */
+export interface ReqDoMatch extends BaseRequest {
+    version: number,
+    player: MatchPlayerState,
+    lastMatchId: string, // 上次对手id,没有发空字符串
+    roomType: number,
+}
+
+/** 开始匹配响应信息 */
+export interface ResDoMatch extends BaseResponse {
+    version: number,
+    isRobot: number,
+    players?: Array<MatchPlayerState>,
+    roomId?: string,
+    server?: string
+}
+
+export const conf: BaseConf = {
+    needLogin: true
+}

+ 10 - 0
assets/script/shared/protocols/match/PtlDoMatch.ts.meta

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "29e2f81f-4960-432a-a189-774adc1eb59b",
+  "importer": "typescript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 13 - 0
assets/script/shared/protocols/room.meta

@@ -0,0 +1,13 @@
+{
+  "ver": "1.1.3",
+  "uuid": "9318a5cb-eaef-421f-8e11-2c949c6c9eb3",
+  "importer": "directory",
+  "isBundle": false,
+  "bundleName": "",
+  "priority": 1,
+  "compressionType": {},
+  "optimizeHotUpdate": {},
+  "inlineSpriteFrames": {},
+  "isRemoteBundle": {},
+  "subMetas": {}
+}

+ 25 - 0
assets/script/shared/protocols/room/PtlRoomJoin.ts

@@ -0,0 +1,25 @@
+import { BaseRequest, BaseResponse } from "../../../CookingScript/Logic/Room/base";
+import { PlayerState } from "../../game/state/PlayerState";
+import { RoomState } from "../../game/state/RoomState";
+
+/** 加入房间 */
+export interface ReqRoomJoin extends BaseRequest {
+    playerId: string,
+    /** 房间编号 */
+    roomId: string,
+    mapData?: string,
+    sn?: number
+}
+
+export interface ResRoomJoin extends BaseResponse {
+    /** 加入房间后,自己的 ID */
+    playerId: string,
+    /** 状态同步:一次性同步当前状态 */
+    players: Array<PlayerState>,
+    mapData: string,
+    /**动作数 */
+    sn: number,
+    startTime?: number
+}
+
+// export const conf = {}

+ 10 - 0
assets/script/shared/protocols/room/PtlRoomJoin.ts.meta

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "71ecc8e4-f587-4026-be9f-e5b7e398cbfb",
+  "importer": "typescript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 14 - 0
assets/script/shared/protocols/room/PtlRoomLeave.ts

@@ -0,0 +1,14 @@
+import { BaseRequest, BaseResponse } from "../../../CookingScript/Logic/Room/base";
+
+
+/** 房间离开请求数据 */
+export interface ReqRoomLeave extends BaseRequest {
+    playerId: string,
+    /** 房间编号 */
+    roomId: string
+}
+
+/** 房间离开响应数据 */
+export interface ResRoomLeave extends BaseResponse {
+    playerId: string,
+}

+ 10 - 0
assets/script/shared/protocols/room/PtlRoomLeave.ts.meta

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "bd488a54-8b60-4971-8502-297efa9baf93",
+  "importer": "typescript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 13 - 0
assets/script/shared/protocols/room/client.meta

@@ -0,0 +1,13 @@
+{
+  "ver": "1.1.3",
+  "uuid": "5918c477-3c44-4f64-b226-1ffd09b10a3a",
+  "importer": "directory",
+  "isBundle": false,
+  "bundleName": "",
+  "priority": 1,
+  "compressionType": {},
+  "optimizeHotUpdate": {},
+  "inlineSpriteFrames": {},
+  "isRemoteBundle": {},
+  "subMetas": {}
+}

+ 6 - 0
assets/script/shared/protocols/room/client/MsgAck.ts

@@ -0,0 +1,6 @@
+
+
+
+export interface MsgAck {
+    sns: Array<number>
+}

+ 10 - 0
assets/script/shared/protocols/room/client/MsgAck.ts.meta

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "4cc79555-67ad-4262-84a9-75719151f1e6",
+  "importer": "typescript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 5 - 0
assets/script/shared/protocols/room/client/MsgGameAction.ts

@@ -0,0 +1,5 @@
+
+import { GameAction } from "../../../types/GameAction";
+
+/** 接受客户端的游戏操作数据 */
+export type MsgGameAction = GameAction

+ 10 - 0
assets/script/shared/protocols/room/client/MsgGameAction.ts.meta

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "7f3e2899-5364-4d67-b5b8-842dba6634ca",
+  "importer": "typescript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 16 - 0
assets/script/shared/protocols/room/client/MsgSyncMap.ts

@@ -0,0 +1,16 @@
+import { RoomPlayerState } from "../../../game/state/PlayerState";
+/** 同步地图数据 */
+export interface MsgSyncMap {
+    data: SyncMapData
+}
+
+export interface SyncMapData {
+    creatorQueue: Array<{ key: string, ids: Array<string> }>,
+    mapData: string,
+    players: Array<RoomPlayerState>,
+    turn: number,
+    sn: number,
+    roundTime: number,
+    round: number,
+    switchCubes: Array<{ key: string, cubeId: string }>,
+}

+ 10 - 0
assets/script/shared/protocols/room/client/MsgSyncMap.ts.meta

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "08bebdde-2f79-4394-96ad-b35e677cf861",
+  "importer": "typescript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 13 - 0
assets/script/shared/protocols/room/server.meta

@@ -0,0 +1,13 @@
+{
+  "ver": "1.1.3",
+  "uuid": "79690717-e357-4c80-9715-a10c261ea943",
+  "importer": "directory",
+  "isBundle": false,
+  "bundleName": "",
+  "priority": 1,
+  "compressionType": {},
+  "optimizeHotUpdate": {},
+  "inlineSpriteFrames": {},
+  "isRemoteBundle": {},
+  "subMetas": {}
+}

+ 6 - 0
assets/script/shared/protocols/room/server/MsgActionAck.ts

@@ -0,0 +1,6 @@
+
+
+export interface MsgActionAck {
+    sendTag: number,
+    players: any
+}

+ 10 - 0
assets/script/shared/protocols/room/server/MsgActionAck.ts.meta

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "aa4c09e8-8cf1-4f0c-9e8f-8340f892c7c6",
+  "importer": "typescript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 9 - 0
assets/script/shared/protocols/room/server/MsgGameAction.ts

@@ -0,0 +1,9 @@
+import { PlayerState } from "../../../game/state/PlayerState";
+import { GameAction } from "../../../types/GameAction";
+
+/** 服务器广播玩家控制数据 */
+export interface MsgGameAction {
+    state: GameAction,
+    sn: number,
+    players: Array<PlayerState>
+}

+ 10 - 0
assets/script/shared/protocols/room/server/MsgGameAction.ts.meta

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "2543545c-a80a-4dbc-95d0-a60c3382e1de",
+  "importer": "typescript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 5 - 0
assets/script/shared/protocols/room/server/MsgNotifySync.ts

@@ -0,0 +1,5 @@
+
+/** 同步地图数据 */
+export interface MsgNotifySync {
+    playerId: string
+}

+ 10 - 0
assets/script/shared/protocols/room/server/MsgNotifySync.ts.meta

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "15e9a248-7486-4bbf-a878-73c6a25cc816",
+  "importer": "typescript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 12 - 0
assets/script/shared/protocols/room/server/MsgPlayerJoin.ts

@@ -0,0 +1,12 @@
+import { PlayerState } from "../../../../shared/game/state/PlayerState";
+
+
+
+/** 服务器通知客户端加入房间 */
+export interface MsgPlayerJoin {
+    player: PlayerState,
+    /** 加入房间时间 */
+    time: number,
+    /**地图初始化数据 */
+    mapData?: string
+}

+ 10 - 0
assets/script/shared/protocols/room/server/MsgPlayerJoin.ts.meta

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "3f92a913-eb50-4411-8b0b-921a02e2674b",
+  "importer": "typescript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 13 - 0
assets/script/shared/types.meta

@@ -0,0 +1,13 @@
+{
+  "ver": "1.1.3",
+  "uuid": "e5a8adc4-bc2f-4697-be36-64cf7ca24c06",
+  "importer": "directory",
+  "isBundle": false,
+  "bundleName": "",
+  "priority": 1,
+  "compressionType": {},
+  "optimizeHotUpdate": {},
+  "inlineSpriteFrames": {},
+  "isRemoteBundle": {},
+  "subMetas": {}
+}

+ 22 - 0
assets/script/shared/types/GameAction.ts

@@ -0,0 +1,22 @@
+
+export class Vc3 {
+    x: number;
+    y: number;
+    z: number
+    constructor(x: number, y: number, z?: number) {
+        this.x = x;
+        this.y = y;
+        this.z = z;
+    }
+}
+
+/** 
+ * 服务端定期广播的同步帧
+ * 包含了这一段期间所有输入
+ */
+export interface GameAction {
+    type: 'GameAction',
+    playerId?: string,
+}
+
+

+ 10 - 0
assets/script/shared/types/GameAction.ts.meta

@@ -0,0 +1,10 @@
+{
+  "ver": "1.1.0",
+  "uuid": "5c9cb071-2838-4fe3-9ccb-a58718be2fb2",
+  "importer": "typescript",
+  "isPlugin": false,
+  "loadPluginInWeb": true,
+  "loadPluginInNative": true,
+  "loadPluginInEditor": false,
+  "subMetas": {}
+}

+ 106 - 2
package-lock.json

@@ -1,5 +1,5 @@
 {
-  "name": "zhetian_client",
+  "name": "ClientFrameWork",
   "lockfileVersion": 3,
   "requires": true,
   "packages": {
@@ -7,7 +7,9 @@
       "dependencies": {
         "crypto-es": "^2.1.0",
         "crypto-js": "^4.2.0",
-        "crypto.js": "^3.2.1"
+        "crypto.js": "^3.2.1",
+        "tsrpc-browser": "^3.4.16",
+        "tsrpc-miniapp": "^3.4.16"
       },
       "devDependencies": {
         "@types/crypto-js": "^4.2.2",
@@ -29,6 +31,16 @@
         "undici-types": "~5.26.4"
       }
     },
+    "node_modules/core-js": {
+      "version": "3.42.0",
+      "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.42.0.tgz",
+      "integrity": "sha512-Sz4PP4ZA+Rq4II21qkNqOEDTDrCvcANId3xpIgB34NDkWc3UduWj2dqEtN9yZIq8Dk3HyPI33x9sqqU5C8sr0g==",
+      "hasInstallScript": true,
+      "funding": {
+        "type": "opencollective",
+        "url": "https://opencollective.com/core-js"
+      }
+    },
     "node_modules/crypto-es": {
       "version": "2.1.0",
       "resolved": "https://registry.npmjs.org/crypto-es/-/crypto-es-2.1.0.tgz",
@@ -44,6 +56,98 @@
       "resolved": "https://registry.npmjs.org/crypto.js/-/crypto.js-3.2.1.tgz",
       "integrity": "sha512-sp04OVtnR7h/Z20k+dd+DbIj7zXQobcKRHHq6dG8T87Be8mHo0MIl50EdAZw9nxGKS5ykHraqIpLVNqpAE/IiQ=="
     },
+    "node_modules/k8w-extend-native": {
+      "version": "1.4.6",
+      "resolved": "https://registry.npmjs.org/k8w-extend-native/-/k8w-extend-native-1.4.6.tgz",
+      "integrity": "sha512-AHTCyFshldMme0s9FKD+QKG+QZdBkHXzl+8kYfNhsSDhcdQ5TYWQwphjecSJjxNdGd78TIbO0fHiOvM+Ei22YA==",
+      "dependencies": {
+        "k8w-linq-array": "*",
+        "k8w-super-date": "*",
+        "k8w-super-object": "*"
+      }
+    },
+    "node_modules/k8w-linq-array": {
+      "version": "0.2.8",
+      "resolved": "https://registry.npmjs.org/k8w-linq-array/-/k8w-linq-array-0.2.8.tgz",
+      "integrity": "sha512-4IAkQN8UJdk804tQi++wuwSZvFWk/Wcl1uG5PR/0c0YvB5hUd2f8tJm3OgOMOxjV9UVByNLvnPYGIwrFQPpjlA=="
+    },
+    "node_modules/k8w-super-date": {
+      "version": "0.1.3",
+      "resolved": "https://registry.npmjs.org/k8w-super-date/-/k8w-super-date-0.1.3.tgz",
+      "integrity": "sha512-IBqKOAMAXR/bgzu+rYI30tEMP/Y6Q8HQuqJiTkE2mLJg11yok9guoi8uZTynTahviVBndcfBpOgi1H/zhihv7w=="
+    },
+    "node_modules/k8w-super-object": {
+      "version": "0.3.0",
+      "resolved": "https://registry.npmjs.org/k8w-super-object/-/k8w-super-object-0.3.0.tgz",
+      "integrity": "sha512-u2jfh4goYXKZmSucaLaOTaNbLRatjv0CSRpzE0KU0732+9XtYZFd5vrdw/mzJfK5fPHb/zyikOSHDX5mJrav+g=="
+    },
+    "node_modules/tsbuffer": {
+      "version": "2.2.10",
+      "resolved": "https://registry.npmjs.org/tsbuffer/-/tsbuffer-2.2.10.tgz",
+      "integrity": "sha512-3+lICDlKm2lLxmFPzvh4hu+aHA//a0D7OWyOP2BX5JMvlOBCaFbsVfyvyb14XIG3iL5voYQ2Qrc2qAc+ec5tbA==",
+      "dependencies": {
+        "k8w-extend-native": "^1.4.6",
+        "tsbuffer-validator": "^2.1.2",
+        "tslib": "*"
+      }
+    },
+    "node_modules/tsbuffer-schema": {
+      "version": "2.2.0",
+      "resolved": "https://registry.npmjs.org/tsbuffer-schema/-/tsbuffer-schema-2.2.0.tgz",
+      "integrity": "sha512-I4+5Xfk7G+D++kXdNnYTeY26WQTaf14C84XQwPKteNmrwxRY3CQCkMqASRiCUqtpOuDn43qmoxuXpT+Vo8Wltg=="
+    },
+    "node_modules/tsbuffer-validator": {
+      "version": "2.1.2",
+      "resolved": "https://registry.npmjs.org/tsbuffer-validator/-/tsbuffer-validator-2.1.2.tgz",
+      "integrity": "sha512-PrqIYy7aANY7ssr92HJN8ZM+eGc4Qmpvu7nNBv+T2DOAb+eqblKjlDZEhNnzxjs/ddqu9PqPe4Aa+fqYdzo98g==",
+      "dependencies": {
+        "k8w-extend-native": "^1.4.6",
+        "tsbuffer-schema": "^2.2.0",
+        "tslib": "*"
+      }
+    },
+    "node_modules/tslib": {
+      "version": "2.8.1",
+      "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
+      "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w=="
+    },
+    "node_modules/tsrpc-base-client": {
+      "version": "2.1.15",
+      "resolved": "https://registry.npmjs.org/tsrpc-base-client/-/tsrpc-base-client-2.1.15.tgz",
+      "integrity": "sha512-ejIsGKF1MtcS2Mqpv1JYjoOmFbkOMaubb0FYglA52Sfl0glnq2UAqbCu5embQISzuIF9DiDeg1Rui9EyOc2hdA==",
+      "dependencies": {
+        "k8w-extend-native": "^1.4.6",
+        "tsbuffer": "^2.2.9",
+        "tslib": "*",
+        "tsrpc-proto": "^1.4.3"
+      }
+    },
+    "node_modules/tsrpc-browser": {
+      "version": "3.4.16",
+      "resolved": "https://registry.npmjs.org/tsrpc-browser/-/tsrpc-browser-3.4.16.tgz",
+      "integrity": "sha512-qitOxgVi8oj6SG4MyQeaOuvhuV3MFvVoF+hqIoTWr0xoD1/wBFieboVoXo54ykChDi9BQ8LSIdquaFqdTznf3A==",
+      "dependencies": {
+        "core-js": "*",
+        "tsrpc-base-client": "^2.1.15"
+      }
+    },
+    "node_modules/tsrpc-miniapp": {
+      "version": "3.4.16",
+      "resolved": "https://registry.npmjs.org/tsrpc-miniapp/-/tsrpc-miniapp-3.4.16.tgz",
+      "integrity": "sha512-r8ASM/TysN3jYpMJfe7dS2KvGuyBzwCbYpp4Di+FdodrA0nV/V7C6p0fQNzc7KG7Ucl2L8BYPzKfF6xZ4dlUiA==",
+      "dependencies": {
+        "tsrpc-base-client": "^2.1.15"
+      }
+    },
+    "node_modules/tsrpc-proto": {
+      "version": "1.4.3",
+      "resolved": "https://registry.npmjs.org/tsrpc-proto/-/tsrpc-proto-1.4.3.tgz",
+      "integrity": "sha512-qtkk5i34m9/K1258EdyXAEikU/ADPELHCCXN/oFJ4XwH+kN3kXnKYmwCDblUuMA73V2+A/EwkgUGyAgPa335Hw==",
+      "dependencies": {
+        "tsbuffer-schema": "^2.2.0",
+        "tslib": "*"
+      }
+    },
     "node_modules/undici-types": {
       "version": "5.26.5",
       "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",

+ 3 - 1
package.json

@@ -6,6 +6,8 @@
   "dependencies": {
     "crypto-es": "^2.1.0",
     "crypto-js": "^4.2.0",
-    "crypto.js": "^3.2.1"
+    "crypto.js": "^3.2.1",
+    "tsrpc-browser": "^3.4.16",
+    "tsrpc-miniapp": "^3.4.16"
   }
 }