From d4226137b6c0a0b319c9286f74b5b9b2c59339d3 Mon Sep 17 00:00:00 2001 From: yflu Date: Thu, 17 Nov 2022 23:39:32 +0800 Subject: [PATCH] Initial draft of an offline map for testing new characters. --- frontend/assets/scenes/login.fire | 2 +- frontend/assets/scenes/offline_map_1.fire | 1108 +++++++++++++++++ .../assets/scenes/offline_map_1.fire.meta | 7 + frontend/assets/scripts/Map.js | 12 - frontend/assets/scripts/OfflineMap.js | 163 +++ frontend/assets/scripts/OfflineMap.js.meta | 9 + 6 files changed, 1288 insertions(+), 13 deletions(-) create mode 100644 frontend/assets/scenes/offline_map_1.fire create mode 100644 frontend/assets/scenes/offline_map_1.fire.meta create mode 100644 frontend/assets/scripts/OfflineMap.js create mode 100644 frontend/assets/scripts/OfflineMap.js.meta diff --git a/frontend/assets/scenes/login.fire b/frontend/assets/scenes/login.fire index 725c63a..2b9da7c 100644 --- a/frontend/assets/scenes/login.fire +++ b/frontend/assets/scenes/login.fire @@ -440,7 +440,7 @@ "array": [ 0, 0, - 343.804582419974, + 344.6705889248102, 0, 0, 0, diff --git a/frontend/assets/scenes/offline_map_1.fire b/frontend/assets/scenes/offline_map_1.fire new file mode 100644 index 0000000..e117c44 --- /dev/null +++ b/frontend/assets/scenes/offline_map_1.fire @@ -0,0 +1,1108 @@ +[ + { + "__type__": "cc.SceneAsset", + "_name": "", + "_objFlags": 0, + "_native": "", + "scene": { + "__id__": 1 + } + }, + { + "__type__": "cc.Scene", + "_objFlags": 0, + "_parent": null, + "_children": [ + { + "__id__": 2 + } + ], + "_active": false, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_is3DNode": true, + "_groupIndex": 0, + "groupIndex": 0, + "autoReleaseAssets": false, + "_id": "368b10b6-88fc-423c-9fcd-545d9fc673bd" + }, + { + "__type__": "cc.Node", + "_name": "Canvas", + "_objFlags": 0, + "_parent": { + "__id__": 1 + }, + "_children": [ + { + "__id__": 3 + }, + { + "__id__": 8 + } + ], + "_active": true, + "_components": [ + { + "__id__": 22 + }, + { + "__id__": 23 + }, + { + "__id__": 24 + }, + { + "__id__": 25 + }, + { + "__id__": 26 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 1024, + "height": 1920 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 512, + 960, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "daDUxCjRFEHak7fx7LvgSJ" + }, + { + "__type__": "cc.Node", + "_name": "Map", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 4 + }, + { + "__id__": 5 + }, + { + "__id__": 21 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 3200, + "height": 3200 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "79f0Sv9OVGwbY3M3efHnGf" + }, + { + "__type__": "cc.TiledMap", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "_tmxFile": null, + "_id": "c8MqKDLJdKz7VhPwMjScDw" + }, + { + "__type__": "41d30TOamhNLZKrUhneboY4", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "canvasNode": { + "__id__": 2 + }, + "tiledAnimPrefab": { + "__uuid__": "1c02b0a0-859a-4467-86b3-ca39c30d1e19" + }, + "player1Prefab": { + "__uuid__": "8a738d50-1dac-4b6e-99e1-d241f5ee7169" + }, + "player2Prefab": { + "__uuid__": "1f479636-9eb8-4612-8f97-371964d6eae3" + }, + "polygonBoundaryBarrierPrefab": { + "__uuid__": "4154eec0-d644-482f-a889-c00ae6b69958" + }, + "keyboardInputControllerNode": { + "__id__": 6 + }, + "joystickInputControllerNode": { + "__id__": 10 + }, + "confirmLogoutPrefab": { + "__uuid__": "8e8c1a65-623d-42ba-97a7-820ce518ea11" + }, + "simplePressToGoDialogPrefab": { + "__uuid__": "670b477e-61a1-4778-879b-35913f7c79d2" + }, + "boundRoomIdLabel": null, + "countdownLabel": { + "__id__": 18 + }, + "resultPanelPrefab": { + "__uuid__": "c4cfe3bd-c59e-4d5b-95cb-c933b120e184" + }, + "gameRulePrefab": { + "__uuid__": "32b8e752-8362-4783-a4a6-1160af8b7109" + }, + "findingPlayerPrefab": { + "__uuid__": "3ed4c7bc-79d0-4075-a563-d5a58ae798f9" + }, + "countdownToBeginGamePrefab": { + "__uuid__": "230eeb1f-e0f9-4a41-ab6c-05b3771cbf3e" + }, + "playersInfoPrefab": { + "__uuid__": "b4e519f4-e698-4403-9ff2-47b8dacb077e" + }, + "forceBigEndianFloatingNumDecoding": false, + "backgroundMapTiledIns": null, + "renderFrameIdLagTolerance": 4, + "jigglingEps1D": 0.001, + "_id": "d12gkAmppNlIzqcRDELa91" + }, + { + "__type__": "cc.Node", + "_name": "KeyboardControlsMount", + "_objFlags": 0, + "_parent": { + "__id__": 7 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 19 + }, + { + "__id__": 20 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 50.4 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + -341.33333, + -640, + 0, + 0, + 0, + 0, + 1, + 0.66667, + 0.66667, + 0.66667 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "e6nL+1zEhLmLSaT8R/9UgD" + }, + { + "__type__": "cc.Node", + "_name": "WidgetsAboveAll", + "_objFlags": 0, + "_parent": { + "__id__": 8 + }, + "_children": [ + { + "__id__": 6 + }, + { + "__id__": 10 + }, + { + "__id__": 17 + } + ], + "_active": true, + "_components": [], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "c6fPdAUURDX69j0zTeIFZv" + }, + { + "__type__": "cc.Node", + "_name": "Main Camera", + "_objFlags": 0, + "_parent": { + "__id__": 2 + }, + "_children": [ + { + "__id__": 7 + } + ], + "_active": true, + "_components": [ + { + "__id__": 9 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 0 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 344.6705889248102, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "76BOk0enxN+b20dtIJ3uk2" + }, + { + "__type__": "cc.Camera", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 8 + }, + "_enabled": true, + "_cullingMask": 4294967295, + "_clearFlags": 7, + "_backgroundColor": { + "__type__": "cc.Color", + "r": 0, + "g": 0, + "b": 0, + "a": 255 + }, + "_depth": -1, + "_zoomRatio": 1.5, + "_targetTexture": null, + "_fov": 60, + "_orthoSize": 10, + "_nearClip": 1, + "_farClip": 4096, + "_ortho": true, + "_rect": { + "__type__": "cc.Rect", + "x": 0, + "y": 0, + "width": 1, + "height": 1 + }, + "_renderStages": 1, + "_alignWithScreen": true, + "_id": "50qiPTLS9NhbPa+JZU0jOP" + }, + { + "__type__": "cc.Node", + "_name": "JoystickContainer", + "_objFlags": 0, + "_parent": { + "__id__": 7 + }, + "_children": [ + { + "__id__": 11 + } + ], + "_active": true, + "_components": [ + { + "__id__": 16 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 1280, + "height": 640 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + -500, + 0, + 0, + 0, + 0, + 1, + 0.66667, + 0.66667, + 0.66667 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "81iBXkC0lFt5FFUUD0k3xE" + }, + { + "__type__": "cc.Node", + "_name": "JoystickBG", + "_objFlags": 0, + "_parent": { + "__id__": 10 + }, + "_children": [ + { + "__id__": 12 + } + ], + "_active": true, + "_components": [ + { + "__id__": 14 + }, + { + "__id__": 15 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 400, + "height": 400 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "88u3wQvvdO8pbrNWhs3ifP" + }, + { + "__type__": "cc.Node", + "_name": "Joystick", + "_objFlags": 0, + "_parent": { + "__id__": 11 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 13 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 150, + "height": 150 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0.8, + 0.8, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "3eybpdW/JK3aDeXxdE86VD" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 12 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "7d4baacd-294c-4a5d-9cd6-5d36e4394c9e" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_id": "7dr8DOX01K7YFqWlRy1ATp" + }, + { + "__type__": "cc.Sprite", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 11 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_srcBlendFactor": 770, + "_dstBlendFactor": 771, + "_spriteFrame": { + "__uuid__": "447f7cfe-e678-4424-be03-0afdab8659de" + }, + "_type": 0, + "_sizeMode": 0, + "_fillType": 0, + "_fillCenter": { + "__type__": "cc.Vec2", + "x": 0, + "y": 0 + }, + "_fillStart": 0, + "_fillRange": 0, + "_isTrimmedMode": true, + "_atlas": { + "__uuid__": "030d9286-e8a2-40cf-98f8-baf713f0b8c4" + }, + "_id": "b28Bh9ZcpM+7K3Bd3bmNf0" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 11 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 0, + "_left": 40, + "_right": 0, + "_top": 0, + "_bottom": 10, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 0, + "_originalHeight": 0, + "_id": "c0cEsj4LpMcZZEldELidxy" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 10 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 0, + "_left": 278, + "_right": 480.0000000000002, + "_top": 544, + "_bottom": 0, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 480, + "_originalHeight": 0, + "_id": "2cxYjEIwNO6rUtXX4WcfnV" + }, + { + "__type__": "cc.Node", + "_name": "CountdownSeconds", + "_objFlags": 0, + "_parent": { + "__id__": 7 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 18 + } + ], + "_prefab": null, + "_opacity": 255, + "_color": { + "__type__": "cc.Color", + "r": 255, + "g": 255, + "b": 255, + "a": 255 + }, + "_contentSize": { + "__type__": "cc.Size", + "width": 0, + "height": 88.2 + }, + "_anchorPoint": { + "__type__": "cc.Vec2", + "x": 0.5, + "y": 0.5 + }, + "_trs": { + "__type__": "TypedArray", + "ctor": "Float64Array", + "array": [ + 0, + 591, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1 + ] + }, + "_eulerAngles": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_skewX": 0, + "_skewY": 0, + "_is3DNode": false, + "_groupIndex": 0, + "groupIndex": 0, + "_id": "f6HMd9ebFPppe/Lu0Ry/qk" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 17 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_useOriginalSize": false, + "_string": "", + "_N$string": "", + "_fontSize": 70, + "_lineHeight": 70, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "dfxSFl+shLcY+0v45FJtGo" + }, + { + "__type__": "cc.Label", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "_materials": [ + { + "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" + } + ], + "_useOriginalSize": false, + "_string": "", + "_N$string": "", + "_fontSize": 40, + "_lineHeight": 40, + "_enableWrapText": true, + "_N$file": null, + "_isSystemFontUsed": true, + "_spacingX": 0, + "_batchAsBitmap": false, + "_N$horizontalAlign": 1, + "_N$verticalAlign": 1, + "_N$fontFamily": "Arial", + "_N$overflow": 0, + "_N$cacheMode": 0, + "_id": "9cS5BRd+NKJIvGQiojJtIs" + }, + { + "__type__": "4561aFzv9JPZLe6iIzODk2d", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 6 + }, + "_enabled": true, + "_id": "5ahzSYC8pCCLVPCBYyCRfZ" + }, + { + "__type__": "09e1b/tEy5K2qaPIpqHDbae", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 3 + }, + "_enabled": true, + "BGMEffect": { + "__uuid__": "64a79efa-97de-4cb5-b2a9-01500c60573a" + }, + "crashedByTrapBullet": { + "__uuid__": "1d604e42-8cee-466f-884d-e74cae21ce3b" + }, + "highScoreTreasurePicked": { + "__uuid__": "0164d22c-d965-461f-867e-b30e2d56cc5c" + }, + "treasurePicked": { + "__uuid__": "7704b97e-6367-420c-b7af-d0750a2bbb30" + }, + "countDown10SecToEnd": { + "__uuid__": "261d1d7d-a5cc-4cb7-a737-194427055fd4" + }, + "mapNode": { + "__id__": 3 + }, + "_id": "3crA1nz5xPSLAnCSLQIPOq" + }, + { + "__type__": "cc.Canvas", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "_designResolution": { + "__type__": "cc.Size", + "width": 1024, + "height": 1920 + }, + "_fitWidth": true, + "_fitHeight": false, + "_id": "94aSq7GcJJZ7A6IzMerm1J" + }, + { + "__type__": "8ac08Cb+Y1M/6ZsO9niGOzW", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "map": { + "__id__": 3 + }, + "_id": "84o2sgpN1NRqlN9x7mSzBj" + }, + { + "__type__": "78830/HTiVJoaf8n504g/J4", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "mapNode": { + "__id__": 3 + }, + "speed": 5000, + "_id": "76ImpM7XtPSbiLHDXdsJa+" + }, + { + "__type__": "cc.Widget", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "alignMode": 0, + "_target": null, + "_alignFlags": 0, + "_left": 6240, + "_right": -4000, + "_top": -8320, + "_bottom": 10880, + "_verticalCenter": 0, + "_horizontalCenter": 0, + "_isAbsLeft": true, + "_isAbsRight": true, + "_isAbsTop": true, + "_isAbsBottom": true, + "_isAbsHorizontalCenter": true, + "_isAbsVerticalCenter": true, + "_originalWidth": 960, + "_originalHeight": 640, + "_id": "a8lQ6mB8RMRajCXQCzw1kG" + }, + { + "__type__": "d34e3c4jd5NqYtg8ltL9QST", + "_name": "", + "_objFlags": 0, + "node": { + "__id__": 2 + }, + "_enabled": true, + "translationListenerNode": { + "__id__": 10 + }, + "zoomingListenerNode": { + "__id__": 3 + }, + "stickhead": { + "__id__": 12 + }, + "base": { + "__id__": 11 + }, + "joyStickEps": 0.1, + "magicLeanLowerBound": 0.414, + "magicLeanUpperBound": 2.414, + "linearScaleFacBase": 1, + "minScale": 1, + "maxScale": 2, + "maxMovingBufferLength": 1, + "zoomingScaleFacBase": 0.1, + "zoomingSpeedBase": 4, + "linearSpeedBase": 320, + "canvasNode": { + "__id__": 2 + }, + "mapNode": { + "__id__": 3 + }, + "linearMovingEps": 0.1, + "scaleByEps": 0.0375, + "_id": "e9oVYTr7ROlpp/IrNjBUmR" + } +] \ No newline at end of file diff --git a/frontend/assets/scenes/offline_map_1.fire.meta b/frontend/assets/scenes/offline_map_1.fire.meta new file mode 100644 index 0000000..1ab1461 --- /dev/null +++ b/frontend/assets/scenes/offline_map_1.fire.meta @@ -0,0 +1,7 @@ +{ + "ver": "1.2.5", + "uuid": "368b10b6-88fc-423c-9fcd-545d9fc673bd", + "asyncLoadAssets": false, + "autoReleaseAssets": false, + "subMetas": {} +} \ No newline at end of file diff --git a/frontend/assets/scripts/Map.js b/frontend/assets/scripts/Map.js index 7cfd8e2..0a84c00 100644 --- a/frontend/assets/scripts/Map.js +++ b/frontend/assets/scripts/Map.js @@ -40,10 +40,6 @@ cc.Class({ type: cc.Node, default: null, }, - tiledAnimPrefab: { - type: cc.Prefab, - default: null, - }, player1Prefab: { type: cc.Prefab, default: null, @@ -52,14 +48,6 @@ cc.Class({ type: cc.Prefab, default: null, }, - polygonBoundaryBarrierPrefab: { - type: cc.Prefab, - default: null, - }, - keyboardInputControllerNode: { - type: cc.Node, - default: null - }, joystickInputControllerNode: { type: cc.Node, default: null diff --git a/frontend/assets/scripts/OfflineMap.js b/frontend/assets/scripts/OfflineMap.js new file mode 100644 index 0000000..84705f5 --- /dev/null +++ b/frontend/assets/scripts/OfflineMap.js @@ -0,0 +1,163 @@ +const i18n = require('LanguageData'); +i18n.init(window.language); // languageID should be equal to the one we input in New Language ID input field + +const OnlineMap = require('./Map'); + +cc.Class({ + extends: OnlineMap, + + properties: { + keyboardInputControllerNode: { + type: cc.Node, + default: null + }, + }, + + onDestroy() { + console.warn("+++++++ Map onDestroy()"); + }, + + onLoad() { + const self = this; + window.mapIns = self; + + self.mainCameraNode = canvasNode.getChildByName("Main Camera"); + self.mainCamera = self.mainCameraNode.getComponent(cc.Camera); + for (let child of self.mainCameraNode.children) { + child.setScale(1 / self.mainCamera.zoomRatio); + } + self.widgetsAboveAllNode = self.mainCameraNode.getChildByName("WidgetsAboveAll"); + self.mainCameraNode.setPosition(cc.v2()); + + /** Init required prefab ended. */ + + self.inputDelayFrames = parsedBattleColliderInfo.inputDelayFrames; + self.inputScaleFrames = parsedBattleColliderInfo.inputScaleFrames; + self.inputFrameUpsyncDelayTolerance = parsedBattleColliderInfo.inputFrameUpsyncDelayTolerance; + + self.battleDurationNanos = parsedBattleColliderInfo.battleDurationNanos; + self.rollbackEstimatedDt = parsedBattleColliderInfo.rollbackEstimatedDt; + self.rollbackEstimatedDtMillis = parsedBattleColliderInfo.rollbackEstimatedDtMillis; + self.rollbackEstimatedDtNanos = parsedBattleColliderInfo.rollbackEstimatedDtNanos; + self.maxChasingRenderFramesPerUpdate = parsedBattleColliderInfo.maxChasingRenderFramesPerUpdate; + + self.worldToVirtualGridRatio = parsedBattleColliderInfo.worldToVirtualGridRatio; + self.virtualGridToWorldRatio = parsedBattleColliderInfo.virtualGridToWorldRatio; + + const tiledMapIns = self.node.getComponent(cc.TiledMap); + + // It's easier to just use the "barrier"s extracted by the backend (all anchor points in world coordinates), but I'd like to verify frontend tmx parser logic as well. + const fullPathOfTmxFile = cc.js.formatStr("map/%s/map", parsedBattleColliderInfo.stageName); + cc.loader.loadRes(fullPathOfTmxFile, cc.TiledMapAsset, (err, tmxAsset) => { + if (null != err) { + console.error(err); + return; + } + + /* + [WARNING] + + - The order of the following statements is important, because we should have finished "_resetCurrentMatch" before the first "RoomDownsyncFrame". + - It's important to assign new "tmxAsset" before "extractBoundaryObjects", to ensure that the correct tilesets are used. + - To ensure clearance, put destruction of the "cc.TiledMap" component preceding that of "mapNode.destroyAllChildren()". + */ + + tiledMapIns.tmxAsset = null; + mapNode.removeAllChildren(); + self._resetCurrentMatch(); + + tiledMapIns.tmxAsset = tmxAsset; + const newMapSize = tiledMapIns.getMapSize(); + const newTileSize = tiledMapIns.getTileSize(); + self.node.setContentSize(newMapSize.width * newTileSize.width, newMapSize.height * newTileSize.height); + self.node.setPosition(cc.v2(0, 0)); + /* + * Deliberately hiding "ImageLayer"s. This dirty fix is specific to "CocosCreator v2.2.1", where it got back the rendering capability of "ImageLayer of Tiled", yet made incorrectly. In this game our "markers of ImageLayers" are rendered by dedicated prefabs with associated colliders. + * + * -- YFLu, 2020-01-23 + */ + const existingImageLayers = tiledMapIns.getObjectGroups(); + for (let singleImageLayer of existingImageLayers) { + singleImageLayer.node.opacity = 0; + } + + let barrierIdCounter = 0; + const boundaryObjs = tileCollisionManager.extractBoundaryObjects(self.node); + for (let boundaryObj of boundaryObjs.barriers) { + const x0 = boundaryObj.anchor.x, + y0 = boundaryObj.anchor.y; + + const newBarrier = self.collisionSys.createPolygon(x0, y0, Array.from(boundaryObj, p => { + return [p.x, p.y]; + })); + + if (self.showCriticalCoordinateLabels) { + for (let i = 0; i < boundaryObj.length; ++i) { + const barrierVertLabelNode = new cc.Node(); + switch (i % 4) { + case 0: + barrierVertLabelNode.color = cc.Color.RED; + break; + case 1: + barrierVertLabelNode.color = cc.Color.GRAY; + break; + case 2: + barrierVertLabelNode.color = cc.Color.BLACK; + break; + default: + barrierVertLabelNode.color = cc.Color.MAGENTA; + break; + } + const wx = boundaryObj.anchor.x + boundaryObj[i].x, + wy = boundaryObj.anchor.y + boundaryObj[i].y; + barrierVertLabelNode.setPosition(cc.v2(wx, wy)); + const barrierVertLabel = barrierVertLabelNode.addComponent(cc.Label); + barrierVertLabel.fontSize = 12; + barrierVertLabel.lineHeight = barrierVertLabel.fontSize + 1; + barrierVertLabel.string = `(${wx.toFixed(1)}, ${wy.toFixed(1)})`; + safelyAddChild(self.node, barrierVertLabelNode); + setLocalZOrder(barrierVertLabelNode, 5); + + barrierVertLabelNode.active = true; + } + + } + // console.log("Created barrier: ", newBarrier); + ++barrierIdCounter; + const collisionBarrierIndex = (self.collisionBarrierIndexPrefix + barrierIdCounter); + self.collisionSysMap.set(collisionBarrierIndex, newBarrier); + } + }); + + }, + + update(dt) { + const self = this; + if (ALL_BATTLE_STATES.IN_BATTLE == self.battleState) { + const elapsedMillisSinceLastFrameIdTriggered = performance.now() - self.lastRenderFrameIdTriggeredAt; + if (elapsedMillisSinceLastFrameIdTriggered < (self.rollbackEstimatedDtMillis)) { + // console.debug("Avoiding too fast frame@renderFrameId=", self.renderFrameId, ": elapsedMillisSinceLastFrameIdTriggered=", elapsedMillisSinceLastFrameIdTriggered); + return; + } + try { + let st = performance.now(); + let prevSelfInput = null, + currSelfInput = null; + const noDelayInputFrameId = self._convertToInputFrameId(self.renderFrameId, 0); // It's important that "inputDelayFrames == 0" here + if (self.shouldGenerateInputFrameUpsync(self.renderFrameId)) { + const prevAndCurrInputs = self._generateInputFrameUpsync(noDelayInputFrameId); + prevSelfInput = prevAndCurrInputs[0]; + currSelfInput = prevAndCurrInputs[1]; + } + + const rdf = self.rollbackAndChase(self.renderFrameId, self.renderFrameId + 1, self.collisionSys, self.collisionSysMap, false); + self.applyRoomDownsyncFrameDynamics(rdf); + let t3 = performance.now(); + } catch (err) { + console.error("Error during Map.update", err); + } finally { + ++self.renderFrameId; // [WARNING] It's important to increment the renderFrameId AFTER all the operations above!!! + } + } + }, +}); diff --git a/frontend/assets/scripts/OfflineMap.js.meta b/frontend/assets/scripts/OfflineMap.js.meta new file mode 100644 index 0000000..4da3509 --- /dev/null +++ b/frontend/assets/scripts/OfflineMap.js.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.0.5", + "uuid": "47d7dcb8-4b89-41da-9c6a-2499463a86a2", + "isPlugin": false, + "loadPluginInWeb": true, + "loadPluginInNative": true, + "loadPluginInEditor": false, + "subMetas": {} +} \ No newline at end of file