mirror of
https://github.com/genxium/DelayNoMore
synced 2025-10-09 16:46:38 +00:00
Fixed backend bullet collision handling.
This commit is contained in:
@@ -529,8 +529,8 @@
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0.5,
|
||||
0.5,
|
||||
1
|
||||
]
|
||||
},
|
||||
@@ -648,7 +648,7 @@
|
||||
"_N$_defaultCacheMode": 0,
|
||||
"_N$timeScale": 1,
|
||||
"_N$debugBones": false,
|
||||
"_N$enableBatch": false,
|
||||
"_N$enableBatch": true,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
@@ -763,7 +763,7 @@
|
||||
"_N$_defaultCacheMode": 0,
|
||||
"_N$timeScale": 1,
|
||||
"_N$debugBones": false,
|
||||
"_N$enableBatch": false,
|
||||
"_N$enableBatch": true,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
@@ -878,7 +878,7 @@
|
||||
"_N$_defaultCacheMode": 0,
|
||||
"_N$timeScale": 1,
|
||||
"_N$debugBones": false,
|
||||
"_N$enableBatch": false,
|
||||
"_N$enableBatch": true,
|
||||
"_id": ""
|
||||
},
|
||||
{
|
||||
|
@@ -761,7 +761,7 @@ cc.Class({
|
||||
|
||||
newPlayerNode.setPosition(cc.v2(wpos[0], wpos[1]));
|
||||
playerScriptIns.mapNode = self.node;
|
||||
const cpos = self.virtualGridToPlayerColliderPos(vx, vy, playerDownsyncInfo);
|
||||
const cpos = self.virtualGridToPolygonColliderAnchorPos(vx, vy, playerDownsyncInfo.colliderRadius, playerDownsyncInfo.colliderRadius);
|
||||
const d = playerDownsyncInfo.colliderRadius * 2,
|
||||
x0 = cpos[0],
|
||||
y0 = cpos[1];
|
||||
@@ -1044,7 +1044,7 @@ cc.Class({
|
||||
|
||||
const newVx = currPlayerDownsync.virtualGridX;
|
||||
const newVy = currPlayerDownsync.virtualGridY;
|
||||
const newCpos = self.virtualGridToPlayerColliderPos(newVx, newVy, self.playerRichInfoArr[joinIndex - 1]);
|
||||
const newCpos = self.virtualGridToPolygonColliderAnchorPos(newVx, newVy, self.playerRichInfoArr[joinIndex - 1].colliderRadius, self.playerRichInfoArr[joinIndex - 1].colliderRadius);
|
||||
playerCollider.x = newCpos[0];
|
||||
playerCollider.y = newCpos[1];
|
||||
}
|
||||
@@ -1064,15 +1064,16 @@ cc.Class({
|
||||
const offenderCollider = collisionSysMap.get(collisionOffenderIndex);
|
||||
const offender = currRenderFrame.players[meleeBullet.offenderPlayerId];
|
||||
|
||||
let xfac = 1,
|
||||
yfac = 0; // By now, straight Punch offset doesn't respect "y-axis"
|
||||
let xfac = 1; // By now, straight Punch offset doesn't respect "y-axis"
|
||||
if (0 > offender.dirX) {
|
||||
xfac = -1;
|
||||
}
|
||||
const x0 = offenderCollider.x + xfac * meleeBullet.hitboxOffset,
|
||||
y0 = offenderCollider.y + yfac * meleeBullet.hitboxOffset;
|
||||
const pts = [[0, 0], [xfac * meleeBullet.hitboxSize.x, 0], [xfac * meleeBullet.hitboxSize.x, meleeBullet.hitboxSize.y], [0, meleeBullet.hitboxSize.y]];
|
||||
const newBulletCollider = collisionSys.createPolygon(x0, y0, pts);
|
||||
const offenderWpos = self.virtualGridToWorldPos(offender.virtualGridX, offender.virtualGridY);
|
||||
const bulletWx = offenderWpos[0] + xfac * meleeBullet.hitboxOffset;
|
||||
const bulletWy = offenderWpos[1];
|
||||
const bulletCpos = self.worldToPolygonColliderAnchorPos(bulletWx, bulletWy, meleeBullet.hitboxSize.x * 0.5, meleeBullet.hitboxSize.y * 0.5);
|
||||
const pts = [[0, 0], [meleeBullet.hitboxSize.x, 0], [meleeBullet.hitboxSize.x, meleeBullet.hitboxSize.y], [0, meleeBullet.hitboxSize.y]];
|
||||
const newBulletCollider = collisionSys.createPolygon(bulletCpos[0], bulletCpos[1], pts);
|
||||
newBulletCollider.data = meleeBullet;
|
||||
collisionSysMap.set(collisionBulletIndex, newBulletCollider);
|
||||
bulletColliders.set(collisionBulletIndex, newBulletCollider);
|
||||
@@ -1208,7 +1209,7 @@ cc.Class({
|
||||
const playerId = self.playerRichInfoArr[j].id;
|
||||
const collisionPlayerIndex = self.collisionPlayerIndexPrefix + joinIndex;
|
||||
const playerCollider = collisionSysMap.get(collisionPlayerIndex);
|
||||
const newVpos = self.playerColliderAnchorToVirtualGridPos(playerCollider.x - effPushbacks[joinIndex - 1][0], playerCollider.y - effPushbacks[joinIndex - 1][1], self.playerRichInfoArr[j]);
|
||||
const newVpos = self.polygonColliderAnchorToVirtualGridPos(playerCollider.x - effPushbacks[joinIndex - 1][0], playerCollider.y - effPushbacks[joinIndex - 1][1], self.playerRichInfoArr[j].colliderRadius, self.playerRichInfoArr[j].colliderRadius);
|
||||
const thatPlayerInNextFrame = nextRenderFramePlayers[playerId];
|
||||
thatPlayerInNextFrame.virtualGridX = newVpos[0];
|
||||
thatPlayerInNextFrame.virtualGridY = newVpos[1];
|
||||
@@ -1340,23 +1341,23 @@ cc.Class({
|
||||
return [wx, wy];
|
||||
},
|
||||
|
||||
playerWorldToCollisionPos(wx, wy, playerRichInfo) {
|
||||
return [wx - playerRichInfo.colliderRadius, wy - playerRichInfo.colliderRadius];
|
||||
worldToPolygonColliderAnchorPos(wx, wy, halfBoundingW, halfBoundingH) {
|
||||
return [wx - halfBoundingW, wy - halfBoundingH];
|
||||
},
|
||||
|
||||
playerColliderAnchorToWorldPos(cx, cy, playerRichInfo) {
|
||||
return [cx + playerRichInfo.colliderRadius, cy + playerRichInfo.colliderRadius];
|
||||
polygonColliderAnchorToWorldPos(cx, cy, halfBoundingW, halfBoundingH) {
|
||||
return [cx + halfBoundingW, cy + halfBoundingH];
|
||||
},
|
||||
|
||||
playerColliderAnchorToVirtualGridPos(cx, cy, playerRichInfo) {
|
||||
polygonColliderAnchorToVirtualGridPos(cx, cy, halfBoundingW, halfBoundingH) {
|
||||
const self = this;
|
||||
const wpos = self.playerColliderAnchorToWorldPos(cx, cy, playerRichInfo);
|
||||
const wpos = self.polygonColliderAnchorToWorldPos(cx, cy, halfBoundingW, halfBoundingH);
|
||||
return self.worldToVirtualGridPos(wpos[0], wpos[1])
|
||||
},
|
||||
|
||||
virtualGridToPlayerColliderPos(vx, vy, playerRichInfo) {
|
||||
virtualGridToPolygonColliderAnchorPos(vx, vy, halfBoundingW, halfBoundingH) {
|
||||
const self = this;
|
||||
const wpos = self.virtualGridToWorldPos(vx, vy);
|
||||
return self.playerWorldToCollisionPos(wpos[0], wpos[1], playerRichInfo)
|
||||
return self.worldToPolygonColliderAnchorPos(wpos[0], wpos[1], halfBoundingW, halfBoundingH)
|
||||
},
|
||||
});
|
||||
|
@@ -42,8 +42,8 @@ cc.Class({
|
||||
self.meleeSkillConfig = {
|
||||
1: {
|
||||
// for offender
|
||||
startupFrames: 18,
|
||||
activeFrames: 42,
|
||||
startupFrames: 23,
|
||||
activeFrames: 3,
|
||||
recoveryFrames: 61, // 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: 61,
|
||||
recoveryFramesOnHit: 61,
|
||||
@@ -60,7 +60,7 @@ cc.Class({
|
||||
// for defender
|
||||
hitStunFrames: 18,
|
||||
blockStunFrames: 9,
|
||||
pushback: 22.0,
|
||||
pushback: 11.0,
|
||||
releaseTriggerType: 1, // 1: rising-edge, 2: falling-edge
|
||||
damage: 5
|
||||
}
|
||||
@@ -140,7 +140,7 @@ cc.Class({
|
||||
joinIndex: 1,
|
||||
virtualGridX: 0,
|
||||
virtualGridY: 0,
|
||||
speed: 2 * self.worldToVirtualGridRatio,
|
||||
speed: 1 * self.worldToVirtualGridRatio,
|
||||
colliderRadius: 12,
|
||||
characterState: window.ATK_CHARACTER_STATE.Idle1[0],
|
||||
framesToRecover: 0,
|
||||
@@ -152,7 +152,7 @@ cc.Class({
|
||||
joinIndex: 2,
|
||||
virtualGridX: 80 * self.worldToVirtualGridRatio,
|
||||
virtualGridY: 40 * self.worldToVirtualGridRatio,
|
||||
speed: 2 * self.worldToVirtualGridRatio,
|
||||
speed: 1 * self.worldToVirtualGridRatio,
|
||||
colliderRadius: 12,
|
||||
characterState: window.ATK_CHARACTER_STATE.Idle1[0],
|
||||
framesToRecover: 0,
|
||||
|
Reference in New Issue
Block a user