Fixed character offset in OfflineMap2.

This commit is contained in:
genxium
2022-12-25 14:18:48 +08:00
parent 72782735d3
commit 013c1ea312
15 changed files with 514 additions and 212930 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{
"ver": "1.0.5",
"uuid": "c402c9d1-1d32-4dbb-993a-6bfa0099fa2b",
"uuid": "d41313ca-b2c3-4436-a05f-7e0eb290b1e6",
"isPlugin": true,
"loadPluginInWeb": true,
"loadPluginInNative": true,

View File

@@ -1,5 +1,5 @@
syntax = "proto3";
option go_package = "jsexport/protos"; // here "./" corresponds to the "--go_out" value in "protoc" command
option go_package = "battle_srv/protos"; // here "./" corresponds to the "--go_out" value in "protoc" command
package protos;
import "geometry.proto"; // The import path here is only w.r.t. the proto file, not the Go package.

View File

@@ -97,7 +97,7 @@
"__id__": 1
},
"_children": [],
"_active": false,
"_active": true,
"_components": [
{
"__id__": 3
@@ -129,7 +129,7 @@
"ctor": "Float64Array",
"array": [
0,
0,
45,
0,
0,
0,

View File

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

View File

@@ -461,7 +461,7 @@
"array": [
0,
0,
216.05530045313827,
217.37237634989413,
0,
0,
0,

View File

@@ -461,7 +461,7 @@
"array": [
0,
0,
216.50635094610968,
217.37237634989413,
0,
0,
0,

View File

@@ -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;
@@ -375,7 +375,18 @@ cc.Class({
halfColliderHeight = playerDownsyncInfo.ColliderRadius + playerDownsyncInfo.ColliderRadius; // avoid multiplying
const colliderWidth = halfColliderWidth + halfColliderWidth,
colliderHeight = halfColliderHeight + halfColliderHeight; // avoid multiplying
const newPlayerCollider = gopkgs.GenerateRectColliderJs(wx, wy, colliderWidth, colliderHeight, self.snapIntoPlatformOverlap, self.snapIntoPlatformOverlap, self.snapIntoPlatformOverlap, self.snapIntoPlatformOverlap, self.spaceOffsetX, self.spaceOffsetY, playerDownsyncInfo, "Player");
const [cx, cy] = gopkgs.WorldToPolygonColliderBLPos(wx, wy, halfColliderWidth, halfColliderHeight, self.snapIntoPlatformOverlap, self.snapIntoPlatformOverlap, self.snapIntoPlatformOverlap, self.snapIntoPlatformOverlap, self.spaceOffsetX, self.spaceOffsetY);
const gopkgsBoundaryAnchor = gopkgs.NewVec2DJs(cx, cy);
const gopkgsBoundaryPts = [
gopkgs.NewVec2DJs(0, 0),
gopkgs.NewVec2DJs(self.snapIntoPlatformOverlap + colliderWidth + self.snapIntoPlatformOverlap, 0),
gopkgs.NewVec2DJs(self.snapIntoPlatformOverlap + colliderWidth + self.snapIntoPlatformOverlap, self.snapIntoPlatformOverlap + colliderHeight + self.snapIntoPlatformOverlap),
gopkgs.NewVec2DJs(0, self.snapIntoPlatformOverlap + colliderHeight + self.snapIntoPlatformOverlap)
];
const gopkgsBoundary = gopkgs.NewPolygon2DJs(gopkgsBoundaryAnchor, gopkgsBoundaryPts);
const newPlayerCollider = gopkgs.GenerateConvexPolygonColliderJs(gopkgsBoundary, self.spaceOffsetX, self.spaceOffsetY, playerDownsyncInfo, "Player");
//const newPlayerCollider = gopkgs.GenerateRectColliderJs(wx, wy, colliderWidth, colliderHeight, self.snapIntoPlatformOverlap, self.snapIntoPlatformOverlap, self.snapIntoPlatformOverlap, self.snapIntoPlatformOverlap, self.spaceOffsetX, self.spaceOffsetY, playerDownsyncInfo, "Player");
self.gopkgsCollisionSys.Add(newPlayerCollider);
const collisionPlayerIndex = self.collisionPlayerIndexPrefix + joinIndex;
self.gopkgsCollisionSysMap[collisionPlayerIndex] = newPlayerCollider;
@@ -394,4 +405,45 @@ cc.Class({
return [newPlayerNode, playerScriptIns];
},
showDebugBoundaries(rdf) {
const self = this;
const leftPadding = self.snapIntoPlatformOverlap,
rightPadding = self.snapIntoPlatformOverlap,
topPadding = self.snapIntoPlatformOverlap,
bottomPadding = self.snapIntoPlatformOverlap;
if (self.showCriticalCoordinateLabels) {
let g = self.g;
g.clear();
const collisionSpaceObjs = gopkgs.GetCollisionSpaceObjsJs(self.gopkgsCollisionSys);
for (let k in collisionSpaceObjs) {
const body = collisionSpaceObjs[k];
let padding = 0;
if (null != body.Data && null != body.Data.JoinIndex) {
// character
if (1 == body.Data.JoinIndex) {
g.strokeColor = cc.Color.BLUE;
} else {
g.strokeColor = cc.Color.RED;
}
padding = self.snapIntoPlatformOverlap;
} else {
// barrier
g.strokeColor = cc.Color.WHITE;
}
const points = body.Shape.Points;
const wpos = [body.X-self.spaceOffsetX, body.Y-self.spaceOffsetY];
g.moveTo(wpos[0], wpos[1]);
const cnt = points.length;
for (let j = 0; j < cnt; j += 1) {
const x = wpos[0]+points[j][0],
y = wpos[1]+points[j][1];
g.lineTo(x, y);
}
g.lineTo(wpos[0], wpos[1]);
g.stroke();
}
}
},
});