mirror of
https://github.com/genxium/DelayNoMore
synced 2025-10-09 16:46:38 +00:00
Simplified backend config loading.
This commit is contained in:
@@ -40,19 +40,15 @@ message PlayerDownsync {
|
||||
sharedprotos.Direction dir = 4;
|
||||
int32 speed = 5; // in terms of virtual grid units
|
||||
int32 battleState = 6;
|
||||
int32 lastMoveGmtMillis = 7;
|
||||
int32 joinIndex = 7;
|
||||
double colliderRadius = 8;
|
||||
bool removed = 9;
|
||||
int32 score = 10;
|
||||
bool removed = 11;
|
||||
int32 joinIndex = 12;
|
||||
}
|
||||
int32 lastMoveGmtMillis = 11;
|
||||
|
||||
message PlayerDownsyncMeta {
|
||||
int32 id = 1;
|
||||
string name = 2;
|
||||
string displayName = 3;
|
||||
string avatar = 4;
|
||||
int32 joinIndex = 5;
|
||||
double colliderRadius = 6;
|
||||
string name = 12;
|
||||
string displayName = 13;
|
||||
string avatar = 14;
|
||||
}
|
||||
|
||||
message InputFrameDecoded {
|
||||
@@ -80,7 +76,6 @@ message RoomDownsyncFrame {
|
||||
int32 id = 1;
|
||||
map<int32, PlayerDownsync> players = 2;
|
||||
int64 countdownNanos = 3;
|
||||
map<int32, PlayerDownsyncMeta> playerMetas = 4;
|
||||
}
|
||||
|
||||
message WsReq {
|
||||
|
@@ -440,7 +440,7 @@
|
||||
"array": [
|
||||
0,
|
||||
0,
|
||||
344.6705889248102,
|
||||
210.4441731196186,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
|
@@ -210,7 +210,7 @@ cc.Class({
|
||||
}
|
||||
}
|
||||
|
||||
// console.info(`inputFrameUpsyncBatch: ${JSON.stringify(inputFrameUpsyncBatch)}`);
|
||||
// console.info(`inputFrameUpsyncBatch: ${JSON.stringify(inputFrameUpsyncBatch)}`);
|
||||
const reqData = window.pb.protos.WsReq.encode({
|
||||
msgId: Date.now(),
|
||||
playerId: self.selfPlayerInfo.id,
|
||||
@@ -376,8 +376,7 @@ cc.Class({
|
||||
window.clearBoundRoomIdInBothVolatileAndPersistentStorage();
|
||||
window.initPersistentSessionClient(self.initAfterWSConnected, null /* Deliberately NOT passing in any `expectedRoomId`. -- YFLu */ );
|
||||
};
|
||||
resultPanelScriptIns.onCloseDelegate = () => {
|
||||
};
|
||||
resultPanelScriptIns.onCloseDelegate = () => {};
|
||||
|
||||
self.gameRuleNode = cc.instantiate(self.gameRulePrefab);
|
||||
self.gameRuleNode.width = self.canvasNode.width;
|
||||
@@ -608,15 +607,13 @@ cc.Class({
|
||||
}
|
||||
|
||||
const players = rdf.players;
|
||||
const playerMetas = rdf.playerMetas;
|
||||
self._initPlayerRichInfoDict(players, playerMetas);
|
||||
self._initPlayerRichInfoDict(players);
|
||||
|
||||
// Show the top status indicators for IN_BATTLE
|
||||
if (self.playersInfoNode) {
|
||||
const playersInfoScriptIns = self.playersInfoNode.getComponent("PlayersInfo");
|
||||
for (let i in playerMetas) {
|
||||
const playerMeta = playerMetas[i];
|
||||
playersInfoScriptIns.updateData(playerMeta);
|
||||
for (let i in players) {
|
||||
playersInfoScriptIns.updateData(players[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -716,7 +713,7 @@ cc.Class({
|
||||
self.showPopupInCanvas(self.findingPlayerNode);
|
||||
}
|
||||
let findingPlayerScriptIns = self.findingPlayerNode.getComponent("FindingPlayer");
|
||||
findingPlayerScriptIns.updatePlayersInfo(rdf.playerMetas);
|
||||
findingPlayerScriptIns.updatePlayersInfo(rdf.players);
|
||||
},
|
||||
|
||||
logBattleStats() {
|
||||
@@ -764,7 +761,9 @@ cc.Class({
|
||||
playerScriptIns.setSpecies("SoldierElf");
|
||||
} else if (2 == joinIndex) {
|
||||
playerScriptIns.setSpecies("SoldierFireGhost");
|
||||
playerScriptIns.animComp.node.scaleX = (-1.0);
|
||||
if (0 == playerRichInfo.dir.dx && 0 == playerRichInfo.dir.dy) {
|
||||
playerScriptIns.animComp.node.scaleX = (-1.0);
|
||||
}
|
||||
}
|
||||
|
||||
const wpos = self.virtualGridToWorldPos(vx, vy);
|
||||
@@ -937,29 +936,27 @@ cc.Class({
|
||||
if (null == self.findingPlayerNode.parent) return;
|
||||
self.findingPlayerNode.parent.removeChild(self.findingPlayerNode);
|
||||
if (null != rdf) {
|
||||
self._initPlayerRichInfoDict(rdf.players, rdf.playerMetas);
|
||||
self._initPlayerRichInfoDict(rdf.players);
|
||||
}
|
||||
},
|
||||
|
||||
onBattleReadyToStart(rdf) {
|
||||
const self = this;
|
||||
const players = rdf.players;
|
||||
const playerMetas = rdf.playerMetas;
|
||||
self._initPlayerRichInfoDict(players, playerMetas);
|
||||
self._initPlayerRichInfoDict(players);
|
||||
|
||||
// Show the top status indicators for IN_BATTLE
|
||||
if (self.playersInfoNode) {
|
||||
const playersInfoScriptIns = self.playersInfoNode.getComponent("PlayersInfo");
|
||||
for (let i in playerMetas) {
|
||||
const playerMeta = playerMetas[i];
|
||||
playersInfoScriptIns.updateData(playerMeta);
|
||||
for (let i in players) {
|
||||
playersInfoScriptIns.updateData(players[i]);
|
||||
}
|
||||
}
|
||||
console.log("Calling `onBattleReadyToStart` with:", playerMetas);
|
||||
console.log("Calling `onBattleReadyToStart` with:", players);
|
||||
if (self.findingPlayerNode) {
|
||||
const findingPlayerScriptIns = self.findingPlayerNode.getComponent("FindingPlayer");
|
||||
findingPlayerScriptIns.hideExitButton();
|
||||
findingPlayerScriptIns.updatePlayersInfo(playerMetas);
|
||||
findingPlayerScriptIns.updatePlayersInfo(players);
|
||||
}
|
||||
|
||||
// Delay to hide the "finding player" GUI, then show a countdown clock
|
||||
@@ -975,6 +972,7 @@ cc.Class({
|
||||
|
||||
applyRoomDownsyncFrameDynamics(rdf) {
|
||||
const self = this;
|
||||
const delayedInputFrameForPrevRenderFrame = self.getCachedInputFrameDownsyncWithPrediction(self._convertToInputFrameId(rdf.id - 1, self.inputDelayFrames));
|
||||
|
||||
self.playerRichInfoDict.forEach((playerRichInfo, playerId) => {
|
||||
const immediatePlayerInfo = rdf.players[playerId];
|
||||
@@ -985,7 +983,10 @@ cc.Class({
|
||||
playerRichInfo.node.setPosition(wpos[0], wpos[1]);
|
||||
playerRichInfo.virtualGridX = immediatePlayerInfo.virtualGridX;
|
||||
playerRichInfo.virtualGridY = immediatePlayerInfo.virtualGridY;
|
||||
playerRichInfo.scriptIns.scheduleNewDirection(immediatePlayerInfo.dir, false);
|
||||
if (null != delayedInputFrameForPrevRenderFrame) {
|
||||
const decodedInput = self.ctrl.decodeInput(delayedInputFrameForPrevRenderFrame.inputList[playerRichInfo.joinIndex - 1]);
|
||||
playerRichInfo.scriptIns.scheduleNewDirection(decodedInput, false);
|
||||
}
|
||||
playerRichInfo.scriptIns.updateSpeed(immediatePlayerInfo.speed);
|
||||
});
|
||||
},
|
||||
@@ -1053,9 +1054,11 @@ cc.Class({
|
||||
const newCpos = self.virtualGridToPlayerColliderPos(newVx, newVy, self.playerRichInfoArr[joinIndex - 1]);
|
||||
playerCollider.x = newCpos[0];
|
||||
playerCollider.y = newCpos[1];
|
||||
// Update directions and thus would eventually update moving animation accordingly
|
||||
nextRenderFramePlayers[playerId].dir.dx = decodedInput.dx;
|
||||
nextRenderFramePlayers[playerId].dir.dy = decodedInput.dy;
|
||||
if (0 != decodedInput.dx || 0 != decodedInput.dy) {
|
||||
// Update directions and thus would eventually update moving animation accordingly
|
||||
nextRenderFramePlayers[playerId].dir.dx = decodedInput.dx;
|
||||
nextRenderFramePlayers[playerId].dir.dy = decodedInput.dy;
|
||||
}
|
||||
}
|
||||
|
||||
collisionSys.update();
|
||||
@@ -1142,15 +1145,13 @@ cc.Class({
|
||||
return latestRdf;
|
||||
},
|
||||
|
||||
_initPlayerRichInfoDict(players, playerMetas) {
|
||||
_initPlayerRichInfoDict(players) {
|
||||
const self = this;
|
||||
for (let k in players) {
|
||||
const playerId = parseInt(k);
|
||||
if (self.playerRichInfoDict.has(playerId)) continue; // Skip already put keys
|
||||
const immediatePlayerInfo = players[playerId];
|
||||
const immediatePlayerMeta = playerMetas[playerId];
|
||||
self.playerRichInfoDict.set(playerId, immediatePlayerInfo);
|
||||
Object.assign(self.playerRichInfoDict.get(playerId), immediatePlayerMeta);
|
||||
|
||||
const nodeAndScriptIns = self.spawnPlayerNode(immediatePlayerInfo.joinIndex, immediatePlayerInfo.virtualGridX, immediatePlayerInfo.virtualGridY, self.playerRichInfoDict.get(playerId));
|
||||
|
||||
|
@@ -410,10 +410,10 @@ cc.Class({
|
||||
console.error("Unexpected encodedDirection = ", encodedDirection);
|
||||
}
|
||||
const btnALevel = ((encodedInput >> 4) & 1);
|
||||
return {
|
||||
return window.pb.protos.InputFrameDecoded.create({
|
||||
dx: mappedDirection[0],
|
||||
dy: mappedDirection[1],
|
||||
a: btnALevel,
|
||||
};
|
||||
btnALevel: btnALevel,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user