From b41b86bbd322e9f8b70a94e3e5e48bd3448f30ce Mon Sep 17 00:00:00 2001 From: genxium Date: Thu, 15 Dec 2022 12:28:39 +0800 Subject: [PATCH] Fixes for bullet and anim offset. --- battle_srv/models/room.go | 28 +++++++------- collider_visualizer/worldColliderDisplay.go | 14 +++---- dnmshared/resolv_helper.go | 2 +- .../prefabs/ControlledCharacter.prefab | 8 ++-- frontend/assets/scenes/login.fire | 2 +- frontend/assets/scenes/offline_map_1.fire | 2 +- frontend/assets/scripts/AttackingCharacter.js | 21 +++++----- frontend/assets/scripts/Map.js | 38 +++++++++---------- frontend/assets/scripts/OfflineMap.js | 2 +- 9 files changed, 58 insertions(+), 59 deletions(-) diff --git a/battle_srv/models/room.go b/battle_srv/models/room.go index 1dc4db2..a3a44b9 100644 --- a/battle_srv/models/room.go +++ b/battle_srv/models/room.go @@ -791,7 +791,7 @@ func (pR *Room) OnDismissed() { pR.SnapIntoPlatformThreshold = float64(0.5) pR.JumpingInitVelY = int32(float64(7) * pR.WorldToVirtualGridRatio) pR.GravityX = 0 - pR.GravityY = -int32(float64(0.5)*pR.WorldToVirtualGridRatio) // makes all "playerCollider.Y" a multiple of 0.5 in all cases + pR.GravityY = -int32(float64(0.5) * pR.WorldToVirtualGridRatio) // makes all "playerCollider.Y" a multiple of 0.5 in all cases pR.ChooseStage() pR.EffectivePlayerCount = 0 @@ -1396,7 +1396,7 @@ func (pR *Room) applyInputFrameDownsyncDynamicsOnSingleRenderFrame(delayedInputF // Reset playerCollider position from the "virtual grid position" newVx, newVy := currPlayerDownsync.VirtualGridX+currPlayerDownsync.VelX, currPlayerDownsync.VirtualGridY+currPlayerDownsync.VelY - colliderWidth, colliderHeight := player.ColliderRadius*2, player.ColliderRadius*4 + colliderWidth, colliderHeight := player.ColliderRadius*2, player.ColliderRadius*4 playerCollider.X, playerCollider.Y = VirtualGridToPolygonColliderBLPos(newVx, newVy, colliderWidth*0.5, colliderHeight*0.5, pR.SnapIntoPlatformOverlap, pR.collisionSpaceOffsetX, pR.collisionSpaceOffsetY, pR.VirtualGridToWorldRatio) // Update in the collision system playerCollider.Update() @@ -1500,7 +1500,7 @@ func (pR *Room) applyInputFrameDownsyncDynamicsOnSingleRenderFrame(delayedInputF } if 1 == joinIndex && currPlayerDownsync.InAir && isBarrier && !landedOnGravityPushback { Logger.Warn(fmt.Sprintf("playerId=%d, joinIndex=%d inAir & pushed back by barrier & not landed at {renderFrame.id: %d, virtualX: %d, virtualY: %d, velX: %d, velY: %d} with effPushback={%.3f, %.3f}, playerColliderPos={%.3f, %.3f}, barrierPos={%.3f, %.3f}, overlapMag=%.4f, len(hardPushbackNorms)=%d", playerId, joinIndex, currRenderFrame.Id, currPlayerDownsync.VirtualGridX, currPlayerDownsync.VirtualGridY, currPlayerDownsync.VelX, currPlayerDownsync.VelY, effPushbacks[joinIndex-1].X, effPushbacks[joinIndex-1].Y, playerCollider.X-pR.collisionSpaceOffsetX, playerCollider.Y-pR.collisionSpaceOffsetY, bShape.X-pR.collisionSpaceOffsetX, bShape.Y-pR.collisionSpaceOffsetY, overlapResult.Overlap, len(hardPushbackNorms))) - } + } if 1 == joinIndex && currPlayerDownsync.InAir && isAnotherPlayer { Logger.Warn(fmt.Sprintf("playerId=%d, joinIndex=%d inAir & pushed back by another player at {renderFrame.id: %d, virtualX: %d, virtualY: %d, velX: %d, velY: %d} with effPushback={%.3f, %.3f}, landedOnGravityPushback=%v, fallStopping=%v, playerColliderPos={%.3f, %.3f}, anotherPlayerColliderPos={%.3f, %.3f}, overlapMag=%.4f, len(hardPushbackNorms)=%d", playerId, joinIndex, currRenderFrame.Id, currPlayerDownsync.VirtualGridX, currPlayerDownsync.VirtualGridY, currPlayerDownsync.VelX, currPlayerDownsync.VelY, effPushbacks[joinIndex-1].X, effPushbacks[joinIndex-1].Y, landedOnGravityPushback, fallStopping, playerCollider.X-pR.collisionSpaceOffsetX, playerCollider.Y-pR.collisionSpaceOffsetY, bShape.X-pR.collisionSpaceOffsetX, bShape.Y-pR.collisionSpaceOffsetY, overlapResult.Overlap, len(hardPushbackNorms))) } @@ -1602,19 +1602,19 @@ func (pR *Room) applyInputFrameDownsyncDynamicsOnSingleRenderFrame(delayedInputF playerShape := playerCollider.Shape.(*resolv.ConvexPolygon) // Update "virtual grid position" currPlayerDownsync, thatPlayerInNextFrame := currRenderFrame.Players[playerId], nextRenderFramePlayers[playerId] - colliderWidth, colliderHeight := player.ColliderRadius*2, player.ColliderRadius*4 + colliderWidth, colliderHeight := player.ColliderRadius*2, player.ColliderRadius*4 thatPlayerInNextFrame.VirtualGridX, thatPlayerInNextFrame.VirtualGridY = PolygonColliderBLToVirtualGridPos(playerCollider.X-effPushbacks[joinIndex-1].X, playerCollider.Y-effPushbacks[joinIndex-1].Y, colliderWidth*0.5, colliderHeight*0.5, pR.SnapIntoPlatformOverlap, pR.collisionSpaceOffsetX, pR.collisionSpaceOffsetY, pR.WorldToVirtualGridRatio) if 1 == thatPlayerInNextFrame.JoinIndex { - if thatPlayerInNextFrame.InAir && (0 != thatPlayerInNextFrame.VelY) { - Logger.Info(fmt.Sprintf("playerId=%d, joinIndex=%d inAir trajectory: {nextRenderFrame.id: %d, nextVirtualX: %d, nextVirtualY: %d, nextVelX: %d, nextVelY: %d}, with playerColliderPos={%.3f, %.3f}, effPushback={%.3f, %.3f}", playerId, joinIndex, currRenderFrame.Id+1, thatPlayerInNextFrame.VirtualGridX, thatPlayerInNextFrame.VirtualGridY, thatPlayerInNextFrame.VelX, thatPlayerInNextFrame.VelY, playerShape.X-pR.collisionSpaceOffsetX, playerShape.Y-pR.collisionSpaceOffsetY, effPushbacks[joinIndex-1].X, effPushbacks[joinIndex-1].Y)) - } - if currPlayerDownsync.InAir && !thatPlayerInNextFrame.InAir { - Logger.Warn(fmt.Sprintf("playerId=%d, joinIndex=%d fallStopping#2 at {nextRenderFrame.id: %d, nextVirtualX: %d, nextVirtualY: %d, nextVelX: %d, nextVelY: %d}, with playerColliderPos={%.3f, %.3f}, effPushback={%.3f, %.3f}", playerId, joinIndex, currRenderFrame.Id+1, thatPlayerInNextFrame.VirtualGridX, thatPlayerInNextFrame.VirtualGridY, thatPlayerInNextFrame.VelX, thatPlayerInNextFrame.VelY, playerShape.X-pR.collisionSpaceOffsetX, playerShape.Y-pR.collisionSpaceOffsetY, effPushbacks[joinIndex-1].X, effPushbacks[joinIndex-1].Y)) - } - if !currPlayerDownsync.InAir && thatPlayerInNextFrame.InAir { - Logger.Warn(fmt.Sprintf("playerId=%d, joinIndex=%d took off at {nextRenderFrame.id: %d, nextVirtualX: %d, nextVirtualY: %d, nextVelX: %d, nextVelY: %d}, with playerColliderPos={%.3f, %.3f}, effPushback={%.3f, %.3f}", playerId, joinIndex, currRenderFrame.Id+1, thatPlayerInNextFrame.VirtualGridX, thatPlayerInNextFrame.VirtualGridY, thatPlayerInNextFrame.VelX, thatPlayerInNextFrame.VelY, playerShape.X-pR.collisionSpaceOffsetX, playerShape.Y-pR.collisionSpaceOffsetY, effPushbacks[joinIndex-1].X, effPushbacks[joinIndex-1].Y)) - } + if thatPlayerInNextFrame.InAir && (0 != thatPlayerInNextFrame.VelY) { + // Logger.Info(fmt.Sprintf("playerId=%d, joinIndex=%d inAir trajectory: {nextRenderFrame.id: %d, nextVirtualX: %d, nextVirtualY: %d, nextVelX: %d, nextVelY: %d}, with playerColliderPos={%.3f, %.3f}, effPushback={%.3f, %.3f}", playerId, joinIndex, currRenderFrame.Id+1, thatPlayerInNextFrame.VirtualGridX, thatPlayerInNextFrame.VirtualGridY, thatPlayerInNextFrame.VelX, thatPlayerInNextFrame.VelY, playerShape.X-pR.collisionSpaceOffsetX, playerShape.Y-pR.collisionSpaceOffsetY, effPushbacks[joinIndex-1].X, effPushbacks[joinIndex-1].Y)) + } + if currPlayerDownsync.InAir && !thatPlayerInNextFrame.InAir { + Logger.Warn(fmt.Sprintf("playerId=%d, joinIndex=%d fallStopping#2 at {nextRenderFrame.id: %d, nextVirtualX: %d, nextVirtualY: %d, nextVelX: %d, nextVelY: %d}, with playerColliderPos={%.3f, %.3f}, effPushback={%.3f, %.3f}", playerId, joinIndex, currRenderFrame.Id+1, thatPlayerInNextFrame.VirtualGridX, thatPlayerInNextFrame.VirtualGridY, thatPlayerInNextFrame.VelX, thatPlayerInNextFrame.VelY, playerShape.X-pR.collisionSpaceOffsetX, playerShape.Y-pR.collisionSpaceOffsetY, effPushbacks[joinIndex-1].X, effPushbacks[joinIndex-1].Y)) + } + if !currPlayerDownsync.InAir && thatPlayerInNextFrame.InAir { + Logger.Warn(fmt.Sprintf("playerId=%d, joinIndex=%d took off at {nextRenderFrame.id: %d, nextVirtualX: %d, nextVirtualY: %d, nextVelX: %d, nextVelY: %d}, with playerColliderPos={%.3f, %.3f}, effPushback={%.3f, %.3f}", playerId, joinIndex, currRenderFrame.Id+1, thatPlayerInNextFrame.VirtualGridX, thatPlayerInNextFrame.VirtualGridY, thatPlayerInNextFrame.VelX, thatPlayerInNextFrame.VelY, playerShape.X-pR.collisionSpaceOffsetX, playerShape.Y-pR.collisionSpaceOffsetY, effPushbacks[joinIndex-1].X, effPushbacks[joinIndex-1].Y)) + } } } @@ -1649,7 +1649,7 @@ func (pR *Room) refreshColliders(spaceW, spaceH int32) { pR.Space = resolv.NewSpace(int(spaceW), int(spaceH), minStep, minStep) // allocate a new collision space everytime after a battle is settled for _, player := range pR.Players { wx, wy := VirtualGridToWorldPos(player.VirtualGridX, player.VirtualGridY, pR.VirtualGridToWorldRatio) - colliderWidth, colliderHeight := player.ColliderRadius*2, player.ColliderRadius*4 + colliderWidth, colliderHeight := player.ColliderRadius*2, player.ColliderRadius*4 playerCollider := GenerateRectCollider(wx, wy, colliderWidth, colliderHeight, pR.SnapIntoPlatformOverlap, pR.collisionSpaceOffsetX, pR.collisionSpaceOffsetY, "Player") // the coords of all barrier boundaries are multiples of tileWidth(i.e. 16), by adding snapping y-padding when "landedOnGravityPushback" all "playerCollider.Y" would be a multiple of 1.0 playerCollider.Data = player pR.Space.Add(playerCollider) diff --git a/collider_visualizer/worldColliderDisplay.go b/collider_visualizer/worldColliderDisplay.go index 537bd47..9e26844 100644 --- a/collider_visualizer/worldColliderDisplay.go +++ b/collider_visualizer/worldColliderDisplay.go @@ -35,15 +35,15 @@ func NewWorldColliderDisplay(game *Game, stageDiscreteW, stageDiscreteH, stageTi spaceOffsetY := float64(spaceH) * 0.5 worldToVirtualGridRatio := float64(1000) - virtualGridToWorldRatio := float64(1)/worldToVirtualGridRatio + virtualGridToWorldRatio := float64(1) / worldToVirtualGridRatio playerDefaultSpeed := 1 * worldToVirtualGridRatio minStep := (int(float64(playerDefaultSpeed)*virtualGridToWorldRatio) << 2) playerColliderRadius := float64(12) playerColliders := make([]*resolv.Object, len(playerPosList.Eles)) - snapIntoPlatformOverlap := float64(0.1) + snapIntoPlatformOverlap := float64(0.1) space := resolv.NewSpace(int(spaceW), int(spaceH), minStep, minStep) for i, playerPos := range playerPosList.Eles { - colliderWidth, colliderHeight := playerColliderRadius*2, playerColliderRadius*4 + colliderWidth, colliderHeight := playerColliderRadius*2, playerColliderRadius*4 playerCollider := GenerateRectCollider(playerPos.X, playerPos.Y, colliderWidth, colliderHeight, snapIntoPlatformOverlap, spaceOffsetX, spaceOffsetY, "Player") // [WARNING] Deliberately not using a circle because "resolv v0.5.1" doesn't yet align circle center with space cell center, regardless of the "specified within-object offset" Logger.Info(fmt.Sprintf("Player Collider#%d: player world pos=(%.2f, %.2f), shape=%v", i, playerPos.X, playerPos.Y, ConvexPolygonStr(playerCollider.Shape.(*resolv.ConvexPolygon)))) playerColliders[i] = playerCollider @@ -65,7 +65,7 @@ func NewWorldColliderDisplay(game *Game, stageDiscreteW, stageDiscreteH, stageTi effPushback := Vec2D{X: float64(0), Y: float64(0)} toTestPlayerCollider := playerColliders[0] newVx, newVy := int32(27999), int32(-420270) - colliderWidth, colliderHeight := playerColliderRadius*2, playerColliderRadius*4 + colliderWidth, colliderHeight := playerColliderRadius*2, playerColliderRadius*4 toTestPlayerCollider.X, toTestPlayerCollider.Y = VirtualGridToPolygonColliderTLPos(newVx, newVy, colliderWidth, colliderHeight, spaceOffsetX, spaceOffsetY, virtualGridToWorldRatio) Logger.Info(fmt.Sprintf("Checking collision for playerShape=%v", ConvexPolygonStr(toTestPlayerCollider.Shape.(*resolv.ConvexPolygon)))) @@ -75,7 +75,7 @@ func NewWorldColliderDisplay(game *Game, stageDiscreteW, stageDiscreteH, stageTi playerShape := toTestPlayerCollider.Shape.(*resolv.ConvexPolygon) for _, obj := range collision.Objects { bShape := obj.Shape.(*resolv.ConvexPolygon) - Logger.Warn(fmt.Sprintf("Checking potential: a=%v, b=%v", ConvexPolygonStr(playerShape), ConvexPolygonStr(bShape))) + Logger.Warn(fmt.Sprintf("Checking potential: a=%v, b=%v", ConvexPolygonStr(playerShape), ConvexPolygonStr(bShape))) if overlapped, pushbackX, pushbackY, overlapResult := CalcPushbacks(0, 0, playerShape, bShape); overlapped { Logger.Warn(fmt.Sprintf("Overlapped: a=%v, b=%v, pushbackX=%v, pushbackY=%v", ConvexPolygonStr(playerShape), ConvexPolygonStr(bShape), pushbackX, pushbackY)) effPushback.X += pushbackX @@ -114,7 +114,7 @@ func NewWorldColliderDisplay(game *Game, stageDiscreteW, stageDiscreteH, stageTi ReleaseTriggerType: int32(1), // 1: rising-edge, 2: falling-edge Damage: int32(5), } - bulletLeftToRight := false + bulletLeftToRight := true if bulletLeftToRight { xfac := float64(1.0) offenderWx, offenderWy := playerPosList.Eles[0].X, playerPosList.Eles[0].Y @@ -137,7 +137,7 @@ func NewWorldColliderDisplay(game *Game, stageDiscreteW, stageDiscreteH, stageTi } } - bulletRightToLeft := false + bulletRightToLeft := true if bulletRightToLeft { xfac := float64(-1.0) offenderWx, offenderWy := playerPosList.Eles[1].X, playerPosList.Eles[1].Y diff --git a/dnmshared/resolv_helper.go b/dnmshared/resolv_helper.go index 2f3ca76..bf53908 100644 --- a/dnmshared/resolv_helper.go +++ b/dnmshared/resolv_helper.go @@ -24,7 +24,7 @@ func GenerateRectCollider(wx, wy, w, h, bottomPadding, spaceOffsetX, spaceOffset } func generateRectColliderInCollisionSpace(blX, blY, w, h float64, tag string) *resolv.Object { - collider := resolv.NewObject(blX, blY, w, h, tag) // Unlike its frontend counter part, the position of a "resolv.Object" must be specified by "bottom-left point" because "w" and "h" must be positive, see "resolv.Object.BoundsToSpace" for details + collider := resolv.NewObject(blX, blY, w, h, tag) // Unlike its frontend counter part, the position of a "resolv.Object" must be specified by "bottom-left point" because "w" and "h" must be positive, see "resolv.Object.BoundsToSpace" for details shape := resolv.NewRectangle(0, 0, w, h) collider.SetShape(shape) return collider diff --git a/frontend/assets/resources/prefabs/ControlledCharacter.prefab b/frontend/assets/resources/prefabs/ControlledCharacter.prefab index de1bae9..78a69a8 100644 --- a/frontend/assets/resources/prefabs/ControlledCharacter.prefab +++ b/frontend/assets/resources/prefabs/ControlledCharacter.prefab @@ -97,7 +97,7 @@ "__id__": 1 }, "_children": [], - "_active": true, + "_active": false, "_components": [ { "__id__": 3 @@ -587,7 +587,7 @@ "ctor": "Float64Array", "array": [ 0, - -10, + -24, 0, 0, 0, @@ -702,7 +702,7 @@ "ctor": "Float64Array", "array": [ 0, - -10, + -24, 0, 0, 0, @@ -820,7 +820,7 @@ "ctor": "Float64Array", "array": [ 0, - -12, + 0, 0, 0, 0, diff --git a/frontend/assets/scenes/login.fire b/frontend/assets/scenes/login.fire index afb1111..f2acb21 100644 --- a/frontend/assets/scenes/login.fire +++ b/frontend/assets/scenes/login.fire @@ -440,7 +440,7 @@ "array": [ 0, 0, - 209.7905580006813, + 216.67520680312998, 0, 0, 0, diff --git a/frontend/assets/scenes/offline_map_1.fire b/frontend/assets/scenes/offline_map_1.fire index 0629f7a..354c327 100644 --- a/frontend/assets/scenes/offline_map_1.fire +++ b/frontend/assets/scenes/offline_map_1.fire @@ -454,7 +454,7 @@ "array": [ 0, 0, - 209.7905580006813, + 216.67520680312998, 0, 0, 0, diff --git a/frontend/assets/scripts/AttackingCharacter.js b/frontend/assets/scripts/AttackingCharacter.js index b7a44c5..0304d82 100644 --- a/frontend/assets/scripts/AttackingCharacter.js +++ b/frontend/assets/scripts/AttackingCharacter.js @@ -11,25 +11,25 @@ window.ATK_CHARACTER_STATE = { }; window.toInAirConjugate = function(foo) { - switch (foo) { + switch (foo) { case window.ATK_CHARACTER_STATE.Idle1[0]: case window.ATK_CHARACTER_STATE.Walking[0]: - return window.ATK_CHARACTER_STATE.InAirIdle1[0]; + return window.ATK_CHARACTER_STATE.InAirIdle1[0]; case window.ATK_CHARACTER_STATE.Atk1[0]: - return window.ATK_CHARACTER_STATE.InAirAtk1[0]; + return window.ATK_CHARACTER_STATE.InAirAtk1[0]; case window.ATK_CHARACTER_STATE.Atked1[0]: - return window.ATK_CHARACTER_STATE.InAirAtked1[0]; + return window.ATK_CHARACTER_STATE.InAirAtked1[0]; case window.ATK_CHARACTER_STATE.InAirIdle1[0]: - return window.ATK_CHARACTER_STATE.Idle1[0]; + return window.ATK_CHARACTER_STATE.Idle1[0]; case window.ATK_CHARACTER_STATE.InAirAtk1[0]: - return window.ATK_CHARACTER_STATE.Atk1[0]; + return window.ATK_CHARACTER_STATE.Atk1[0]; case window.ATK_CHARACTER_STATE.InAirAtked1[0]: - return window.ATK_CHARACTER_STATE.Atked1[0]; + return window.ATK_CHARACTER_STATE.Atked1[0]; default: - console.warn(`Invalid characterState ${foo} received, no in air conjugate is available!`); - return null; - } + console.warn(`Invalid characterState ${foo} received, no in air conjugate is available!`); + return null; + } } window.ATK_CHARACTER_STATE_ARR = []; @@ -81,7 +81,6 @@ cc.Class({ this.animComp = this.effAnimNode.getComponent(dragonBones.ArmatureDisplay); if (!this.animComp) { this.animComp = this.effAnimNode.getComponent(cc.Animation); - this.effAnimNode.anchorY = 0.0; // Otherwise the anim will show with an incorrect y-offset even if the collider boundaries are all correct! } this.effAnimNode.active = true; }, diff --git a/frontend/assets/scripts/Map.js b/frontend/assets/scripts/Map.js index 92c4285..956cc25 100644 --- a/frontend/assets/scripts/Map.js +++ b/frontend/assets/scripts/Map.js @@ -331,7 +331,7 @@ cc.Class({ window.mapIns = self; window.forceBigEndianFloatingNumDecoding = self.forceBigEndianFloatingNumDecoding; - self.showCriticalCoordinateLabels = true; + self.showCriticalCoordinateLabels = false; console.warn("+++++++ Map onLoad()"); window.handleClientSessionError = function() { @@ -456,8 +456,8 @@ cc.Class({ const refBoundaryObjs = tileCollisionManager.extractBoundaryObjects(self.node).barriers; const boundaryObjs = parsedBattleColliderInfo.strToPolygon2DListMap; for (let k = 0; k < boundaryObjs["Barrier"].eles.length; k++) { - let boundaryObj = boundaryObjs["Barrier"].eles[k]; - const refBoundaryObj = refBoundaryObjs[k]; + let boundaryObj = boundaryObjs["Barrier"].eles[k]; + const refBoundaryObj = refBoundaryObjs[k]; // boundaryObj = refBoundaryObj; const [x0, y0] = [boundaryObj.anchor.x, boundaryObj.anchor.y]; const newBarrierCollider = self.collisionSys.createPolygon(x0, y0, Array.from(boundaryObj.points, p => { @@ -778,7 +778,7 @@ cc.Class({ if (1 == joinIndex) { playerScriptIns.setSpecies("SoldierWaterGhost"); } else if (2 == joinIndex) { - playerScriptIns.setSpecies("SoldierFireGhost"); + playerScriptIns.setSpecies("SoldierFireGhostFrameAnim"); } const [wx, wy] = self.virtualGridToWorldPos(vx, vy); @@ -786,8 +786,8 @@ cc.Class({ playerScriptIns.mapNode = self.node; const colliderWidth = playerDownsyncInfo.colliderRadius * 2, colliderHeight = playerDownsyncInfo.colliderRadius * 4; - const cpos = self.virtualGridToPolygonColliderTLPos(vx, vy, colliderWidth*0.5, colliderHeight*0.5); // the top-left corner is kept having integer coords - const pts = [[0, 0], [colliderWidth, 0], [colliderWidth, -colliderHeight-self.snapIntoPlatformOverlap], [0, -colliderHeight-self.snapIntoPlatformOverlap]]; + const cpos = self.virtualGridToPolygonColliderTLPos(vx, vy, colliderWidth * 0.5, colliderHeight * 0.5); // the top-left corner is kept having integer coords + const pts = [[0, 0], [colliderWidth, 0], [colliderWidth, -colliderHeight - self.snapIntoPlatformOverlap], [0, -colliderHeight - self.snapIntoPlatformOverlap]]; // [WARNING] The animNode "anchor & offset" are tuned to fit in this collider by "ControlledCharacter prefab & AttackingCharacter.js"! const newPlayerCollider = self.collisionSys.createPolygon(cpos[0], cpos[1], pts); @@ -1047,15 +1047,15 @@ cc.Class({ } const [offenderWx, offenderWy] = self.virtualGridToWorldPos(offender.virtualGridX, offender.virtualGridY); const bulletWx = offenderWx + xfac * meleeBullet.hitboxOffset; - const bulletWy = offenderWy + 0.5 * meleeBullet.hitboxSize.y; - const [bulletCx, bulletCy] = self.worldToPolygonColliderTLPos(bulletWx, bulletWy, meleeBullet.hitboxSize.x * 0.5, meleeBullet.hitboxSize.y * 0.5); + const bulletWy = offenderWy; + const bulletCpos = self.worldToPolygonColliderTLPos(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]]; - g.moveTo(bulletCx, bulletCy); + g.moveTo(bulletCpos[0], bulletCpos[1]); for (let j = 0; j < pts.length; j += 1) { - g.lineTo(pts[j][0] + bulletCx, pts[j][1] + bulletCy); + g.lineTo(pts[j][0] + bulletCpos[0], pts[j][1] + bulletCpos[1]); } - g.lineTo(bulletCx, bulletCy); + g.lineTo(bulletCpos[0], bulletCpos[1]); g.stroke(); } } @@ -1118,7 +1118,7 @@ cc.Class({ const joinIndex = parseInt(j) + 1; const playerRichInfo = self.playerRichInfoArr[j]; const playerId = playerRichInfo.id; - const currPlayerDownsync = currRenderFrame.players[playerId]; + const currPlayerDownsync = currRenderFrame.players[playerId]; const thatPlayerInNextFrame = nextRenderFramePlayers[playerId]; if (0 < thatPlayerInNextFrame.framesToRecover) { // No need to process inputs for this player, but there might be bullet pushbacks on this player @@ -1191,9 +1191,9 @@ cc.Class({ const [newVx, newVy] = [currPlayerDownsync.virtualGridX + currPlayerDownsync.velX, currPlayerDownsync.virtualGridY + currPlayerDownsync.velY]; const colliderWidth = self.playerRichInfoArr[joinIndex - 1].colliderRadius * 2, colliderHeight = self.playerRichInfoArr[joinIndex - 1].colliderRadius * 4; - const newCpos = self.virtualGridToPolygonColliderTLPos(newVx, newVy, colliderWidth*0.5, colliderHeight*0.5); + const newCpos = self.virtualGridToPolygonColliderTLPos(newVx, newVy, colliderWidth * 0.5, colliderHeight * 0.5); playerCollider.x = newCpos[0]; - playerCollider.y = newCpos[1]; + playerCollider.y = newCpos[1]; if (currPlayerDownsync.inAir) { thatPlayerInNextFrame.velX += self.gravityX; @@ -1222,10 +1222,10 @@ cc.Class({ } const [offenderWx, offenderWy] = self.virtualGridToWorldPos(offender.virtualGridX, offender.virtualGridY); const bulletWx = offenderWx + xfac * meleeBullet.hitboxOffset; - const bulletWy = offenderWy + 0.5 * meleeBullet.hitboxSize.y; - const [bulletCx, bulletCy] = self.worldToPolygonColliderTLPos(bulletWx, bulletWy, meleeBullet.hitboxSize.x * 0.5, meleeBullet.hitboxSize.y * 0.5), + const bulletWy = offenderWy; + const bulletCpos = self.worldToPolygonColliderTLPos(bulletWx, bulletWy, meleeBullet.hitboxSize.x * 0.5, meleeBullet.hitboxSize.y * 0.5), pts = [[0, 0], [meleeBullet.hitboxSize.x, 0], [meleeBullet.hitboxSize.x, -meleeBullet.hitboxSize.y], [0, -meleeBullet.hitboxSize.y]]; - const newBulletCollider = collisionSys.createPolygon(bulletCx, bulletCy, pts); + const newBulletCollider = collisionSys.createPolygon(bulletCpos[0], bulletCpos[1], pts); newBulletCollider.data = meleeBullet; collisionSysMap.set(collisionBulletIndex, newBulletCollider); bulletColliders.set(collisionBulletIndex, newBulletCollider); @@ -1380,13 +1380,13 @@ cc.Class({ const thatPlayerInNextFrame = nextRenderFramePlayers[playerId]; const colliderWidth = self.playerRichInfoArr[joinIndex - 1].colliderRadius * 2, colliderHeight = self.playerRichInfoArr[joinIndex - 1].colliderRadius * 4; - const newVpos = self.polygonColliderTLToVirtualGridPos(playerCollider.x - effPushbacks[joinIndex - 1][0], playerCollider.y - effPushbacks[joinIndex - 1][1], colliderWidth*0.5, colliderHeight*0.5); + const newVpos = self.polygonColliderTLToVirtualGridPos(playerCollider.x - effPushbacks[joinIndex - 1][0], playerCollider.y - effPushbacks[joinIndex - 1][1], colliderWidth * 0.5, colliderHeight * 0.5); thatPlayerInNextFrame.virtualGridX = newVpos[0]; thatPlayerInNextFrame.virtualGridY = newVpos[1]; if (1 == thatPlayerInNextFrame.joinIndex) { if (thatPlayerInNextFrame.inAir && 0 != thatPlayerInNextFrame.velY) { - console.log(`playerId=${playerId}, joinIndex=${thatPlayerInNextFrame.joinIndex} inAir trajectory: {nextRenderFrame.id: ${currRenderFrame.id + 1}, nextVirtualX: ${thatPlayerInNextFrame.virtualGridX}, nextVirtualY: ${thatPlayerInNextFrame.virtualGridY}, nextVelX: ${thatPlayerInNextFrame.velX}, nextVelY: ${thatPlayerInNextFrame.velY}}, with playerColliderPos={${playerCollider.x.toFixed(3)}, ${playerCollider.y.toFixed(3)}}, effPushback={${effPushbacks[joinIndex - 1][0].toFixed(3)}, ${effPushbacks[joinIndex - 1][1].toFixed(3)}}`); + // console.log(`playerId=${playerId}, joinIndex=${thatPlayerInNextFrame.joinIndex} inAir trajectory: {nextRenderFrame.id: ${currRenderFrame.id + 1}, nextVirtualX: ${thatPlayerInNextFrame.virtualGridX}, nextVirtualY: ${thatPlayerInNextFrame.virtualGridY}, nextVelX: ${thatPlayerInNextFrame.velX}, nextVelY: ${thatPlayerInNextFrame.velY}}, with playerColliderPos={${playerCollider.x.toFixed(3)}, ${playerCollider.y.toFixed(3)}}, effPushback={${effPushbacks[joinIndex - 1][0].toFixed(3)}, ${effPushbacks[joinIndex - 1][1].toFixed(3)}}`); } if (currPlayerDownsync.inAir && !thatPlayerInNextFrame.inAir) { console.warn(`playerId=${playerId}, joinIndex=${thatPlayerInNextFrame.joinIndex} fallStopping#2 at {nextRenderFrame.id: ${currRenderFrame.id + 1}, nextVirtualX: ${thatPlayerInNextFrame.virtualGridX}, nextVirtualY: ${thatPlayerInNextFrame.virtualGridY}, nextVelX: ${thatPlayerInNextFrame.velX}, nextVelY: ${thatPlayerInNextFrame.velY}}, with playerColliderPos={${playerCollider.x.toFixed(3)}, ${playerCollider.y.toFixed(3)}}, effPushback={${effPushbacks[joinIndex - 1][0].toFixed(3)}, ${effPushbacks[joinIndex - 1][1].toFixed(3)}}`); diff --git a/frontend/assets/scripts/OfflineMap.js b/frontend/assets/scripts/OfflineMap.js index 61faa59..9b417b4 100644 --- a/frontend/assets/scripts/OfflineMap.js +++ b/frontend/assets/scripts/OfflineMap.js @@ -196,7 +196,7 @@ cc.Class({ } }); self.selfPlayerInfo = { - id: 10 + id: 11 }; self._initPlayerRichInfoDict(startRdf.players); self.onRoomDownsyncFrame(startRdf);