Add wave to daily run scoreboard
parent
babc32211f
commit
fc86f5c05a
|
@ -6,7 +6,8 @@ import * as Utils from "../utils";
|
||||||
interface RankingEntry {
|
interface RankingEntry {
|
||||||
rank: integer,
|
rank: integer,
|
||||||
username: string,
|
username: string,
|
||||||
score: integer
|
score: integer,
|
||||||
|
wave: integer
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DailyRunScoreboard extends Phaser.GameObjects.Container {
|
export class DailyRunScoreboard extends Phaser.GameObjects.Container {
|
||||||
|
@ -21,14 +22,14 @@ export class DailyRunScoreboard extends Phaser.GameObjects.Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
const titleWindow = addWindow(this.scene, 0, 0, 104, 16, false, false, null, null, WindowVariant.THIN);
|
const titleWindow = addWindow(this.scene, 0, 0, 114, 16, false, false, null, null, WindowVariant.THIN);
|
||||||
this.add(titleWindow);
|
this.add(titleWindow);
|
||||||
|
|
||||||
this.titleLabel = addTextObject(this.scene, titleWindow.displayWidth / 2, titleWindow.displayHeight / 2, 'Daily Rankings', TextStyle.WINDOW, { fontSize: '64px' });
|
this.titleLabel = addTextObject(this.scene, titleWindow.displayWidth / 2, titleWindow.displayHeight / 2, 'Daily Rankings', TextStyle.WINDOW, { fontSize: '64px' });
|
||||||
this.titleLabel.setOrigin(0.5, 0.5);
|
this.titleLabel.setOrigin(0.5, 0.5);
|
||||||
this.add(this.titleLabel);
|
this.add(this.titleLabel);
|
||||||
|
|
||||||
const window = addWindow(this.scene, 0, 15, 104, 115, false, false, null, null, WindowVariant.THIN);
|
const window = addWindow(this.scene, 0, 15, 114, 115, false, false, null, null, WindowVariant.THIN);
|
||||||
this.add(window);
|
this.add(window);
|
||||||
|
|
||||||
this.rankingsContainer = this.scene.add.container(6, 19);
|
this.rankingsContainer = this.scene.add.container(6, 19);
|
||||||
|
@ -44,7 +45,7 @@ export class DailyRunScoreboard extends Phaser.GameObjects.Container {
|
||||||
}
|
}
|
||||||
|
|
||||||
updateRankings(rankings: RankingEntry[]) {
|
updateRankings(rankings: RankingEntry[]) {
|
||||||
const getEntry = (rank: string, username: string, score: string) => {
|
const getEntry = (rank: string, username: string, score: string, wave: string) => {
|
||||||
const entryContainer = this.scene.add.container(0, 0);
|
const entryContainer = this.scene.add.container(0, 0);
|
||||||
|
|
||||||
const rankLabel = addTextObject(this.scene, 0, 0, rank, TextStyle.WINDOW, { fontSize: '54px' });
|
const rankLabel = addTextObject(this.scene, 0, 0, rank, TextStyle.WINDOW, { fontSize: '54px' });
|
||||||
|
@ -56,13 +57,16 @@ export class DailyRunScoreboard extends Phaser.GameObjects.Container {
|
||||||
const scoreLabel = addTextObject(this.scene, 68, 0, score, TextStyle.WINDOW, { fontSize: '54px' });
|
const scoreLabel = addTextObject(this.scene, 68, 0, score, TextStyle.WINDOW, { fontSize: '54px' });
|
||||||
entryContainer.add(scoreLabel);
|
entryContainer.add(scoreLabel);
|
||||||
|
|
||||||
|
const waveLabel = addTextObject(this.scene, 90, 0, wave, TextStyle.WINDOW, { fontSize: '54px' });
|
||||||
|
entryContainer.add(waveLabel);
|
||||||
|
|
||||||
return entryContainer;
|
return entryContainer;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.rankingsContainer.add(getEntry('#', 'Username', 'Score'));
|
this.rankingsContainer.add(getEntry('#', 'Username', 'Score', 'Wave'));
|
||||||
|
|
||||||
rankings.forEach((r: RankingEntry, i: integer) => {
|
rankings.forEach((r: RankingEntry, i: integer) => {
|
||||||
const entryContainer = getEntry(r.rank.toString(), r.username, r.score.toString());
|
const entryContainer = getEntry(r.rank.toString(), r.username, r.score.toString(), r.wave.toString());
|
||||||
entryContainer.setY(r.rank * 9);
|
entryContainer.setY(r.rank * 9);
|
||||||
this.rankingsContainer.add(entryContainer);
|
this.rankingsContainer.add(entryContainer);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue