This commit is contained in:
k8w 2021-12-03 00:29:22 +08:00
parent 03aeff62c5
commit 22c9913ed6
50 changed files with 1762 additions and 1190 deletions

View File

@ -68,7 +68,7 @@ export class Room {
}); });
// TimePast // TimePast
let now = process.uptime(); let now = process.uptime() * 1000;
this.applyInput({ this.applyInput({
type: 'TimePast', type: 'TimePast',
dt: now - (this.lastSyncTime ?? now) dt: now - (this.lastSyncTime ?? now)

View File

@ -5,7 +5,7 @@ import { PlayerState } from "./state/PlayerState";
export interface GameSystemState { export interface GameSystemState {
now: number, now: number,
players: PlayerState[], players: PlayerState[],
arrow: ArrowState[], arrows: ArrowState[],
nextArrowId: number nextArrowId: number
} }
@ -15,7 +15,7 @@ export class GameSystem {
private _state: GameSystemState = { private _state: GameSystemState = {
now: 0, now: 0,
players: [], players: [],
arrow: [], arrows: [],
nextArrowId: 1 nextArrowId: 1
} }
get state(): Readonly<GameSystemState> { get state(): Readonly<GameSystemState> {
@ -43,7 +43,7 @@ export class GameSystem {
else if (input.type === 'PlayerAttack') { else if (input.type === 'PlayerAttack') {
let player = this._state.players.find(v => v.id === input.playerId); let player = this._state.players.find(v => v.id === input.playerId);
if (player) { if (player) {
this._state.arrow.push({ this._state.arrows.push({
id: this._state.nextArrowId++, id: this._state.nextArrowId++,
fromPlayerId: input.playerId, fromPlayerId: input.playerId,
startPos: { ...player.pos }, startPos: { ...player.pos },
@ -69,11 +69,16 @@ export class GameSystem {
this._state.now += input.dt; this._state.now += input.dt;
// 落地的 Arrow // 落地的 Arrow
for (let i = this._state.arrow.length - 1; i > -1; --i) { for (let i = this._state.arrows.length - 1; i > -1; --i) {
let arrow = this._state.arrow[i]; let arrow = this._state.arrows[i];
if (arrow.targetTime <= this._state.now) { if (arrow.targetTime <= this._state.now) {
// 伤害判定 // 伤害判定
let damagedPlayers = this._state.players.filter(v => { 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 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 => { damagedPlayers.forEach(p => {
@ -86,6 +91,7 @@ export class GameSystem {
toPlayerId: p.id toPlayerId: p.id
})) }))
}) })
this._state.arrows.splice(i, 1);
} }
} }
} }

View File

@ -8,7 +8,7 @@ export const gameConfig = {
moveSpeed: 10, moveSpeed: 10,
arrowFlyTime: 1000, arrowFlyTime: 500,
arrowDistance: 2, arrowDistance: 7,
arrowDizzyTime: 1000 arrowDizzyTime: 1000
} }

View File

@ -17,6 +17,7 @@ export interface ServiceType {
} }
export const serviceProto: ServiceProto<ServiceType> = { export const serviceProto: ServiceProto<ServiceType> = {
"version": 1,
"services": [ "services": [
{ {
"id": 0, "id": 0,
@ -227,8 +228,8 @@ export const serviceProto: ServiceProto<ServiceType> = {
} }
}, },
{ {
"id": 2, "id": 4,
"name": "arrow", "name": "arrows",
"type": { "type": {
"type": "Array", "type": "Array",
"elementType": { "elementType": {

View File

@ -2,7 +2,7 @@
"ver": "1.1.0", "ver": "1.1.0",
"importer": "directory", "importer": "directory",
"imported": true, "imported": true,
"uuid": "b62bf789-093f-4583-8530-86e00cd8a2a6", "uuid": "d739d6a2-6087-4eb8-992d-7782bb91ca03",
"files": [], "files": [],
"subMetas": {}, "subMetas": {},
"userData": { "userData": {

View File

@ -27,7 +27,7 @@
"_props": [ "_props": [
{ {
"mainTexture": { "mainTexture": {
"__uuid__": "e90ad74a-b668-4e2c-bf91-51a2a91b02aa@6c48a", "__uuid__": "81f16ace-2b57-44c3-804d-c192ed53aaee@6c48a",
"__expectedType__": "cc.Texture2D" "__expectedType__": "cc.Texture2D"
} }
} }

View File

@ -2,7 +2,7 @@
"ver": "1.0.9", "ver": "1.0.9",
"importer": "material", "importer": "material",
"imported": true, "imported": true,
"uuid": "5cf1ff47-b589-490a-bc78-a88f743b9798", "uuid": "034d148f-998d-453d-baed-7ebbea501d20",
"files": [ "files": [
".json" ".json"
], ],

View File

@ -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
}
}

View File

@ -4,34 +4,32 @@
"_objFlags": 0, "_objFlags": 0,
"_native": "", "_native": "",
"_effectAsset": { "_effectAsset": {
"__uuid__": "1baf0fc9-befa-459c-8bdd-af1a450a0319" "__uuid__": "a3cd009f-0ab0-420d-9278-b9fdab939bbc",
"__expectedType__": "cc.EffectAsset"
}, },
"_techIdx": 0, "_techIdx": 0,
"_defines": [ "_defines": [
{ {
"USE_SKINNING": 2, "USE_TEXTURE": true
"USE_ALBEDO_MAP": true
} }
], ],
"_states": [ "_states": [
{ {
"rasterizerState": {},
"depthStencilState": {},
"blendState": { "blendState": {
"targets": [ "targets": [
{} {}
] ]
}, }
"depthStencilState": {},
"rasterizerState": {}
} }
], ],
"_props": [ "_props": [
{ {
"alphaThreshold": 0,
"roughness": 0.70710676908493,
"metallic": 0.400000005960464,
"mainTexture": { "mainTexture": {
"__uuid__": "8b8d74a3-bdf7-4c4d-8334-2cb7e0f7bf88@6c48a" "__uuid__": "8b29322f-dd78-4a56-98d7-b3d60e2d8a84@6c48a",
"__expectedType__": "cc.Texture2D"
} }
} }
] ]
} }

View File

@ -0,0 +1,11 @@
{
"ver": "1.0.9",
"importer": "material",
"imported": true,
"uuid": "5d9da4c3-349b-4309-8efe-7c16bffd5ed4",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}

View File

@ -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"
}
},
{},
{},
{}
]
}

View File

@ -2,7 +2,7 @@
"ver": "1.0.9", "ver": "1.0.9",
"importer": "material", "importer": "material",
"imported": true, "imported": true,
"uuid": "5620e8a2-444d-4e80-9eb8-f6f54bd4d3cf", "uuid": "75328980-c98c-4c02-ab3d-180696f319a0",
"files": [ "files": [
".json" ".json"
], ],

View File

@ -0,0 +1,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "ec996a75-19b5-4c0c-a9cd-f493a945a73e",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@ -0,0 +1,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "9ca73d01-a6f2-4dc2-b7d7-658d9d101d8c",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@ -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"
}
}
]
}

View File

@ -0,0 +1,11 @@
{
"ver": "1.0.9",
"importer": "material",
"imported": true,
"uuid": "196eebe8-170f-4ba9-a767-9f6d664c6e04",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}

View File

@ -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"
}
},
{},
{},
{}
]
}

View File

@ -0,0 +1,11 @@
{
"ver": "1.0.9",
"importer": "material",
"imported": true,
"uuid": "c2e9d35e-0f85-4427-9368-096fe7b303d6",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}

View File

@ -2,33 +2,17 @@
"ver": "2.1.4", "ver": "2.1.4",
"importer": "fbx", "importer": "fbx",
"imported": true, "imported": true,
"uuid": "57d4c4ef-3199-4596-bf79-7c065964ca9c", "uuid": "e8fe9966-5f03-4cc0-ad69-01d536be6c21",
"files": [ "files": [
"__original-animation-0.cconb" "__original-animation-0.cconb"
], ],
"subMetas": { "subMetas": {
"95953": { "2ed96": {
"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": {
"importer": "gltf-mesh", "importer": "gltf-mesh",
"uuid": "57d4c4ef-3199-4596-bf79-7c065964ca9c@6868c", "uuid": "e8fe9966-5f03-4cc0-ad69-01d536be6c21@2ed96",
"displayName": "", "displayName": "",
"id": "6868c", "id": "2ed96",
"name": "soldier01.mesh", "name": "javelin01.mesh",
"userData": { "userData": {
"gltfIndex": 0 "gltfIndex": 0
}, },
@ -42,7 +26,7 @@
}, },
"1f586": { "1f586": {
"importer": "gltf-animation", "importer": "gltf-animation",
"uuid": "57d4c4ef-3199-4596-bf79-7c065964ca9c@1f586", "uuid": "e8fe9966-5f03-4cc0-ad69-01d536be6c21@1f586",
"displayName": "", "displayName": "",
"id": "1f586", "id": "1f586",
"name": "idle.animation", "name": "idle.animation",
@ -65,7 +49,7 @@
}, },
"cf5ee": { "cf5ee": {
"importer": "gltf-animation", "importer": "gltf-animation",
"uuid": "57d4c4ef-3199-4596-bf79-7c065964ca9c@cf5ee", "uuid": "e8fe9966-5f03-4cc0-ad69-01d536be6c21@cf5ee",
"displayName": "", "displayName": "",
"id": "cf5ee", "id": "cf5ee",
"name": "run.animation", "name": "run.animation",
@ -88,7 +72,7 @@
}, },
"989ed": { "989ed": {
"importer": "gltf-animation", "importer": "gltf-animation",
"uuid": "57d4c4ef-3199-4596-bf79-7c065964ca9c@989ed", "uuid": "e8fe9966-5f03-4cc0-ad69-01d536be6c21@989ed",
"displayName": "", "displayName": "",
"id": "989ed", "id": "989ed",
"name": "attack.animation", "name": "attack.animation",
@ -102,12 +86,12 @@
}, },
"events": [ "events": [
{ {
"frame": 0.23333333333333334, "frame": 0.3,
"func": "", "func": "",
"params": [] "params": []
}, },
{ {
"frame": 0.23333333333333334, "frame": 0.3,
"func": "triggerEffect", "func": "triggerEffect",
"params": [] "params": []
} }
@ -123,7 +107,7 @@
}, },
"ee525": { "ee525": {
"importer": "gltf-animation", "importer": "gltf-animation",
"uuid": "57d4c4ef-3199-4596-bf79-7c065964ca9c@ee525", "uuid": "e8fe9966-5f03-4cc0-ad69-01d536be6c21@ee525",
"displayName": "", "displayName": "",
"id": "ee525", "id": "ee525",
"name": "win.animation", "name": "win.animation",
@ -146,7 +130,7 @@
}, },
"5b2e9": { "5b2e9": {
"importer": "gltf-animation", "importer": "gltf-animation",
"uuid": "57d4c4ef-3199-4596-bf79-7c065964ca9c@5b2e9", "uuid": "e8fe9966-5f03-4cc0-ad69-01d536be6c21@5b2e9",
"displayName": "", "displayName": "",
"id": "5b2e9", "id": "5b2e9",
"name": "died.animation", "name": "died.animation",
@ -156,7 +140,7 @@
"sample": 30, "sample": 30,
"span": { "span": {
"from": 2.8, "from": 2.8,
"to": 4.333333333333333 "to": 4.125
}, },
"events": [] "events": []
}, },
@ -169,7 +153,7 @@
}, },
"438fe": { "438fe": {
"importer": "gltf-skeleton", "importer": "gltf-skeleton",
"uuid": "57d4c4ef-3199-4596-bf79-7c065964ca9c@438fe", "uuid": "e8fe9966-5f03-4cc0-ad69-01d536be6c21@438fe",
"displayName": "", "displayName": "",
"id": "438fe", "id": "438fe",
"name": "UnnamedSkeleton.skeleton", "name": "UnnamedSkeleton.skeleton",
@ -184,12 +168,12 @@
], ],
"subMetas": {} "subMetas": {}
}, },
"fa1d4": { "ab717": {
"importer": "gltf-embeded-image", "importer": "gltf-embeded-image",
"uuid": "57d4c4ef-3199-4596-bf79-7c065964ca9c@fa1d4", "uuid": "e8fe9966-5f03-4cc0-ad69-01d536be6c21@ab717",
"displayName": "", "displayName": "",
"id": "fa1d4", "id": "ab717",
"name": "soldier01.jpg.image", "name": "javelin01.jpg.image",
"userData": { "userData": {
"gltfIndex": 0 "gltfIndex": 0
}, },
@ -201,12 +185,12 @@
], ],
"subMetas": {} "subMetas": {}
}, },
"291d4": { "eb794": {
"importer": "texture", "importer": "texture",
"uuid": "57d4c4ef-3199-4596-bf79-7c065964ca9c@291d4", "uuid": "e8fe9966-5f03-4cc0-ad69-01d536be6c21@eb794",
"displayName": "", "displayName": "",
"id": "291d4", "id": "eb794",
"name": "贴图 #6.texture", "name": "贴图 #5.texture",
"userData": { "userData": {
"wrapModeS": "repeat", "wrapModeS": "repeat",
"wrapModeT": "repeat", "wrapModeT": "repeat",
@ -215,7 +199,7 @@
"mipfilter": "none", "mipfilter": "none",
"anisotropy": 0, "anisotropy": 0,
"isUuid": true, "isUuid": true,
"imageUuidOrDatabaseUri": "57d4c4ef-3199-4596-bf79-7c065964ca9c@fa1d4" "imageUuidOrDatabaseUri": "e8fe9966-5f03-4cc0-ad69-01d536be6c21@ab717"
}, },
"ver": "1.0.21", "ver": "1.0.21",
"imported": true, "imported": true,
@ -224,12 +208,28 @@
], ],
"subMetas": {} "subMetas": {}
}, },
"33dba": { "a47c6": {
"importer": "gltf-scene", "importer": "gltf-material",
"uuid": "57d4c4ef-3199-4596-bf79-7c065964ca9c@33dba", "uuid": "e8fe9966-5f03-4cc0-ad69-01d536be6c21@a47c6",
"displayName": "", "displayName": "",
"id": "33dba", "id": "a47c6",
"name": "soldier01.prefab", "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": { "userData": {
"gltfIndex": 0 "gltfIndex": 0
}, },
@ -244,14 +244,14 @@
"userData": { "userData": {
"imageMetas": [ "imageMetas": [
{ {
"name": "soldier01.jpg", "name": "javelin01.jpg",
"uri": "57d4c4ef-3199-4596-bf79-7c065964ca9c@fa1d4" "uri": "e8fe9966-5f03-4cc0-ad69-01d536be6c21@ab717"
} }
], ],
"animationImportSettings": [ "animationImportSettings": [
{ {
"name": "Take 001", "name": "Take 001",
"duration": 4.666666507720947, "duration": 4.125,
"fps": 30, "fps": 30,
"splits": [ "splits": [
{ {
@ -281,30 +281,32 @@
{ {
"name": "died", "name": "died",
"from": 2.8, "from": 2.8,
"to": 4.333333333333333, "to": 4.125,
"wrapMode": 2 "wrapMode": 2
} }
] ]
} }
], ],
"redirect": "57d4c4ef-3199-4596-bf79-7c065964ca9c@33dba", "redirect": "e8fe9966-5f03-4cc0-ad69-01d536be6c21@665d9",
"assetFinder": { "assetFinder": {
"meshes": [ "meshes": [
"57d4c4ef-3199-4596-bf79-7c065964ca9c@6868c" "e8fe9966-5f03-4cc0-ad69-01d536be6c21@2ed96"
], ],
"skeletons": [ "skeletons": [
"57d4c4ef-3199-4596-bf79-7c065964ca9c@438fe" "e8fe9966-5f03-4cc0-ad69-01d536be6c21@438fe"
], ],
"textures": [ "textures": [
"57d4c4ef-3199-4596-bf79-7c065964ca9c@291d4" "e8fe9966-5f03-4cc0-ad69-01d536be6c21@eb794"
], ],
"materials": [ "materials": [
"57d4c4ef-3199-4596-bf79-7c065964ca9c@95953" "e8fe9966-5f03-4cc0-ad69-01d536be6c21@a47c6"
], ],
"scenes": [ "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"
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

@ -2,7 +2,7 @@
"ver": "1.0.21", "ver": "1.0.21",
"importer": "image", "importer": "image",
"imported": true, "imported": true,
"uuid": "e90ad74a-b668-4e2c-bf91-51a2a91b02aa", "uuid": "81f16ace-2b57-44c3-804d-c192ed53aaee",
"files": [ "files": [
".jpg", ".jpg",
".json" ".json"
@ -11,7 +11,7 @@
"6c48a": { "6c48a": {
"ver": "1.0.21", "ver": "1.0.21",
"importer": "texture", "importer": "texture",
"uuid": "e90ad74a-b668-4e2c-bf91-51a2a91b02aa@6c48a", "uuid": "81f16ace-2b57-44c3-804d-c192ed53aaee@6c48a",
"imported": true, "imported": true,
"files": [ "files": [
".json" ".json"
@ -26,16 +26,16 @@
"premultiplyAlpha": false, "premultiplyAlpha": false,
"anisotropy": 0, "anisotropy": 0,
"isUuid": true, "isUuid": true,
"imageUuidOrDatabaseUri": "e90ad74a-b668-4e2c-bf91-51a2a91b02aa" "imageUuidOrDatabaseUri": "81f16ace-2b57-44c3-804d-c192ed53aaee"
}, },
"displayName": "soldier01", "displayName": "javelin01",
"id": "6c48a", "id": "6c48a",
"name": "texture" "name": "texture"
} }
}, },
"userData": { "userData": {
"type": "texture", "type": "texture",
"redirect": "e90ad74a-b668-4e2c-bf91-51a2a91b02aa@6c48a", "redirect": "81f16ace-2b57-44c3-804d-c192ed53aaee@6c48a",
"hasAlpha": false "hasAlpha": false
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

View File

@ -2,7 +2,7 @@
"ver": "1.0.21", "ver": "1.0.21",
"importer": "image", "importer": "image",
"imported": true, "imported": true,
"uuid": "f35bcb71-cd72-443c-94a9-5482c2d63d66", "uuid": "8b29322f-dd78-4a56-98d7-b3d60e2d8a84",
"files": [ "files": [
".jpg", ".jpg",
".json" ".json"
@ -11,7 +11,7 @@
"6c48a": { "6c48a": {
"ver": "1.0.21", "ver": "1.0.21",
"importer": "texture", "importer": "texture",
"uuid": "f35bcb71-cd72-443c-94a9-5482c2d63d66@6c48a", "uuid": "8b29322f-dd78-4a56-98d7-b3d60e2d8a84@6c48a",
"imported": true, "imported": true,
"files": [ "files": [
".json" ".json"
@ -26,16 +26,16 @@
"premultiplyAlpha": false, "premultiplyAlpha": false,
"anisotropy": 0, "anisotropy": 0,
"isUuid": true, "isUuid": true,
"imageUuidOrDatabaseUri": "f35bcb71-cd72-443c-94a9-5482c2d63d66" "imageUuidOrDatabaseUri": "8b29322f-dd78-4a56-98d7-b3d60e2d8a84"
}, },
"displayName": "soldier02", "displayName": "javelin02",
"id": "6c48a", "id": "6c48a",
"name": "texture" "name": "texture"
} }
}, },
"userData": { "userData": {
"type": "texture", "type": "texture",
"redirect": "f35bcb71-cd72-443c-94a9-5482c2d63d66@6c48a", "redirect": "8b29322f-dd78-4a56-98d7-b3d60e2d8a84@6c48a",
"hasAlpha": false "hasAlpha": false
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

View File

@ -2,7 +2,7 @@
"ver": "1.0.21", "ver": "1.0.21",
"importer": "image", "importer": "image",
"imported": true, "imported": true,
"uuid": "8b8d74a3-bdf7-4c4d-8334-2cb7e0f7bf88", "uuid": "00463b4b-2098-43bf-ab0f-75d68a7b19aa",
"files": [ "files": [
".jpg", ".jpg",
".json" ".json"
@ -11,7 +11,7 @@
"6c48a": { "6c48a": {
"ver": "1.0.21", "ver": "1.0.21",
"importer": "texture", "importer": "texture",
"uuid": "8b8d74a3-bdf7-4c4d-8334-2cb7e0f7bf88@6c48a", "uuid": "00463b4b-2098-43bf-ab0f-75d68a7b19aa@6c48a",
"imported": true, "imported": true,
"files": [ "files": [
".json" ".json"
@ -26,16 +26,16 @@
"premultiplyAlpha": false, "premultiplyAlpha": false,
"anisotropy": 0, "anisotropy": 0,
"isUuid": true, "isUuid": true,
"imageUuidOrDatabaseUri": "8b8d74a3-bdf7-4c4d-8334-2cb7e0f7bf88" "imageUuidOrDatabaseUri": "00463b4b-2098-43bf-ab0f-75d68a7b19aa"
}, },
"displayName": "soldier03", "displayName": "javelin03",
"id": "6c48a", "id": "6c48a",
"name": "texture" "name": "texture"
} }
}, },
"userData": { "userData": {
"type": "texture", "type": "texture",
"redirect": "8b8d74a3-bdf7-4c4d-8334-2cb7e0f7bf88@6c48a", "redirect": "00463b4b-2098-43bf-ab0f-75d68a7b19aa@6c48a",
"hasAlpha": false "hasAlpha": false
} }
} }

View File

@ -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"
}
},
{},
{},
{}
]
}

View File

@ -0,0 +1,11 @@
{
"ver": "1.0.9",
"importer": "material",
"imported": true,
"uuid": "08f0736d-0b54-4a93-9991-17d426a9fb01",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}

View File

@ -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"
}
},
{},
{},
{}
]
}

View File

@ -0,0 +1,11 @@
{
"ver": "1.0.9",
"importer": "material",
"imported": true,
"uuid": "40462a03-2591-4a93-8e5f-5815118c7fcb",
"files": [
".json"
],
"subMetas": {},
"userData": {}
}

View File

@ -2,86 +2,85 @@
"ver": "2.1.4", "ver": "2.1.4",
"importer": "fbx", "importer": "fbx",
"imported": true, "imported": true,
"uuid": "c26a63b9-5039-47ae-b027-ef2bce881f6f", "uuid": "3777d1a7-cafe-44be-9efd-ae46b6457e2c",
"files": [], "files": [],
"subMetas": { "subMetas": {
"f6845": { "f6845": {
"ver": "1.1.0",
"importer": "gltf-mesh", "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, "imported": true,
"files": [ "files": [
".bin", ".bin",
".json" ".json"
], ],
"subMetas": {}, "subMetas": {}
},
"1cdc4": {
"importer": "gltf-embeded-image",
"uuid": "3777d1a7-cafe-44be-9efd-ae46b6457e2c@1cdc4",
"displayName": "",
"id": "1cdc4",
"name": "贴图 #3.image",
"userData": { "userData": {
"gltfIndex": 0 "gltfIndex": 0
}, },
"displayName": "",
"id": "f6845",
"name": "newMap01.mesh"
},
"3500c": {
"ver": "1.0.3", "ver": "1.0.3",
"importer": "gltf-embeded-image",
"uuid": "c26a63b9-5039-47ae-b027-ef2bce881f6f@3500c",
"imported": true, "imported": true,
"files": [ "files": [
".jpg", ".jpg",
".json" ".json"
], ],
"subMetas": {}, "subMetas": {}
"userData": {
"gltfIndex": 0
},
"displayName": "",
"id": "3500c",
"name": "newMap01.jpg.image"
}, },
"bfae8": { "bfae8": {
"ver": "1.0.21",
"importer": "texture", "importer": "texture",
"uuid": "c26a63b9-5039-47ae-b027-ef2bce881f6f@bfae8", "uuid": "3777d1a7-cafe-44be-9efd-ae46b6457e2c@bfae8",
"imported": true, "displayName": "",
"files": [ "id": "bfae8",
".json" "name": "贴图 #3.texture",
],
"subMetas": {},
"userData": { "userData": {
"wrapModeS": "repeat", "wrapModeS": "repeat",
"wrapModeT": "repeat", "wrapModeT": "repeat",
"minfilter": "linear", "minfilter": "linear",
"magfilter": "linear", "magfilter": "linear",
"mipfilter": "none", "mipfilter": "none",
"premultiplyAlpha": false,
"anisotropy": 0, "anisotropy": 0,
"isUuid": true, "isUuid": true,
"imageUuidOrDatabaseUri": "c26a63b9-5039-47ae-b027-ef2bce881f6f@3500c" "imageUuidOrDatabaseUri": "3777d1a7-cafe-44be-9efd-ae46b6457e2c@1cdc4"
}, },
"displayName": "", "ver": "1.0.21",
"id": "bfae8",
"name": "贴图 #3.texture"
},
"7ff75": {
"ver": "1.0.14",
"importer": "gltf-material",
"uuid": "c26a63b9-5039-47ae-b027-ef2bce881f6f@7ff75",
"imported": true, "imported": true,
"files": [ "files": [
".json" ".json"
], ],
"subMetas": {}, "subMetas": {}
},
"7ff75": {
"importer": "gltf-material",
"uuid": "3777d1a7-cafe-44be-9efd-ae46b6457e2c@7ff75",
"displayName": "",
"id": "7ff75",
"name": "Material #27.material",
"userData": { "userData": {
"gltfIndex": 0 "gltfIndex": 0
}, },
"displayName": "", "ver": "1.0.14",
"id": "7ff75", "imported": true,
"name": "Material #27.material" "files": [
".json"
],
"subMetas": {}
}, },
"fc11b": { "fc11b": {
"importer": "gltf-scene", "importer": "gltf-scene",
"uuid": "c26a63b9-5039-47ae-b027-ef2bce881f6f@fc11b", "uuid": "3777d1a7-cafe-44be-9efd-ae46b6457e2c@fc11b",
"displayName": "", "displayName": "",
"id": "fc11b", "id": "fc11b",
"name": "newMap01.prefab", "name": "newMap01.prefab",
@ -99,26 +98,26 @@
"userData": { "userData": {
"imageMetas": [ "imageMetas": [
{ {
"name": "newMap01.jpg", "name": "贴图 #3",
"uri": "c26a63b9-5039-47ae-b027-ef2bce881f6f@3500c" "uri": "3777d1a7-cafe-44be-9efd-ae46b6457e2c@1cdc4"
} }
], ],
"redirect": "c26a63b9-5039-47ae-b027-ef2bce881f6f@fc11b", "legacyFbxImporter": false,
"redirect": "3777d1a7-cafe-44be-9efd-ae46b6457e2c@fc11b",
"assetFinder": { "assetFinder": {
"meshes": [ "meshes": [
"c26a63b9-5039-47ae-b027-ef2bce881f6f@f6845" "3777d1a7-cafe-44be-9efd-ae46b6457e2c@f6845"
], ],
"skeletons": [], "skeletons": [],
"textures": [ "textures": [
"c26a63b9-5039-47ae-b027-ef2bce881f6f@bfae8" "3777d1a7-cafe-44be-9efd-ae46b6457e2c@bfae8"
], ],
"materials": [ "materials": [
"c26a63b9-5039-47ae-b027-ef2bce881f6f@7ff75" "3777d1a7-cafe-44be-9efd-ae46b6457e2c@7ff75"
], ],
"scenes": [ "scenes": [
"c26a63b9-5039-47ae-b027-ef2bce881f6f@fc11b" "3777d1a7-cafe-44be-9efd-ae46b6457e2c@fc11b"
] ]
}, }
"legacyFbxImporter": true
} }
} }

View File

@ -2,40 +2,39 @@
"ver": "1.0.21", "ver": "1.0.21",
"importer": "image", "importer": "image",
"imported": true, "imported": true,
"uuid": "27e1fcb7-5016-4252-8c43-ac9c1c97308e", "uuid": "96c88bc3-119a-412a-ac6f-5936ba8b9dc7",
"files": [ "files": [
".jpg", ".jpg",
".json" ".json"
], ],
"subMetas": { "subMetas": {
"6c48a": { "6c48a": {
"ver": "1.0.21",
"importer": "texture", "importer": "texture",
"uuid": "27e1fcb7-5016-4252-8c43-ac9c1c97308e@6c48a", "uuid": "96c88bc3-119a-412a-ac6f-5936ba8b9dc7@6c48a",
"imported": true, "displayName": "newMap01",
"files": [ "id": "6c48a",
".json" "name": "texture",
],
"subMetas": {},
"userData": { "userData": {
"wrapModeS": "repeat", "wrapModeS": "repeat",
"wrapModeT": "repeat", "wrapModeT": "repeat",
"minfilter": "linear", "minfilter": "linear",
"magfilter": "linear", "magfilter": "linear",
"mipfilter": "none", "mipfilter": "none",
"premultiplyAlpha": false,
"anisotropy": 0, "anisotropy": 0,
"isUuid": true, "isUuid": true,
"imageUuidOrDatabaseUri": "27e1fcb7-5016-4252-8c43-ac9c1c97308e" "imageUuidOrDatabaseUri": "96c88bc3-119a-412a-ac6f-5936ba8b9dc7"
}, },
"displayName": "newMap01", "ver": "1.0.21",
"id": "6c48a", "imported": true,
"name": "texture" "files": [
".json"
],
"subMetas": {}
} }
}, },
"userData": { "userData": {
"hasAlpha": false,
"type": "texture", "type": "texture",
"redirect": "27e1fcb7-5016-4252-8c43-ac9c1c97308e@6c48a", "redirect": "96c88bc3-119a-412a-ac6f-5936ba8b9dc7@6c48a"
"hasAlpha": false
} }
} }

View File

@ -27,7 +27,7 @@
"_props": [ "_props": [
{ {
"mainTexture": { "mainTexture": {
"__uuid__": "27e1fcb7-5016-4252-8c43-ac9c1c97308e@6c48a", "__uuid__": "96c88bc3-119a-412a-ac6f-5936ba8b9dc7@6c48a",
"__expectedType__": "cc.Texture2D" "__expectedType__": "cc.Texture2D"
} }
} }

View File

@ -2,7 +2,7 @@
"ver": "1.0.9", "ver": "1.0.9",
"importer": "material", "importer": "material",
"imported": true, "imported": true,
"uuid": "b7d6d595-6cd1-43c6-8bc7-3a92644870b9", "uuid": "5ff93eca-e35a-43eb-b801-6e99d62ccac5",
"files": [ "files": [
".json" ".json"
], ],

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.4 KiB

View File

@ -0,0 +1,12 @@
{
"ver": "1.1.0",
"importer": "directory",
"imported": true,
"uuid": "3569d420-d152-4b7b-936c-80d250e96cc6",
"files": [],
"subMetas": {},
"userData": {
"compressionType": {},
"isRemoteBundle": {}
}
}

View File

@ -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"
}
]

View File

@ -0,0 +1,13 @@
{
"ver": "1.1.32",
"importer": "prefab",
"imported": true,
"uuid": "6eda806d-83a6-474f-a7b7-b75c57ba73b3",
"files": [
".json"
],
"subMetas": {},
"userData": {
"syncNodeName": "Arrow"
}
}

View File

@ -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;
}
}

View File

@ -0,0 +1,9 @@
{
"ver": "4.0.22",
"importer": "typescript",
"imported": true,
"uuid": "2330ebe3-30fb-4108-9873-2696d0fca824",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@ -19,18 +19,40 @@ export class Player extends Component {
playerId!: number; playerId!: number;
isSelf = false; isSelf = false;
state!: PlayerState;
now: number = 0;
private _tweens: Tween<any>[] = []; private _tweens: Tween<any>[] = [];
private _targetPos = new Vec3; private _targetPos = new Vec3;
start() {
this.ani.getState('win').speed = 4;
}
init(state: PlayerState, isSelf: boolean) { init(state: PlayerState, isSelf: boolean) {
this.playerId = state.id; this.playerId = state.id;
this.isSelf = isSelf; this.isSelf = isSelf;
this.mesh.material!.setProperty('mainTexture', this.isSelf ? this.texSelf : this.texOther); this.mesh.material!.setProperty('mainTexture', this.isSelf ? this.texSelf : this.texOther);
} }
// 把 GameSystem 空间映射到游戏空间 updateState(state: PlayerState, now: number) {
updateSelf(state: PlayerState) { 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); this._targetPos.set(state.pos.x, 0, -state.pos.y);
if (!this.node.position.equals(this._targetPos)) { if (!this.node.position.equals(this._targetPos)) {
@ -45,7 +67,9 @@ export class Player extends Component {
this.setAni('idle'); this.setAni('idle');
} }
} }
updateOther(state: PlayerState) {
// 插值更新
private _tweenState(state: PlayerState, now: number) {
// 更新位置 // 更新位置
let newPos = new Vec3(state.pos.x, 0, -state.pos.y); let newPos = new Vec3(state.pos.x, 0, -state.pos.y);
if (!this._targetPos.equals(newPos)) { if (!this._targetPos.equals(newPos)) {
@ -73,10 +97,16 @@ export class Player extends Component {
} }
} }
private _lastAni?: string;
setAni(ani: 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; return;
} }
this._lastAni = ani;
this.ani.crossFade(ani, 0.1); this.ani.crossFade(ani, 0.1);
} }

View File

@ -20,24 +20,24 @@
{ {
"__id__": 6 "__id__": 6
}, },
{
"__id__": 9
},
{ {
"__id__": 5 "__id__": 5
}, },
{ {
"__id__": 19 "__id__": 16
},
{
"__id__": 25
} }
], ],
"_active": true, "_active": true,
"_components": [], "_components": [],
"_prefab": { "_prefab": {
"__id__": 43 "__id__": 57
}, },
"autoReleaseAssets": false, "autoReleaseAssets": false,
"_globals": { "_globals": {
"__id__": 46 "__id__": 60
}, },
"_id": "0d3889f6-dc9c-424e-b8cd-6fa78d63af15" "_id": "0d3889f6-dc9c-424e-b8cd-6fa78d63af15"
}, },
@ -185,18 +185,148 @@
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_name": "Plane",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 1 "__id__": 1
}, },
"_children": [], "_prefab": {
"_active": false, "__id__": 7
"_components": [ }
},
{
"__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, "_prefab": null,
"_lpos": { "_lpos": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
@ -213,9 +343,9 @@
}, },
"_lscale": { "_lscale": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 100, "x": 1,
"y": 100, "y": 1,
"z": 100 "z": 1
}, },
"_layer": 1073741824, "_layer": 1073741824,
"_euler": { "_euler": {
@ -224,97 +354,49 @@
"y": 0, "y": 0,
"z": 0 "z": 0
}, },
"_id": "1erbampNxCKK1cr4qjZjeX" "_id": "46+eJFPoNAd75C26ynMBuo"
},
{
"__type__": "cc.MeshRenderer",
"_name": "Plane<ModelComponent>",
"_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
}, },
{ {
"__type__": "cc.Node", "__type__": "cc.Node",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 1 "__id__": 16
}, },
"_prefab": { "_prefab": {
"__id__": 10 "__id__": 18
} }
}, },
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
"root": { "root": {
"__id__": 9 "__id__": 17
}, },
"asset": { "asset": {
"__uuid__": "c26a63b9-5039-47ae-b027-ef2bce881f6f@fc11b", "__uuid__": "6eda806d-83a6-474f-a7b7-b75c57ba73b3",
"__expectedType__": "cc.Prefab" "__expectedType__": "cc.Prefab"
}, },
"fileId": "2cyg9D4KRTnaWvFuyUcwrn", "fileId": "ad10ECDidH979xbvqlbbgn",
"instance": { "instance": {
"__id__": 11 "__id__": 19
} }
}, },
{ {
"__type__": "cc.PrefabInstance", "__type__": "cc.PrefabInstance",
"fileId": "e7wpFdRzxFupYfDrzr/lg7", "fileId": "f7+AxAbd1K15HySl2cJ7yx",
"mountedChildren": [], "mountedChildren": [],
"mountedComponents": [], "mountedComponents": [],
"propertyOverrides": [ "propertyOverrides": [
{ {
"__id__": 12 "__id__": 20
}, },
{ {
"__id__": 14 "__id__": 22
}, },
{ {
"__id__": 15 "__id__": 23
}, },
{ {
"__id__": 16 "__id__": 24
},
{
"__id__": 17
} }
], ],
"removedComponents": [] "removedComponents": []
@ -322,23 +404,23 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 13 "__id__": 21
}, },
"propertyPath": [ "propertyPath": [
"_name" "_name"
], ],
"value": "newMap01" "value": "Arrow"
}, },
{ {
"__type__": "cc.TargetInfo", "__type__": "cc.TargetInfo",
"localID": [ "localID": [
"2cyg9D4KRTnaWvFuyUcwrn" "ad10ECDidH979xbvqlbbgn"
] ]
}, },
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 13 "__id__": 21
}, },
"propertyPath": [ "propertyPath": [
"_lpos" "_lpos"
@ -346,14 +428,14 @@
"value": { "value": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 0, "y": 1.248,
"z": 0 "z": 0
} }
}, },
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 13 "__id__": 21
}, },
"propertyPath": [ "propertyPath": [
"_lrot" "_lrot"
@ -369,7 +451,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 13 "__id__": 21
}, },
"propertyPath": [ "propertyPath": [
"_euler" "_euler"
@ -381,26 +463,6 @@
"z": 0 "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", "__type__": "cc.Node",
"_name": "Canvas", "_name": "Canvas",
@ -410,25 +472,28 @@
}, },
"_children": [ "_children": [
{ {
"__id__": 20 "__id__": 26
}, },
{ {
"__id__": 22 "__id__": 28
},
{
"__id__": 45
} }
], ],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 39 "__id__": 53
}, },
{ {
"__id__": 40 "__id__": 54
}, },
{ {
"__id__": 41 "__id__": 55
}, },
{ {
"__id__": 42 "__id__": 56
} }
], ],
"_prefab": null, "_prefab": null,
@ -465,13 +530,13 @@
"_name": "Camera", "_name": "Camera",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 19 "__id__": 25
}, },
"_children": [], "_children": [],
"_active": true, "_active": true,
"_components": [ "_components": [
{ {
"__id__": 21 "__id__": 27
} }
], ],
"_prefab": null, "_prefab": null,
@ -508,7 +573,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 20 "__id__": 26
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
@ -548,16 +613,16 @@
"__type__": "cc.Node", "__type__": "cc.Node",
"_objFlags": 0, "_objFlags": 0,
"_parent": { "_parent": {
"__id__": 19 "__id__": 25
}, },
"_prefab": { "_prefab": {
"__id__": 23 "__id__": 29
} }
}, },
{ {
"__type__": "cc.PrefabInfo", "__type__": "cc.PrefabInfo",
"root": { "root": {
"__id__": 22 "__id__": 28
}, },
"asset": { "asset": {
"__uuid__": "0363f7f8-204e-410e-ade0-03adca6ea835", "__uuid__": "0363f7f8-204e-410e-ade0-03adca6ea835",
@ -565,7 +630,7 @@
}, },
"fileId": "25fHuwytBN2qk6dH5oVJvO", "fileId": "25fHuwytBN2qk6dH5oVJvO",
"instance": { "instance": {
"__id__": 24 "__id__": 30
} }
}, },
{ {
@ -575,31 +640,31 @@
"mountedComponents": [], "mountedComponents": [],
"propertyOverrides": [ "propertyOverrides": [
{ {
"__id__": 25 "__id__": 31
},
{
"__id__": 27
},
{
"__id__": 28
},
{
"__id__": 29
},
{
"__id__": 30
},
{
"__id__": 32
}, },
{ {
"__id__": 33 "__id__": 33
}, },
{
"__id__": 34
},
{ {
"__id__": 35 "__id__": 35
}, },
{ {
"__id__": 37 "__id__": 36
},
{
"__id__": 38
},
{
"__id__": 39
},
{
"__id__": 41
},
{
"__id__": 43
} }
], ],
"removedComponents": [] "removedComponents": []
@ -607,7 +672,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 26 "__id__": 32
}, },
"propertyPath": [ "propertyPath": [
"_name" "_name"
@ -623,7 +688,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 26 "__id__": 32
}, },
"propertyPath": [ "propertyPath": [
"_lpos" "_lpos"
@ -638,7 +703,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 26 "__id__": 32
}, },
"propertyPath": [ "propertyPath": [
"_lrot" "_lrot"
@ -654,7 +719,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 26 "__id__": 32
}, },
"propertyPath": [ "propertyPath": [
"_euler" "_euler"
@ -669,7 +734,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 31 "__id__": 37
}, },
"propertyPath": [ "propertyPath": [
"_contentSize" "_contentSize"
@ -689,7 +754,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 26 "__id__": 32
}, },
"propertyPath": [ "propertyPath": [
"_layer" "_layer"
@ -699,7 +764,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 34 "__id__": 40
}, },
"propertyPath": [ "propertyPath": [
"_layer" "_layer"
@ -715,7 +780,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 36 "__id__": 42
}, },
"propertyPath": [ "propertyPath": [
"_layer" "_layer"
@ -731,7 +796,7 @@
{ {
"__type__": "CCPropertyOverrideInfo", "__type__": "CCPropertyOverrideInfo",
"targetInfo": { "targetInfo": {
"__id__": 38 "__id__": 44
}, },
"propertyPath": [ "propertyPath": [
"_layer" "_layer"
@ -744,12 +809,307 @@
"ceQ/tc9/lBPIsW1Hwyb91a" "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", "__type__": "cc.UITransform",
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "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, "_enabled": true,
"__prefab": null, "__prefab": null,
@ -770,12 +1130,12 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 19 "__id__": 25
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
"_cameraComponent": { "_cameraComponent": {
"__id__": 21 "__id__": 27
}, },
"_alignCanvasWithScreen": true, "_alignCanvasWithScreen": true,
"_id": "ebX9QTnS1AlKH1eI+/bdJk" "_id": "ebX9QTnS1AlKH1eI+/bdJk"
@ -785,7 +1145,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 19 "__id__": 25
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
@ -814,7 +1174,7 @@
"_name": "", "_name": "",
"_objFlags": 0, "_objFlags": 0,
"node": { "node": {
"__id__": 19 "__id__": 25
}, },
"_enabled": true, "_enabled": true,
"__prefab": null, "__prefab": null,
@ -823,9 +1183,16 @@
"__uuid__": "809957ef-4f3f-4527-87cc-cb3223f7500a", "__uuid__": "809957ef-4f3f-4527-87cc-cb3223f7500a",
"__expectedType__": "cc.Prefab" "__expectedType__": "cc.Prefab"
}, },
"prefabArrow": {
"__uuid__": "6eda806d-83a6-474f-a7b7-b75c57ba73b3",
"__expectedType__": "cc.Prefab"
},
"players": { "players": {
"__id__": 5 "__id__": 5
}, },
"arrows": {
"__id__": 16
},
"camera": { "camera": {
"__id__": 4 "__id__": 4
}, },
@ -836,24 +1203,24 @@
"fileId": "", "fileId": "",
"targetOverrides": [ "targetOverrides": [
{ {
"__id__": 44 "__id__": 58
} }
] ]
}, },
{ {
"__type__": "cc.TargetOverrideInfo", "__type__": "cc.TargetOverrideInfo",
"source": { "source": {
"__id__": 42 "__id__": 56
}, },
"sourceInfo": null, "sourceInfo": null,
"propertyPath": [ "propertyPath": [
"joyStick" "joyStick"
], ],
"target": { "target": {
"__id__": 22 "__id__": 28
}, },
"targetInfo": { "targetInfo": {
"__id__": 45 "__id__": 59
} }
}, },
{ {
@ -865,16 +1232,16 @@
{ {
"__type__": "cc.SceneGlobals", "__type__": "cc.SceneGlobals",
"ambient": { "ambient": {
"__id__": 47 "__id__": 61
}, },
"shadows": { "shadows": {
"__id__": 48 "__id__": 62
}, },
"_skybox": { "_skybox": {
"__id__": 49 "__id__": 63
}, },
"fog": { "fog": {
"__id__": 50 "__id__": 64
} }
}, },
{ {

View File

@ -1,5 +1,6 @@
import { Component, instantiate, Node, Prefab, Vec2, _decorator } from 'cc'; import { Component, instantiate, Node, Prefab, Vec2, _decorator } from 'cc';
import { Arrow } from '../../prefabs/Arrow/Arrow';
import { Joystick } from '../../prefabs/Joystick/Joystick'; import { Joystick } from '../../prefabs/Joystick/Joystick';
import { Player } from '../../prefabs/Player/Player'; import { Player } from '../../prefabs/Player/Player';
import { FollowCamera } from '../../scripts/components/FollowCamera'; import { FollowCamera } from '../../scripts/components/FollowCamera';
@ -27,9 +28,13 @@ export class GameScene extends Component {
@property(Prefab) @property(Prefab)
prefabPlayer!: Prefab; prefabPlayer!: Prefab;
@property(Prefab)
prefabArrow!: Prefab;
@property(Node) @property(Node)
players!: Node; players!: Node;
@property(Node)
arrows!: Node;
@property(FollowCamera) @property(FollowCamera)
camera: FollowCamera = null as any; camera: FollowCamera = null as any;
@ -37,6 +42,7 @@ export class GameScene extends Component {
gameManager = new GameManager(); gameManager = new GameManager();
private _playerInstances: { [playerId: number]: Player } = {}; private _playerInstances: { [playerId: number]: Player } = {};
private _arrowInstances: { [arrowId: number]: Arrow } = {};
private _selfSpeed?: Vec2 = new Vec2(0, 0); private _selfSpeed?: Vec2 = new Vec2(0, 0);
onLoad() { onLoad() {
@ -63,7 +69,6 @@ export class GameScene extends Component {
} }
update(dt: number) { update(dt: number) {
// Send Inputs // Send Inputs
if (this._selfSpeed && this._selfSpeed.lengthSqr()) { if (this._selfSpeed && this._selfSpeed.lengthSqr()) {
this._selfSpeed.normalize().multiplyScalar(gameConfig.moveSpeed); this._selfSpeed.normalize().multiplyScalar(gameConfig.moveSpeed);
@ -77,6 +82,11 @@ export class GameScene extends Component {
}) })
} }
this._updatePlayers();
this._updateArrows();
}
private _updatePlayers() {
// Update pos // Update pos
let playerStates = this.gameManager.state.players; let playerStates = this.gameManager.state.players;
for (let playerState of playerStates) { 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 // 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
})
}
} }

View File

@ -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'; import { MathUtil } from '../models/MathUtil';
const { ccclass, property } = _decorator; const { ccclass, property } = _decorator;
@ -34,7 +34,7 @@ export class FollowCamera extends Component {
minZ = -Infinity; minZ = -Infinity;
maxZ = Infinity; maxZ = Infinity;
protected _tweenFollow?: Tween; protected _tweenFollow?: Tween<any>;
protected _targetWorldPos = new Vec3; protected _targetWorldPos = new Vec3;
protected _lastTargetPos = new Vec3; protected _lastTargetPos = new Vec3;

View File

@ -38,7 +38,6 @@ export class GameManager {
}); });
} }
(window as any).gm = this; (window as any).gm = this;
} }