mirror of
https://github.com/genxium/DelayNoMore
synced 2024-12-26 11:48:56 +00:00
Fixed frontend countdown display.
This commit is contained in:
parent
70e552f5f0
commit
0324b584a5
@ -1338,6 +1338,7 @@ func (pR *Room) applyInputFrameDownsyncDynamicsOnSingleRenderFrame(delayedInputF
|
|||||||
thatPlayerInNextFrame := nextRenderFramePlayers[playerId]
|
thatPlayerInNextFrame := nextRenderFramePlayers[playerId]
|
||||||
if 0 < thatPlayerInNextFrame.FramesToRecover {
|
if 0 < thatPlayerInNextFrame.FramesToRecover {
|
||||||
// No need to process inputs for this player, but there might be bullet pushbacks on this player
|
// No need to process inputs for this player, but there might be bullet pushbacks on this player
|
||||||
|
// Also note that in this case we keep "CharacterState" of this player from last render frame
|
||||||
playerCollider.X += bulletPushbacks[joinIndex-1].X
|
playerCollider.X += bulletPushbacks[joinIndex-1].X
|
||||||
playerCollider.Y += bulletPushbacks[joinIndex-1].Y
|
playerCollider.Y += bulletPushbacks[joinIndex-1].Y
|
||||||
// Update in the collision system
|
// Update in the collision system
|
||||||
@ -1373,6 +1374,7 @@ func (pR *Room) applyInputFrameDownsyncDynamicsOnSingleRenderFrame(delayedInputF
|
|||||||
Logger.Debug(fmt.Sprintf("roomId=%v, playerId=%v triggered a falling-edge of btnA at currRenderFrame.id=%v, delayedInputFrame.id=%v", pR.Id, playerId, currRenderFrame.Id, delayedInputFrame.InputFrameId))
|
Logger.Debug(fmt.Sprintf("roomId=%v, playerId=%v triggered a falling-edge of btnA at currRenderFrame.id=%v, delayedInputFrame.id=%v", pR.Id, playerId, currRenderFrame.Id, delayedInputFrame.InputFrameId))
|
||||||
} else {
|
} else {
|
||||||
// No bullet trigger, process movement inputs
|
// No bullet trigger, process movement inputs
|
||||||
|
// Note that by now "0 == thatPlayerInNextFrame.FramesToRecover", we should change "CharacterState" to "WALKING" or "IDLE" depending on player inputs
|
||||||
if 0 != decodedInput.Dx || 0 != decodedInput.Dy {
|
if 0 != decodedInput.Dx || 0 != decodedInput.Dy {
|
||||||
thatPlayerInNextFrame.DirX = decodedInput.Dx
|
thatPlayerInNextFrame.DirX = decodedInput.Dx
|
||||||
thatPlayerInNextFrame.DirY = decodedInput.Dy
|
thatPlayerInNextFrame.DirY = decodedInput.Dy
|
||||||
|
@ -440,7 +440,7 @@
|
|||||||
"array": [
|
"array": [
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
210.7364624020594,
|
216.50635094610968,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
@ -54,12 +54,12 @@ cc.Class({
|
|||||||
let newCharacterState = rdfPlayer.characterState;
|
let newCharacterState = rdfPlayer.characterState;
|
||||||
let prevCharacterState = (null == prevRdfPlayer ? window.ATK_CHARACTER_STATE.Idle1[0] : prevRdfPlayer.characterState);
|
let prevCharacterState = (null == prevRdfPlayer ? window.ATK_CHARACTER_STATE.Idle1[0] : prevRdfPlayer.characterState);
|
||||||
if (newCharacterState != prevCharacterState) {
|
if (newCharacterState != prevCharacterState) {
|
||||||
// Anim is edge-triggered
|
|
||||||
const newAnimName = window.ATK_CHARACTER_STATE_ARR[newCharacterState][1];
|
const newAnimName = window.ATK_CHARACTER_STATE_ARR[newCharacterState][1];
|
||||||
if (newAnimName != this.animComp.animationName) {
|
// Anim is edge-triggered
|
||||||
this.animComp.playAnimation(newAnimName);
|
if (newAnimName == this.animComp.animationName) {
|
||||||
console.log(`JoinIndex=${rdfPlayer.joinIndex}, Resetting anim to ${newAnimName}, state changed: (${prevCharacterState}, prevRdfPlayer is null? ${null == prevRdfPlayer}) -> (${newCharacterState})`);
|
console.warn(`JoinIndex=${rdfPlayer.joinIndex}, possibly playing weird anim by resetting anim to ${newAnimName} while the playing anim is also ${this.animComp.animationName}, player rdf changed from: ${null == prevRdfPlayer ? null : JSON.stringify(prevRdfPlayer)}, to: ${JSON.stringify(rdfPlayer)}`);
|
||||||
}
|
}
|
||||||
|
this.animComp.playAnimation(newAnimName);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -632,7 +632,7 @@ cc.Class({
|
|||||||
self.musicEffectManagerScriptIns.playBGM();
|
self.musicEffectManagerScriptIns.playBGM();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.warn(`Anomaly when onRoomDownsyncFrame is called by rdf=${JSON.stringify(rdf)}`);
|
console.warn(`Anomaly when onRoomDownsyncFrame is called by rdf=${JSON.stringify(rdf)}, recentRenderCache=${self._stringifyRecentRenderCache(false)}, recentInputCache=${self._stringifyRecentInputCache(false)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// [WARNING] Leave all graphical updates in "update(dt)" by "applyRoomDownsyncFrameDynamics"
|
// [WARNING] Leave all graphical updates in "update(dt)" by "applyRoomDownsyncFrameDynamics"
|
||||||
@ -827,17 +827,17 @@ cc.Class({
|
|||||||
console.error("Error during Map.update", err);
|
console.error("Error during Map.update", err);
|
||||||
} finally {
|
} finally {
|
||||||
// Update countdown
|
// Update countdown
|
||||||
if (null != self.countdownNanos) {
|
self.countdownNanos = self.battleDurationNanos - self.renderFrameId * self.rollbackEstimatedDtNanos;
|
||||||
self.countdownNanos = self.battleDurationNanos - self.renderFrameId * self.rollbackEstimatedDtNanos;
|
if (self.countdownNanos <= 0) {
|
||||||
if (self.countdownNanos <= 0) {
|
self.onBattleStopped(self.playerRichInfoDict);
|
||||||
self.onBattleStopped(self.playerRichInfoDict);
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
const countdownSeconds = parseInt(self.countdownNanos / 1000000000);
|
const countdownSeconds = parseInt(self.countdownNanos / 1000000000);
|
||||||
if (isNaN(countdownSeconds)) {
|
if (isNaN(countdownSeconds)) {
|
||||||
console.warn(`countdownSeconds is NaN for countdownNanos == ${self.countdownNanos}.`);
|
console.warn(`countdownSeconds is NaN for countdownNanos == ${self.countdownNanos}.`);
|
||||||
}
|
}
|
||||||
|
if (null != self.countdownLabel) {
|
||||||
self.countdownLabel.string = countdownSeconds;
|
self.countdownLabel.string = countdownSeconds;
|
||||||
}
|
}
|
||||||
++self.renderFrameId; // [WARNING] It's important to increment the renderFrameId AFTER all the operations above!!!
|
++self.renderFrameId; // [WARNING] It's important to increment the renderFrameId AFTER all the operations above!!!
|
||||||
|
Loading…
Reference in New Issue
Block a user