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

143 lines
4.7 KiB
JavaScript

/////////////////////////////
// Result
class Result {
preload() {
game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png');
Animal.loadResources();
}
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( () => {
if(isTypingPracticeStage())
location.href = '../../web/client/menu_typing_practice.html';
else if(isTypingTestStage())
location.href = '../../web/client/menu_typing_test.html';
else
location.href = '../../web/client/menu_app.html';
sessionStorageManager.resetPlayingAppData();
});
let fullscreenButton = new FullscreenButton(this.game);
// contents
this.printRecord();
this.uploadRecord();
this.makeRestartButton();
if(sessionStorageManager.maestroAccountType >= 100) { // experience account
let recordBoard = new RecordBoard(RecordBoard.TYPE_SAMPLE);
this.announceBox = new AnnounceBox(50, 648);
this.announceBox.drawBox("체험 계정에서는 기록이 저장되지 않습니다.");
} else {
let recordBoard = new RecordBoard(RecordBoard.TYPE_DB);
}
// bottom
let screenBottom = new ScreenBottom();
screenBottom.makeBottomLine();
screenBottom.printBottomLeftTextWithBestRecord(Math.floor(sessionStorageManager.bestRecord));
screenBottom.printBottomCenterText(sessionStorageManager.playingAppKoreanName);
screenBottom.printBottomRightText(sessionStorageManager.playerName);
}
printRecord() {
const style = { font: "bold 38px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" };
let titleText = game.add.text(game.world.width / 2, 35, "결과", style);
titleText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
titleText.anchor.set(0.5);
let x = game.world.width / 2;
let y = 150;
if(sessionStorageManager.record === null)
sessionStorageManager.record = 0;
let record = NumberUtil.numberWithCommas(Math.floor(sessionStorageManager.record));
style.font = "80px Arial";
if(sessionStorageManager.playingAppID < 100) {
let leftAnimal = new Animal(Animal.TYPE_ANIMATION, game.world.centerX - 200, 150);
let animalLevelID = leftAnimal.animalLevelIDByRecord(sessionStorageManager.record);
leftAnimal.setSpecies(Animal.SPECIES_DATA[animalLevelID]);;
// leftAnimal.tweenAnimation(Animal.ANIMATION_TYPE_CHANGE);
leftAnimal.startAnimation();
let rightAnimal = new Animal(Animal.TYPE_ANIMATION, game.world.centerX + 200, 150);
rightAnimal.setSpecies(Animal.SPECIES_DATA[animalLevelID]);;
// rightAnimal.tweenAnimation(Animal.ANIMATION_TYPE_CHANGE);
rightAnimal.startAnimation();
}
let scoreText = game.add.text(
x, y,
record + StringUtil.getScoreUnit(sessionStorageManager.playingAppID),
style
);
scoreText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
scoreText.anchor.set(0.5);
if(sessionStorageManager.isNewBestRecrd === true) {
style.font = "32px Arial";
let bestRecordText = game.add.text(game.world.width / 2, 110, "!!! 새로운 최고 기록 !!!", style);
// .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
bestRecordText.anchor.set(0.5);
bestRecordText.stroke = "#333";
bestRecordText.strokeThickness = 5;
}
/*
if(sessionStorageManager.bestRecord === null)
sessionStorageManager.bestRecord = 0;
let bestRecord = NumberUtil.numberWithCommas(sessionStorageManager.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() {
if(sessionStorageManager.maestroAccountType >= 100) { // experience account
return;
}
this.dbConnectManager.updateTodayBestRecord(
sessionStorageManager.maestroID,
sessionStorageManager.playerID,
sessionStorageManager.playingAppID,
sessionStorageManager.record
);
}
makeRestartButton() {
let setting = new RoundRectButtonSetting(game.world.centerX, game.world.height / 2 - 70, 200, 100);
setting.fontStyle.fontWeight = "bold";
let startButton = new RoundRectButton(setting, RoundRectButton.NONE_ICON, "다시 시작", this.restartStage);
}
restartStage() {
if(sessionStorageManager.playingAppName.indexOf("practice_") == 0) {
location.href = "../../web/client/typing_practice.html";
} else if(sessionStorageManager.playingAppName.indexOf("test_") == 0) {
location.href = "../../web/client/typing_test.html";
} else {
location.href = "../../web/client/" + sessionStorageManager.playingAppName + ".html";
}
}
}