From 7985a242fdc4f27f7f5b262f38e0be2b012d3172 Mon Sep 17 00:00:00 2001 From: genxium Date: Mon, 12 Dec 2022 16:42:11 +0800 Subject: [PATCH] Updated OfflineMap position loading. --- frontend/assets/scenes/login.fire | 2 +- frontend/assets/scenes/offline_map_1.fire | 10 +++++----- frontend/assets/scripts/OfflineMap.js | 16 +++++++++------- .../scripts/TileCollisionManagerSingleton.js | 13 +++++++++++++ 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/frontend/assets/scenes/login.fire b/frontend/assets/scenes/login.fire index 76a6bfa..31ccba3 100644 --- a/frontend/assets/scenes/login.fire +++ b/frontend/assets/scenes/login.fire @@ -440,7 +440,7 @@ "array": [ 0, 0, - 216.50635094610968, + 209.73151519075364, 0, 0, 0, diff --git a/frontend/assets/scenes/offline_map_1.fire b/frontend/assets/scenes/offline_map_1.fire index 98ab253..9e6102e 100644 --- a/frontend/assets/scenes/offline_map_1.fire +++ b/frontend/assets/scenes/offline_map_1.fire @@ -172,8 +172,8 @@ }, "_contentSize": { "__type__": "cc.Size", - "width": 3200, - "height": 3200 + "width": 2048, + "height": 2048 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -191,8 +191,8 @@ 0, 0, 1, - 2, - 2, + 1.5, + 1.5, 1 ] }, @@ -454,7 +454,7 @@ "array": [ 0, 0, - 217.71545143883017, + 209.73151519075364, 0, 0, 0, diff --git a/frontend/assets/scripts/OfflineMap.js b/frontend/assets/scripts/OfflineMap.js index e54ba7c..ab14a1b 100644 --- a/frontend/assets/scripts/OfflineMap.js +++ b/frontend/assets/scripts/OfflineMap.js @@ -76,8 +76,8 @@ cc.Class({ */ self.snapIntoPlatformOverlap = 0.1; self.snapIntoPlatformThreshold = 0.5; // a platform must be "horizontal enough" for a character to "stand on" - self.jumpingInitVelY = 5 * self.worldToVirtualGridRatio; // unit: (virtual grid length/renderFrame) - [self.gravityX, self.gravityY] = [0, -Math.ceil(4*self.jumpingInitVelY/self.serverFps)]; // unit: (virtual grid length/renderFrame^2) + self.jumpingInitVelY = 6 * self.worldToVirtualGridRatio; // unit: (virtual grid length/renderFrame) + [self.gravityX, self.gravityY] = [0, -Math.ceil(4 * self.jumpingInitVelY / self.serverFps)]; // unit: (virtual grid length/renderFrame^2) const tiledMapIns = self.node.getComponent(cc.TiledMap); @@ -162,8 +162,8 @@ cc.Class({ 10: window.pb.protos.PlayerDownsync.create({ id: 10, joinIndex: 1, - virtualGridX: -50 * self.worldToVirtualGridRatio, - virtualGridY: -400 * self.worldToVirtualGridRatio, + virtualGridX: self.worldToVirtualGridPos(boundaryObjs.playerStartingPositions[0].x, boundaryObjs.playerStartingPositions[0].y)[0], + virtualGridY: self.worldToVirtualGridPos(boundaryObjs.playerStartingPositions[0].x, boundaryObjs.playerStartingPositions[0].y)[1], speed: 1 * self.worldToVirtualGridRatio, colliderRadius: 12, characterState: window.ATK_CHARACTER_STATE.InAirIdle1[0], @@ -177,8 +177,8 @@ cc.Class({ 11: window.pb.protos.PlayerDownsync.create({ id: 11, joinIndex: 2, - virtualGridX: 100 * self.worldToVirtualGridRatio, - virtualGridY: -350 * self.worldToVirtualGridRatio, + virtualGridX: self.worldToVirtualGridPos(boundaryObjs.playerStartingPositions[1].x, boundaryObjs.playerStartingPositions[1].y)[0], + virtualGridY: self.worldToVirtualGridPos(boundaryObjs.playerStartingPositions[1].x, boundaryObjs.playerStartingPositions[1].y)[1], speed: 1 * self.worldToVirtualGridRatio, colliderRadius: 12, characterState: window.ATK_CHARACTER_STATE.InAirIdle1[0], @@ -432,7 +432,9 @@ cc.Class({ // console.log(`A rising-edge of meleeBullet is created at renderFrame.id=${currRenderFrame.id}, delayedInputFrame.id=${delayedInputFrame.inputFrameId}`); thatPlayerInNextFrame.characterState = window.ATK_CHARACTER_STATE.Atk1[0]; - thatPlayerInNextFrame.velX = 0; // prohibits simultaneous movement with Atk1 (including inAir) + if (false == currPlayerDownsync.inAir) { + thatPlayerInNextFrame.velX = 0; // prohibits simultaneous movement with Atk1 on the ground + } } } else if (0 == decodedInput.btnALevel && 1 == prevBtnALevel) { // console.log(`playerId=${playerId} triggered a falling-edge of btnA at renderFrame.id=${currRenderFrame.id}, delayedInputFrame.id=${delayedInputFrame.inputFrameId}`); diff --git a/frontend/assets/scripts/TileCollisionManagerSingleton.js b/frontend/assets/scripts/TileCollisionManagerSingleton.js index 2487371..342b111 100644 --- a/frontend/assets/scripts/TileCollisionManagerSingleton.js +++ b/frontend/assets/scripts/TileCollisionManagerSingleton.js @@ -108,6 +108,7 @@ TileCollisionManager.prototype.continuousMapNodePosToContinuousObjLayerOffset = window.battleEntityTypeNameToGlobalGid = {}; TileCollisionManager.prototype.extractBoundaryObjects = function(withTiledMapNode) { let toRet = { + playerStartingPositions: [], barriers: [], }; const tiledMapIns = withTiledMapNode.getComponent(cc.TiledMap); // This is a magic name. @@ -115,6 +116,18 @@ TileCollisionManager.prototype.extractBoundaryObjects = function(withTiledMapNod const allObjectGroups = tiledMapIns.getObjectGroups(); for (let i = 0; i < allObjectGroups.length; ++i) { var objectGroup = allObjectGroups[i]; + if ("PlayerStartingPos" == objectGroup.getGroupName()) { + var allObjects = objectGroup.getObjects(); + for (let j = 0; j < allObjects.length; ++j) { + const cccMaskedX = allObjects[j].x, + cccMaskedY = allObjects[j].y; + const origX = cccMaskedX, + origY = withTiledMapNode.getContentSize().height - cccMaskedY; // FIXME: I don't know why CocosCreator did this, it's stupid and MIGHT NOT WORK IN ISOMETRIC orientation! + let wpos = this.continuousObjLayerOffsetToContinuousMapNodePos(withTiledMapNode, cc.v2(origX, origY)); + toRet.playerStartingPositions.push(wpos); + } + continue; + } if ("barrier_and_shelter" != objectGroup.getProperty("type")) continue; var allObjects = objectGroup.getObjects(); for (let j = 0; j < allObjects.length; ++j) {