Files
chocomae/src/game/result/result.js
T

91 lines
2.6 KiB
JavaScript

/////////////////////////////
// Result
class Result {
preload() {
game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png');
}
create() {
this.dbConnectManager = new DBConnectManager();
this.game.stage.backgroundColor = '#4d4d4d';
this.chartGraphics = game.add.graphics(100, game.world.height - 120);
// top
let backButton = new BackButton( () => {
location.href = '../../web/client/menu_app.html';
});
let fullscreenButton = new FullscreenButton(this.game);
// contents
this.printRecord();
this.uploadRecord();
this.makeStartButton();
let recordBoard = new RecordBoard();
// bottom
let screenBottom = new ScreenBottom();
screenBottom.makeBottomLine();
screenBottom.printBottomLeftText("게임 진행 정보");
screenBottom.printBottomCenterText(sessionStorageManager.playingAppKoreanName);
screenBottom.printBottomRightText(sessionStorageManager.playerName);
}
printRecord() {
const style = { font: "64px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" };
game.add.text(0, 0, "결과", style)
.setTextBounds(0, 0, game.world.width, 100)
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
let posY = 120;
if(sessionStorageManager.record === null)
sessionStorageManager.record = 0;
let record = NumberUtil.numberWithCommas(sessionStorageManager.record);
console.log(record);
style.font = "bold 80px Arial";
game.add.text(0, 0, record, style)
.setTextBounds(0, posY, game.world.width, 60)
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
if(sessionStorageManager.bestRecord === null)
sessionStorageManager.bestRecord = 0;
let bestRecord = NumberUtil.numberWithCommas(sessionStorageManager.bestRecord);
console.log(bestRecord);
style.font = "32px Arial";
let bestRecordText = game.add.text(0, 0, "오늘 최고 기록 : " + bestRecord, style)
.setTextBounds(0, posY + 80, game.world.width, 40);
// .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
bestRecordText.stroke = "#333";
bestRecordText.strokeThickness = 5;
}
uploadRecord() {
this.dbConnectManager.updateTodayBestRecord(
sessionStorageManager.maestroID,
sessionStorageManager.playerUserID,
sessionStorageManager.playingAppID,
sessionStorageManager.record
);
}
makeStartButton() {
let setting = new RoundRectButtonSetting(200, 100);
setting.fontStyle.fontWeight = "bold";
let startButton = new RoundRectButton(setting, RoundRectButton.NONE_ICON, "다시 시작", this.startStage);
startButton.move(game.world.centerX, game.world.height / 2 - 70);
}
startStage() {
location.href = "../../web/client/" + sessionStorageManager.playingAppName + ".html";
}
}