Fix: restructing session manager, ES6 -> ES5

This commit is contained in:
2018-09-14 22:22:22 +09:00
parent 72e7c1a28f
commit 3f340535ac
44 changed files with 3100 additions and 3262 deletions
+22 -25
View File
@@ -1,35 +1,32 @@
class AverageTypingSpeed {
function AverageTypingSpeed() {
var fontStyle = AverageTypingSpeed.DEFAULT_TEXT_FONT;
constructor() {
let fontStyle = AverageTypingSpeed.DEFAULT_TEXT_FONT;
fontStyle.align = "right";
fontStyle.boundsAlignH = "right";
this.tytleSpeedText = game.add.text(game.world.width / 2 + 20, AverageTypingSpeed.FONT_HEIGHT_PX, "현재 타수 : ", fontStyle);
this.tytleSpeedText.anchor.set(1, 0.5);
fontStyle.align = "right";
fontStyle.boundsAlignH = "right";
this.tytleSpeedText = game.add.text(game.world.width / 2 + 20, AverageTypingSpeed.FONT_HEIGHT_PX, "현재 타수 : ", fontStyle);
this.tytleSpeedText.anchor.set(1, 0.5);
fontStyle.align = "left";
fontStyle.boundsAlignH = "left";
this.typingSpeedText = game.add.text(game.world.width / 2 + 20, AverageTypingSpeed.FONT_HEIGHT_PX, "0", fontStyle);
this.typingSpeedText.anchor.set(0, 0.5);
fontStyle.align = "left";
fontStyle.boundsAlignH = "left";
this.typingSpeedText = game.add.text(game.world.width / 2 + 20, AverageTypingSpeed.FONT_HEIGHT_PX, "0", fontStyle);
this.typingSpeedText.anchor.set(0, 0.5);
// var grd = this.label.context.createLinearGradient(0, 0, 0, AverageTypingSpeed.FONT_HEIGHT_PX);
// grd.addColorStop(0, '#8ED6FF');
// grd.addColorStop(1, '#004CB3');
// this.label.fill = grd;
// this.scoreText.fill = grd;
// var grd = this.label.context.createLinearGradient(0, 0, 0, AverageTypingSpeed.FONT_HEIGHT_PX);
// grd.addColorStop(0, '#8ED6FF');
// grd.addColorStop(1, '#004CB3');
// this.label.fill = grd;
// this.scoreText.fill = grd;
// this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
// this.label.stroke = '#000';
// this.label.strokeThickness = 3;
};
print(typingSpeed) {
this.typingSpeedText.text = typingSpeed;
}
// this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
// this.label.stroke = '#000';
// this.label.strokeThickness = 3;
};
AverageTypingSpeed.prototype.print = function(typingSpeed) {
this.typingSpeedText.text = typingSpeed;
}
AverageTypingSpeed.FONT_HEIGHT_PX = 30;
AverageTypingSpeed.DEFAULT_TEXT_FONT = {
+39 -42
View File
@@ -1,13 +1,10 @@
/////////////////////////////
// TypingTest
var TypingTest = {
class TypingTest {
create() {
create: function() {
self = this;
this.initTypingData();
sessionStorageManager.isNewBestRecrd = false;
sessionStorageManager.setIsNewBestRecord(false);
game.stage.backgroundColor = '#4d4d4d';
@@ -105,14 +102,14 @@ class TypingTest {
// bottom ui
let screenBottomUI = new ScreenBottomUI();
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.bestRecord);
screenBottomUI.printCenterText(sessionStorageManager.playingAppKoreanName);
screenBottomUI.printRightText(sessionStorageManager.playerName);
screenBottomUI.printLeftTextWithBestRecord(sessionStorageManager.getBestRecord());
screenBottomUI.printCenterText(sessionStorageManager.getPlayingAppKoreanName());
screenBottomUI.printRightText(sessionStorageManager.getPlayerName());
this.startGame();
// this.countDown();
}
},
/*
countDown() {
@@ -145,30 +142,30 @@ class TypingTest {
}
*/
startGame() {
startGame: function() {
this.averageTypingSpeedText.print(0);
this.showTypingTestContents();
this.showPlayingWordNumber();
}
},
gameOver() {
gameOver: function() {
let gameOverText = new GameOverText();
this.animalOnTitle.stopAnimation();
game.time.events.add(Phaser.Timer.SECOND * 2, this.goResult, this);
}
},
goResult() {
sessionStorageManager.record = this.typingRecordTotal;
if(sessionStorageManager.record > sessionStorageManager.bestRecord)
sessionStorageManager.bestRecord = sessionStorageManager.record;
goResult: function() {
sessionStorageManager.setRecord(this.typingRecordTotal);
if(sessionStorageManager.getRecord() > sessionStorageManager.getBestRecord())
sessionStorageManager.setBestRecord(sessionStorageManager.record);
location.href = '../../web/client/result.html';
}
},
initTypingData() {
initTypingData: function() {
let typingTextMan = new TypingTextManager();
let typingPracticeContents = this.getTypingTestContents();
@@ -190,10 +187,10 @@ class TypingTest {
this.typingLetterCountTotal = 0;
this.typingRecordTotal = 0;
}
},
getTypingTestContents() {
getTypingTestContents: function() {
let typingTestContents = this.loadTestContent();
// console.log('playingStageData.language : ' + playingStageData.language);
// console.log('playingStageData.level : ' + playingStageData.level);
@@ -207,14 +204,14 @@ class TypingTest {
}
return typingTestContents;
}
},
loadTestContent() {
loadTestContent: function() {
let appName = "";
if(isTypingTestStage())
appName = sessionStorageManager.playingAppName.substring(5);
appName = sessionStorageManager.getPlayingAppName().substring(5);
else if(isTypingPracticeStage())
appName = sessionStorageManager.playingAppName.substring(9);
appName = sessionStorageManager.getPlayingAppName().substring(9);
let testContent = [];
switch(appName) {
@@ -276,9 +273,9 @@ class TypingTest {
}
return testContent;
}
},
showTypingTestContents() {
showTypingTestContents: function() {
for(let i = 0; i < TypingTest.TYPING_CONTENT_DONE_COUNT; i++) {
let doneIndex = this.typingIndex - i - 1;
if(doneIndex < 0) {
@@ -304,15 +301,15 @@ class TypingTest {
else
this.textTypingContentPreview[i].text = "";
}
}
},
resetTypingContent() {
resetTypingContent: function() {
this.textTypingContent.clearColors();
this.textTypingContent.addColor(TypingTest.COLOR_CONTENT_INPUT, 0);
this.inputTextContent.canvasInput.value('');
}
},
checkTypingContents(evnet) {
checkTypingContents: function(evnet) {
if(event.keyCode == Phaser.Keyboard.ENTER) {
// console.log("### enter ###");
let inputContent = this.inputTextContent.canvasInput.value();
@@ -336,9 +333,9 @@ class TypingTest {
this.showTypingContentHighlight();
}
}
},
showTypingContentHighlight() {
showTypingContentHighlight: function() {
let typingContent = this.typingRandomContents[this.typingIndex];
let inputContent = this.inputTextContent.canvasInput.value();
@@ -358,9 +355,9 @@ class TypingTest {
return;
}
}
}
},
calculateTypingRecord(typingContent) {
calculateTypingRecord: function(typingContent) {
// console.log('입력 단어 : ' + this.typingRandomContents[this.typingIndex]);
this.isTyping = false;
@@ -404,20 +401,20 @@ class TypingTest {
this.animalOnTitle.tweenAnimation(Animal.ANIMATION_TYPE_CHANGE);
this.animalOnTitle.startAnimation();
}
},
playNextContent() {
playNextContent: function() {
this.typingIndex++;
this.showTypingTestContents();
this.showPlayingWordNumber();
this.resetTypingContent();
}
},
showPlayingWordNumber() {
showPlayingWordNumber: function() {
this.contentProgressText.print(this.typingIndex + 1, this.typingContentLength);
}
},
setTimeTypingStart() {
setTimeTypingStart: function() {
this.timeTypingStart = game.time.elapsedSince(0);
let timeGap = this.timeTypingStart - this.timeTypingEnd;
+12 -18
View File
@@ -1,17 +1,11 @@
/////////////////////////////
// Loading
var Loading = {
// var x = 32;
// var y = 80;
class Loading {
preload() {
preload: function() {
// this.game.load.image('loadingbar', './image/phaser.png');
}
},
create() {
// let userID = sessionStorage.getItem("UserID");
create: function() {
// var userID = sessionStorage.getItem("UserID");
// console.log("userID : " + userID);
// this.game.stage.backgroundColor = '#4d4d4d';
@@ -30,9 +24,9 @@ class Loading {
this.game.load.onLoadComplete.add(this.loadComplete, this);
this.startLoading();
}
},
startLoading() {
startLoading: function() {
this.game.load.image('icon_fullscreen', '../../../resources/image/icon/fullscreen_white.png');
Animal.loadResources();
@@ -61,9 +55,9 @@ class Loading {
// this.game.load.image('medal_bronze', './image/medal_bronze.png');
this.game.load.start();
}
},
fileComplete(progress, cacheKey, success, totalLoaded, totalFiles) {
fileComplete: function(progress, cacheKey, success, totalLoaded, totalFiles) {
// this.preloadBar.alpha = progress / 100;
// console.log('progress : ' + progress);
@@ -79,9 +73,9 @@ class Loading {
// x = 32;
// y += 332;
// }
}
},
loadComplete(progress, cacheKey, success, totalLoaded, totalFiles) {
loadComplete: function(progress, cacheKey, success, totalLoaded, totalFiles) {
// this.preloadBar.alpha = 1;
if(isDebugMode()) {
@@ -93,5 +87,5 @@ class Loading {
// this.startMenu();
// this.startTypingTestStage();
// this.startTypingTestResult();
}
},
}