diff --git a/examples/cocos-creator-multiplayer/backend/src/models/Room.ts b/examples/cocos-creator-multiplayer/backend/src/models/Room.ts index 3937a64..3e6b1b0 100644 --- a/examples/cocos-creator-multiplayer/backend/src/models/Room.ts +++ b/examples/cocos-creator-multiplayer/backend/src/models/Room.ts @@ -68,7 +68,7 @@ export class Room { }); // TimePast - let now = process.uptime(); + let now = process.uptime() * 1000; this.applyInput({ type: 'TimePast', dt: now - (this.lastSyncTime ?? now) diff --git a/examples/cocos-creator-multiplayer/backend/src/shared/game/GameSystem.ts b/examples/cocos-creator-multiplayer/backend/src/shared/game/GameSystem.ts index 2c4bba0..6a4621a 100644 --- a/examples/cocos-creator-multiplayer/backend/src/shared/game/GameSystem.ts +++ b/examples/cocos-creator-multiplayer/backend/src/shared/game/GameSystem.ts @@ -5,7 +5,7 @@ import { PlayerState } from "./state/PlayerState"; export interface GameSystemState { now: number, players: PlayerState[], - arrow: ArrowState[], + arrows: ArrowState[], nextArrowId: number } @@ -15,7 +15,7 @@ export class GameSystem { private _state: GameSystemState = { now: 0, players: [], - arrow: [], + arrows: [], nextArrowId: 1 } get state(): Readonly { @@ -43,7 +43,7 @@ export class GameSystem { else if (input.type === 'PlayerAttack') { let player = this._state.players.find(v => v.id === input.playerId); if (player) { - this._state.arrow.push({ + this._state.arrows.push({ id: this._state.nextArrowId++, fromPlayerId: input.playerId, startPos: { ...player.pos }, @@ -69,11 +69,16 @@ export class GameSystem { this._state.now += input.dt; // 落地的 Arrow - for (let i = this._state.arrow.length - 1; i > -1; --i) { - let arrow = this._state.arrow[i]; + for (let i = this._state.arrows.length - 1; i > -1; --i) { + let arrow = this._state.arrows[i]; if (arrow.targetTime <= this._state.now) { // 伤害判定 let damagedPlayers = this._state.players.filter(v => { + // 不能伤害自己 + if (v.id === arrow.fromPlayerId) { + return false; + } + return (v.pos.x - arrow.targetPos.x) * (v.pos.x - arrow.targetPos.x) + (v.pos.y - arrow.targetPos.y) * (v.pos.y - arrow.targetPos.y) <= gameConfig.arrowDistance * gameConfig.arrowDistance }); damagedPlayers.forEach(p => { @@ -86,6 +91,7 @@ export class GameSystem { toPlayerId: p.id })) }) + this._state.arrows.splice(i, 1); } } } diff --git a/examples/cocos-creator-multiplayer/backend/src/shared/game/gameConfig.ts b/examples/cocos-creator-multiplayer/backend/src/shared/game/gameConfig.ts index 4068dfd..9f6b124 100644 --- a/examples/cocos-creator-multiplayer/backend/src/shared/game/gameConfig.ts +++ b/examples/cocos-creator-multiplayer/backend/src/shared/game/gameConfig.ts @@ -8,7 +8,7 @@ export const gameConfig = { moveSpeed: 10, - arrowFlyTime: 1000, - arrowDistance: 2, + arrowFlyTime: 500, + arrowDistance: 7, arrowDizzyTime: 1000 } \ No newline at end of file diff --git a/examples/cocos-creator-multiplayer/backend/src/shared/protocols/serviceProto.ts b/examples/cocos-creator-multiplayer/backend/src/shared/protocols/serviceProto.ts index fc9b4ff..cf61964 100644 --- a/examples/cocos-creator-multiplayer/backend/src/shared/protocols/serviceProto.ts +++ b/examples/cocos-creator-multiplayer/backend/src/shared/protocols/serviceProto.ts @@ -17,6 +17,7 @@ export interface ServiceType { } export const serviceProto: ServiceProto = { + "version": 1, "services": [ { "id": 0, @@ -227,8 +228,8 @@ export const serviceProto: ServiceProto = { } }, { - "id": 2, - "name": "arrow", + "id": 4, + "name": "arrows", "type": { "type": "Array", "elementType": { diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier.meta b/examples/cocos-creator-multiplayer/frontend/assets/3d/javalin_weapon.meta similarity index 77% rename from examples/cocos-creator-multiplayer/frontend/assets/3d/soldier.meta rename to examples/cocos-creator-multiplayer/frontend/assets/3d/javalin_weapon.meta index 4058be8..4457476 100644 --- a/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier.meta +++ b/examples/cocos-creator-multiplayer/frontend/assets/3d/javalin_weapon.meta @@ -2,7 +2,7 @@ "ver": "1.1.0", "importer": "directory", "imported": true, - "uuid": "b62bf789-093f-4583-8530-86e00cd8a2a6", + "uuid": "d739d6a2-6087-4eb8-992d-7782bb91ca03", "files": [], "subMetas": {}, "userData": { diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/mat_soldier.mtl b/examples/cocos-creator-multiplayer/frontend/assets/3d/javalin_weapon/blue.mtl similarity index 89% rename from examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/mat_soldier.mtl rename to examples/cocos-creator-multiplayer/frontend/assets/3d/javalin_weapon/blue.mtl index e7a8289..d3ed79a 100644 --- a/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/mat_soldier.mtl +++ b/examples/cocos-creator-multiplayer/frontend/assets/3d/javalin_weapon/blue.mtl @@ -27,7 +27,7 @@ "_props": [ { "mainTexture": { - "__uuid__": "e90ad74a-b668-4e2c-bf91-51a2a91b02aa@6c48a", + "__uuid__": "81f16ace-2b57-44c3-804d-c192ed53aaee@6c48a", "__expectedType__": "cc.Texture2D" } } diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/mat_soldier.mtl.meta b/examples/cocos-creator-multiplayer/frontend/assets/3d/javalin_weapon/blue.mtl.meta similarity index 72% rename from examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/mat_soldier.mtl.meta rename to examples/cocos-creator-multiplayer/frontend/assets/3d/javalin_weapon/blue.mtl.meta index 1e1c27c..89cf9c3 100644 --- a/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/mat_soldier.mtl.meta +++ b/examples/cocos-creator-multiplayer/frontend/assets/3d/javalin_weapon/blue.mtl.meta @@ -2,7 +2,7 @@ "ver": "1.0.9", "importer": "material", "imported": true, - "uuid": "5cf1ff47-b589-490a-bc78-a88f743b9798", + "uuid": "034d148f-998d-453d-baed-7ebbea501d20", "files": [ ".json" ], diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/javalin_weapon/javelin.FBX b/examples/cocos-creator-multiplayer/frontend/assets/3d/javalin_weapon/javelin.FBX new file mode 100644 index 0000000..351926f Binary files /dev/null and b/examples/cocos-creator-multiplayer/frontend/assets/3d/javalin_weapon/javelin.FBX differ diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/javalin_weapon/javelin.FBX.meta b/examples/cocos-creator-multiplayer/frontend/assets/3d/javalin_weapon/javelin.FBX.meta new file mode 100644 index 0000000..db5df03 --- /dev/null +++ b/examples/cocos-creator-multiplayer/frontend/assets/3d/javalin_weapon/javelin.FBX.meta @@ -0,0 +1,123 @@ +{ + "ver": "2.1.4", + "importer": "fbx", + "imported": true, + "uuid": "401c28d6-3085-4209-9f2e-3aff6da5855c", + "files": [], + "subMetas": { + "035c0": { + "importer": "gltf-mesh", + "uuid": "401c28d6-3085-4209-9f2e-3aff6da5855c@035c0", + "displayName": "", + "id": "035c0", + "name": "对象001.mesh", + "userData": { + "gltfIndex": 0 + }, + "ver": "1.1.0", + "imported": true, + "files": [ + ".bin", + ".json" + ], + "subMetas": {} + }, + "1cdc4": { + "importer": "gltf-embeded-image", + "uuid": "401c28d6-3085-4209-9f2e-3aff6da5855c@1cdc4", + "displayName": "", + "id": "1cdc4", + "name": "贴图 #3.image", + "userData": { + "gltfIndex": 0 + }, + "ver": "1.0.3", + "imported": true, + "files": [ + ".png", + ".json" + ], + "subMetas": {} + }, + "bfae8": { + "importer": "texture", + "uuid": "401c28d6-3085-4209-9f2e-3aff6da5855c@bfae8", + "displayName": "", + "id": "bfae8", + "name": "贴图 #3.texture", + "userData": { + "wrapModeS": "repeat", + "wrapModeT": "repeat", + "minfilter": "linear", + "magfilter": "linear", + "mipfilter": "none", + "anisotropy": 0, + "isUuid": true, + "imageUuidOrDatabaseUri": "401c28d6-3085-4209-9f2e-3aff6da5855c@1cdc4" + }, + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {} + }, + "b1faf": { + "importer": "gltf-material", + "uuid": "401c28d6-3085-4209-9f2e-3aff6da5855c@b1faf", + "displayName": "", + "id": "b1faf", + "name": "Material #3.material", + "userData": { + "gltfIndex": 0 + }, + "ver": "1.0.14", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {} + }, + "5c1a1": { + "importer": "gltf-scene", + "uuid": "401c28d6-3085-4209-9f2e-3aff6da5855c@5c1a1", + "displayName": "", + "id": "5c1a1", + "name": "javelin.prefab", + "userData": { + "gltfIndex": 0 + }, + "ver": "1.0.12", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {} + } + }, + "userData": { + "imageMetas": [ + { + "name": "贴图 #3", + "uri": "401c28d6-3085-4209-9f2e-3aff6da5855c@1cdc4" + } + ], + "redirect": "401c28d6-3085-4209-9f2e-3aff6da5855c@5c1a1", + "assetFinder": { + "meshes": [ + "401c28d6-3085-4209-9f2e-3aff6da5855c@035c0" + ], + "skeletons": [], + "textures": [ + "401c28d6-3085-4209-9f2e-3aff6da5855c@bfae8" + ], + "materials": [ + "401c28d6-3085-4209-9f2e-3aff6da5855c@b1faf" + ], + "scenes": [ + "401c28d6-3085-4209-9f2e-3aff6da5855c@5c1a1" + ] + }, + "legacyFbxImporter": true + } +} diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/yellow.mtl b/examples/cocos-creator-multiplayer/frontend/assets/3d/javalin_weapon/red.mtl similarity index 52% rename from examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/yellow.mtl rename to examples/cocos-creator-multiplayer/frontend/assets/3d/javalin_weapon/red.mtl index 9b85b72..8818585 100644 --- a/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/yellow.mtl +++ b/examples/cocos-creator-multiplayer/frontend/assets/3d/javalin_weapon/red.mtl @@ -4,34 +4,32 @@ "_objFlags": 0, "_native": "", "_effectAsset": { - "__uuid__": "1baf0fc9-befa-459c-8bdd-af1a450a0319" + "__uuid__": "a3cd009f-0ab0-420d-9278-b9fdab939bbc", + "__expectedType__": "cc.EffectAsset" }, "_techIdx": 0, "_defines": [ { - "USE_SKINNING": 2, - "USE_ALBEDO_MAP": true + "USE_TEXTURE": true } ], "_states": [ { + "rasterizerState": {}, + "depthStencilState": {}, "blendState": { "targets": [ {} ] - }, - "depthStencilState": {}, - "rasterizerState": {} + } } ], "_props": [ { - "alphaThreshold": 0, - "roughness": 0.70710676908493, - "metallic": 0.400000005960464, "mainTexture": { - "__uuid__": "8b8d74a3-bdf7-4c4d-8334-2cb7e0f7bf88@6c48a" + "__uuid__": "8b29322f-dd78-4a56-98d7-b3d60e2d8a84@6c48a", + "__expectedType__": "cc.Texture2D" } } ] -} +} \ No newline at end of file diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/javalin_weapon/red.mtl.meta b/examples/cocos-creator-multiplayer/frontend/assets/3d/javalin_weapon/red.mtl.meta new file mode 100644 index 0000000..f0802cf --- /dev/null +++ b/examples/cocos-creator-multiplayer/frontend/assets/3d/javalin_weapon/red.mtl.meta @@ -0,0 +1,11 @@ +{ + "ver": "1.0.9", + "importer": "material", + "imported": true, + "uuid": "5d9da4c3-349b-4309-8efe-7c16bffd5ed4", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/javalin_weapon/yellow.mtl b/examples/cocos-creator-multiplayer/frontend/assets/3d/javalin_weapon/yellow.mtl new file mode 100644 index 0000000..b8f2da7 --- /dev/null +++ b/examples/cocos-creator-multiplayer/frontend/assets/3d/javalin_weapon/yellow.mtl @@ -0,0 +1,48 @@ +{ + "__type__": "cc.Material", + "_name": "", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "1baf0fc9-befa-459c-8bdd-af1a450a0319", + "__expectedType__": "cc.EffectAsset" + }, + "_techIdx": 0, + "_defines": [ + { + "USE_INSTANCING": true, + "USE_ALBEDO_MAP": true + }, + {}, + {}, + {} + ], + "_states": [ + { + "rasterizerState": {}, + "depthStencilState": {}, + "blendState": { + "targets": [ + {} + ] + } + }, + {}, + {}, + {} + ], + "_props": [ + { + "alphaThreshold": 0, + "roughness": 0.333333402872086, + "metallic": 0.400000005960464, + "mainTexture": { + "__uuid__": "00463b4b-2098-43bf-ab0f-75d68a7b19aa@6c48a", + "__expectedType__": "cc.Texture2D" + } + }, + {}, + {}, + {} + ] +} diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/yellow.mtl.meta b/examples/cocos-creator-multiplayer/frontend/assets/3d/javalin_weapon/yellow.mtl.meta similarity index 72% rename from examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/yellow.mtl.meta rename to examples/cocos-creator-multiplayer/frontend/assets/3d/javalin_weapon/yellow.mtl.meta index a407fcd..93e4645 100644 --- a/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/yellow.mtl.meta +++ b/examples/cocos-creator-multiplayer/frontend/assets/3d/javalin_weapon/yellow.mtl.meta @@ -2,7 +2,7 @@ "ver": "1.0.9", "importer": "material", "imported": true, - "uuid": "5620e8a2-444d-4e80-9eb8-f6f54bd4d3cf", + "uuid": "75328980-c98c-4c02-ab3d-180696f319a0", "files": [ ".json" ], diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin.meta b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin.meta new file mode 100644 index 0000000..bec29ee --- /dev/null +++ b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.0", + "importer": "directory", + "imported": true, + "uuid": "ec996a75-19b5-4c0c-a9cd-f493a945a73e", + "files": [], + "subMetas": {}, + "userData": { + "compressionType": {}, + "isRemoteBundle": {} + } +} diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/Materials_javelin01.meta b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/Materials_javelin01.meta new file mode 100644 index 0000000..5d77048 --- /dev/null +++ b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/Materials_javelin01.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.0", + "importer": "directory", + "imported": true, + "uuid": "9ca73d01-a6f2-4dc2-b7d7-658d9d101d8c", + "files": [], + "subMetas": {}, + "userData": { + "compressionType": {}, + "isRemoteBundle": {} + } +} diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/Materials_javelin01/Material #6.mtl b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/Materials_javelin01/Material #6.mtl new file mode 100644 index 0000000..d3ed79a --- /dev/null +++ b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/Materials_javelin01/Material #6.mtl @@ -0,0 +1,35 @@ +{ + "__type__": "cc.Material", + "_name": "", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "a3cd009f-0ab0-420d-9278-b9fdab939bbc", + "__expectedType__": "cc.EffectAsset" + }, + "_techIdx": 0, + "_defines": [ + { + "USE_TEXTURE": true + } + ], + "_states": [ + { + "rasterizerState": {}, + "depthStencilState": {}, + "blendState": { + "targets": [ + {} + ] + } + } + ], + "_props": [ + { + "mainTexture": { + "__uuid__": "81f16ace-2b57-44c3-804d-c192ed53aaee@6c48a", + "__expectedType__": "cc.Texture2D" + } + } + ] +} \ No newline at end of file diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/Materials_javelin01/Material #6.mtl.meta b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/Materials_javelin01/Material #6.mtl.meta new file mode 100644 index 0000000..00d5ea2 --- /dev/null +++ b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/Materials_javelin01/Material #6.mtl.meta @@ -0,0 +1,11 @@ +{ + "ver": "1.0.9", + "importer": "material", + "imported": true, + "uuid": "196eebe8-170f-4ba9-a767-9f6d664c6e04", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/blue.mtl b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/blue.mtl new file mode 100644 index 0000000..c0a81dc --- /dev/null +++ b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/blue.mtl @@ -0,0 +1,48 @@ +{ + "__type__": "cc.Material", + "_name": "", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "1baf0fc9-befa-459c-8bdd-af1a450a0319", + "__expectedType__": "cc.EffectAsset" + }, + "_techIdx": 0, + "_defines": [ + { + "USE_INSTANCING": true, + "USE_ALBEDO_MAP": true + }, + {}, + {}, + {} + ], + "_states": [ + { + "rasterizerState": {}, + "depthStencilState": {}, + "blendState": { + "targets": [ + {} + ] + } + }, + {}, + {}, + {} + ], + "_props": [ + { + "alphaThreshold": 0, + "roughness": 0.30360022187233, + "metallic": 0.400000005960464, + "mainTexture": { + "__uuid__": "81f16ace-2b57-44c3-804d-c192ed53aaee@6c48a", + "__expectedType__": "cc.Texture2D" + } + }, + {}, + {}, + {} + ] +} diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/blue.mtl.meta b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/blue.mtl.meta new file mode 100644 index 0000000..b709d76 --- /dev/null +++ b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/blue.mtl.meta @@ -0,0 +1,11 @@ +{ + "ver": "1.0.9", + "importer": "material", + "imported": true, + "uuid": "c2e9d35e-0f85-4427-9368-096fe7b303d6", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/javelin01.FBX b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/javelin01.FBX new file mode 100644 index 0000000..f865647 Binary files /dev/null and b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/javelin01.FBX differ diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/soldier01.FBX.meta b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/javelin01.FBX.meta similarity index 73% rename from examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/soldier01.FBX.meta rename to examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/javelin01.FBX.meta index 97046ae..397910f 100644 --- a/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/soldier01.FBX.meta +++ b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/javelin01.FBX.meta @@ -2,33 +2,17 @@ "ver": "2.1.4", "importer": "fbx", "imported": true, - "uuid": "57d4c4ef-3199-4596-bf79-7c065964ca9c", + "uuid": "e8fe9966-5f03-4cc0-ad69-01d536be6c21", "files": [ "__original-animation-0.cconb" ], "subMetas": { - "95953": { - "importer": "gltf-material", - "uuid": "57d4c4ef-3199-4596-bf79-7c065964ca9c@95953", - "displayName": "", - "id": "95953", - "name": "Material #7.material", - "userData": { - "gltfIndex": 0 - }, - "ver": "1.0.14", - "imported": true, - "files": [ - ".json" - ], - "subMetas": {} - }, - "6868c": { + "2ed96": { "importer": "gltf-mesh", - "uuid": "57d4c4ef-3199-4596-bf79-7c065964ca9c@6868c", + "uuid": "e8fe9966-5f03-4cc0-ad69-01d536be6c21@2ed96", "displayName": "", - "id": "6868c", - "name": "soldier01.mesh", + "id": "2ed96", + "name": "javelin01.mesh", "userData": { "gltfIndex": 0 }, @@ -42,7 +26,7 @@ }, "1f586": { "importer": "gltf-animation", - "uuid": "57d4c4ef-3199-4596-bf79-7c065964ca9c@1f586", + "uuid": "e8fe9966-5f03-4cc0-ad69-01d536be6c21@1f586", "displayName": "", "id": "1f586", "name": "idle.animation", @@ -65,7 +49,7 @@ }, "cf5ee": { "importer": "gltf-animation", - "uuid": "57d4c4ef-3199-4596-bf79-7c065964ca9c@cf5ee", + "uuid": "e8fe9966-5f03-4cc0-ad69-01d536be6c21@cf5ee", "displayName": "", "id": "cf5ee", "name": "run.animation", @@ -88,7 +72,7 @@ }, "989ed": { "importer": "gltf-animation", - "uuid": "57d4c4ef-3199-4596-bf79-7c065964ca9c@989ed", + "uuid": "e8fe9966-5f03-4cc0-ad69-01d536be6c21@989ed", "displayName": "", "id": "989ed", "name": "attack.animation", @@ -102,12 +86,12 @@ }, "events": [ { - "frame": 0.23333333333333334, + "frame": 0.3, "func": "", "params": [] }, { - "frame": 0.23333333333333334, + "frame": 0.3, "func": "triggerEffect", "params": [] } @@ -123,7 +107,7 @@ }, "ee525": { "importer": "gltf-animation", - "uuid": "57d4c4ef-3199-4596-bf79-7c065964ca9c@ee525", + "uuid": "e8fe9966-5f03-4cc0-ad69-01d536be6c21@ee525", "displayName": "", "id": "ee525", "name": "win.animation", @@ -146,7 +130,7 @@ }, "5b2e9": { "importer": "gltf-animation", - "uuid": "57d4c4ef-3199-4596-bf79-7c065964ca9c@5b2e9", + "uuid": "e8fe9966-5f03-4cc0-ad69-01d536be6c21@5b2e9", "displayName": "", "id": "5b2e9", "name": "died.animation", @@ -156,7 +140,7 @@ "sample": 30, "span": { "from": 2.8, - "to": 4.333333333333333 + "to": 4.125 }, "events": [] }, @@ -169,7 +153,7 @@ }, "438fe": { "importer": "gltf-skeleton", - "uuid": "57d4c4ef-3199-4596-bf79-7c065964ca9c@438fe", + "uuid": "e8fe9966-5f03-4cc0-ad69-01d536be6c21@438fe", "displayName": "", "id": "438fe", "name": "UnnamedSkeleton.skeleton", @@ -184,12 +168,12 @@ ], "subMetas": {} }, - "fa1d4": { + "ab717": { "importer": "gltf-embeded-image", - "uuid": "57d4c4ef-3199-4596-bf79-7c065964ca9c@fa1d4", + "uuid": "e8fe9966-5f03-4cc0-ad69-01d536be6c21@ab717", "displayName": "", - "id": "fa1d4", - "name": "soldier01.jpg.image", + "id": "ab717", + "name": "javelin01.jpg.image", "userData": { "gltfIndex": 0 }, @@ -201,12 +185,12 @@ ], "subMetas": {} }, - "291d4": { + "eb794": { "importer": "texture", - "uuid": "57d4c4ef-3199-4596-bf79-7c065964ca9c@291d4", + "uuid": "e8fe9966-5f03-4cc0-ad69-01d536be6c21@eb794", "displayName": "", - "id": "291d4", - "name": "贴图 #6.texture", + "id": "eb794", + "name": "贴图 #5.texture", "userData": { "wrapModeS": "repeat", "wrapModeT": "repeat", @@ -215,7 +199,7 @@ "mipfilter": "none", "anisotropy": 0, "isUuid": true, - "imageUuidOrDatabaseUri": "57d4c4ef-3199-4596-bf79-7c065964ca9c@fa1d4" + "imageUuidOrDatabaseUri": "e8fe9966-5f03-4cc0-ad69-01d536be6c21@ab717" }, "ver": "1.0.21", "imported": true, @@ -224,12 +208,28 @@ ], "subMetas": {} }, - "33dba": { - "importer": "gltf-scene", - "uuid": "57d4c4ef-3199-4596-bf79-7c065964ca9c@33dba", + "a47c6": { + "importer": "gltf-material", + "uuid": "e8fe9966-5f03-4cc0-ad69-01d536be6c21@a47c6", "displayName": "", - "id": "33dba", - "name": "soldier01.prefab", + "id": "a47c6", + "name": "Material #6.material", + "userData": { + "gltfIndex": 0 + }, + "ver": "1.0.14", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {} + }, + "665d9": { + "importer": "gltf-scene", + "uuid": "e8fe9966-5f03-4cc0-ad69-01d536be6c21@665d9", + "displayName": "", + "id": "665d9", + "name": "javelin01.prefab", "userData": { "gltfIndex": 0 }, @@ -244,14 +244,14 @@ "userData": { "imageMetas": [ { - "name": "soldier01.jpg", - "uri": "57d4c4ef-3199-4596-bf79-7c065964ca9c@fa1d4" + "name": "javelin01.jpg", + "uri": "e8fe9966-5f03-4cc0-ad69-01d536be6c21@ab717" } ], "animationImportSettings": [ { "name": "Take 001", - "duration": 4.666666507720947, + "duration": 4.125, "fps": 30, "splits": [ { @@ -281,30 +281,32 @@ { "name": "died", "from": 2.8, - "to": 4.333333333333333, + "to": 4.125, "wrapMode": 2 } ] } ], - "redirect": "57d4c4ef-3199-4596-bf79-7c065964ca9c@33dba", + "redirect": "e8fe9966-5f03-4cc0-ad69-01d536be6c21@665d9", "assetFinder": { "meshes": [ - "57d4c4ef-3199-4596-bf79-7c065964ca9c@6868c" + "e8fe9966-5f03-4cc0-ad69-01d536be6c21@2ed96" ], "skeletons": [ - "57d4c4ef-3199-4596-bf79-7c065964ca9c@438fe" + "e8fe9966-5f03-4cc0-ad69-01d536be6c21@438fe" ], "textures": [ - "57d4c4ef-3199-4596-bf79-7c065964ca9c@291d4" + "e8fe9966-5f03-4cc0-ad69-01d536be6c21@eb794" ], "materials": [ - "57d4c4ef-3199-4596-bf79-7c065964ca9c@95953" + "e8fe9966-5f03-4cc0-ad69-01d536be6c21@a47c6" ], "scenes": [ - "57d4c4ef-3199-4596-bf79-7c065964ca9c@33dba" + "e8fe9966-5f03-4cc0-ad69-01d536be6c21@665d9" ] }, - "legacyFbxImporter": true + "dumpMaterials": false, + "legacyFbxImporter": true, + "materialDumpDir": "db://assets/resources/subPackage/model/javelin/Materials_javelin01" } } diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/javelin01.jpg b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/javelin01.jpg new file mode 100644 index 0000000..4ac7d1a Binary files /dev/null and b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/javelin01.jpg differ diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/soldier01.jpg.meta b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/javelin01.jpg.meta similarity index 70% rename from examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/soldier01.jpg.meta rename to examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/javelin01.jpg.meta index 7007391..a3aacd5 100644 --- a/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/soldier01.jpg.meta +++ b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/javelin01.jpg.meta @@ -2,7 +2,7 @@ "ver": "1.0.21", "importer": "image", "imported": true, - "uuid": "e90ad74a-b668-4e2c-bf91-51a2a91b02aa", + "uuid": "81f16ace-2b57-44c3-804d-c192ed53aaee", "files": [ ".jpg", ".json" @@ -11,7 +11,7 @@ "6c48a": { "ver": "1.0.21", "importer": "texture", - "uuid": "e90ad74a-b668-4e2c-bf91-51a2a91b02aa@6c48a", + "uuid": "81f16ace-2b57-44c3-804d-c192ed53aaee@6c48a", "imported": true, "files": [ ".json" @@ -26,16 +26,16 @@ "premultiplyAlpha": false, "anisotropy": 0, "isUuid": true, - "imageUuidOrDatabaseUri": "e90ad74a-b668-4e2c-bf91-51a2a91b02aa" + "imageUuidOrDatabaseUri": "81f16ace-2b57-44c3-804d-c192ed53aaee" }, - "displayName": "soldier01", + "displayName": "javelin01", "id": "6c48a", "name": "texture" } }, "userData": { "type": "texture", - "redirect": "e90ad74a-b668-4e2c-bf91-51a2a91b02aa@6c48a", + "redirect": "81f16ace-2b57-44c3-804d-c192ed53aaee@6c48a", "hasAlpha": false } } diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/javelin02.jpg b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/javelin02.jpg new file mode 100644 index 0000000..6185c7e Binary files /dev/null and b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/javelin02.jpg differ diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/soldier02.jpg.meta b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/javelin02.jpg.meta similarity index 70% rename from examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/soldier02.jpg.meta rename to examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/javelin02.jpg.meta index 5fbe7f7..ad2c95a 100644 --- a/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/soldier02.jpg.meta +++ b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/javelin02.jpg.meta @@ -2,7 +2,7 @@ "ver": "1.0.21", "importer": "image", "imported": true, - "uuid": "f35bcb71-cd72-443c-94a9-5482c2d63d66", + "uuid": "8b29322f-dd78-4a56-98d7-b3d60e2d8a84", "files": [ ".jpg", ".json" @@ -11,7 +11,7 @@ "6c48a": { "ver": "1.0.21", "importer": "texture", - "uuid": "f35bcb71-cd72-443c-94a9-5482c2d63d66@6c48a", + "uuid": "8b29322f-dd78-4a56-98d7-b3d60e2d8a84@6c48a", "imported": true, "files": [ ".json" @@ -26,16 +26,16 @@ "premultiplyAlpha": false, "anisotropy": 0, "isUuid": true, - "imageUuidOrDatabaseUri": "f35bcb71-cd72-443c-94a9-5482c2d63d66" + "imageUuidOrDatabaseUri": "8b29322f-dd78-4a56-98d7-b3d60e2d8a84" }, - "displayName": "soldier02", + "displayName": "javelin02", "id": "6c48a", "name": "texture" } }, "userData": { "type": "texture", - "redirect": "f35bcb71-cd72-443c-94a9-5482c2d63d66@6c48a", + "redirect": "8b29322f-dd78-4a56-98d7-b3d60e2d8a84@6c48a", "hasAlpha": false } } diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/javelin03.jpg b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/javelin03.jpg new file mode 100644 index 0000000..eee1aca Binary files /dev/null and b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/javelin03.jpg differ diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/soldier03.jpg.meta b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/javelin03.jpg.meta similarity index 70% rename from examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/soldier03.jpg.meta rename to examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/javelin03.jpg.meta index 9f25815..b0258fa 100644 --- a/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/soldier03.jpg.meta +++ b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/javelin03.jpg.meta @@ -2,7 +2,7 @@ "ver": "1.0.21", "importer": "image", "imported": true, - "uuid": "8b8d74a3-bdf7-4c4d-8334-2cb7e0f7bf88", + "uuid": "00463b4b-2098-43bf-ab0f-75d68a7b19aa", "files": [ ".jpg", ".json" @@ -11,7 +11,7 @@ "6c48a": { "ver": "1.0.21", "importer": "texture", - "uuid": "8b8d74a3-bdf7-4c4d-8334-2cb7e0f7bf88@6c48a", + "uuid": "00463b4b-2098-43bf-ab0f-75d68a7b19aa@6c48a", "imported": true, "files": [ ".json" @@ -26,16 +26,16 @@ "premultiplyAlpha": false, "anisotropy": 0, "isUuid": true, - "imageUuidOrDatabaseUri": "8b8d74a3-bdf7-4c4d-8334-2cb7e0f7bf88" + "imageUuidOrDatabaseUri": "00463b4b-2098-43bf-ab0f-75d68a7b19aa" }, - "displayName": "soldier03", + "displayName": "javelin03", "id": "6c48a", "name": "texture" } }, "userData": { "type": "texture", - "redirect": "8b8d74a3-bdf7-4c4d-8334-2cb7e0f7bf88@6c48a", + "redirect": "00463b4b-2098-43bf-ab0f-75d68a7b19aa@6c48a", "hasAlpha": false } } diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/red.mtl b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/red.mtl new file mode 100644 index 0000000..3473823 --- /dev/null +++ b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/red.mtl @@ -0,0 +1,48 @@ +{ + "__type__": "cc.Material", + "_name": "", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "1baf0fc9-befa-459c-8bdd-af1a450a0319", + "__expectedType__": "cc.EffectAsset" + }, + "_techIdx": 0, + "_defines": [ + { + "USE_INSTANCING": true, + "USE_ALBEDO_MAP": true + }, + {}, + {}, + {} + ], + "_states": [ + { + "rasterizerState": {}, + "depthStencilState": {}, + "blendState": { + "targets": [ + {} + ] + } + }, + {}, + {}, + {} + ], + "_props": [ + { + "alphaThreshold": 0, + "roughness": 0.30360022187233, + "metallic": 0.400000005960464, + "mainTexture": { + "__uuid__": "8b29322f-dd78-4a56-98d7-b3d60e2d8a84@6c48a", + "__expectedType__": "cc.Texture2D" + } + }, + {}, + {}, + {} + ] +} diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/red.mtl.meta b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/red.mtl.meta new file mode 100644 index 0000000..1a2c074 --- /dev/null +++ b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/red.mtl.meta @@ -0,0 +1,11 @@ +{ + "ver": "1.0.9", + "importer": "material", + "imported": true, + "uuid": "08f0736d-0b54-4a93-9991-17d426a9fb01", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/yellow.mtl b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/yellow.mtl new file mode 100644 index 0000000..1ce8d24 --- /dev/null +++ b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/yellow.mtl @@ -0,0 +1,48 @@ +{ + "__type__": "cc.Material", + "_name": "", + "_objFlags": 0, + "_native": "", + "_effectAsset": { + "__uuid__": "1baf0fc9-befa-459c-8bdd-af1a450a0319", + "__expectedType__": "cc.EffectAsset" + }, + "_techIdx": 0, + "_defines": [ + { + "USE_INSTANCING": true, + "USE_ALBEDO_MAP": true + }, + {}, + {}, + {} + ], + "_states": [ + { + "rasterizerState": {}, + "depthStencilState": {}, + "blendState": { + "targets": [ + {} + ] + } + }, + {}, + {}, + {} + ], + "_props": [ + { + "alphaThreshold": 0, + "roughness": 0.30360022187233, + "metallic": 0.400000005960464, + "mainTexture": { + "__uuid__": "00463b4b-2098-43bf-ab0f-75d68a7b19aa@6c48a", + "__expectedType__": "cc.Texture2D" + } + }, + {}, + {}, + {} + ] +} diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/yellow.mtl.meta b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/yellow.mtl.meta new file mode 100644 index 0000000..7aef2eb --- /dev/null +++ b/examples/cocos-creator-multiplayer/frontend/assets/3d/javelin/yellow.mtl.meta @@ -0,0 +1,11 @@ +{ + "ver": "1.0.9", + "importer": "material", + "imported": true, + "uuid": "40462a03-2591-4a93-8e5f-5815118c7fcb", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": {} +} diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/map/newMap01.FBX.meta b/examples/cocos-creator-multiplayer/frontend/assets/3d/map/newMap01.FBX.meta index 5287e4e..932df2e 100644 --- a/examples/cocos-creator-multiplayer/frontend/assets/3d/map/newMap01.FBX.meta +++ b/examples/cocos-creator-multiplayer/frontend/assets/3d/map/newMap01.FBX.meta @@ -2,86 +2,85 @@ "ver": "2.1.4", "importer": "fbx", "imported": true, - "uuid": "c26a63b9-5039-47ae-b027-ef2bce881f6f", + "uuid": "3777d1a7-cafe-44be-9efd-ae46b6457e2c", "files": [], "subMetas": { "f6845": { - "ver": "1.1.0", "importer": "gltf-mesh", - "uuid": "c26a63b9-5039-47ae-b027-ef2bce881f6f@f6845", + "uuid": "3777d1a7-cafe-44be-9efd-ae46b6457e2c@f6845", + "displayName": "", + "id": "f6845", + "name": "newMap01.mesh", + "userData": { + "gltfIndex": 0 + }, + "ver": "1.1.0", "imported": true, "files": [ ".bin", ".json" ], - "subMetas": {}, + "subMetas": {} + }, + "1cdc4": { + "importer": "gltf-embeded-image", + "uuid": "3777d1a7-cafe-44be-9efd-ae46b6457e2c@1cdc4", + "displayName": "", + "id": "1cdc4", + "name": "贴图 #3.image", "userData": { "gltfIndex": 0 }, - "displayName": "", - "id": "f6845", - "name": "newMap01.mesh" - }, - "3500c": { "ver": "1.0.3", - "importer": "gltf-embeded-image", - "uuid": "c26a63b9-5039-47ae-b027-ef2bce881f6f@3500c", "imported": true, "files": [ ".jpg", ".json" ], - "subMetas": {}, - "userData": { - "gltfIndex": 0 - }, - "displayName": "", - "id": "3500c", - "name": "newMap01.jpg.image" + "subMetas": {} }, "bfae8": { - "ver": "1.0.21", "importer": "texture", - "uuid": "c26a63b9-5039-47ae-b027-ef2bce881f6f@bfae8", - "imported": true, - "files": [ - ".json" - ], - "subMetas": {}, + "uuid": "3777d1a7-cafe-44be-9efd-ae46b6457e2c@bfae8", + "displayName": "", + "id": "bfae8", + "name": "贴图 #3.texture", "userData": { "wrapModeS": "repeat", "wrapModeT": "repeat", "minfilter": "linear", "magfilter": "linear", "mipfilter": "none", - "premultiplyAlpha": false, "anisotropy": 0, "isUuid": true, - "imageUuidOrDatabaseUri": "c26a63b9-5039-47ae-b027-ef2bce881f6f@3500c" + "imageUuidOrDatabaseUri": "3777d1a7-cafe-44be-9efd-ae46b6457e2c@1cdc4" }, - "displayName": "", - "id": "bfae8", - "name": "贴图 #3.texture" - }, - "7ff75": { - "ver": "1.0.14", - "importer": "gltf-material", - "uuid": "c26a63b9-5039-47ae-b027-ef2bce881f6f@7ff75", + "ver": "1.0.21", "imported": true, "files": [ ".json" ], - "subMetas": {}, + "subMetas": {} + }, + "7ff75": { + "importer": "gltf-material", + "uuid": "3777d1a7-cafe-44be-9efd-ae46b6457e2c@7ff75", + "displayName": "", + "id": "7ff75", + "name": "Material #27.material", "userData": { "gltfIndex": 0 }, - "displayName": "", - "id": "7ff75", - "name": "Material #27.material" + "ver": "1.0.14", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {} }, "fc11b": { "importer": "gltf-scene", - "uuid": "c26a63b9-5039-47ae-b027-ef2bce881f6f@fc11b", + "uuid": "3777d1a7-cafe-44be-9efd-ae46b6457e2c@fc11b", "displayName": "", "id": "fc11b", "name": "newMap01.prefab", @@ -99,26 +98,26 @@ "userData": { "imageMetas": [ { - "name": "newMap01.jpg", - "uri": "c26a63b9-5039-47ae-b027-ef2bce881f6f@3500c" + "name": "贴图 #3", + "uri": "3777d1a7-cafe-44be-9efd-ae46b6457e2c@1cdc4" } ], - "redirect": "c26a63b9-5039-47ae-b027-ef2bce881f6f@fc11b", + "legacyFbxImporter": false, + "redirect": "3777d1a7-cafe-44be-9efd-ae46b6457e2c@fc11b", "assetFinder": { "meshes": [ - "c26a63b9-5039-47ae-b027-ef2bce881f6f@f6845" + "3777d1a7-cafe-44be-9efd-ae46b6457e2c@f6845" ], "skeletons": [], "textures": [ - "c26a63b9-5039-47ae-b027-ef2bce881f6f@bfae8" + "3777d1a7-cafe-44be-9efd-ae46b6457e2c@bfae8" ], "materials": [ - "c26a63b9-5039-47ae-b027-ef2bce881f6f@7ff75" + "3777d1a7-cafe-44be-9efd-ae46b6457e2c@7ff75" ], "scenes": [ - "c26a63b9-5039-47ae-b027-ef2bce881f6f@fc11b" + "3777d1a7-cafe-44be-9efd-ae46b6457e2c@fc11b" ] - }, - "legacyFbxImporter": true + } } } diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/map/newMap01.jpg.meta b/examples/cocos-creator-multiplayer/frontend/assets/3d/map/newMap01.jpg.meta index 59e0cf5..22831f5 100644 --- a/examples/cocos-creator-multiplayer/frontend/assets/3d/map/newMap01.jpg.meta +++ b/examples/cocos-creator-multiplayer/frontend/assets/3d/map/newMap01.jpg.meta @@ -2,40 +2,39 @@ "ver": "1.0.21", "importer": "image", "imported": true, - "uuid": "27e1fcb7-5016-4252-8c43-ac9c1c97308e", + "uuid": "96c88bc3-119a-412a-ac6f-5936ba8b9dc7", "files": [ ".jpg", ".json" ], "subMetas": { "6c48a": { - "ver": "1.0.21", "importer": "texture", - "uuid": "27e1fcb7-5016-4252-8c43-ac9c1c97308e@6c48a", - "imported": true, - "files": [ - ".json" - ], - "subMetas": {}, + "uuid": "96c88bc3-119a-412a-ac6f-5936ba8b9dc7@6c48a", + "displayName": "newMap01", + "id": "6c48a", + "name": "texture", "userData": { "wrapModeS": "repeat", "wrapModeT": "repeat", "minfilter": "linear", "magfilter": "linear", "mipfilter": "none", - "premultiplyAlpha": false, "anisotropy": 0, "isUuid": true, - "imageUuidOrDatabaseUri": "27e1fcb7-5016-4252-8c43-ac9c1c97308e" + "imageUuidOrDatabaseUri": "96c88bc3-119a-412a-ac6f-5936ba8b9dc7" }, - "displayName": "newMap01", - "id": "6c48a", - "name": "texture" + "ver": "1.0.21", + "imported": true, + "files": [ + ".json" + ], + "subMetas": {} } }, "userData": { + "hasAlpha": false, "type": "texture", - "redirect": "27e1fcb7-5016-4252-8c43-ac9c1c97308e@6c48a", - "hasAlpha": false + "redirect": "96c88bc3-119a-412a-ac6f-5936ba8b9dc7@6c48a" } } diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/map/newMap01.mtl b/examples/cocos-creator-multiplayer/frontend/assets/3d/map/newMap01.mtl index f6505cb..ac6e670 100644 --- a/examples/cocos-creator-multiplayer/frontend/assets/3d/map/newMap01.mtl +++ b/examples/cocos-creator-multiplayer/frontend/assets/3d/map/newMap01.mtl @@ -27,7 +27,7 @@ "_props": [ { "mainTexture": { - "__uuid__": "27e1fcb7-5016-4252-8c43-ac9c1c97308e@6c48a", + "__uuid__": "96c88bc3-119a-412a-ac6f-5936ba8b9dc7@6c48a", "__expectedType__": "cc.Texture2D" } } diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/map/newMap01.mtl.meta b/examples/cocos-creator-multiplayer/frontend/assets/3d/map/newMap01.mtl.meta index 36d1e1c..930fe11 100644 --- a/examples/cocos-creator-multiplayer/frontend/assets/3d/map/newMap01.mtl.meta +++ b/examples/cocos-creator-multiplayer/frontend/assets/3d/map/newMap01.mtl.meta @@ -2,7 +2,7 @@ "ver": "1.0.9", "importer": "material", "imported": true, - "uuid": "b7d6d595-6cd1-43c6-8bc7-3a92644870b9", + "uuid": "5ff93eca-e35a-43eb-b801-6e99d62ccac5", "files": [ ".json" ], diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/soldier01.FBX b/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/soldier01.FBX deleted file mode 100644 index 3774d44..0000000 Binary files a/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/soldier01.FBX and /dev/null differ diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/soldier01.jpg b/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/soldier01.jpg deleted file mode 100644 index 73a07f3..0000000 Binary files a/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/soldier01.jpg and /dev/null differ diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/soldier02.jpg b/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/soldier02.jpg deleted file mode 100644 index 0ad1fdd..0000000 Binary files a/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/soldier02.jpg and /dev/null differ diff --git a/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/soldier03.jpg b/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/soldier03.jpg deleted file mode 100644 index adfebcd..0000000 Binary files a/examples/cocos-creator-multiplayer/frontend/assets/3d/soldier/soldier03.jpg and /dev/null differ diff --git a/examples/cocos-creator-multiplayer/frontend/assets/prefabs/Arrow.meta b/examples/cocos-creator-multiplayer/frontend/assets/prefabs/Arrow.meta new file mode 100644 index 0000000..c6c3dda --- /dev/null +++ b/examples/cocos-creator-multiplayer/frontend/assets/prefabs/Arrow.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.1.0", + "importer": "directory", + "imported": true, + "uuid": "3569d420-d152-4b7b-936c-80d250e96cc6", + "files": [], + "subMetas": {}, + "userData": { + "compressionType": {}, + "isRemoteBundle": {} + } +} diff --git a/examples/cocos-creator-multiplayer/frontend/assets/prefabs/Arrow/Arrow.prefab b/examples/cocos-creator-multiplayer/frontend/assets/prefabs/Arrow/Arrow.prefab new file mode 100644 index 0000000..b1369cb --- /dev/null +++ b/examples/cocos-creator-multiplayer/frontend/assets/prefabs/Arrow/Arrow.prefab @@ -0,0 +1,303 @@ +[ + { + "__type__": "cc.Prefab", + "_name": "", + "_objFlags": 0, + "_native": "", + "data": { + "__id__": 1 + }, + "optimizationPolicy": 0, + "asyncLoadAssets": false + }, + { + "__type__": "cc.Node", + "_name": "Arrow", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": true, + "_components": [ + { + "__id__": 11 + } + ], + "_prefab": { + "__id__": 13 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 1.248, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "javelin", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 10 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 1.194 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 1, + "z": 0, + "w": 6.123233995736766e-17 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 180, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "RootNode", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 4 + } + ], + "_active": true, + "_components": [], + "_prefab": { + "__id__": 9 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.Node", + "_name": "对象001", + "_objFlags": 0, + "_parent": { + "__id__": 3 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 5 + } + ], + "_prefab": { + "__id__": 8 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": -8.46988434943796e-9 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": -0.7071067811865476, + "y": 0, + "z": 0, + "w": 0.7071067811865476 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 2.53999996185303, + "y": 2.53999996185303, + "z": 2.53999996185303 + }, + "_layer": 1073741824, + "_euler": { + "__type__": "cc.Vec3", + "x": -90.00000000000003, + "y": 0, + "z": 0 + }, + "_id": "" + }, + { + "__type__": "cc.MeshRenderer", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 4 + }, + "_enabled": true, + "__prefab": { + "__id__": 6 + }, + "_materials": [ + { + "__uuid__": "5d9da4c3-349b-4309-8efe-7c16bffd5ed4", + "__expectedType__": "cc.Material" + } + ], + "_visFlags": 0, + "lightmapSettings": { + "__id__": 7 + }, + "_mesh": { + "__uuid__": "401c28d6-3085-4209-9f2e-3aff6da5855c@035c0", + "__expectedType__": "cc.Mesh" + }, + "_shadowCastingMode": 0, + "_shadowReceivingMode": 1, + "_enableMorph": true, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "fek3uGwZpCJqPRuj2/l+Ij" + }, + { + "__type__": "cc.ModelLightmapSettings", + "texture": null, + "uvParam": { + "__type__": "cc.Vec4", + "x": 0, + "y": 0, + "z": 0, + "w": 0 + }, + "_bakeable": false, + "_castShadow": false, + "_receiveShadow": false, + "_recieveShadow": false, + "_lightmapSize": 64 + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "6dBrH1nxxJXqvnSzh5DKhe" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "f2EQ0N/h5K/binLoiKCW0X" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "e4s27HRhlBboS6EhifyuWl" + }, + { + "__type__": "2330evjMPtBCJhzJpbQ/Kgk", + "_name": "", + "_objFlags": 0, + "__editorExtras__": {}, + "node": { + "__id__": 1 + }, + "_enabled": true, + "__prefab": { + "__id__": 12 + }, + "_id": "" + }, + { + "__type__": "cc.CompPrefabInfo", + "fileId": "dfK9a027hMZ61jBs2XWMQk" + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 1 + }, + "asset": { + "__id__": 0 + }, + "fileId": "ad10ECDidH979xbvqlbbgn" + } +] \ No newline at end of file diff --git a/examples/cocos-creator-multiplayer/frontend/assets/prefabs/Arrow/Arrow.prefab.meta b/examples/cocos-creator-multiplayer/frontend/assets/prefabs/Arrow/Arrow.prefab.meta new file mode 100644 index 0000000..509df81 --- /dev/null +++ b/examples/cocos-creator-multiplayer/frontend/assets/prefabs/Arrow/Arrow.prefab.meta @@ -0,0 +1,13 @@ +{ + "ver": "1.1.32", + "importer": "prefab", + "imported": true, + "uuid": "6eda806d-83a6-474f-a7b7-b75c57ba73b3", + "files": [ + ".json" + ], + "subMetas": {}, + "userData": { + "syncNodeName": "Arrow" + } +} diff --git a/examples/cocos-creator-multiplayer/frontend/assets/prefabs/Arrow/Arrow.ts b/examples/cocos-creator-multiplayer/frontend/assets/prefabs/Arrow/Arrow.ts new file mode 100644 index 0000000..d615b46 --- /dev/null +++ b/examples/cocos-creator-multiplayer/frontend/assets/prefabs/Arrow/Arrow.ts @@ -0,0 +1,43 @@ + +import { Component, Vec3, _decorator } from 'cc'; +import { MathUtil } from '../../scripts/models/MathUtil'; +import { ArrowState } from '../../scripts/shared/game/state/ArrowState'; +const { ccclass, property } = _decorator; + +const ARROW_TOP = 7; + +@ccclass('Arrow') +export class Arrow extends Component { + + id!: number; + state!: ArrowState; + + private _startPos = new Vec3; + private _endPos = new Vec3; + + init(state: ArrowState) { + this.id = state.id; + this.state = state; + this._startPos.set(state.startPos.x, 0, -state.startPos.y); + this._endPos.set(state.targetPos.x, 0, -state.targetPos.y); + } + + + updateState(state: ArrowState, now: number) { + let percent = MathUtil.limit((now - state.startTime) / (state.targetTime - state.startTime), 0, 1); + + //下一个目标位置 + let newPos = this._startPos.clone().lerp(this._endPos, percent) + //下一个目标位置的高度 + newPos.y = ARROW_TOP * Math.cos(percent * Math.PI - Math.PI / 2); + + //武器朝向下一个目标位置, 形成曲线飞行的感觉 + let newForward = newPos.clone().subtract(this.node.position).normalize(); + if (!newForward.equals(Vec3.ZERO)) { + this.node.forward = newForward; + } + + this.node.position = newPos; + } + +} \ No newline at end of file diff --git a/examples/cocos-creator-multiplayer/frontend/assets/prefabs/Arrow/Arrow.ts.meta b/examples/cocos-creator-multiplayer/frontend/assets/prefabs/Arrow/Arrow.ts.meta new file mode 100644 index 0000000..1840764 --- /dev/null +++ b/examples/cocos-creator-multiplayer/frontend/assets/prefabs/Arrow/Arrow.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.22", + "importer": "typescript", + "imported": true, + "uuid": "2330ebe3-30fb-4108-9873-2696d0fca824", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/examples/cocos-creator-multiplayer/frontend/assets/prefabs/Player/Player.prefab b/examples/cocos-creator-multiplayer/frontend/assets/prefabs/Player/Player.prefab index b92766a..8af4529 100644 --- a/examples/cocos-creator-multiplayer/frontend/assets/prefabs/Player/Player.prefab +++ b/examples/cocos-creator-multiplayer/frontend/assets/prefabs/Player/Player.prefab @@ -22,646 +22,13 @@ ], "_active": true, "_components": [ - { - "__id__": 35 - } - ], - "_prefab": { - "__id__": 36 - }, - "_lpos": { - "__type__": "cc.Vec3", - "x": 0, - "y": 0, - "z": 0 - }, - "_lrot": { - "__type__": "cc.Quat", - "x": 0, - "y": 0, - "z": 0, - "w": 1 - }, - "_lscale": { - "__type__": "cc.Vec3", - "x": 1, - "y": 1, - "z": 1 - }, - "_layer": 1073741824, - "_euler": { - "__type__": "cc.Vec3", - "x": 0, - "y": 0, - "z": 0 - }, - "_id": "" - }, - { - "__type__": "cc.Node", - "_name": "soldier01", - "_objFlags": 0, - "_parent": { - "__id__": 1 - }, - "_children": [ - { - "__id__": 3 - } - ], - "_active": true, - "_components": [ - { - "__id__": 32 - } - ], - "_prefab": { - "__id__": 34 - }, - "_lpos": { - "__type__": "cc.Vec3", - "x": 0, - "y": 0, - "z": 0 - }, - "_lrot": { - "__type__": "cc.Quat", - "x": 0, - "y": 1, - "z": 0, - "w": 6.123233995736766e-17 - }, - "_lscale": { - "__type__": "cc.Vec3", - "x": 1, - "y": 1, - "z": 1 - }, - "_layer": 1073741824, - "_euler": { - "__type__": "cc.Vec3", - "x": 0, - "y": 180, - "z": 0 - }, - "_id": "" - }, - { - "__type__": "cc.Node", - "_name": "RootNode", - "_objFlags": 0, - "_parent": { - "__id__": 2 - }, - "_children": [ - { - "__id__": 4 - }, - { - "__id__": 18 - }, - { - "__id__": 20 - }, - { - "__id__": 22 - }, - { - "__id__": 27 - }, - { - "__id__": 29 - } - ], - "_active": true, - "_components": [], - "_prefab": { - "__id__": 31 - }, - "_lpos": { - "__type__": "cc.Vec3", - "x": 0, - "y": 0, - "z": 0 - }, - "_lrot": { - "__type__": "cc.Quat", - "x": 0, - "y": 0, - "z": 0, - "w": 1 - }, - "_lscale": { - "__type__": "cc.Vec3", - "x": 1, - "y": 1, - "z": 1 - }, - "_layer": 1073741824, - "_euler": { - "__type__": "cc.Vec3", - "x": 0, - "y": 0, - "z": 0 - }, - "_id": "" - }, - { - "__type__": "cc.Node", - "_name": "Dummy01", - "_objFlags": 0, - "_parent": { - "__id__": 3 - }, - "_children": [ - { - "__id__": 5 - }, - { - "__id__": 9 - }, - { - "__id__": 11 - }, - { - "__id__": 13 - }, { "__id__": 15 } ], - "_active": true, - "_components": [], - "_prefab": { - "__id__": 17 - }, - "_lpos": { - "__type__": "cc.Vec3", - "x": 0, - "y": 4.31247441140831e-32, - "z": 2.27106511374586e-9 - }, - "_lrot": { - "__type__": "cc.Quat", - "x": 8.146034247147302e-8, - "y": 0, - "z": 0, - "w": 0.9999999999999967 - }, - "_lscale": { - "__type__": "cc.Vec3", - "x": 2.53999996185303, - "y": 2.53999996185303, - "z": 2.53999996185303 - }, - "_layer": 1073741824, - "_euler": { - "__type__": "cc.Vec3", - "x": 0.000009334667642611398, - "y": 0, - "z": 0 - }, - "_id": "" - }, - { - "__type__": "cc.Node", - "_name": "Body", - "_objFlags": 0, - "_parent": { - "__id__": 4 - }, - "_children": [ - { - "__id__": 6 - } - ], - "_active": true, - "_components": [], - "_prefab": { - "__id__": 8 - }, - "_lpos": { - "__type__": "cc.Vec3", - "x": -0.000466376630356535, - "y": 0.0555356666445732, - "z": -4.76837147544984e-9 - }, - "_lrot": { - "__type__": "cc.Quat", - "x": 0.0000013147252531426701, - "y": 5.898311123805427e-7, - "z": 0.7037748466382776, - "w": 0.7104230888964633 - }, - "_lscale": { - "__type__": "cc.Vec3", - "x": 0.256809949874878, - "y": 0.439815044403076, - "z": 0.0870304778218269 - }, - "_layer": 1073741824, - "_euler": { - "__type__": "cc.Vec3", - "x": 0.006324434041980695, - "y": -0.006170109051330866, - "z": 89.46130112452344 - }, - "_id": "" - }, - { - "__type__": "cc.Node", - "_name": "head", - "_objFlags": 0, - "_parent": { - "__id__": 5 - }, - "_children": [], - "_active": true, - "_components": [], - "_prefab": { - "__id__": 7 - }, - "_lpos": { - "__type__": "cc.Vec3", - "x": 0.931041061878204, - "y": -1.62124635494365e-7, - "z": 1.28416282052513e-8 - }, - "_lrot": { - "__type__": "cc.Quat", - "x": -0.000007869318285142453, - "y": -2.023334521019378e-7, - "z": -0.001340885290760051, - "w": 0.9999991009819308 - }, - "_lscale": { - "__type__": "cc.Vec3", - "x": 1.24272096157074, - "y": 1.03568971157074, - "z": 1.0696634054184 - }, - "_layer": 1073741824, - "_euler": { - "__type__": "cc.Vec3", - "x": -0.0009017909722726095, - "y": -0.00002439492589956044, - "z": -0.15365418180060705 - }, - "_id": "" - }, - { - "__type__": "cc.PrefabInfo", - "root": { - "__id__": 1 - }, - "asset": { - "__id__": 0 - }, - "fileId": "1etT/vqTVXbIC6bSTTJON5" - }, - { - "__type__": "cc.PrefabInfo", - "root": { - "__id__": 1 - }, - "asset": { - "__id__": 0 - }, - "fileId": "38UefSlhhbc7fGntsIPZh6" - }, - { - "__type__": "cc.Node", - "_name": "legRight", - "_objFlags": 0, - "_parent": { - "__id__": 4 - }, - "_children": [], - "_active": true, - "_components": [], - "_prefab": { - "__id__": 10 - }, - "_lpos": { - "__type__": "cc.Vec3", - "x": -0.15381583571434, - "y": 0.0330642610788345, - "z": -4.76837147544984e-9 - }, - "_lrot": { - "__type__": "cc.Quat", - "x": 0.6775014926325843, - "y": 0.20089959890094192, - "z": 0.6787423421146606, - "w": -0.19984972269874676 - }, - "_lscale": { - "__type__": "cc.Vec3", - "x": 0.184104666113853, - "y": 0.347824722528458, - "z": 0.0710852295160294 - }, - "_layer": 1073741824, - "_euler": { - "__type__": "cc.Vec3", - "x": -147.07673505109858, - "y": -90.12052935501679, - "z": 0.05309133906220757 - }, - "_id": "" - }, - { - "__type__": "cc.PrefabInfo", - "root": { - "__id__": 1 - }, - "asset": { - "__id__": 0 - }, - "fileId": "a7AVcLwkBZ46dzYAYb4QPx" - }, - { - "__type__": "cc.Node", - "_name": "legLeft", - "_objFlags": 0, - "_parent": { - "__id__": 4 - }, - "_children": [], - "_active": true, - "_components": [], - "_prefab": { - "__id__": 12 - }, - "_lpos": { - "__type__": "cc.Vec3", - "x": 0.150058135390282, - "y": 0.0330642610788345, - "z": -1.43051144263495e-8 - }, - "_lrot": { - "__type__": "cc.Quat", - "x": 0.6356643535110694, - "y": 0.3106639432517853, - "z": 0.635291228429095, - "w": -0.3095541941561399 - }, - "_lscale": { - "__type__": "cc.Vec3", - "x": 0.184104397892952, - "y": 0.347825288772583, - "z": 0.0710852593183517 - }, - "_layer": 1073741824, - "_euler": { - "__type__": "cc.Vec3", - "x": -127.97583425594252, - "y": -90.01226481486562, - "z": 0.09407173384696697 - }, - "_id": "" - }, - { - "__type__": "cc.PrefabInfo", - "root": { - "__id__": 1 - }, - "asset": { - "__id__": 0 - }, - "fileId": "6egLmgEjJSxb7mZpFf7FSD" - }, - { - "__type__": "cc.Node", - "_name": "handRight", - "_objFlags": 0, - "_parent": { - "__id__": 4 - }, - "_children": [], - "_active": true, - "_components": [], - "_prefab": { - "__id__": 14 - }, - "_lpos": { - "__type__": "cc.Vec3", - "x": -0.204364582896233, - "y": 0.240019470453262, - "z": -1.90734859017994e-8 - }, - "_lrot": { - "__type__": "cc.Quat", - "x": -0.00043949465228992625, - "y": -0.00002823252593632647, - "z": 0.9849262411574669, - "w": -0.17297429151986207 - }, - "_lscale": { - "__type__": "cc.Vec3", - "x": 0.184104412794113, - "y": 0.347825288772583, - "z": 0.07108523696661 - }, - "_layer": 1073741824, - "_euler": { - "__type__": "cc.Vec3", - "x": 179.9873448759303, - "y": 179.94664434517173, - "z": -19.921588202819525 - }, - "_id": "" - }, - { - "__type__": "cc.PrefabInfo", - "root": { - "__id__": 1 - }, - "asset": { - "__id__": 0 - }, - "fileId": "50DRmSLnFemalb9mhuT9XN" - }, - { - "__type__": "cc.Node", - "_name": "handLeft", - "_objFlags": 0, - "_parent": { - "__id__": 4 - }, - "_children": [], - "_active": true, - "_components": [], "_prefab": { "__id__": 16 }, - "_lpos": { - "__type__": "cc.Vec3", - "x": 0.203091412782669, - "y": 0.240019470453262, - "z": -1.90734859017994e-8 - }, - "_lrot": { - "__type__": "cc.Quat", - "x": -0.00001006337055508986, - "y": -0.0003337875805372209, - "z": -0.17397424484232848, - "w": 0.9847501462889564 - }, - "_lscale": { - "__type__": "cc.Vec3", - "x": 0.184104338288307, - "y": 0.347825139760971, - "z": 0.0710852667689323 - }, - "_layer": 1073741824, - "_euler": { - "__type__": "cc.Vec3", - "x": -0.008291917560534557, - "y": -0.04030648567970078, - "z": -20.037940451355507 - }, - "_id": "" - }, - { - "__type__": "cc.PrefabInfo", - "root": { - "__id__": 1 - }, - "asset": { - "__id__": 0 - }, - "fileId": "5eMcps3V1RoqefFsSsm8Sx" - }, - { - "__type__": "cc.PrefabInfo", - "root": { - "__id__": 1 - }, - "asset": { - "__id__": 0 - }, - "fileId": "e14q0XOvhSf7Wwpr+JP8WX" - }, - { - "__type__": "cc.Node", - "_name": "Bip001", - "_objFlags": 0, - "_parent": { - "__id__": 3 - }, - "_children": [], - "_active": true, - "_components": [], - "_prefab": { - "__id__": 19 - }, - "_lpos": { - "__type__": "cc.Vec3", - "x": -2.95868706703186, - "y": 0.568015873432159, - "z": 2.59012746810913 - }, - "_lrot": { - "__type__": "cc.Quat", - "x": -0.5000003129242964, - "y": -0.49999968707550774, - "z": -0.49999968707550774, - "w": 0.5000003129242964 - }, - "_lscale": { - "__type__": "cc.Vec3", - "x": 6.45159912109375, - "y": 6.45159912109375, - "z": 6.45160007476807 - }, - "_layer": 1073741824, - "_euler": { - "__type__": "cc.Vec3", - "x": -90, - "y": -89.99992828301158, - "z": 0 - }, - "_id": "" - }, - { - "__type__": "cc.PrefabInfo", - "root": { - "__id__": 1 - }, - "asset": { - "__id__": 0 - }, - "fileId": "72wx+9XH9fS5Jsw9lb3u/+" - }, - { - "__type__": "cc.Node", - "_name": "mixamorig:HeadTop_End", - "_objFlags": 0, - "_parent": { - "__id__": 3 - }, - "_children": [], - "_active": true, - "_components": [], - "_prefab": { - "__id__": 21 - }, - "_lpos": { - "__type__": "cc.Vec3", - "x": -12.6684627532959, - "y": 2.27624535560608, - "z": -0.396418631076813 - }, - "_lrot": { - "__type__": "cc.Quat", - "x": 0.07992084217915124, - "y": 0.35555240038341984, - "z": 0.03850968875854815, - "w": 0.9304365391786178 - }, - "_lscale": { - "__type__": "cc.Vec3", - "x": 65.5876159667969, - "y": 65.5876617431641, - "z": 65.587646484375 - }, - "_layer": 1073741824, - "_euler": { - "__type__": "cc.Vec3", - "x": 7.027884698082062, - "y": 41.37325087834414, - "z": 7.382559841159056 - }, - "_id": "" - }, - { - "__type__": "cc.PrefabInfo", - "root": { - "__id__": 1 - }, - "asset": { - "__id__": 0 - }, - "fileId": "758sU4GMNYEaDn4WLPV8VV" - }, - { - "__type__": "cc.Node", - "_name": "soldier01", - "_objFlags": 0, - "_parent": { - "__id__": 3 - }, - "_children": [], - "_active": true, - "_components": [ - { - "__id__": 23 - } - ], - "_prefab": { - "__id__": 26 - }, "_lpos": { "__type__": "cc.Vec3", "x": 0, @@ -670,260 +37,192 @@ }, "_lrot": { "__type__": "cc.Quat", - "x": -0.7071067811865476, - "y": 0, - "z": 0, - "w": 0.7071067811865476 - }, - "_lscale": { - "__type__": "cc.Vec3", - "x": 2.53999996185303, - "y": 2.53999996185303, - "z": 2.53999996185303 - }, - "_layer": 1073741824, - "_euler": { - "__type__": "cc.Vec3", - "x": -90.00000000000003, - "y": 0, - "z": 0 - }, - "_id": "" - }, - { - "__type__": "cc.SkinnedMeshRenderer", - "_name": "", - "_objFlags": 0, - "node": { - "__id__": 22 - }, - "_enabled": true, - "__prefab": { - "__id__": 24 - }, - "_materials": [ - { - "__uuid__": "5cf1ff47-b589-490a-bc78-a88f743b9798", - "__expectedType__": "cc.Material" - } - ], - "_visFlags": 0, - "lightmapSettings": { - "__id__": 25 - }, - "_mesh": { - "__uuid__": "57d4c4ef-3199-4596-bf79-7c065964ca9c@6868c", - "__expectedType__": "cc.Mesh" - }, - "_shadowCastingMode": 0, - "_shadowReceivingMode": 1, - "_enableMorph": true, - "_skeleton": { - "__uuid__": "57d4c4ef-3199-4596-bf79-7c065964ca9c@438fe", - "__expectedType__": "cc.Skeleton" - }, - "_skinningRoot": { - "__id__": 2 - }, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "01bZIFKkBZQ5BDP5OTFTyW" - }, - { - "__type__": "cc.ModelLightmapSettings", - "texture": null, - "uvParam": { - "__type__": "cc.Vec4", "x": 0, "y": 0, "z": 0, - "w": 0 - }, - "_bakeable": false, - "_castShadow": false, - "_receiveShadow": false, - "_recieveShadow": false, - "_lightmapSize": 64 - }, - { - "__type__": "cc.PrefabInfo", - "root": { - "__id__": 1 - }, - "asset": { - "__id__": 0 - }, - "fileId": "61gKhO2zhY0LoTCP8qRD7M" - }, - { - "__type__": "cc.Node", - "_name": "Bip001(__autogen 4)", - "_objFlags": 0, - "_parent": { - "__id__": 3 - }, - "_children": [], - "_active": true, - "_components": [], - "_prefab": { - "__id__": 28 - }, - "_lpos": { - "__type__": "cc.Vec3", - "x": 9.61940002441406, - "y": 0.568015873432159, - "z": 1.51320099830627 - }, - "_lrot": { - "__type__": "cc.Quat", - "x": -0.5000003129242964, - "y": -0.49999968707550774, - "z": -0.49999968707550774, - "w": 0.5000003129242964 + "w": 1 }, "_lscale": { "__type__": "cc.Vec3", - "x": 6.45159912109375, - "y": 6.45159912109375, - "z": 6.45160007476807 + "x": 1, + "y": 1, + "z": 1 }, "_layer": 1073741824, "_euler": { "__type__": "cc.Vec3", - "x": -90, - "y": -89.99992828301158, + "x": 0, + "y": 0, "z": 0 }, "_id": "" }, - { - "__type__": "cc.PrefabInfo", - "root": { - "__id__": 1 - }, - "asset": { - "__id__": 0 - }, - "fileId": "ceW5W7cCxbcIDrr7BHLBqe" - }, { "__type__": "cc.Node", - "_name": "mixamorig:HeadTop_End(__autogen 5)", "_objFlags": 0, "_parent": { - "__id__": 3 + "__id__": 1 }, - "_children": [], - "_active": true, - "_components": [], "_prefab": { - "__id__": 30 - }, - "_lpos": { - "__type__": "cc.Vec3", - "x": -0.0903754904866219, - "y": 2.27624559402466, - "z": -1.47334516048431 - }, - "_lrot": { - "__type__": "cc.Quat", - "x": 0.07992084217915124, - "y": 0.35555240038341984, - "z": 0.03850968875854815, - "w": 0.9304365391786178 - }, - "_lscale": { - "__type__": "cc.Vec3", - "x": 65.5876159667969, - "y": 65.5876617431641, - "z": 65.587646484375 - }, - "_layer": 1073741824, - "_euler": { - "__type__": "cc.Vec3", - "x": 7.027884698082062, - "y": 41.37325087834414, - "z": 7.382559841159056 - }, - "_id": "" + "__id__": 3 + } }, { "__type__": "cc.PrefabInfo", "root": { - "__id__": 1 - }, - "asset": { - "__id__": 0 - }, - "fileId": "9evQBDrbhSio1m7RjvuLjN" - }, - { - "__type__": "cc.PrefabInfo", - "root": { - "__id__": 1 - }, - "asset": { - "__id__": 0 - }, - "fileId": "30u7fnOj9WDp8SK/8khE/U" - }, - { - "__type__": "cc.SkeletalAnimation", - "_name": "", - "_objFlags": 0, - "node": { "__id__": 2 }, - "_enabled": true, - "__prefab": { - "__id__": 33 + "asset": { + "__uuid__": "e8fe9966-5f03-4cc0-ad69-01d536be6c21@665d9", + "__expectedType__": "cc.Prefab" }, - "playOnLoad": true, - "_clips": [ - { - "__uuid__": "57d4c4ef-3199-4596-bf79-7c065964ca9c@1f586", - "__expectedType__": "cc.AnimationClip" - }, - { - "__uuid__": "57d4c4ef-3199-4596-bf79-7c065964ca9c@cf5ee", - "__expectedType__": "cc.AnimationClip" - }, - { - "__uuid__": "57d4c4ef-3199-4596-bf79-7c065964ca9c@989ed", - "__expectedType__": "cc.AnimationClip" - }, - { - "__uuid__": "57d4c4ef-3199-4596-bf79-7c065964ca9c@ee525", - "__expectedType__": "cc.AnimationClip" - }, - { - "__uuid__": "57d4c4ef-3199-4596-bf79-7c065964ca9c@5b2e9", - "__expectedType__": "cc.AnimationClip" - } - ], - "_defaultClip": { - "__uuid__": "57d4c4ef-3199-4596-bf79-7c065964ca9c@1f586", - "__expectedType__": "cc.AnimationClip" - }, - "_useBakedAnimation": false, - "_sockets": [], - "_id": "" + "fileId": "0ci76LBW5T0pcTlJAggzPr", + "instance": { + "__id__": 4 + } }, { - "__type__": "cc.CompPrefabInfo", - "fileId": "71bamidCpRLIBqyoKSaXUX" - }, - { - "__type__": "cc.PrefabInfo", - "root": { + "__type__": "cc.PrefabInstance", + "fileId": "4dEd1Qo6RLgaIfCNHLepAL", + "prefabRootNode": { "__id__": 1 }, - "asset": { - "__id__": 0 + "mountedChildren": [], + "mountedComponents": [], + "propertyOverrides": [ + { + "__id__": 5 + }, + { + "__id__": 7 + }, + { + "__id__": 8 + }, + { + "__id__": 9 + }, + { + "__id__": 10 + }, + { + "__id__": 12 + }, + { + "__id__": 13 + } + ], + "removedComponents": [] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 6 }, - "fileId": "71qfN53ihYmaSuBoR11P0t" + "propertyPath": [ + "_name" + ], + "value": "javelin01" + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "0ci76LBW5T0pcTlJAggzPr" + ] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 6 + }, + "propertyPath": [ + "_lpos" + ], + "value": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 6 + }, + "propertyPath": [ + "_lrot" + ], + "value": { + "__type__": "cc.Quat", + "x": 0, + "y": 1, + "z": 0, + "w": 6.123233995736766e-17 + } + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 6 + }, + "propertyPath": [ + "_euler" + ], + "value": { + "__type__": "cc.Vec3", + "x": 0, + "y": 180, + "z": 0 + } + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 11 + }, + "propertyPath": [ + "_materials", + "0" + ], + "value": { + "__uuid__": "196eebe8-170f-4ba9-a767-9f6d664c6e04", + "__expectedType__": "cc.Material" + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "69OA7jJHlTl7JAQ/mCNrhv" + ] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 11 + }, + "propertyPath": [ + "_skinningRoot" + ], + "value": { + "__id__": 2 + } + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 14 + }, + "propertyPath": [ + "_useBakedAnimation" + ], + "value": false + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "61qK2CThVWNItyFdAnh23r" + ] }, { "__type__": "720b7a4EnZJjYpzLWJrmvT/", @@ -934,18 +233,14 @@ }, "_enabled": true, "__prefab": null, - "ani": { - "__id__": 32 - }, - "mesh": { - "__id__": 23 - }, + "ani": null, + "mesh": null, "texSelf": { - "__uuid__": "e90ad74a-b668-4e2c-bf91-51a2a91b02aa@6c48a", + "__uuid__": "81f16ace-2b57-44c3-804d-c192ed53aaee@6c48a", "__expectedType__": "cc.Texture2D" }, "texOther": { - "__uuid__": "f35bcb71-cd72-443c-94a9-5482c2d63d66@6c48a", + "__uuid__": "8b29322f-dd78-4a56-98d7-b3d60e2d8a84@6c48a", "__expectedType__": "cc.Texture2D" }, "_id": "" @@ -961,14 +256,17 @@ "fileId": "087WztcUlE+rBZWXq8jy1C", "targetOverrides": [ { - "__id__": 37 + "__id__": 17 + }, + { + "__id__": 19 } ] }, { "__type__": "cc.TargetOverrideInfo", "source": { - "__id__": 35 + "__id__": 15 }, "sourceInfo": null, "propertyPath": [ @@ -978,13 +276,35 @@ "__id__": 2 }, "targetInfo": { - "__id__": 38 + "__id__": 18 } }, { "__type__": "cc.TargetInfo", "localID": [ - "71bamidCpRLIBqyoKSaXUX" + "61qK2CThVWNItyFdAnh23r" + ] + }, + { + "__type__": "cc.TargetOverrideInfo", + "source": { + "__id__": 15 + }, + "sourceInfo": null, + "propertyPath": [ + "mesh" + ], + "target": { + "__id__": 2 + }, + "targetInfo": { + "__id__": 20 + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "69OA7jJHlTl7JAQ/mCNrhv" ] } ] \ No newline at end of file diff --git a/examples/cocos-creator-multiplayer/frontend/assets/prefabs/Player/Player.ts b/examples/cocos-creator-multiplayer/frontend/assets/prefabs/Player/Player.ts index df4fcda..5af1a66 100644 --- a/examples/cocos-creator-multiplayer/frontend/assets/prefabs/Player/Player.ts +++ b/examples/cocos-creator-multiplayer/frontend/assets/prefabs/Player/Player.ts @@ -19,18 +19,40 @@ export class Player extends Component { playerId!: number; isSelf = false; + state!: PlayerState; + now: number = 0; private _tweens: Tween[] = []; private _targetPos = new Vec3; + start() { + this.ani.getState('win').speed = 4; + } + init(state: PlayerState, isSelf: boolean) { this.playerId = state.id; this.isSelf = isSelf; this.mesh.material!.setProperty('mainTexture', this.isSelf ? this.texSelf : this.texOther); } - // 把 GameSystem 空间映射到游戏空间 - updateSelf(state: PlayerState) { + updateState(state: PlayerState, now: number) { + this.state = state; + this.now = now; + + if (state.dizzyEndTime && state.dizzyEndTime >= now) { + this.setAni('win'); + } + else { + if (this._lastAni === 'win') { + this.setAni('idle') + } + } + + this.isSelf ? this._resetState(state, now) : this._tweenState(state, now); + } + + // 直接更新 + private _resetState(state: PlayerState, now: number) { // 更新位置 this._targetPos.set(state.pos.x, 0, -state.pos.y); if (!this.node.position.equals(this._targetPos)) { @@ -45,7 +67,9 @@ export class Player extends Component { this.setAni('idle'); } } - updateOther(state: PlayerState) { + + // 插值更新 + private _tweenState(state: PlayerState, now: number) { // 更新位置 let newPos = new Vec3(state.pos.x, 0, -state.pos.y); if (!this._targetPos.equals(newPos)) { @@ -73,10 +97,16 @@ export class Player extends Component { } } + private _lastAni?: string; setAni(ani: string) { - if (this.ani.getState(ani)?.isPlaying) { + if (this.state.dizzyEndTime && this.state.dizzyEndTime >= this.now) { + ani = 'win'; + } + + if (this._lastAni === ani) { return; } + this._lastAni = ani; this.ani.crossFade(ani, 0.1); } diff --git a/examples/cocos-creator-multiplayer/frontend/assets/scenes/GameScene/GameScene.scene b/examples/cocos-creator-multiplayer/frontend/assets/scenes/GameScene/GameScene.scene index ffa8349..bb6b39e 100644 --- a/examples/cocos-creator-multiplayer/frontend/assets/scenes/GameScene/GameScene.scene +++ b/examples/cocos-creator-multiplayer/frontend/assets/scenes/GameScene/GameScene.scene @@ -20,24 +20,24 @@ { "__id__": 6 }, - { - "__id__": 9 - }, { "__id__": 5 }, { - "__id__": 19 + "__id__": 16 + }, + { + "__id__": 25 } ], "_active": true, "_components": [], "_prefab": { - "__id__": 43 + "__id__": 57 }, "autoReleaseAssets": false, "_globals": { - "__id__": 46 + "__id__": 60 }, "_id": "0d3889f6-dc9c-424e-b8cd-6fa78d63af15" }, @@ -185,18 +185,148 @@ }, { "__type__": "cc.Node", - "_name": "Plane", "_objFlags": 0, "_parent": { "__id__": 1 }, - "_children": [], - "_active": false, - "_components": [ + "_prefab": { + "__id__": 7 + } + }, + { + "__type__": "cc.PrefabInfo", + "root": { + "__id__": 6 + }, + "asset": { + "__uuid__": "3777d1a7-cafe-44be-9efd-ae46b6457e2c@fc11b", + "__expectedType__": "cc.Prefab" + }, + "fileId": "2cyg9D4KRTnaWvFuyUcwrn", + "instance": { + "__id__": 8 + } + }, + { + "__type__": "cc.PrefabInstance", + "fileId": "0aP//OBbtBM7WKwKJf+Wup", + "mountedChildren": [], + "mountedComponents": [], + "propertyOverrides": [ { - "__id__": 7 + "__id__": 9 + }, + { + "__id__": 11 + }, + { + "__id__": 12 + }, + { + "__id__": 13 + }, + { + "__id__": 14 } ], + "removedComponents": [] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 10 + }, + "propertyPath": [ + "_name" + ], + "value": "newMap01" + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "2cyg9D4KRTnaWvFuyUcwrn" + ] + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 10 + }, + "propertyPath": [ + "_lpos" + ], + "value": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 10 + }, + "propertyPath": [ + "_lrot" + ], + "value": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + } + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 10 + }, + "propertyPath": [ + "_euler" + ], + "value": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + } + }, + { + "__type__": "CCPropertyOverrideInfo", + "targetInfo": { + "__id__": 15 + }, + "propertyPath": [ + "_materials", + "0" + ], + "value": { + "__uuid__": "5ff93eca-e35a-43eb-b801-6e99d62ccac5", + "__expectedType__": "cc.Material" + } + }, + { + "__type__": "cc.TargetInfo", + "localID": [ + "70i4FgkglSS44fGyMM5mGT" + ] + }, + { + "__type__": "cc.Node", + "_name": "arrows", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 17 + } + ], + "_active": true, + "_components": [], "_prefab": null, "_lpos": { "__type__": "cc.Vec3", @@ -213,9 +343,9 @@ }, "_lscale": { "__type__": "cc.Vec3", - "x": 100, - "y": 100, - "z": 100 + "x": 1, + "y": 1, + "z": 1 }, "_layer": 1073741824, "_euler": { @@ -224,97 +354,49 @@ "y": 0, "z": 0 }, - "_id": "1erbampNxCKK1cr4qjZjeX" - }, - { - "__type__": "cc.MeshRenderer", - "_name": "Plane", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 6 - }, - "_enabled": true, - "__prefab": null, - "_materials": [ - { - "__uuid__": "00f711c1-6f4c-4de3-bc9b-52888e03f3ac", - "__expectedType__": "cc.Material" - } - ], - "_visFlags": 0, - "lightmapSettings": { - "__id__": 8 - }, - "_mesh": { - "__uuid__": "1263d74c-8167-4928-91a6-4e2672411f47@2e76e", - "__expectedType__": "cc.Mesh" - }, - "_shadowCastingMode": 0, - "_shadowReceivingMode": 1, - "_enableMorph": true, - "_id": "82T+4KKehOcqLqvINaID/a" - }, - { - "__type__": "cc.ModelLightmapSettings", - "texture": null, - "uvParam": { - "__type__": "cc.Vec4", - "x": 0, - "y": 0, - "z": 0, - "w": 0 - }, - "_bakeable": false, - "_castShadow": false, - "_receiveShadow": false, - "_recieveShadow": false, - "_lightmapSize": 64 + "_id": "46+eJFPoNAd75C26ynMBuo" }, { "__type__": "cc.Node", "_objFlags": 0, "_parent": { - "__id__": 1 + "__id__": 16 }, "_prefab": { - "__id__": 10 + "__id__": 18 } }, { "__type__": "cc.PrefabInfo", "root": { - "__id__": 9 + "__id__": 17 }, "asset": { - "__uuid__": "c26a63b9-5039-47ae-b027-ef2bce881f6f@fc11b", + "__uuid__": "6eda806d-83a6-474f-a7b7-b75c57ba73b3", "__expectedType__": "cc.Prefab" }, - "fileId": "2cyg9D4KRTnaWvFuyUcwrn", + "fileId": "ad10ECDidH979xbvqlbbgn", "instance": { - "__id__": 11 + "__id__": 19 } }, { "__type__": "cc.PrefabInstance", - "fileId": "e7wpFdRzxFupYfDrzr/lg7", + "fileId": "f7+AxAbd1K15HySl2cJ7yx", "mountedChildren": [], "mountedComponents": [], "propertyOverrides": [ { - "__id__": 12 + "__id__": 20 }, { - "__id__": 14 + "__id__": 22 }, { - "__id__": 15 + "__id__": 23 }, { - "__id__": 16 - }, - { - "__id__": 17 + "__id__": 24 } ], "removedComponents": [] @@ -322,23 +404,23 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 13 + "__id__": 21 }, "propertyPath": [ "_name" ], - "value": "newMap01" + "value": "Arrow" }, { "__type__": "cc.TargetInfo", "localID": [ - "2cyg9D4KRTnaWvFuyUcwrn" + "ad10ECDidH979xbvqlbbgn" ] }, { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 13 + "__id__": 21 }, "propertyPath": [ "_lpos" @@ -346,14 +428,14 @@ "value": { "__type__": "cc.Vec3", "x": 0, - "y": 0, + "y": 1.248, "z": 0 } }, { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 13 + "__id__": 21 }, "propertyPath": [ "_lrot" @@ -369,7 +451,7 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 13 + "__id__": 21 }, "propertyPath": [ "_euler" @@ -381,26 +463,6 @@ "z": 0 } }, - { - "__type__": "CCPropertyOverrideInfo", - "targetInfo": { - "__id__": 18 - }, - "propertyPath": [ - "_materials", - "0" - ], - "value": { - "__uuid__": "b7d6d595-6cd1-43c6-8bc7-3a92644870b9", - "__expectedType__": "cc.Material" - } - }, - { - "__type__": "cc.TargetInfo", - "localID": [ - "7cPmRsw4Ne67cKUY0ub3s2" - ] - }, { "__type__": "cc.Node", "_name": "Canvas", @@ -410,25 +472,28 @@ }, "_children": [ { - "__id__": 20 + "__id__": 26 }, { - "__id__": 22 + "__id__": 28 + }, + { + "__id__": 45 } ], "_active": true, "_components": [ { - "__id__": 39 + "__id__": 53 }, { - "__id__": 40 + "__id__": 54 }, { - "__id__": 41 + "__id__": 55 }, { - "__id__": 42 + "__id__": 56 } ], "_prefab": null, @@ -465,13 +530,13 @@ "_name": "Camera", "_objFlags": 0, "_parent": { - "__id__": 19 + "__id__": 25 }, "_children": [], "_active": true, "_components": [ { - "__id__": 21 + "__id__": 27 } ], "_prefab": null, @@ -508,7 +573,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 20 + "__id__": 26 }, "_enabled": true, "__prefab": null, @@ -548,16 +613,16 @@ "__type__": "cc.Node", "_objFlags": 0, "_parent": { - "__id__": 19 + "__id__": 25 }, "_prefab": { - "__id__": 23 + "__id__": 29 } }, { "__type__": "cc.PrefabInfo", "root": { - "__id__": 22 + "__id__": 28 }, "asset": { "__uuid__": "0363f7f8-204e-410e-ade0-03adca6ea835", @@ -565,7 +630,7 @@ }, "fileId": "25fHuwytBN2qk6dH5oVJvO", "instance": { - "__id__": 24 + "__id__": 30 } }, { @@ -575,31 +640,31 @@ "mountedComponents": [], "propertyOverrides": [ { - "__id__": 25 - }, - { - "__id__": 27 - }, - { - "__id__": 28 - }, - { - "__id__": 29 - }, - { - "__id__": 30 - }, - { - "__id__": 32 + "__id__": 31 }, { "__id__": 33 }, + { + "__id__": 34 + }, { "__id__": 35 }, { - "__id__": 37 + "__id__": 36 + }, + { + "__id__": 38 + }, + { + "__id__": 39 + }, + { + "__id__": 41 + }, + { + "__id__": 43 } ], "removedComponents": [] @@ -607,7 +672,7 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 26 + "__id__": 32 }, "propertyPath": [ "_name" @@ -623,7 +688,7 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 26 + "__id__": 32 }, "propertyPath": [ "_lpos" @@ -638,7 +703,7 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 26 + "__id__": 32 }, "propertyPath": [ "_lrot" @@ -654,7 +719,7 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 26 + "__id__": 32 }, "propertyPath": [ "_euler" @@ -669,7 +734,7 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 31 + "__id__": 37 }, "propertyPath": [ "_contentSize" @@ -689,7 +754,7 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 26 + "__id__": 32 }, "propertyPath": [ "_layer" @@ -699,7 +764,7 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 34 + "__id__": 40 }, "propertyPath": [ "_layer" @@ -715,7 +780,7 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 36 + "__id__": 42 }, "propertyPath": [ "_layer" @@ -731,7 +796,7 @@ { "__type__": "CCPropertyOverrideInfo", "targetInfo": { - "__id__": 38 + "__id__": 44 }, "propertyPath": [ "_layer" @@ -744,12 +809,307 @@ "ceQ/tc9/lBPIsW1Hwyb91a" ] }, + { + "__type__": "cc.Node", + "_name": "Button", + "_objFlags": 0, + "_parent": { + "__id__": 25 + }, + "_children": [ + { + "__id__": 46 + } + ], + "_active": true, + "_components": [ + { + "__id__": 49 + }, + { + "__id__": 50 + }, + { + "__id__": 51 + } + ], + "_prefab": null, + "_lpos": { + "__type__": "cc.Vec3", + "x": 264.283, + "y": -478.226, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 33554432, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "44lzj+VZRCMLuziTcP1V6q" + }, + { + "__type__": "cc.Node", + "_name": "Label", + "_objFlags": 512, + "_parent": { + "__id__": 45 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 47 + }, + { + "__id__": 48 + } + ], + "_prefab": null, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_layer": 33554432, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "afHTkFAaBL6qlFBW/06nBo" + }, { "__type__": "cc.UITransform", "_name": "", "_objFlags": 0, "node": { - "__id__": 19 + "__id__": 46 + }, + "_enabled": true, + "__prefab": null, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 40 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "d0+XZjhtFN4o0VtZ3cP1zP" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 46 + }, + "_enabled": true, + "__prefab": null, + "_visFlags": 0, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_string": "射", + "_horizontalAlign": 1, + "_verticalAlign": 1, + "_actualFontSize": 40, + "_fontSize": 40, + "_fontFamily": "Arial", + "_lineHeight": 40, + "_overflow": 1, + "_enableWrapText": false, + "_font": null, + "_isSystemFontUsed": true, + "_isItalic": false, + "_isBold": false, + "_isUnderline": false, + "_underlineHeight": 2, + "_cacheMode": 0, + "_id": "c1kmr4puZOWoZlBemNQ7cf" + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 45 + }, + "_enabled": true, + "__prefab": null, + "_contentSize": { + "__type__": "cc.Size", + "width": 100, + "height": 100 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_id": "d93lLsU2NL9oCpzxLfa4KT" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 45 + }, + "_enabled": true, + "__prefab": null, + "_visFlags": 0, + "_customMaterial": null, + "_srcBlendFactor": 2, + "_dstBlendFactor": 4, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_spriteFrame": { + "__uuid__": "20835ba4-6145-4fbc-a58a-051ce700aa3e@f9941", + "__expectedType__": "cc.SpriteFrame" + }, + "_type": 1, + "_fillType": 0, + "_sizeMode": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_useGrayscale": false, + "_atlas": null, + "_id": "4cPoFJnW5GHrHtY9gw0VbP" + }, + { + "__type__": "cc.Button", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 45 + }, + "_enabled": true, + "__prefab": null, + "clickEvents": [ + { + "__id__": 52 + } + ], + "_interactable": true, + "_transition": 3, + "_normalColor": { + "__type__": "cc.Color", + "r": 214, + "g": 214, + "b": 214, + "a": 255 + }, + "_hoverColor": { + "__type__": "cc.Color", + "r": 211, + "g": 211, + "b": 211, + "a": 255 + }, + "_pressedColor": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_disabledColor": { + "__type__": "cc.Color", + "r": 124, + "g": 124, + "b": 124, + "a": 255 + }, + "_normalSprite": { + "__uuid__": "20835ba4-6145-4fbc-a58a-051ce700aa3e@f9941", + "__expectedType__": "cc.SpriteFrame" + }, + "_hoverSprite": { + "__uuid__": "20835ba4-6145-4fbc-a58a-051ce700aa3e@f9941", + "__expectedType__": "cc.SpriteFrame" + }, + "_pressedSprite": { + "__uuid__": "544e49d6-3f05-4fa8-9a9e-091f98fc2ce8@f9941", + "__expectedType__": "cc.SpriteFrame" + }, + "_disabledSprite": { + "__uuid__": "951249e0-9f16-456d-8b85-a6ca954da16b@f9941", + "__expectedType__": "cc.SpriteFrame" + }, + "_duration": 0.1, + "_zoomScale": 1.2, + "_target": { + "__id__": 45 + }, + "_id": "96d2z2/TpJ558pTlUMNNUO" + }, + { + "__type__": "cc.ClickEvent", + "target": { + "__id__": 25 + }, + "component": "", + "_componentId": "d4728cOzxlKHLMu5Xg48U8U", + "handler": "onBtnAttack", + "customEventData": "" + }, + { + "__type__": "cc.UITransform", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 25 }, "_enabled": true, "__prefab": null, @@ -770,12 +1130,12 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 19 + "__id__": 25 }, "_enabled": true, "__prefab": null, "_cameraComponent": { - "__id__": 21 + "__id__": 27 }, "_alignCanvasWithScreen": true, "_id": "ebX9QTnS1AlKH1eI+/bdJk" @@ -785,7 +1145,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 19 + "__id__": 25 }, "_enabled": true, "__prefab": null, @@ -814,7 +1174,7 @@ "_name": "", "_objFlags": 0, "node": { - "__id__": 19 + "__id__": 25 }, "_enabled": true, "__prefab": null, @@ -823,9 +1183,16 @@ "__uuid__": "809957ef-4f3f-4527-87cc-cb3223f7500a", "__expectedType__": "cc.Prefab" }, + "prefabArrow": { + "__uuid__": "6eda806d-83a6-474f-a7b7-b75c57ba73b3", + "__expectedType__": "cc.Prefab" + }, "players": { "__id__": 5 }, + "arrows": { + "__id__": 16 + }, "camera": { "__id__": 4 }, @@ -836,24 +1203,24 @@ "fileId": "", "targetOverrides": [ { - "__id__": 44 + "__id__": 58 } ] }, { "__type__": "cc.TargetOverrideInfo", "source": { - "__id__": 42 + "__id__": 56 }, "sourceInfo": null, "propertyPath": [ "joyStick" ], "target": { - "__id__": 22 + "__id__": 28 }, "targetInfo": { - "__id__": 45 + "__id__": 59 } }, { @@ -865,16 +1232,16 @@ { "__type__": "cc.SceneGlobals", "ambient": { - "__id__": 47 + "__id__": 61 }, "shadows": { - "__id__": 48 + "__id__": 62 }, "_skybox": { - "__id__": 49 + "__id__": 63 }, "fog": { - "__id__": 50 + "__id__": 64 } }, { diff --git a/examples/cocos-creator-multiplayer/frontend/assets/scenes/GameScene/GameScene.ts b/examples/cocos-creator-multiplayer/frontend/assets/scenes/GameScene/GameScene.ts index 560c105..c089af8 100644 --- a/examples/cocos-creator-multiplayer/frontend/assets/scenes/GameScene/GameScene.ts +++ b/examples/cocos-creator-multiplayer/frontend/assets/scenes/GameScene/GameScene.ts @@ -1,5 +1,6 @@ import { Component, instantiate, Node, Prefab, Vec2, _decorator } from 'cc'; +import { Arrow } from '../../prefabs/Arrow/Arrow'; import { Joystick } from '../../prefabs/Joystick/Joystick'; import { Player } from '../../prefabs/Player/Player'; import { FollowCamera } from '../../scripts/components/FollowCamera'; @@ -27,9 +28,13 @@ export class GameScene extends Component { @property(Prefab) prefabPlayer!: Prefab; + @property(Prefab) + prefabArrow!: Prefab; @property(Node) players!: Node; + @property(Node) + arrows!: Node; @property(FollowCamera) camera: FollowCamera = null as any; @@ -37,6 +42,7 @@ export class GameScene extends Component { gameManager = new GameManager(); private _playerInstances: { [playerId: number]: Player } = {}; + private _arrowInstances: { [arrowId: number]: Arrow } = {}; private _selfSpeed?: Vec2 = new Vec2(0, 0); onLoad() { @@ -63,7 +69,6 @@ export class GameScene extends Component { } update(dt: number) { - // Send Inputs if (this._selfSpeed && this._selfSpeed.lengthSqr()) { this._selfSpeed.normalize().multiplyScalar(gameConfig.moveSpeed); @@ -77,6 +82,11 @@ export class GameScene extends Component { }) } + this._updatePlayers(); + this._updateArrows(); + } + + private _updatePlayers() { // Update pos let playerStates = this.gameManager.state.players; for (let playerState of playerStates) { @@ -94,7 +104,7 @@ export class GameScene extends Component { } // 自己不插值(本地预测),插值其它人 - player.isSelf ? player.updateSelf(playerState) : player.updateOther(playerState); + player.updateState(playerState, this.gameManager.state.now); } // Clear left players @@ -107,4 +117,36 @@ export class GameScene extends Component { } } + private _updateArrows() { + // Update pos + let arrowStates = this.gameManager.state.arrows; + for (let arrowState of arrowStates) { + let arrow: Arrow = this._arrowInstances[arrowState.id]; + if (!arrow) { + let node = instantiate(this.prefabArrow); + this.arrows.addChild(node); + arrow = this._arrowInstances[arrowState.id] = node.getComponent(Arrow)!; + arrow.init(arrowState) + } + + arrow.updateState(arrowState, this.gameManager.state.now); + } + + // Clear left players + for (let i = this.arrows.children.length - 1; i > -1; --i) { + let arrow = this.arrows.children[i].getComponent(Arrow)!; + if (!this.gameManager.state.arrows.find(v => v.id === arrow.id)) { + arrow.node.removeFromParent(); + delete this._arrowInstances[arrow.id]; + } + } + } + + onBtnAttack() { + this.gameManager.sendClientInput({ + type: 'PlayerAttack', + direction: this._playerInstances[this.gameManager.selfPlayerId].node.forward + }) + } + } \ No newline at end of file diff --git a/examples/cocos-creator-multiplayer/frontend/assets/scripts/components/FollowCamera.ts b/examples/cocos-creator-multiplayer/frontend/assets/scripts/components/FollowCamera.ts index 3a0450c..eb40da3 100644 --- a/examples/cocos-creator-multiplayer/frontend/assets/scripts/components/FollowCamera.ts +++ b/examples/cocos-creator-multiplayer/frontend/assets/scripts/components/FollowCamera.ts @@ -1,4 +1,4 @@ -import { _decorator, Component, Node, Vec3, Quat, Tween, tween } from "cc"; +import { Component, Node, Tween, Vec3, _decorator } from "cc"; import { MathUtil } from '../models/MathUtil'; const { ccclass, property } = _decorator; @@ -34,7 +34,7 @@ export class FollowCamera extends Component { minZ = -Infinity; maxZ = Infinity; - protected _tweenFollow?: Tween; + protected _tweenFollow?: Tween; protected _targetWorldPos = new Vec3; protected _lastTargetPos = new Vec3; diff --git a/examples/cocos-creator-multiplayer/frontend/assets/scripts/models/GameManager.ts b/examples/cocos-creator-multiplayer/frontend/assets/scripts/models/GameManager.ts index 57a390f..6ec3182 100644 --- a/examples/cocos-creator-multiplayer/frontend/assets/scripts/models/GameManager.ts +++ b/examples/cocos-creator-multiplayer/frontend/assets/scripts/models/GameManager.ts @@ -38,7 +38,6 @@ export class GameManager { }); } - (window as any).gm = this; }