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
|
// for developing
|
||||||
// sessionStorageManager.setMaestroName("삼화초");
|
// sessionStorageManager.setMaestroName("삼화초");
|
||||||
// sessionStorageManager.setMaestroID(3);
|
// sessionStorageManager.setMaestroID(3);
|
||||||
@@ -20,8 +47,6 @@ var TypingExamination = {
|
|||||||
|
|
||||||
sessionStorageManager.setRecord(0);
|
sessionStorageManager.setRecord(0);
|
||||||
|
|
||||||
var self = this;
|
|
||||||
|
|
||||||
this.initTypingData();
|
this.initTypingData();
|
||||||
sessionStorageManager.setIsNewAppHighestRecord(false);
|
sessionStorageManager.setIsNewAppHighestRecord(false);
|
||||||
|
|
||||||
@@ -233,10 +258,10 @@ var TypingExamination = {
|
|||||||
|
|
||||||
this.loadExaminationContent();
|
this.loadExaminationContent();
|
||||||
// this.countDown();
|
// this.countDown();
|
||||||
},
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
countDown() {
|
countDown() {
|
||||||
var style = { font: "bold 200px Arial", fill: "#fff", boundsAlignH: "center", boundsAlignV: "middle" };
|
var style = { font: "bold 200px Arial", fill: "#fff", boundsAlignH: "center", boundsAlignV: "middle" };
|
||||||
this.countDownText = game.add.text(0, 0, "", style);
|
this.countDownText = game.add.text(0, 0, "", style);
|
||||||
this.countDownText.setTextBounds(0, 0, game.world.width, game.world.height);
|
this.countDownText.setTextBounds(0, 0, game.world.width, game.world.height);
|
||||||
@@ -247,9 +272,9 @@ var TypingExamination = {
|
|||||||
if(isDebugMode())
|
if(isDebugMode())
|
||||||
this.countDownNumber = 1;
|
this.countDownNumber = 1;
|
||||||
this.tweenCountDown();
|
this.tweenCountDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
tweenCountDown() {
|
tweenCountDown() {
|
||||||
if(this.countDownNumber === 0) {
|
if(this.countDownNumber === 0) {
|
||||||
this.startGame();
|
this.startGame();
|
||||||
return;
|
return;
|
||||||
@@ -263,34 +288,34 @@ var TypingExamination = {
|
|||||||
countDownTween.onComplete.add(this.tweenCountDown, this);
|
countDownTween.onComplete.add(this.tweenCountDown, this);
|
||||||
|
|
||||||
this.countDownNumber--;
|
this.countDownNumber--;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
back: function() {
|
TypingExamination.prototype.back = function() {
|
||||||
sessionStorageManager.resetPlayingAppData();
|
sessionStorageManager.resetPlayingAppData();
|
||||||
// location.href = '../../web/client/menu_typing_exam.html';
|
// location.href = '../../web/client/menu_typing_exam.html';
|
||||||
location.href = '../../web/client/main_menu.html';
|
location.href = '../../web/client/main_menu.html';
|
||||||
},
|
}
|
||||||
|
|
||||||
startGame: function() {
|
TypingExamination.prototype.startGame = function() {
|
||||||
this.averageTypingSpeedText.print(0);
|
this.averageTypingSpeedText.print(0);
|
||||||
|
|
||||||
this.showTypingExaminationContents();
|
this.showTypingExaminationContents();
|
||||||
this.showPlayingWordNumber();
|
this.showPlayingWordNumber();
|
||||||
},
|
}
|
||||||
|
|
||||||
timeOver: function() {
|
TypingExamination.prototype.timeOver = function() {
|
||||||
var timeOverText = new TimeOverText();
|
var timeOverText = new TimeOverText();
|
||||||
// this.stopAndGoResult();
|
// this.stopAndGoResult();
|
||||||
},
|
}
|
||||||
|
|
||||||
gameOver: function() {
|
TypingExamination.prototype.gameOver = function() {
|
||||||
var missionClearText = new MissionClearText();
|
var missionClearText = new MissionClearText();
|
||||||
this.stopAndGoResult();
|
this.stopAndGoResult();
|
||||||
},
|
}
|
||||||
|
|
||||||
stopAndGoResult: function() {
|
TypingExamination.prototype.stopAndGoResult = function() {
|
||||||
this.animalList.stopAnimation();
|
this.animalList.stopAnimation();
|
||||||
|
|
||||||
sessionStorageManager.setRecord(this.typingRecordTotal);
|
sessionStorageManager.setRecord(this.typingRecordTotal);
|
||||||
@@ -298,9 +323,9 @@ var TypingExamination = {
|
|||||||
this.updateResultRecord();
|
this.updateResultRecord();
|
||||||
|
|
||||||
game.time.events.add(Phaser.Timer.SECOND * 2, this.goResult, this);
|
game.time.events.add(Phaser.Timer.SECOND * 2, this.goResult, this);
|
||||||
},
|
}
|
||||||
|
|
||||||
updateResultRecord: function() {
|
TypingExamination.prototype.updateResultRecord = function() {
|
||||||
if(sessionStorageManager.getMaestroAccountType() < 100) { // experience account
|
if(sessionStorageManager.getMaestroAccountType() < 100) { // experience account
|
||||||
this.dbService.updateTypingExamRecord(
|
this.dbService.updateTypingExamRecord(
|
||||||
sessionStorageManager.getWritingID(),
|
sessionStorageManager.getWritingID(),
|
||||||
@@ -313,14 +338,14 @@ var TypingExamination = {
|
|||||||
}).bind(this)
|
}).bind(this)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
goResult: function() {
|
TypingExamination.prototype.goResult = function() {
|
||||||
location.href = '../../web/client/result.html';
|
location.href = '../../web/client/result.html';
|
||||||
},
|
}
|
||||||
|
|
||||||
|
|
||||||
initTypingData: function() {
|
TypingExamination.prototype.initTypingData = function() {
|
||||||
this.typingIndex = 0;
|
this.typingIndex = 0;
|
||||||
|
|
||||||
|
|
||||||
@@ -331,10 +356,10 @@ var TypingExamination = {
|
|||||||
|
|
||||||
this.typingLetterCountTotal = 0;
|
this.typingLetterCountTotal = 0;
|
||||||
this.typingRecordTotal = 0;
|
this.typingRecordTotal = 0;
|
||||||
},
|
}
|
||||||
|
|
||||||
|
|
||||||
loadExaminationContent: function() {
|
TypingExamination.prototype.loadExaminationContent = function() {
|
||||||
this.dbService.requestWritingInfo(
|
this.dbService.requestWritingInfo(
|
||||||
sessionStorageManager.getWritingID(),
|
sessionStorageManager.getWritingID(),
|
||||||
(function(jsonData) { // onSucceeded
|
(function(jsonData) { // onSucceeded
|
||||||
@@ -344,12 +369,12 @@ var TypingExamination = {
|
|||||||
this.downloadListFailed(jsonData);
|
this.downloadListFailed(jsonData);
|
||||||
}).bind(this)
|
}).bind(this)
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
|
|
||||||
downloadListSucceeded: function(jsonData) {
|
TypingExamination.prototype.downloadListSucceeded = function(jsonData) {
|
||||||
console.log(jsonData);
|
// console.log(jsonData);
|
||||||
var writingInfo = jsonData["writingInfo"];
|
var writingInfo = jsonData["writingInfo"];
|
||||||
console.log(writingInfo);
|
// console.log(writingInfo);
|
||||||
|
|
||||||
var writer = writingInfo["writer"];
|
var writer = writingInfo["writer"];
|
||||||
var writerID = "";
|
var writerID = "";
|
||||||
@@ -367,13 +392,13 @@ var TypingExamination = {
|
|||||||
game.load.onLoadComplete.add(this.completeLoadingWriting, this);
|
game.load.onLoadComplete.add(this.completeLoadingWriting, this);
|
||||||
game.load.text("writing", url);
|
game.load.text("writing", url);
|
||||||
game.load.start();
|
game.load.start();
|
||||||
},
|
}
|
||||||
|
|
||||||
downloadListFailed: function(jsonData) {
|
TypingExamination.prototype.downloadListFailed = function(jsonData) {
|
||||||
console.log(jsonData);
|
console.log(jsonData);
|
||||||
},
|
}
|
||||||
|
|
||||||
completeLoadingWriting: function() {
|
TypingExamination.prototype.completeLoadingWriting = function() {
|
||||||
game.load.onFileComplete.remove(this.loadExaminationContent, this);
|
game.load.onFileComplete.remove(this.loadExaminationContent, this);
|
||||||
game.load.onLoadComplete.remove(this.completeLoadingWriting, this);
|
game.load.onLoadComplete.remove(this.completeLoadingWriting, this);
|
||||||
|
|
||||||
@@ -403,18 +428,18 @@ var TypingExamination = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.startGame();
|
this.startGame();
|
||||||
},
|
}
|
||||||
|
|
||||||
setTypingContentText: function(text) {
|
TypingExamination.prototype.setTypingContentText = function(text) {
|
||||||
this.textTypingContent.text = text;
|
this.textTypingContent.text = text;
|
||||||
this.textTypedContentBack.text = text;
|
this.textTypedContentBack.text = text;
|
||||||
},
|
}
|
||||||
|
|
||||||
setTypingContentBackText: function(text) {
|
TypingExamination.prototype.setTypingContentBackText = function(text) {
|
||||||
this.textTypingContentBack.text = text;
|
this.textTypingContentBack.text = text;
|
||||||
},
|
}
|
||||||
|
|
||||||
showTypingExaminationContents: function() {
|
TypingExamination.prototype.showTypingExaminationContents = function() {
|
||||||
for(var i = 0; i < TypingExamination.TYPING_CONTENT_DONE_COUNT; i++) {
|
for(var i = 0; i < TypingExamination.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||||
var doneIndex = this.typingIndex - i - 1;
|
var doneIndex = this.typingIndex - i - 1;
|
||||||
if(doneIndex < 0) {
|
if(doneIndex < 0) {
|
||||||
@@ -443,18 +468,18 @@ var TypingExamination = {
|
|||||||
} else
|
} else
|
||||||
this.textTypingContentPreview[i].text = "";
|
this.textTypingContentPreview[i].text = "";
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
resetTypingContent: function() {
|
TypingExamination.prototype.resetTypingContent = function() {
|
||||||
this.textTypingContent.clearColors();
|
this.textTypingContent.clearColors();
|
||||||
this.textTypingContent.addColor(TypingExamination.COLOR_CONTENT_INPUT, 0);
|
this.textTypingContent.addColor(TypingExamination.COLOR_CONTENT_INPUT, 0);
|
||||||
|
|
||||||
this.setTypingContentBackText("");
|
this.setTypingContentBackText("");
|
||||||
|
|
||||||
this.inputTextContent.canvasInput.value('');
|
this.inputTextContent.canvasInput.value('');
|
||||||
},
|
}
|
||||||
|
|
||||||
checkTypingContents: function(event) {
|
TypingExamination.prototype.checkTypingContents = function(event) {
|
||||||
if(this.isGameOver)
|
if(this.isGameOver)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -493,9 +518,9 @@ var TypingExamination = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.showTypingContentHighlight(inputContent, typingContent);
|
this.showTypingContentHighlight(inputContent, typingContent);
|
||||||
},
|
}
|
||||||
|
|
||||||
showTypingContentHighlight: function(inputContent, typingContent) {
|
TypingExamination.prototype.showTypingContentHighlight = function(inputContent, typingContent) {
|
||||||
// console.log(inputContent + "=");
|
// console.log(inputContent + "=");
|
||||||
// console.log(typingContent + "=");
|
// console.log(typingContent + "=");
|
||||||
|
|
||||||
@@ -527,9 +552,9 @@ var TypingExamination = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
calculateTypingRecord: function(typingContent) {
|
TypingExamination.prototype.calculateTypingRecord = function(typingContent) {
|
||||||
// console.log('입력 단어 : ' + this.typingExaminationContents[this.typingIndex]);
|
// console.log('입력 단어 : ' + this.typingExaminationContents[this.typingIndex]);
|
||||||
|
|
||||||
this.isTyping = false;
|
this.isTyping = false;
|
||||||
@@ -572,21 +597,21 @@ var TypingExamination = {
|
|||||||
var animalLevelID = Animal.animalLevelIDByRecord(typingRecordTotalInteger, Animal.TYPE_TEST);
|
var animalLevelID = Animal.animalLevelIDByRecord(typingRecordTotalInteger, Animal.TYPE_TEST);
|
||||||
this.animalList.activate(animalLevelID);
|
this.animalList.activate(animalLevelID);
|
||||||
this.animalList.tweenAnimation(Animal.ANIMATION_TYPE_CHANGE);
|
this.animalList.tweenAnimation(Animal.ANIMATION_TYPE_CHANGE);
|
||||||
},
|
}
|
||||||
|
|
||||||
playNextContent: function() {
|
TypingExamination.prototype.playNextContent = function() {
|
||||||
this.typingIndex++;
|
this.typingIndex++;
|
||||||
this.showTypingExaminationContents();
|
this.showTypingExaminationContents();
|
||||||
this.showPlayingWordNumber();
|
this.showPlayingWordNumber();
|
||||||
this.resetTypingContent();
|
this.resetTypingContent();
|
||||||
},
|
}
|
||||||
|
|
||||||
showPlayingWordNumber: function() {
|
TypingExamination.prototype.showPlayingWordNumber = function() {
|
||||||
var currentLine = this.typingIndex + 1;
|
var currentLine = this.typingIndex + 1;
|
||||||
this.textTypingLine.text = currentLine + " / " + this.typingContentLength;
|
this.textTypingLine.text = currentLine + " / " + this.typingContentLength;
|
||||||
},
|
}
|
||||||
|
|
||||||
setTimeTypingStart: function() {
|
TypingExamination.prototype.setTimeTypingStart = function() {
|
||||||
if(this.inputTextContent.canvasInput.value() == "")
|
if(this.inputTextContent.canvasInput.value() == "")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -601,11 +626,10 @@ var TypingExamination = {
|
|||||||
// console.log('this.timeTypingStart : ' + this.timeTypingStart);
|
// console.log('this.timeTypingStart : ' + this.timeTypingStart);
|
||||||
|
|
||||||
// console.log('time gap : ' + (this.timeTypingStart - this.timeTypingEnd));
|
// console.log('time gap : ' + (this.timeTypingStart - this.timeTypingEnd));
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
TypingExamination.GAME_TIME_SEC = 60 * 5; // 5 minutes
|
TypingExamination.GAME_TIME_SEC = 60 * 5; // 5 minutes
|
||||||
|
|
||||||
TypingExamination.SPACE_INDICATOR = "ˇ"; // "ᵔ"; // "ᵕ"; // "ˣ"; // "ᵛ"; // " · ";
|
TypingExamination.SPACE_INDICATOR = "ˇ"; // "ᵔ"; // "ᵕ"; // "ˣ"; // "ᵛ"; // " · ";
|
||||||
@@ -625,3 +649,4 @@ TypingExamination.STAGE_BACKGROUND_COLOR = "#4d4d4d";
|
|||||||
TypingExamination.INPUT_CONTENT_BACKGROUND_COLOR = "#333333";
|
TypingExamination.INPUT_CONTENT_BACKGROUND_COLOR = "#333333";
|
||||||
TypingExamination.STAGE_BACKGROUND_COLOR_HEX = 0x4d4d4d;
|
TypingExamination.STAGE_BACKGROUND_COLOR_HEX = 0x4d4d4d;
|
||||||
TypingExamination.INPUT_CONTENT_BACKGROUND_COLOR_HEX = 0x333333;
|
TypingExamination.INPUT_CONTENT_BACKGROUND_COLOR_HEX = 0x333333;
|
||||||
|
*/
|
||||||
@@ -9,8 +9,31 @@ var game = new Phaser.Game(
|
|||||||
this, false, false
|
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.add('Loading', Loading);
|
||||||
game.state.start('Loading');
|
game.state.start('Loading');
|
||||||
|
|
||||||
game.state.add('TypingExamination', TypingExamination);
|
game.state.add('TypingExamination', typingExamination);
|
||||||
// game.state.add('Menu', Menu);
|
|
||||||
|
function fontLoaded() {
|
||||||
|
typingExamination.fontLoaded();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user