177 lines
5.8 KiB
JavaScript
177 lines
5.8 KiB
JavaScript
var Result = {
|
|
|
|
preload: function() {
|
|
game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png');
|
|
|
|
if(isTypingPracticeApp() || isTypingTestApp())
|
|
Animal.loadResources();
|
|
|
|
RankingBoard.loadResources();
|
|
game.load.image('star', '../../../resources/image/ui/star_particle.png');
|
|
},
|
|
|
|
create: function() {
|
|
this.dbConnectManager = new DBConnectManager();
|
|
|
|
this.game.stage.backgroundColor = '#4d4d4d';
|
|
this.chartGraphics = game.add.graphics(100, game.world.height - 120);
|
|
|
|
// keyboard shortcut
|
|
this.keyboardShortcut = new KeyboardShortcut();
|
|
this.keyboardShortcut.addCallback(
|
|
Phaser.KeyCode.ESC, // keyCode
|
|
null, // keyDownHandler
|
|
(function() { this.back(); }).bind(this), // keyUpHandler
|
|
"result" // callerClassName
|
|
);
|
|
this.keyboardShortcut.addCallback(
|
|
Phaser.KeyCode.ENTER, // keyCode
|
|
null, // keyDownHandler
|
|
(function() { this.restartStage(); }).bind(this), // keyUpHandler
|
|
"result" // callerClassName
|
|
);
|
|
|
|
// top ui
|
|
var screenTopUI = new ScreenTopUI();
|
|
screenTopUI.makeBackButton( (function() { this.back(); }).bind(this) );
|
|
screenTopUI.makeFullScreenButton();
|
|
|
|
|
|
// contents
|
|
this.printRecord();
|
|
this.uploadRecord();
|
|
|
|
this.makeRestartButton();
|
|
|
|
if(sessionStorageManager.getMaestroAccountType() >= 100) { // experience account
|
|
var recordBoard = new RecordBoard(RecordBoard.TYPE_SAMPLE);
|
|
this.announceBox = new AnnounceBox(50, 648);
|
|
this.announceBox.drawBox("체험 계정에서는 기록이 저장되지 않습니다.");
|
|
} else {
|
|
var recordBoard = new RecordBoard(RecordBoard.TYPE_DB);
|
|
this.printTodayBestRecord();
|
|
}
|
|
|
|
|
|
// bottom ui
|
|
var screenBottomUI = new ScreenBottomUI();
|
|
screenBottomUI.printLeftTextWithBestRecord(Math.floor(sessionStorageManager.getBestRecord()));
|
|
screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName());
|
|
screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
|
|
},
|
|
|
|
|
|
back: function() {
|
|
if(isTypingPracticeApp())
|
|
location.href = '../../web/client/menu_typing_practice.html';
|
|
else if(isTypingTestApp())
|
|
location.href = '../../web/client/menu_typing_test.html';
|
|
else
|
|
location.href = '../../web/client/menu_app.html';
|
|
|
|
sessionStorageManager.resetPlayingAppData();
|
|
},
|
|
|
|
printRecord: function() {
|
|
const style = { font: "bold 38px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" };
|
|
var 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);
|
|
|
|
|
|
var x = game.world.width / 2;
|
|
var y = 150;
|
|
if(sessionStorageManager.getRecord() === null)
|
|
sessionStorageManager.setRecord(0);
|
|
var record = NumberUtil.numberWithCommas(Math.floor(sessionStorageManager.getRecord()));
|
|
style.font = "80px Arial";
|
|
|
|
// if(sessionStorageManager.getPlayingAppID() < 100) {
|
|
if(isTypingPracticeApp() || isTypingTestApp()) {
|
|
var leftAnimal = new Animal(Animal.TYPE_ANIMATION, game.world.centerX - 200, 150);
|
|
var animalLevelID = 0;
|
|
// if(sessionStorageManager.getPlayingAppID() < 20)
|
|
if(isTypingPracticeApp())
|
|
animalLevelID = Animal.animalLevelIDByRecord(sessionStorageManager.getRecord(), Animal.TYPE_PRACTICE);
|
|
else
|
|
animalLevelID = Animal.animalLevelIDByRecord(sessionStorageManager.getRecord(), Animal.TYPE_TEST);
|
|
// leftAnimal.tweenAnimation(Animal.ANIMATION_TYPE_CHANGE);
|
|
leftAnimal.startAnimation(Animal.SPECIES_DATA[animalLevelID]);
|
|
|
|
var rightAnimal = new Animal(Animal.TYPE_ANIMATION, game.world.centerX + 200, 150);
|
|
// rightAnimal.tweenAnimation(Animal.ANIMATION_TYPE_CHANGE);
|
|
rightAnimal.startAnimation(Animal.SPECIES_DATA[animalLevelID]);
|
|
}
|
|
|
|
var scoreText = game.add.text(
|
|
x, y,
|
|
record + StringUtil.getScoreUnit(sessionStorageManager.getPlayingAppID()),
|
|
style
|
|
);
|
|
scoreText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
|
scoreText.anchor.set(0.5);
|
|
},
|
|
|
|
recordUnit: function() {
|
|
var recordUnit = "";
|
|
if(sessionStorageManager.getPlayingAppID() >= 100)
|
|
return "점";
|
|
else
|
|
return "타";
|
|
},
|
|
|
|
printTodayBestRecord: function() {
|
|
var newRecordEmitter = game.add.emitter(game.world.centerX, 140, 300);
|
|
newRecordEmitter.makeParticles('star');
|
|
newRecordEmitter.gravity = 300;
|
|
|
|
var style = { font: "32px Arial", fill: "#ff0", align: "left", boundsAlignH: "center", boundsAlignV: "middle" };
|
|
var bestRecordText = game.add.text(game.world.centerX, 220, "", style);
|
|
bestRecordText.anchor.set(0.5);
|
|
bestRecordText.stroke = "#333";
|
|
bestRecordText.strokeThickness = 5;
|
|
|
|
if(sessionStorageManager.getBestRecord() === 'undefined')
|
|
sessionStorageManager.setBestRecord(0);
|
|
|
|
var todayBestRecord = 0;
|
|
var flooredBestRecord = Math.floor(sessionStorageManager.getBestRecord());
|
|
var bestRecordWithCommas = NumberUtil.numberWithCommas(flooredBestRecord);
|
|
|
|
if(sessionStorageManager.getRecord() >= sessionStorageManager.getBestRecord()) {
|
|
sessionStorageManager.setBestRecord(sessionStorageManager.getRecord());
|
|
|
|
bestRecordText.text = "! : . 오늘 최고 기록 . : !";
|
|
newRecordEmitter.start(true, 2000, null, 20);
|
|
} else {
|
|
bestRecordText.text = "";
|
|
}
|
|
},
|
|
|
|
uploadRecord: function() {
|
|
if(sessionStorageManager.getMaestroAccountType() >= 100) { // experience account
|
|
return;
|
|
}
|
|
|
|
this.dbConnectManager.updateTodayBestRecord(
|
|
sessionStorageManager.getMaestroID(),
|
|
sessionStorageManager.getPlayerID(),
|
|
sessionStorageManager.getPlayingAppID(),
|
|
sessionStorageManager.getRecord()
|
|
);
|
|
},
|
|
|
|
makeRestartButton: function() {
|
|
var setting = new RoundRectButtonSetting(game.world.centerX, game.world.height / 2 - 70, 200, 100);
|
|
setting.fontStyle.fontWeight = "bold";
|
|
|
|
var startButton = new RoundRectButton(setting, RoundRectButton.NONE_ICON, "다시 시작", this.restartStage);
|
|
startButton.addShortcutText("Enter");
|
|
},
|
|
|
|
|
|
restartStage: function() {
|
|
location.href = "../../web/client/" + getGameAppName() + ".html";
|
|
}
|
|
|
|
} |