From 0b0de0beb3b7da44bb3656ba80a64b7e57a6a81e Mon Sep 17 00:00:00 2001 From: genxium Date: Mon, 26 Dec 2022 15:11:35 +0800 Subject: [PATCH] Fixes for backend integration. --- battle_srv/models/room.go | 12 +- .../{offline_map_2.fire => offline_map.fire} | 0 ..._map_2.fire.meta => offline_map.fire.meta} | 0 frontend/assets/scenes/offline_map_1.fire | 1361 ----------------- .../assets/scenes/offline_map_1.fire.meta | 7 - frontend/assets/scripts/Map.js | 13 +- frontend/assets/scripts/OfflineMap.js | 74 +- frontend/assets/scripts/OfflineMap.js.meta | 2 +- frontend/assets/scripts/OfflineMapBackend.js | 243 --- .../assets/scripts/OfflineMapBackend.js.meta | 9 - 10 files changed, 57 insertions(+), 1664 deletions(-) rename frontend/assets/scenes/{offline_map_2.fire => offline_map.fire} (100%) rename frontend/assets/scenes/{offline_map_2.fire.meta => offline_map.fire.meta} (100%) delete mode 100644 frontend/assets/scenes/offline_map_1.fire delete mode 100644 frontend/assets/scenes/offline_map_1.fire.meta delete mode 100644 frontend/assets/scripts/OfflineMapBackend.js delete mode 100644 frontend/assets/scripts/OfflineMapBackend.js.meta diff --git a/battle_srv/models/room.go b/battle_srv/models/room.go index 0898d5c..cc59a0d 100644 --- a/battle_srv/models/room.go +++ b/battle_srv/models/room.go @@ -1212,8 +1212,8 @@ func (pR *Room) applyInputFrameDownsyncDynamics(fromRenderFrameId int32, toRende } currRenderFrame := currRenderFrameTmp.(*battle.RoomDownsyncFrame) delayedInputFrameId := pR.ConvertToInputFrameId(collisionSysRenderFrameId, pR.InputDelayFrames) - var delayedInputList []uint64 = nil - var delayedInputListForPrevRenderFrame []uint64 = nil + var delayedInputList *[]uint64 = nil + var delayedInputListForPrevRenderFrame *[]uint64 = nil if 0 <= delayedInputFrameId { if delayedInputFrameId > pR.LastAllConfirmedInputFrameId { panic(fmt.Sprintf("delayedInputFrameId=%v is not yet all-confirmed for roomId=%v, this is abnormal because it's to be used for applying dynamics to [fromRenderFrameId:%v, toRenderFrameId:%v) @ collisionSysRenderFrameId=%v! InputsBuffer=%v", delayedInputFrameId, pR.Id, fromRenderFrameId, toRenderFrameId, collisionSysRenderFrameId, pR.InputsBufferString(false))) @@ -1223,19 +1223,19 @@ func (pR *Room) applyInputFrameDownsyncDynamics(fromRenderFrameId int32, toRende panic(fmt.Sprintf("delayedInputFrameId=%v doesn't exist for roomId=%v, this is abnormal because it's to be used for applying dynamics to [fromRenderFrameId:%v, toRenderFrameId:%v) @ collisionSysRenderFrameId=%v! InputsBuffer=%v", delayedInputFrameId, pR.Id, fromRenderFrameId, toRenderFrameId, collisionSysRenderFrameId, pR.InputsBufferString(false))) } delayedInputFrame := tmp.(*pb.InputFrameDownsync) - delayedInputList = delayedInputFrame.InputList + delayedInputList = &delayedInputFrame.InputList delayedInputFrameIdForPrevRenderFrame := pR.ConvertToInputFrameId(collisionSysRenderFrameId-1, pR.InputDelayFrames) if 0 <= delayedInputFrameIdForPrevRenderFrame { - tmp = pR.InputsBuffer.GetByFrameId(delayedInputFrameId) + tmp = pR.InputsBuffer.GetByFrameId(delayedInputFrameIdForPrevRenderFrame) if nil == tmp { panic(fmt.Sprintf("delayedInputFrameIdForPrevRenderFrame=%v doesn't exist for roomId=%v, this is abnormal because it's to be used for applying dynamics to [fromRenderFrameId:%v, toRenderFrameId:%v) @ collisionSysRenderFrameId-1=%v! InputsBuffer=%v", delayedInputFrameIdForPrevRenderFrame, pR.Id, fromRenderFrameId, toRenderFrameId, collisionSysRenderFrameId-1, pR.InputsBufferString(false))) } delayedInputFrameForPrevRenderFrame := tmp.(*pb.InputFrameDownsync) - delayedInputListForPrevRenderFrame = delayedInputFrameForPrevRenderFrame.InputList + delayedInputListForPrevRenderFrame = &delayedInputFrameForPrevRenderFrame.InputList } } - nextRenderFrame := battle.ApplyInputFrameDownsyncDynamicsOnSingleRenderFrame(delayedInputList, delayedInputListForPrevRenderFrame, currRenderFrame, pR.Space, pR.CollisionSysMap, pR.GravityX, pR.GravityY, pR.JumpingInitVelY, pR.InputDelayFrames, pR.InputScaleFrames, pR.collisionSpaceOffsetX, pR.collisionSpaceOffsetY, pR.SnapIntoPlatformOverlap, pR.SnapIntoPlatformThreshold, pR.WorldToVirtualGridRatio, pR.VirtualGridToWorldRatio) + nextRenderFrame := battle.ApplyInputFrameDownsyncDynamicsOnSingleRenderFrame(*delayedInputList, *delayedInputListForPrevRenderFrame, currRenderFrame, pR.Space, pR.CollisionSysMap, pR.GravityX, pR.GravityY, pR.JumpingInitVelY, pR.InputDelayFrames, pR.InputScaleFrames, pR.collisionSpaceOffsetX, pR.collisionSpaceOffsetY, pR.SnapIntoPlatformOverlap, pR.SnapIntoPlatformThreshold, pR.WorldToVirtualGridRatio, pR.VirtualGridToWorldRatio) pR.RenderFrameBuffer.Put(nextRenderFrame) pR.CurDynamicsRenderFrameId++ } diff --git a/frontend/assets/scenes/offline_map_2.fire b/frontend/assets/scenes/offline_map.fire similarity index 100% rename from frontend/assets/scenes/offline_map_2.fire rename to frontend/assets/scenes/offline_map.fire diff --git a/frontend/assets/scenes/offline_map_2.fire.meta b/frontend/assets/scenes/offline_map.fire.meta similarity index 100% rename from frontend/assets/scenes/offline_map_2.fire.meta rename to frontend/assets/scenes/offline_map.fire.meta diff --git a/frontend/assets/scenes/offline_map_1.fire b/frontend/assets/scenes/offline_map_1.fire deleted file mode 100644 index 5937eab..0000000 --- a/frontend/assets/scenes/offline_map_1.fire +++ /dev/null @@ -1,1361 +0,0 @@ -[ - { - "__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__": 9 - } - ], - "_active": true, - "_components": [ - { - "__id__": 27 - }, - { - "__id__": 28 - }, - { - "__id__": 29 - }, - { - "__id__": 30 - }, - { - "__id__": 31 - } - ], - "_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__": 6 - } - ], - "_prefab": null, - "_opacity": 255, - "_color": { - "__type__": "cc.Color", - "r": 255, - "g": 255, - "b": 255, - "a": 255 - }, - "_contentSize": { - "__type__": "cc.Size", - "width": 2048, - "height": 2048 - }, - "_anchorPoint": { - "__type__": "cc.Vec2", - "x": 0.5, - "y": 0.5 - }, - "_trs": { - "__type__": "TypedArray", - "ctor": "Float64Array", - "array": [ - 0, - 0, - 0, - 0, - 0, - 0, - 1, - 1.5, - 1.5, - 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__": "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__": "47d7dy4S4lB2pxqJJlGOoai", - "_name": "", - "_objFlags": 0, - "node": { - "__id__": 3 - }, - "_enabled": true, - "canvasNode": { - "__id__": 2 - }, - "controlledCharacterPrefab": { - "__uuid__": "59bff7a2-23e1-4d69-bce7-afb37eae196a" - }, - "joystickInputControllerNode": { - "__id__": 7 - }, - "confirmLogoutPrefab": null, - "simplePressToGoDialogPrefab": null, - "boundRoomIdLabel": null, - "countdownLabel": null, - "resultPanelPrefab": null, - "gameRulePrefab": null, - "findingPlayerPrefab": null, - "countdownToBeginGamePrefab": null, - "playersInfoPrefab": null, - "forceBigEndianFloatingNumDecoding": false, - "renderFrameIdLagTolerance": 4, - "jigglingEps1D": 0.001, - "bulletTriggerEnabled": true, - "closeOnForcedtoResyncNotSelf": true, - "_id": "4b+kZ46VhC0LCBixXEK2dk" - }, - { - "__type__": "cc.Node", - "_name": "JoystickContainer", - "_objFlags": 0, - "_parent": { - "__id__": 8 - }, - "_children": [ - { - "__id__": 21 - } - ], - "_active": true, - "_components": [ - { - "__id__": 26 - } - ], - "_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": "WidgetsAboveAll", - "_objFlags": 0, - "_parent": { - "__id__": 9 - }, - "_children": [ - { - "__id__": 7 - }, - { - "__id__": 11 - }, - { - "__id__": 13 - }, - { - "__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__": 8 - } - ], - "_active": true, - "_components": [ - { - "__id__": 10 - } - ], - "_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, - 217.37237634989413, - 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__": 9 - }, - "_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": "CountdownSeconds", - "_objFlags": 0, - "_parent": { - "__id__": 8 - }, - "_children": [], - "_active": true, - "_components": [ - { - "__id__": 12 - } - ], - "_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__": 11 - }, - "_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.Node", - "_name": "BtnA", - "_objFlags": 0, - "_parent": { - "__id__": 8 - }, - "_children": [ - { - "__id__": 14 - } - ], - "_active": true, - "_components": [], - "_prefab": null, - "_opacity": 255, - "_color": { - "__type__": "cc.Color", - "r": 255, - "g": 255, - "b": 255, - "a": 255 - }, - "_contentSize": { - "__type__": "cc.Size", - "width": 200, - "height": 200 - }, - "_anchorPoint": { - "__type__": "cc.Vec2", - "x": 0.5, - "y": 0.5 - }, - "_trs": { - "__type__": "TypedArray", - "ctor": "Float64Array", - "array": [ - 143.689, - -584.849, - 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": "a5pbciqqBEiYlyy7SLwP4V" - }, - { - "__type__": "cc.Node", - "_name": "Background", - "_objFlags": 0, - "_parent": { - "__id__": 13 - }, - "_children": [], - "_active": true, - "_components": [ - { - "__id__": 15 - }, - { - "__id__": 16 - } - ], - "_prefab": null, - "_opacity": 255, - "_color": { - "__type__": "cc.Color", - "r": 255, - "g": 255, - "b": 255, - "a": 255 - }, - "_contentSize": { - "__type__": "cc.Size", - "width": 200, - "height": 200 - }, - "_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": "ffojLoj41JCpizkLkManxw" - }, - { - "__type__": "cc.Sprite", - "_name": "", - "_objFlags": 0, - "node": { - "__id__": 14 - }, - "_enabled": true, - "_materials": [ - { - "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" - } - ], - "_srcBlendFactor": 770, - "_dstBlendFactor": 771, - "_spriteFrame": { - "__uuid__": "350fd890-3d28-4e53-9dfa-1bf00d857737" - }, - "_type": 1, - "_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": "21Oz9QwBZPALzRoJujKVPG" - }, - { - "__type__": "cc.Widget", - "_name": "", - "_objFlags": 0, - "node": { - "__id__": 14 - }, - "_enabled": true, - "alignMode": 0, - "_target": null, - "_alignFlags": 45, - "_left": 0, - "_right": 0, - "_top": 0, - "_bottom": 0, - "_verticalCenter": 0, - "_horizontalCenter": 0, - "_isAbsLeft": true, - "_isAbsRight": true, - "_isAbsTop": true, - "_isAbsBottom": true, - "_isAbsHorizontalCenter": true, - "_isAbsVerticalCenter": true, - "_originalWidth": 100, - "_originalHeight": 40, - "_id": "beUmgK1D1M07I7kTL4NFLK" - }, - { - "__type__": "cc.Node", - "_name": "BtnB", - "_objFlags": 0, - "_parent": { - "__id__": 8 - }, - "_children": [ - { - "__id__": 18 - } - ], - "_active": true, - "_components": [], - "_prefab": null, - "_opacity": 255, - "_color": { - "__type__": "cc.Color", - "r": 255, - "g": 255, - "b": 255, - "a": 255 - }, - "_contentSize": { - "__type__": "cc.Size", - "width": 200, - "height": 200 - }, - "_anchorPoint": { - "__type__": "cc.Vec2", - "x": 0.5, - "y": 0.5 - }, - "_trs": { - "__type__": "TypedArray", - "ctor": "Float64Array", - "array": [ - 370.368, - -424.647, - 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": "9eZHUAtItPMKp7OrItdaWA" - }, - { - "__type__": "cc.Node", - "_name": "Background", - "_objFlags": 0, - "_parent": { - "__id__": 17 - }, - "_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": 200, - "height": 200 - }, - "_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": "e2JXxje+hAC7LjZqzgq8RF" - }, - { - "__type__": "cc.Sprite", - "_name": "", - "_objFlags": 0, - "node": { - "__id__": 18 - }, - "_enabled": true, - "_materials": [ - { - "__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432" - } - ], - "_srcBlendFactor": 770, - "_dstBlendFactor": 771, - "_spriteFrame": { - "__uuid__": "a2170e4c-df31-41ef-be73-f4f605e75821" - }, - "_type": 1, - "_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": "54DvUzQvpKMrmsuRaQRSxf" - }, - { - "__type__": "cc.Widget", - "_name": "", - "_objFlags": 0, - "node": { - "__id__": 18 - }, - "_enabled": true, - "alignMode": 0, - "_target": null, - "_alignFlags": 45, - "_left": 0, - "_right": 0, - "_top": 0, - "_bottom": 0, - "_verticalCenter": 0, - "_horizontalCenter": 0, - "_isAbsLeft": true, - "_isAbsRight": true, - "_isAbsTop": true, - "_isAbsBottom": true, - "_isAbsHorizontalCenter": true, - "_isAbsVerticalCenter": true, - "_originalWidth": 100, - "_originalHeight": 40, - "_id": "5fVLGAIhROj6UDGotnneup" - }, - { - "__type__": "cc.Node", - "_name": "JoystickBG", - "_objFlags": 0, - "_parent": { - "__id__": 7 - }, - "_children": [ - { - "__id__": 22 - } - ], - "_active": true, - "_components": [ - { - "__id__": 24 - }, - { - "__id__": 25 - } - ], - "_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": [ - -380, - 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__": 21 - }, - "_children": [], - "_active": true, - "_components": [ - { - "__id__": 23 - } - ], - "_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__": 22 - }, - "_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__": 21 - }, - "_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__": 21 - }, - "_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__": 7 - }, - "_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.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__": 7 - }, - "zoomingListenerNode": { - "__id__": 3 - }, - "stickhead": { - "__id__": 22 - }, - "base": { - "__id__": 21 - }, - "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, - "btnA": { - "__id__": 13 - }, - "btnB": { - "__id__": 17 - }, - "_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 deleted file mode 100644 index 1ab1461..0000000 --- a/frontend/assets/scenes/offline_map_1.fire.meta +++ /dev/null @@ -1,7 +0,0 @@ -{ - "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 b78eb3c..529280c 100644 --- a/frontend/assets/scripts/Map.js +++ b/frontend/assets/scripts/Map.js @@ -605,8 +605,8 @@ cc.Class({ } const shouldForceDumping1 = (window.MAGIC_ROOM_DOWNSYNC_FRAME_ID.BATTLE_START == rdf.Id); let shouldForceDumping2 = (rdf.Id >= self.renderFrameId + self.renderFrameIdLagTolerance); - let shouldForceResync = pbRdf.ShouldForceResync; - const notSelfUnconfirmed = (0 == (rdf.BackendUnconfirmedMask & (1 << (self.selfPlayerInfo.joinIndex - 1)))); + let shouldForceResync = pbRdf.shouldForceResync; + const notSelfUnconfirmed = (0 == (pbRdf.backendUnconfirmedMask & (1 << (self.selfPlayerInfo.joinIndex - 1)))); if (notSelfUnconfirmed) { shouldForceDumping2 = false; shouldForceResync = false; @@ -647,7 +647,8 @@ cc.Class({ if (window.MAGIC_ROOM_DOWNSYNC_FRAME_ID.BATTLE_START == rdf.Id) { console.log('On battle started! renderFrameId=', rdf.Id); } else { - console.log('On battle resynced! renderFrameId=', rdf.Id); + self.hideFindingPlayersGUI(); + console.warn('On battle resynced! renderFrameId=', rdf.Id); } self.renderFrameId = rdf.Id; self.lastRenderFrameIdTriggeredAt = performance.now(); @@ -1071,6 +1072,12 @@ ${self._stringifyRecentInputAndRenderCacheCorrespondingly()}`); currPlayerDownsync.framesToRecover = currPlayerDownsync.FrameToRecover; playerRichInfo.scriptIns.updateCharacterAnim(currPlayerDownsync, prevRdfPlayer, false); } + + // Update countdown + self.countdownNanos = self.battleDurationNanos - self.renderFrameId * self.rollbackEstimatedDtNanos; + if (self.countdownNanos <= 0) { + self.onBattleStopped(self.playerRichInfoDict); + } }, getCachedInputFrameDownsyncWithPrediction(inputFrameId) { diff --git a/frontend/assets/scripts/OfflineMap.js b/frontend/assets/scripts/OfflineMap.js index 65bce12..8153846 100644 --- a/frontend/assets/scripts/OfflineMap.js +++ b/frontend/assets/scripts/OfflineMap.js @@ -13,7 +13,7 @@ cc.Class({ onLoad() { const self = this; window.mapIns = self; - self.showCriticalCoordinateLabels = true; + self.showCriticalCoordinateLabels = false; const mapNode = self.node; const canvasNode = mapNode.parent; @@ -31,6 +31,7 @@ cc.Class({ self.inputDelayFrames = 8; self.inputScaleFrames = 2; self.inputFrameUpsyncDelayTolerance = 2; + self.collisionMinStep = 8; self.renderCacheSize = 1024; self.serverFps = 60; @@ -49,22 +50,17 @@ cc.Class({ recoveryFrames: 34, // usually but not always "startupFrames+activeFrames", I hereby set it to be 1 frame more than the actual animation to avoid critical transition, i.e. when the animation is 1 frame from ending but "rdfPlayer.framesToRecover" is already counted 0 and the player triggers an other same attack, making an effective bullet trigger but no animation is played due to same animName is still playing recoveryFramesOnBlock: 34, recoveryFramesOnHit: 34, - moveforward: { - x: 0, - y: 0, - }, hitboxOffset: 12.0, // should be about the radius of the PlayerCollider - hitboxSize: { - x: 23.0, - y: 32.0, - }, - // for defender hitStunFrames: 18, blockStunFrames: 9, pushback: 8.0, releaseTriggerType: 1, // 1: rising-edge, 2: falling-edge - damage: 5 + damage: 5, + hitboxSizeX: 24.0, + hitboxSizeY: 32.0, + selfMoveforwardX: 0, + selfMoveforwardY: 0, } }; @@ -76,7 +72,7 @@ cc.Class({ self.snapIntoPlatformOverlap = 0.1; self.snapIntoPlatformThreshold = 0.5; // a platform must be "horizontal enough" for a character to "stand on" self.jumpingInitVelY = 7 * self.worldToVirtualGridRatio; // unit: (virtual grid length/renderFrame) - [self.gravityX, self.gravityY] = [0, -0.5*self.worldToVirtualGridRatio]; // unit: (virtual grid length/renderFrame^2) + [self.gravityX, self.gravityY] = [0, -0.5 * self.worldToVirtualGridRatio]; // unit: (virtual grid length/renderFrame^2) const tiledMapIns = self.node.getComponent(cc.TiledMap); @@ -89,7 +85,6 @@ cc.Class({ tiledMapIns.tmxAsset = null; mapNode.removeAllChildren(); - self._resetCurrentMatch(); if (self.showCriticalCoordinateLabels) { const drawer = new cc.Node(); @@ -101,25 +96,30 @@ cc.Class({ self.g = g; } - 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)); + self.stageDiscreteW = newMapSize.width; + self.stageDiscreteH = newMapSize.height; + self.stageTileW = newTileSize.width; + self.stageTileH = newTileSize.height; + + self._resetCurrentMatch(); 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 gopkgsBoundaryAnchor = gopkgs.NewVec2DJs(boundaryObj.anchor.x, boundaryObj.anchor.y); + const gopkgsBoundaryPts = Array.from(boundaryObj, p => { + return gopkgs.NewVec2DJs(p.x, p.y); + }); + const gopkgsBoundary = gopkgs.NewPolygon2DJs(gopkgsBoundaryAnchor, gopkgsBoundaryPts); + const gopkgsBarrier = gopkgs.NewBarrierJs(gopkgsBoundary); - const newBarrier = self.collisionSys.createPolygon(x0, y0, Array.from(boundaryObj, p => { - return [p.x, p.y]; - })); - newBarrier.data = { - hardPushback: true - }; + const newBarrierCollider = gopkgs.GenerateConvexPolygonColliderJs(gopkgsBoundary, self.spaceOffsetX, self.spaceOffsetY, gopkgsBarrier, "Barrier"); + self.gopkgsCollisionSys.Add(newBarrierCollider); if (false && self.showCriticalCoordinateLabels) { for (let i = 0; i < boundaryObj.length; ++i) { @@ -152,20 +152,20 @@ cc.Class({ } } - // console.log("Created barrier: ", newBarrier); + // console.log("Created barrier: ", newBarrierCollider); ++barrierIdCounter; const collisionBarrierIndex = (self.collisionBarrierIndexPrefix + barrierIdCounter); - self.collisionSysMap.set(collisionBarrierIndex, newBarrier); + self.gopkgsCollisionSysMap[collisionBarrierIndex] = newBarrierCollider; } const startRdf = window.pb.protos.RoomDownsyncFrame.create({ id: window.MAGIC_ROOM_DOWNSYNC_FRAME_ID.BATTLE_START, - players: { - 10: window.pb.protos.PlayerDownsync.create({ + playersArr: [ + window.pb.protos.PlayerDownsync.create({ id: 10, joinIndex: 1, - virtualGridX: self.worldToVirtualGridPos(boundaryObjs.playerStartingPositions[0].x, boundaryObjs.playerStartingPositions[0].y)[0], - virtualGridY: self.worldToVirtualGridPos(boundaryObjs.playerStartingPositions[0].x, boundaryObjs.playerStartingPositions[0].y)[1], + virtualGridX: boundaryObjs.playerStartingPositions[0].x * self.worldToVirtualGridRatio, + virtualGridY: boundaryObjs.playerStartingPositions[0].y * self.worldToVirtualGridRatio, speed: 1 * self.worldToVirtualGridRatio, colliderRadius: 12, characterState: window.ATK_CHARACTER_STATE.InAirIdle1[0], @@ -176,11 +176,11 @@ cc.Class({ velY: 0, inAir: true, }), - 11: window.pb.protos.PlayerDownsync.create({ + window.pb.protos.PlayerDownsync.create({ id: 11, joinIndex: 2, - virtualGridX: self.worldToVirtualGridPos(boundaryObjs.playerStartingPositions[1].x, boundaryObjs.playerStartingPositions[1].y)[0], - virtualGridY: self.worldToVirtualGridPos(boundaryObjs.playerStartingPositions[1].x, boundaryObjs.playerStartingPositions[1].y)[1], + virtualGridX: boundaryObjs.playerStartingPositions[1].x * self.worldToVirtualGridRatio, + virtualGridY: boundaryObjs.playerStartingPositions[1].y * self.worldToVirtualGridRatio, speed: 1 * self.worldToVirtualGridRatio, colliderRadius: 12, characterState: window.ATK_CHARACTER_STATE.InAirIdle1[0], @@ -191,10 +191,15 @@ cc.Class({ velY: 0, inAir: true, }), - } + ] }); + self.selfPlayerInfo = { - id: 11 + Id: 11, + JoinIndex: 2, + // For compatibility + id: 11, + joinIndex: 2, }; self.onRoomDownsyncFrame(startRdf); @@ -223,7 +228,7 @@ cc.Class({ currSelfInput = prevAndCurrInputs[1]; } - const [prevRdf, rdf] = self.rollbackAndChase(self.renderFrameId, self.renderFrameId + 1, self.collisionSys, self.collisionSysMap, false); + const [prevRdf, rdf] = self.rollbackAndChase(self.renderFrameId, self.renderFrameId + 1, self.gopkgsCollisionSys, self.gopkgsCollisionSysMap, false); self.applyRoomDownsyncFrameDynamics(rdf, prevRdf); self.showDebugBoundaries(rdf); ++self.renderFrameId; @@ -234,4 +239,5 @@ cc.Class({ } } }, + }); diff --git a/frontend/assets/scripts/OfflineMap.js.meta b/frontend/assets/scripts/OfflineMap.js.meta index 4da3509..bb0072c 100644 --- a/frontend/assets/scripts/OfflineMap.js.meta +++ b/frontend/assets/scripts/OfflineMap.js.meta @@ -1,6 +1,6 @@ { "ver": "1.0.5", - "uuid": "47d7dcb8-4b89-41da-9c6a-2499463a86a2", + "uuid": "b3810903-496b-43d7-8461-898cee958548", "isPlugin": false, "loadPluginInWeb": true, "loadPluginInNative": true, diff --git a/frontend/assets/scripts/OfflineMapBackend.js b/frontend/assets/scripts/OfflineMapBackend.js deleted file mode 100644 index 8153846..0000000 --- a/frontend/assets/scripts/OfflineMapBackend.js +++ /dev/null @@ -1,243 +0,0 @@ -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, - - onDestroy() { - console.warn("+++++++ Map onDestroy()"); - }, - - onLoad() { - const self = this; - window.mapIns = self; - self.showCriticalCoordinateLabels = false; - - const mapNode = self.node; - const canvasNode = mapNode.parent; - - self.mainCameraNode = self.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 = 8; - self.inputScaleFrames = 2; - self.inputFrameUpsyncDelayTolerance = 2; - self.collisionMinStep = 8; - - self.renderCacheSize = 1024; - self.serverFps = 60; - self.rollbackEstimatedDt = 0.016667; - self.rollbackEstimatedDtMillis = 16.667; - self.rollbackEstimatedDtNanos = 16666666; - self.tooFastDtIntervalMillis = 0.5 * self.rollbackEstimatedDtMillis; - - self.worldToVirtualGridRatio = 1000; - self.virtualGridToWorldRatio = 1.0 / self.worldToVirtualGridRatio; - self.meleeSkillConfig = { - 1: { - // for offender - startupFrames: 10, - activeFrames: 20, - recoveryFrames: 34, // usually but not always "startupFrames+activeFrames", I hereby set it to be 1 frame more than the actual animation to avoid critical transition, i.e. when the animation is 1 frame from ending but "rdfPlayer.framesToRecover" is already counted 0 and the player triggers an other same attack, making an effective bullet trigger but no animation is played due to same animName is still playing - recoveryFramesOnBlock: 34, - recoveryFramesOnHit: 34, - hitboxOffset: 12.0, // should be about the radius of the PlayerCollider - // for defender - hitStunFrames: 18, - blockStunFrames: 9, - pushback: 8.0, - releaseTriggerType: 1, // 1: rising-edge, 2: falling-edge - damage: 5, - hitboxSizeX: 24.0, - hitboxSizeY: 32.0, - selfMoveforwardX: 0, - selfMoveforwardY: 0, - } - }; - - /* - [WARNING] As when a character is standing on a barrier, if not carefully curated there MIGHT BE a bouncing sequence of "[(inAir -> dropIntoBarrier ->), (notInAir -> pushedOutOfBarrier ->)], [(inAir -> ..." - - Moreover, "snapIntoPlatformOverlap" should be small enough such that the walking "velX" or jumping initial "velY" can escape from it by 1 renderFrame (when jumping is triggered, the character is waived from snappig for 1 renderFrame). - */ - self.snapIntoPlatformOverlap = 0.1; - self.snapIntoPlatformThreshold = 0.5; // a platform must be "horizontal enough" for a character to "stand on" - self.jumpingInitVelY = 7 * self.worldToVirtualGridRatio; // unit: (virtual grid length/renderFrame) - [self.gravityX, self.gravityY] = [0, -0.5 * self.worldToVirtualGridRatio]; // unit: (virtual grid length/renderFrame^2) - - const tiledMapIns = self.node.getComponent(cc.TiledMap); - - const fullPathOfTmxFile = cc.js.formatStr("map/%s/map", "dungeon"); - cc.loader.loadRes(fullPathOfTmxFile, cc.TiledMapAsset, (err, tmxAsset) => { - if (null != err) { - console.error(err); - return; - } - - tiledMapIns.tmxAsset = null; - mapNode.removeAllChildren(); - - if (self.showCriticalCoordinateLabels) { - const drawer = new cc.Node(); - drawer.setPosition(cc.v2(0, 0)) - safelyAddChild(self.node, drawer); - setLocalZOrder(drawer, 999); - const g = drawer.addComponent(cc.Graphics); - g.lineWidth = 2; - self.g = g; - } - - 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)); - - self.stageDiscreteW = newMapSize.width; - self.stageDiscreteH = newMapSize.height; - self.stageTileW = newTileSize.width; - self.stageTileH = newTileSize.height; - - self._resetCurrentMatch(); - let barrierIdCounter = 0; - const boundaryObjs = tileCollisionManager.extractBoundaryObjects(self.node); - for (let boundaryObj of boundaryObjs.barriers) { - const gopkgsBoundaryAnchor = gopkgs.NewVec2DJs(boundaryObj.anchor.x, boundaryObj.anchor.y); - const gopkgsBoundaryPts = Array.from(boundaryObj, p => { - return gopkgs.NewVec2DJs(p.x, p.y); - }); - const gopkgsBoundary = gopkgs.NewPolygon2DJs(gopkgsBoundaryAnchor, gopkgsBoundaryPts); - const gopkgsBarrier = gopkgs.NewBarrierJs(gopkgsBoundary); - - const newBarrierCollider = gopkgs.GenerateConvexPolygonColliderJs(gopkgsBoundary, self.spaceOffsetX, self.spaceOffsetY, gopkgsBarrier, "Barrier"); - self.gopkgsCollisionSys.Add(newBarrierCollider); - - if (false && 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: ", newBarrierCollider); - ++barrierIdCounter; - const collisionBarrierIndex = (self.collisionBarrierIndexPrefix + barrierIdCounter); - self.gopkgsCollisionSysMap[collisionBarrierIndex] = newBarrierCollider; - } - - const startRdf = window.pb.protos.RoomDownsyncFrame.create({ - id: window.MAGIC_ROOM_DOWNSYNC_FRAME_ID.BATTLE_START, - playersArr: [ - window.pb.protos.PlayerDownsync.create({ - id: 10, - joinIndex: 1, - virtualGridX: boundaryObjs.playerStartingPositions[0].x * self.worldToVirtualGridRatio, - virtualGridY: boundaryObjs.playerStartingPositions[0].y * self.worldToVirtualGridRatio, - speed: 1 * self.worldToVirtualGridRatio, - colliderRadius: 12, - characterState: window.ATK_CHARACTER_STATE.InAirIdle1[0], - framesToRecover: 0, - dirX: 0, - dirY: 0, - velX: 0, - velY: 0, - inAir: true, - }), - window.pb.protos.PlayerDownsync.create({ - id: 11, - joinIndex: 2, - virtualGridX: boundaryObjs.playerStartingPositions[1].x * self.worldToVirtualGridRatio, - virtualGridY: boundaryObjs.playerStartingPositions[1].y * self.worldToVirtualGridRatio, - speed: 1 * self.worldToVirtualGridRatio, - colliderRadius: 12, - characterState: window.ATK_CHARACTER_STATE.InAirIdle1[0], - framesToRecover: 0, - dirX: 0, - dirY: 0, - velX: 0, - velY: 0, - inAir: true, - }), - ] - }); - - self.selfPlayerInfo = { - Id: 11, - JoinIndex: 2, - // For compatibility - id: 11, - joinIndex: 2, - }; - self.onRoomDownsyncFrame(startRdf); - - self.battleState = ALL_BATTLE_STATES.IN_BATTLE; - }); - - }, - - update(dt) { - const self = this; - if (ALL_BATTLE_STATES.IN_BATTLE == self.battleState) { - const elapsedMillisSinceLastFrameIdTriggered = performance.now() - self.lastRenderFrameIdTriggeredAt; - if (elapsedMillisSinceLastFrameIdTriggered < self.tooFastDtIntervalMillis) { - // [WARNING] We should avoid a frontend ticking too fast to prevent cheating, as well as ticking too slow to cause a "resync avalanche" that impacts user experience! - // 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.getOrPrefabInputFrameUpsync(noDelayInputFrameId); - prevSelfInput = prevAndCurrInputs[0]; - currSelfInput = prevAndCurrInputs[1]; - } - - const [prevRdf, rdf] = self.rollbackAndChase(self.renderFrameId, self.renderFrameId + 1, self.gopkgsCollisionSys, self.gopkgsCollisionSysMap, false); - self.applyRoomDownsyncFrameDynamics(rdf, prevRdf); - self.showDebugBoundaries(rdf); - ++self.renderFrameId; - self.lastRenderFrameIdTriggeredAt = performance.now(); - let t3 = performance.now(); - } catch (err) { - console.error("Error during Map.update", err); - } - } - }, - -}); diff --git a/frontend/assets/scripts/OfflineMapBackend.js.meta b/frontend/assets/scripts/OfflineMapBackend.js.meta deleted file mode 100644 index bb0072c..0000000 --- a/frontend/assets/scripts/OfflineMapBackend.js.meta +++ /dev/null @@ -1,9 +0,0 @@ -{ - "ver": "1.0.5", - "uuid": "b3810903-496b-43d7-8461-898cee958548", - "isPlugin": false, - "loadPluginInWeb": true, - "loadPluginInNative": true, - "loadPluginInEditor": false, - "subMetas": {} -} \ No newline at end of file