Fix: result.js -> classify
This commit is contained in:
+167
-170
@@ -1,185 +1,182 @@
|
|||||||
var Result = {
|
Result.prototype = Object.create(Phaser.State.prototype);
|
||||||
|
Result.constructor = Result;
|
||||||
|
|
||||||
preload: function() {
|
function Result() {
|
||||||
game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png');
|
}
|
||||||
|
|
||||||
if(isTypingPracticeApp() || isTypingTestApp() || isTypingExamApp())
|
Result.prototype.preload = function() {
|
||||||
Animal.loadResources();
|
game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png');
|
||||||
|
|
||||||
RankingBoard.loadResources();
|
if(isTypingPracticeApp() || isTypingTestApp() || isTypingExamApp())
|
||||||
game.load.image('star', '../../../resources/image/ui/star_particle.png');
|
Animal.loadResources();
|
||||||
},
|
|
||||||
|
|
||||||
create: function() {
|
RankingBoard.loadResources();
|
||||||
this.dbConnectManager = new DBConnectManager();
|
game.load.image('star', '../../../resources/image/ui/star_particle.png');
|
||||||
|
}
|
||||||
|
|
||||||
this.game.stage.backgroundColor = '#4d4d4d';
|
Result.prototype.create = function() {
|
||||||
this.chartGraphics = game.add.graphics(100, game.world.height - 120);
|
this.dbConnectManager = new DBConnectManager();
|
||||||
|
|
||||||
// keyboard shortcut
|
this.game.stage.backgroundColor = '#4d4d4d';
|
||||||
this.keyboardShortcut = new KeyboardShortcut();
|
this.chartGraphics = game.add.graphics(100, game.world.height - 120);
|
||||||
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
|
// keyboard shortcut
|
||||||
var screenTopUI = new ScreenTopUI();
|
this.keyboardShortcut = new KeyboardShortcut();
|
||||||
screenTopUI.makeBackButton( (function() { this.back(); }).bind(this) );
|
this.keyboardShortcut.addCallback(
|
||||||
screenTopUI.makeFullScreenButton();
|
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();
|
||||||
|
|
||||||
|
var titleText = this.makeDefaultText(game.world.width / 2, 35);
|
||||||
|
titleText.text = "결과";
|
||||||
|
titleText.fontSize = 38;
|
||||||
|
titleText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||||
|
titleText.anchor.set(0.5);
|
||||||
|
|
||||||
|
|
||||||
// contents
|
// contents
|
||||||
this.printRecord();
|
this.printRecord();
|
||||||
|
|
||||||
this.makeRestartButton();
|
this.makeRestartButton();
|
||||||
|
|
||||||
|
|
||||||
if(sessionStorageManager.getMaestroAccountType() >= 100) { // experience account
|
if(sessionStorageManager.getMaestroAccountType() >= 100) { // experience account
|
||||||
var recordBoard = new RecordBoard(RecordBoard.TYPE_SAMPLE);
|
var recordBoard = new RecordBoard(RecordBoard.TYPE_SAMPLE);
|
||||||
this.announceBox = new AnnounceBox(50, 648);
|
this.announceBox = new AnnounceBox(50, 648);
|
||||||
this.announceBox.drawBox("체험 계정에서는 기록이 저장되지 않습니다.");
|
this.announceBox.drawBox("체험 계정에서는 기록이 저장되지 않습니다.");
|
||||||
} else {
|
} else {
|
||||||
this.printTodayBestRecord();
|
this.printTodayBestRecord();
|
||||||
var recordBoard = new RecordBoard(RecordBoard.TYPE_DB);
|
var recordBoard = new RecordBoard(RecordBoard.TYPE_DB);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// bottom ui
|
|
||||||
var screenBottomUI = new ScreenBottomUI();
|
|
||||||
screenBottomUI.printLeftTextWithAppHighestRecord(sessionStorageManager.getAppHighestRecord());
|
|
||||||
screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName());
|
|
||||||
screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
|
|
||||||
},
|
|
||||||
|
|
||||||
|
|
||||||
back: function() {
|
|
||||||
location.href = '../../web/client/main_menu.html';
|
|
||||||
|
|
||||||
/*
|
|
||||||
if(isTypingExamApp())
|
|
||||||
location.href = '../../web/client/menu_typing_exam.html';
|
|
||||||
else 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() {
|
|
||||||
var 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 = sessionStorageManager.getRecord();
|
|
||||||
style.font = "80px Arial";
|
|
||||||
var scoreText = game.add.text(
|
|
||||||
x, y,
|
|
||||||
"",
|
|
||||||
style
|
|
||||||
);
|
|
||||||
scoreText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
|
||||||
scoreText.anchor.set(0.5);
|
|
||||||
|
|
||||||
if(record < 0) {
|
|
||||||
scoreText.text = "제한 시간 초과!";
|
|
||||||
scoreText.style.fill = MainColor.INDIAN_RED_STRING;
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
scoreText.text = RecordUtil.getRecordValueWithUnit(record, sessionStorageManager.getPlayingAppID());
|
|
||||||
|
|
||||||
if(isTypingPracticeApp() || isTypingTestApp() || isTypingExamApp()) {
|
|
||||||
var animalLevelID = 0;
|
|
||||||
if(isTypingPracticeApp())
|
|
||||||
animalLevelID = Animal.animalLevelIDByRecord(sessionStorageManager.getRecord(), Animal.TYPE_PRACTICE);
|
|
||||||
else // Typing Test App
|
|
||||||
animalLevelID = Animal.animalLevelIDByRecord(sessionStorageManager.getRecord(), Animal.TYPE_TEST);
|
|
||||||
|
|
||||||
var leftAnimal = new Animal(Animal.TYPE_ANIMATION, animalLevelID, game.world.centerX - 200, 150);
|
|
||||||
leftAnimal.startAnimation(Animal.SPECIES_DATA[animalLevelID]);
|
|
||||||
|
|
||||||
var rightAnimal = new Animal(Animal.TYPE_ANIMATION, animalLevelID, game.world.centerX + 200, 150);
|
|
||||||
rightAnimal.startAnimation(Animal.SPECIES_DATA[animalLevelID]);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
printTodayBestRecord: function() {
|
|
||||||
// console.log(sessionStorageManager.getAppHighestRecord());
|
|
||||||
// console.log(sessionStorageManager.getRecord());
|
|
||||||
var appHighestRecord = sessionStorageManager.getAppHighestRecord();
|
|
||||||
var prevRecord = sessionStorageManager.getRecord();
|
|
||||||
if(appHighestRecord == 'undefined' || appHighestRecord == null) {
|
|
||||||
this.showHighestRecordEffect(prevRecord);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(this.isHighestRecordPreferApp()) {
|
|
||||||
if(prevRecord > appHighestRecord)
|
|
||||||
this.showHighestRecordEffect(prevRecord);
|
|
||||||
} else {
|
|
||||||
if(appHighestRecord == 0)
|
|
||||||
this.showHighestRecordEffect(prevRecord);
|
|
||||||
else if(prevRecord < appHighestRecord)
|
|
||||||
this.showHighestRecordEffect(prevRecord);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
showHighestRecordEffect: function(record) {
|
|
||||||
sessionStorageManager.setAppHighestRecord(record);
|
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
bestRecordText.text = "! : . 최고 기록 경신 . : !";
|
|
||||||
newRecordEmitter.start(true, 2000, null, 20);
|
|
||||||
},
|
|
||||||
|
|
||||||
isHighestRecordPreferApp: function() {
|
|
||||||
if(sessionStorageManager.getPlayingAppID() == 105)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
|
|
||||||
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";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// bottom ui
|
||||||
|
var screenBottomUI = new ScreenBottomUI();
|
||||||
|
screenBottomUI.printLeftTextWithAppHighestRecord(sessionStorageManager.getAppHighestRecord());
|
||||||
|
screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName());
|
||||||
|
screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Result.prototype.back = function() {
|
||||||
|
location.href = '../../web/client/main_menu.html';
|
||||||
|
}
|
||||||
|
|
||||||
|
Result.prototype.makeDefaultText = function(x, y) {
|
||||||
|
var defaultText = game.add.text(x, y, "");
|
||||||
|
defaultText.anchor.set(0, 0.5);
|
||||||
|
// defaultText.font = "Nanum Gothic Coding";
|
||||||
|
defaultText.fontSize = 26;
|
||||||
|
defaultText.fontWeight = "normal";
|
||||||
|
defaultText.style.fill = "white";
|
||||||
|
|
||||||
|
return defaultText;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result.prototype.printRecord = function() {
|
||||||
|
if(sessionStorageManager.getRecord() === null)
|
||||||
|
sessionStorageManager.setRecord(0);
|
||||||
|
var record = sessionStorageManager.getRecord();
|
||||||
|
|
||||||
|
var x = game.world.width / 2;
|
||||||
|
var y = 150;
|
||||||
|
|
||||||
|
var scoreText = this.makeDefaultText(x, y);
|
||||||
|
scoreText.text = "";
|
||||||
|
scoreText.fontSize = 80;
|
||||||
|
scoreText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||||
|
scoreText.anchor.set(0.5);
|
||||||
|
|
||||||
|
if(record < 0) {
|
||||||
|
scoreText.text = "제한 시간 초과!";
|
||||||
|
scoreText.style.fill = MainColor.INDIAN_RED_STRING;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
scoreText.text = RecordUtil.getRecordValueWithUnit(record, sessionStorageManager.getPlayingAppID());
|
||||||
|
|
||||||
|
if(isTypingPracticeApp() || isTypingTestApp() || isTypingExamApp()) {
|
||||||
|
var animalLevelID = 0;
|
||||||
|
if(isTypingPracticeApp())
|
||||||
|
animalLevelID = Animal.animalLevelIDByRecord(sessionStorageManager.getRecord(), Animal.TYPE_PRACTICE);
|
||||||
|
else // Typing Test App
|
||||||
|
animalLevelID = Animal.animalLevelIDByRecord(sessionStorageManager.getRecord(), Animal.TYPE_TEST);
|
||||||
|
|
||||||
|
var leftAnimal = new Animal(Animal.TYPE_ANIMATION, animalLevelID, game.world.centerX - 200, 150);
|
||||||
|
leftAnimal.startAnimation(Animal.SPECIES_DATA[animalLevelID]);
|
||||||
|
|
||||||
|
var rightAnimal = new Animal(Animal.TYPE_ANIMATION, animalLevelID, game.world.centerX + 200, 150);
|
||||||
|
rightAnimal.startAnimation(Animal.SPECIES_DATA[animalLevelID]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Result.prototype.printTodayBestRecord = function() {
|
||||||
|
// console.log(sessionStorageManager.getAppHighestRecord());
|
||||||
|
// console.log(sessionStorageManager.getRecord());
|
||||||
|
var appHighestRecord = sessionStorageManager.getAppHighestRecord();
|
||||||
|
var prevRecord = sessionStorageManager.getRecord();
|
||||||
|
if(appHighestRecord == 'undefined' || appHighestRecord == null) {
|
||||||
|
this.showHighestRecordEffect(prevRecord);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.isHighestRecordPreferApp()) {
|
||||||
|
if(prevRecord > appHighestRecord)
|
||||||
|
this.showHighestRecordEffect(prevRecord);
|
||||||
|
} else {
|
||||||
|
if(appHighestRecord == 0)
|
||||||
|
this.showHighestRecordEffect(prevRecord);
|
||||||
|
else if(prevRecord < appHighestRecord)
|
||||||
|
this.showHighestRecordEffect(prevRecord);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Result.prototype.showHighestRecordEffect = function(record) {
|
||||||
|
sessionStorageManager.setAppHighestRecord(record);
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
bestRecordText.text = "! : . 최고 기록 경신 . : !";
|
||||||
|
newRecordEmitter.start(true, 2000, null, 20);
|
||||||
|
}
|
||||||
|
|
||||||
|
Result.prototype.isHighestRecordPreferApp = function() {
|
||||||
|
if(sessionStorageManager.getPlayingAppID() == 105)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result.prototype.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");
|
||||||
|
}
|
||||||
|
|
||||||
|
Result.prototype.restartStage = function() {
|
||||||
|
location.href = "../../web/client/" + getGameAppName() + ".html";
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user