Fix: TypingExamination classify
This commit is contained in:
@@ -1,6 +1,33 @@
|
||||
var TypingExamination = {
|
||||
TypingExamination.prototype = Object.create(Phaser.State.prototype);
|
||||
TypingExamination.constructor = TypingExamination;
|
||||
|
||||
create: function() {
|
||||
|
||||
TypingExamination.GAME_TIME_SEC = 60 * 5; // 5 minutes
|
||||
|
||||
TypingExamination.SPACE_INDICATOR = "ˇ"; // "ᵔ"; // "ᵕ"; // "ˣ"; // "ᵛ"; // " · ";
|
||||
|
||||
TypingExamination.TYPING_CONTENT_PREVIEW_COUNT = 4; // 3;
|
||||
TypingExamination.TYPING_CONTENT_DONE_COUNT = 4; // 3;
|
||||
TypingExamination.TYPING_COUNT_PLUS_ENTER = 1;
|
||||
|
||||
TypingExamination.OFFSET_RIGHT_ALIGN = 10;
|
||||
|
||||
TypingExamination.WORD_COUNT_FOR_STAGE = 10;
|
||||
|
||||
TypingExamination.COLOR_CONTENT_INPUT = "#dddddd";
|
||||
TypingExamination.COLOR_CONTENT_RIGHT = "#ffff4d";
|
||||
|
||||
TypingExamination.STAGE_BACKGROUND_COLOR = "#4d4d4d";
|
||||
TypingExamination.INPUT_CONTENT_BACKGROUND_COLOR = "#333333";
|
||||
TypingExamination.STAGE_BACKGROUND_COLOR_HEX = 0x4d4d4d;
|
||||
TypingExamination.INPUT_CONTENT_BACKGROUND_COLOR_HEX = 0x333333;
|
||||
|
||||
|
||||
|
||||
function TypingExamination() {
|
||||
}
|
||||
|
||||
TypingExamination.prototype.create = function() {
|
||||
// for developing
|
||||
// sessionStorageManager.setMaestroName("삼화초");
|
||||
// sessionStorageManager.setMaestroID(3);
|
||||
@@ -20,8 +47,6 @@ var TypingExamination = {
|
||||
|
||||
sessionStorageManager.setRecord(0);
|
||||
|
||||
var self = this;
|
||||
|
||||
this.initTypingData();
|
||||
sessionStorageManager.setIsNewAppHighestRecord(false);
|
||||
|
||||
@@ -233,10 +258,10 @@ var TypingExamination = {
|
||||
|
||||
this.loadExaminationContent();
|
||||
// this.countDown();
|
||||
},
|
||||
}
|
||||
|
||||
/*
|
||||
countDown() {
|
||||
/*
|
||||
countDown() {
|
||||
var style = { font: "bold 200px Arial", fill: "#fff", boundsAlignH: "center", boundsAlignV: "middle" };
|
||||
this.countDownText = game.add.text(0, 0, "", style);
|
||||
this.countDownText.setTextBounds(0, 0, game.world.width, game.world.height);
|
||||
@@ -247,9 +272,9 @@ var TypingExamination = {
|
||||
if(isDebugMode())
|
||||
this.countDownNumber = 1;
|
||||
this.tweenCountDown();
|
||||
}
|
||||
}
|
||||
|
||||
tweenCountDown() {
|
||||
tweenCountDown() {
|
||||
if(this.countDownNumber === 0) {
|
||||
this.startGame();
|
||||
return;
|
||||
@@ -263,34 +288,34 @@ var TypingExamination = {
|
||||
countDownTween.onComplete.add(this.tweenCountDown, this);
|
||||
|
||||
this.countDownNumber--;
|
||||
}
|
||||
*/
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
back: function() {
|
||||
TypingExamination.prototype.back = function() {
|
||||
sessionStorageManager.resetPlayingAppData();
|
||||
// location.href = '../../web/client/menu_typing_exam.html';
|
||||
location.href = '../../web/client/main_menu.html';
|
||||
},
|
||||
}
|
||||
|
||||
startGame: function() {
|
||||
TypingExamination.prototype.startGame = function() {
|
||||
this.averageTypingSpeedText.print(0);
|
||||
|
||||
this.showTypingExaminationContents();
|
||||
this.showPlayingWordNumber();
|
||||
},
|
||||
}
|
||||
|
||||
timeOver: function() {
|
||||
TypingExamination.prototype.timeOver = function() {
|
||||
var timeOverText = new TimeOverText();
|
||||
// this.stopAndGoResult();
|
||||
},
|
||||
}
|
||||
|
||||
gameOver: function() {
|
||||
TypingExamination.prototype.gameOver = function() {
|
||||
var missionClearText = new MissionClearText();
|
||||
this.stopAndGoResult();
|
||||
},
|
||||
}
|
||||
|
||||
stopAndGoResult: function() {
|
||||
TypingExamination.prototype.stopAndGoResult = function() {
|
||||
this.animalList.stopAnimation();
|
||||
|
||||
sessionStorageManager.setRecord(this.typingRecordTotal);
|
||||
@@ -298,9 +323,9 @@ var TypingExamination = {
|
||||
this.updateResultRecord();
|
||||
|
||||
game.time.events.add(Phaser.Timer.SECOND * 2, this.goResult, this);
|
||||
},
|
||||
}
|
||||
|
||||
updateResultRecord: function() {
|
||||
TypingExamination.prototype.updateResultRecord = function() {
|
||||
if(sessionStorageManager.getMaestroAccountType() < 100) { // experience account
|
||||
this.dbService.updateTypingExamRecord(
|
||||
sessionStorageManager.getWritingID(),
|
||||
@@ -313,14 +338,14 @@ var TypingExamination = {
|
||||
}).bind(this)
|
||||
);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
goResult: function() {
|
||||
TypingExamination.prototype.goResult = function() {
|
||||
location.href = '../../web/client/result.html';
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
initTypingData: function() {
|
||||
TypingExamination.prototype.initTypingData = function() {
|
||||
this.typingIndex = 0;
|
||||
|
||||
|
||||
@@ -331,10 +356,10 @@ var TypingExamination = {
|
||||
|
||||
this.typingLetterCountTotal = 0;
|
||||
this.typingRecordTotal = 0;
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
loadExaminationContent: function() {
|
||||
TypingExamination.prototype.loadExaminationContent = function() {
|
||||
this.dbService.requestWritingInfo(
|
||||
sessionStorageManager.getWritingID(),
|
||||
(function(jsonData) { // onSucceeded
|
||||
@@ -344,12 +369,12 @@ var TypingExamination = {
|
||||
this.downloadListFailed(jsonData);
|
||||
}).bind(this)
|
||||
);
|
||||
},
|
||||
}
|
||||
|
||||
downloadListSucceeded: function(jsonData) {
|
||||
console.log(jsonData);
|
||||
TypingExamination.prototype.downloadListSucceeded = function(jsonData) {
|
||||
// console.log(jsonData);
|
||||
var writingInfo = jsonData["writingInfo"];
|
||||
console.log(writingInfo);
|
||||
// console.log(writingInfo);
|
||||
|
||||
var writer = writingInfo["writer"];
|
||||
var writerID = "";
|
||||
@@ -367,13 +392,13 @@ var TypingExamination = {
|
||||
game.load.onLoadComplete.add(this.completeLoadingWriting, this);
|
||||
game.load.text("writing", url);
|
||||
game.load.start();
|
||||
},
|
||||
}
|
||||
|
||||
downloadListFailed: function(jsonData) {
|
||||
TypingExamination.prototype.downloadListFailed = function(jsonData) {
|
||||
console.log(jsonData);
|
||||
},
|
||||
}
|
||||
|
||||
completeLoadingWriting: function() {
|
||||
TypingExamination.prototype.completeLoadingWriting = function() {
|
||||
game.load.onFileComplete.remove(this.loadExaminationContent, this);
|
||||
game.load.onLoadComplete.remove(this.completeLoadingWriting, this);
|
||||
|
||||
@@ -403,18 +428,18 @@ var TypingExamination = {
|
||||
}
|
||||
|
||||
this.startGame();
|
||||
},
|
||||
}
|
||||
|
||||
setTypingContentText: function(text) {
|
||||
TypingExamination.prototype.setTypingContentText = function(text) {
|
||||
this.textTypingContent.text = text;
|
||||
this.textTypedContentBack.text = text;
|
||||
},
|
||||
}
|
||||
|
||||
setTypingContentBackText: function(text) {
|
||||
TypingExamination.prototype.setTypingContentBackText = function(text) {
|
||||
this.textTypingContentBack.text = text;
|
||||
},
|
||||
}
|
||||
|
||||
showTypingExaminationContents: function() {
|
||||
TypingExamination.prototype.showTypingExaminationContents = function() {
|
||||
for(var i = 0; i < TypingExamination.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||
var doneIndex = this.typingIndex - i - 1;
|
||||
if(doneIndex < 0) {
|
||||
@@ -443,18 +468,18 @@ var TypingExamination = {
|
||||
} else
|
||||
this.textTypingContentPreview[i].text = "";
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
resetTypingContent: function() {
|
||||
TypingExamination.prototype.resetTypingContent = function() {
|
||||
this.textTypingContent.clearColors();
|
||||
this.textTypingContent.addColor(TypingExamination.COLOR_CONTENT_INPUT, 0);
|
||||
|
||||
this.setTypingContentBackText("");
|
||||
|
||||
this.inputTextContent.canvasInput.value('');
|
||||
},
|
||||
}
|
||||
|
||||
checkTypingContents: function(event) {
|
||||
TypingExamination.prototype.checkTypingContents = function(event) {
|
||||
if(this.isGameOver)
|
||||
return;
|
||||
|
||||
@@ -493,9 +518,9 @@ var TypingExamination = {
|
||||
}
|
||||
|
||||
this.showTypingContentHighlight(inputContent, typingContent);
|
||||
},
|
||||
}
|
||||
|
||||
showTypingContentHighlight: function(inputContent, typingContent) {
|
||||
TypingExamination.prototype.showTypingContentHighlight = function(inputContent, typingContent) {
|
||||
// console.log(inputContent + "=");
|
||||
// console.log(typingContent + "=");
|
||||
|
||||
@@ -527,9 +552,9 @@ var TypingExamination = {
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
calculateTypingRecord: function(typingContent) {
|
||||
TypingExamination.prototype.calculateTypingRecord = function(typingContent) {
|
||||
// console.log('입력 단어 : ' + this.typingExaminationContents[this.typingIndex]);
|
||||
|
||||
this.isTyping = false;
|
||||
@@ -572,21 +597,21 @@ var TypingExamination = {
|
||||
var animalLevelID = Animal.animalLevelIDByRecord(typingRecordTotalInteger, Animal.TYPE_TEST);
|
||||
this.animalList.activate(animalLevelID);
|
||||
this.animalList.tweenAnimation(Animal.ANIMATION_TYPE_CHANGE);
|
||||
},
|
||||
}
|
||||
|
||||
playNextContent: function() {
|
||||
TypingExamination.prototype.playNextContent = function() {
|
||||
this.typingIndex++;
|
||||
this.showTypingExaminationContents();
|
||||
this.showPlayingWordNumber();
|
||||
this.resetTypingContent();
|
||||
},
|
||||
}
|
||||
|
||||
showPlayingWordNumber: function() {
|
||||
TypingExamination.prototype.showPlayingWordNumber = function() {
|
||||
var currentLine = this.typingIndex + 1;
|
||||
this.textTypingLine.text = currentLine + " / " + this.typingContentLength;
|
||||
},
|
||||
}
|
||||
|
||||
setTimeTypingStart: function() {
|
||||
TypingExamination.prototype.setTimeTypingStart = function() {
|
||||
if(this.inputTextContent.canvasInput.value() == "")
|
||||
return;
|
||||
|
||||
@@ -601,11 +626,10 @@ var TypingExamination = {
|
||||
// console.log('this.timeTypingStart : ' + this.timeTypingStart);
|
||||
|
||||
// console.log('time gap : ' + (this.timeTypingStart - this.timeTypingEnd));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
TypingExamination.GAME_TIME_SEC = 60 * 5; // 5 minutes
|
||||
|
||||
TypingExamination.SPACE_INDICATOR = "ˇ"; // "ᵔ"; // "ᵕ"; // "ˣ"; // "ᵛ"; // " · ";
|
||||
@@ -625,3 +649,4 @@ TypingExamination.STAGE_BACKGROUND_COLOR = "#4d4d4d";
|
||||
TypingExamination.INPUT_CONTENT_BACKGROUND_COLOR = "#333333";
|
||||
TypingExamination.STAGE_BACKGROUND_COLOR_HEX = 0x4d4d4d;
|
||||
TypingExamination.INPUT_CONTENT_BACKGROUND_COLOR_HEX = 0x333333;
|
||||
*/
|
||||
@@ -9,8 +9,31 @@ var game = new Phaser.Game(
|
||||
this, false, false
|
||||
);
|
||||
|
||||
WebFontConfig = {
|
||||
// 'active' means all requested fonts have finished loading
|
||||
// We set a 1 second delay before calling 'createText'.
|
||||
// For some reason if we don't the browser cannot render the text the first time it's created.
|
||||
active: function() { game.time.events.add(Phaser.Timer.SECOND * 0.1, fontLoaded, this); },
|
||||
|
||||
// The Google Fonts we want to load (specify as many as you like in the array)
|
||||
google: {
|
||||
families: [
|
||||
'Nanum Gothic:400, 700, 800',
|
||||
'Nanum Gothic Coding:400,700',
|
||||
'Nanum Brush Script',
|
||||
'Nanum Pen Script'
|
||||
]
|
||||
// families: ['Nanum Brush Script']
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var typingExamination = new TypingExamination();
|
||||
game.state.add('Loading', Loading);
|
||||
game.state.start('Loading');
|
||||
|
||||
game.state.add('TypingExamination', TypingExamination);
|
||||
// game.state.add('Menu', Menu);
|
||||
game.state.add('TypingExamination', typingExamination);
|
||||
|
||||
function fontLoaded() {
|
||||
typingExamination.fontLoaded();
|
||||
}
|
||||
Reference in New Issue
Block a user