Skip to content

Commit

Permalink
remove player if tower destroyed
Browse files Browse the repository at this point in the history
  • Loading branch information
keshav2010 committed Apr 9, 2024
1 parent a03daf3 commit c67e986
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 4 additions & 1 deletion gameserver/schema/SoldierState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,10 @@ export class SoldierState extends Schema implements ISceneItem, IBoidAgent {
enemyTowers
.map((d) => stateManager.getPlayer(d.id))
.forEach((playerBase) => {
if (playerBase) playerBase.spawnFlagHealth -= 0.5 * delta;
if (playerBase) {
const flagHealth = playerBase.spawnFlagHealth - 0.5 * delta;
playerBase.spawnFlagHealth = Math.max(0, flagHealth);
}
});
this.stateMachine.tick({ delta, stateManager, soldier: this });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,15 @@ export default {
);
if (!isAlreadyInScene) gameStateManager.addSceneItem(player);
});

sessionState.sessionState = "BATTLE_STATE";
}
var deltaTime = delta / 1000;
playersConnected.forEach((player) => {
player.tick(deltaTime, gameStateManager);
if (player.spawnFlagHealth === 0) {
sessionState.removePlayer(player.id, gameStateManager);
}
});
} catch (err) {
console.log(err);
Expand All @@ -113,5 +116,10 @@ export default {
delta: number;
sessionState: SessionState;
tick: Room;
}) => {},
}) => {
try {
} catch (error) {
console.log(error);
}
},
};

0 comments on commit c67e986

Please sign in to comment.