Updated OfflineMap position loading.

This commit is contained in:
genxium 2022-12-12 16:42:11 +08:00
parent bef1df48aa
commit 7985a242fd
4 changed files with 28 additions and 13 deletions

View File

@ -440,7 +440,7 @@
"array": [
0,
0,
216.50635094610968,
209.73151519075364,
0,
0,
0,

View File

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

View File

@ -76,7 +76,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 = 5 * self.worldToVirtualGridRatio; // unit: (virtual grid length/renderFrame)
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}`);

View File

@ -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) {