Fix: change runMode as release
Add: apply start, result to typing practice, score text, stage timer Fix: ranking board text postion
This commit is contained in:
@@ -3,7 +3,7 @@ const LANGUAGE_ENGLISH = "english";
|
|||||||
|
|
||||||
const MODE_RELEASE = "release";
|
const MODE_RELEASE = "release";
|
||||||
const MODE_DEBUG = "debug";
|
const MODE_DEBUG = "debug";
|
||||||
const runMode = MODE_DEBUG;
|
const runMode = MODE_RELEASE;
|
||||||
|
|
||||||
function isDebugMode() {
|
function isDebugMode() {
|
||||||
// console.log("debug mode ? " + runMode);
|
// console.log("debug mode ? " + runMode);
|
||||||
|
|||||||
@@ -0,0 +1,108 @@
|
|||||||
|
const LANGUAGE_KOREAN = "korean";
|
||||||
|
const LANGUAGE_ENGLISH = "english";
|
||||||
|
|
||||||
|
const MODE_RELEASE = "release";
|
||||||
|
const MODE_DEBUG = "debug";
|
||||||
|
const runMode = MODE_DEBUG;
|
||||||
|
|
||||||
|
function isDebugMode() {
|
||||||
|
// console.log("debug mode ? " + runMode);
|
||||||
|
return runMode == MODE_DEBUG ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isReleaseMode() {
|
||||||
|
// console.log("release mode ? " + runMode);
|
||||||
|
return runMode == MODE_RELEASE ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const GAME_SCREEN_SIZE = { x: 1024, y: 768 }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
let sessionStorageManager = new SessionStorageManager();
|
||||||
|
{
|
||||||
|
// if(isDebugMode()) {
|
||||||
|
// sessionStorageManager.playerName = "부현율";
|
||||||
|
// sessionStorageManager.playerID = 8;
|
||||||
|
// sessionStorageManager.playingAppID = 101;
|
||||||
|
// sessionStorageManager.playingAppName = "space_invaders";
|
||||||
|
// sessionStorageManager.score = 1000;
|
||||||
|
// sessionStorageManager.highScore = 2000;
|
||||||
|
// }
|
||||||
|
|
||||||
|
console.log("maestroID : " + sessionStorageManager.maestroID);
|
||||||
|
console.log("maestroAccountType : " + sessionStorageManager.maestroAccountType);
|
||||||
|
console.log("playerName : " + sessionStorageManager.playerName);
|
||||||
|
console.log("playerID : " + sessionStorageManager.playerID);
|
||||||
|
console.log("playerAccountType : " + sessionStorageManager.playerAccountType);
|
||||||
|
console.log("playingAppID : " + sessionStorageManager.playingAppID);
|
||||||
|
console.log("playingAppName : " + sessionStorageManager.playingAppName);
|
||||||
|
console.log("playingAppKoreanName : " + sessionStorageManager.playingAppKoreanName);
|
||||||
|
console.log("record : " + sessionStorageManager.record);
|
||||||
|
console.log("bestRecord : " + sessionStorageManager.bestRecord);
|
||||||
|
|
||||||
|
if(sessionStorageManager.maestroID === null && !isLogin()) {
|
||||||
|
goLogin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function isLogin() {
|
||||||
|
let filename = location.pathname.substring(location.pathname.lastIndexOf("/") + 1);
|
||||||
|
// console.log(filename);
|
||||||
|
|
||||||
|
return filename === "login.html" ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function goLogin() {
|
||||||
|
location.href = "login.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
function isTypingGame() {
|
||||||
|
if(sessionStorageManager.playingAppName === null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(sessionStorageManager.playingAppName.indexOf("typing") < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isTypingPracticeStage() {
|
||||||
|
let appName = sessionStorageManager.playingAppName;
|
||||||
|
|
||||||
|
if(appName.indexOf("practice_") > -1)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isTypingTestStage() {
|
||||||
|
let appName = sessionStorageManager.playingAppName;
|
||||||
|
|
||||||
|
if(appName.indexOf("test_") > -1)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isTypingWordStage() {
|
||||||
|
let appName = sessionStorageManager.playingAppName;
|
||||||
|
|
||||||
|
if((isTypingPracticeStage() || isTypingTestStage()) && appName.indexOf("_word") > -1)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isTypingSentenceStage() {
|
||||||
|
let appName = sessionStorageManager.playingAppName;
|
||||||
|
|
||||||
|
if((isTypingPracticeStage() || isTypingTestStage()) && appName.indexOf("_sentence") > -1)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let textStyleBasic = { font: "bold 32px Arial", fill: "#fff", align: "center", boundsAlignH: "center", boundsAlignV: "middle" };
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
const LANGUAGE_KOREAN = "korean";
|
||||||
|
const LANGUAGE_ENGLISH = "english";
|
||||||
|
|
||||||
|
const MODE_RELEASE = "release";
|
||||||
|
const MODE_DEBUG = "debug";
|
||||||
|
const runMode = MODE_RELEASE;
|
||||||
|
|
||||||
|
function isDebugMode() {
|
||||||
|
// console.log("debug mode ? " + runMode);
|
||||||
|
return runMode == MODE_DEBUG ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isReleaseMode() {
|
||||||
|
// console.log("release mode ? " + runMode);
|
||||||
|
return runMode == MODE_RELEASE ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const GAME_SCREEN_SIZE = { x: 1024, y: 768 }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
let sessionStorageManager = new SessionStorageManager();
|
||||||
|
{
|
||||||
|
// if(isDebugMode()) {
|
||||||
|
// sessionStorageManager.playerName = "부현율";
|
||||||
|
// sessionStorageManager.playerID = 8;
|
||||||
|
// sessionStorageManager.playingAppID = 101;
|
||||||
|
// sessionStorageManager.playingAppName = "space_invaders";
|
||||||
|
// sessionStorageManager.score = 1000;
|
||||||
|
// sessionStorageManager.highScore = 2000;
|
||||||
|
// }
|
||||||
|
|
||||||
|
console.log("maestroID : " + sessionStorageManager.maestroID);
|
||||||
|
console.log("maestroAccountType : " + sessionStorageManager.maestroAccountType);
|
||||||
|
console.log("playerName : " + sessionStorageManager.playerName);
|
||||||
|
console.log("playerID : " + sessionStorageManager.playerID);
|
||||||
|
console.log("playerAccountType : " + sessionStorageManager.playerAccountType);
|
||||||
|
console.log("playingAppID : " + sessionStorageManager.playingAppID);
|
||||||
|
console.log("playingAppName : " + sessionStorageManager.playingAppName);
|
||||||
|
console.log("playingAppKoreanName : " + sessionStorageManager.playingAppKoreanName);
|
||||||
|
console.log("record : " + sessionStorageManager.record);
|
||||||
|
console.log("bestRecord : " + sessionStorageManager.bestRecord);
|
||||||
|
|
||||||
|
if(sessionStorageManager.maestroID === null && !isLogin()) {
|
||||||
|
goLogin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function isLogin() {
|
||||||
|
let filename = location.pathname.substring(location.pathname.lastIndexOf("/") + 1);
|
||||||
|
// console.log(filename);
|
||||||
|
|
||||||
|
return filename === "login.html" ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function goLogin() {
|
||||||
|
location.href = "login.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
function isTypingGame() {
|
||||||
|
if(sessionStorageManager.playingAppName === null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(sessionStorageManager.playingAppName.indexOf("typing") < 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isTypingPracticeStage() {
|
||||||
|
let appName = sessionStorageManager.playingAppName;
|
||||||
|
|
||||||
|
if(appName.indexOf("practice_") > -1)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isTypingTestStage() {
|
||||||
|
let appName = sessionStorageManager.playingAppName;
|
||||||
|
|
||||||
|
if(appName.indexOf("test_") > -1)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isTypingWordStage() {
|
||||||
|
let appName = sessionStorageManager.playingAppName;
|
||||||
|
|
||||||
|
if((isTypingPracticeStage() || isTypingTestStage()) && appName.indexOf("_word") > -1)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isTypingSentenceStage() {
|
||||||
|
let appName = sessionStorageManager.playingAppName;
|
||||||
|
|
||||||
|
if((isTypingPracticeStage() || isTypingTestStage()) && appName.indexOf("_sentence") > -1)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let textStyleBasic = { font: "bold 32px Arial", fill: "#fff", align: "center", boundsAlignH: "center", boundsAlignV: "middle" };
|
||||||
@@ -28,7 +28,7 @@ class Chart {
|
|||||||
|
|
||||||
this.drawText(
|
this.drawText(
|
||||||
posX, posY - Chart.CHART_HEIGHT - Chart.CHART_RECORD_OFFSET_Y,
|
posX, posY - Chart.CHART_HEIGHT - Chart.CHART_RECORD_OFFSET_Y,
|
||||||
StringUtil.getRecordTextWithUnit(bestRecord)
|
StringUtil.getRecordTextWithoutUnit(bestRecord) + StringUtil.getScoreUnit(sessionStorageManager.playingAppID),
|
||||||
);
|
);
|
||||||
|
|
||||||
// chart
|
// chart
|
||||||
|
|||||||
@@ -86,5 +86,11 @@ class StringUtil {
|
|||||||
return alphabetCount;
|
return alphabetCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static getScoreUnit(playingAppID) {
|
||||||
|
if(playingAppID < 100)
|
||||||
|
return " 타";
|
||||||
|
else
|
||||||
|
return " 점";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -65,7 +65,7 @@ class MenuTypingPractice {
|
|||||||
sessionStorageManager.playingAppID = activeApp.AppID;
|
sessionStorageManager.playingAppID = activeApp.AppID;
|
||||||
sessionStorageManager.playingAppName = activeApp.AppName;
|
sessionStorageManager.playingAppName = activeApp.AppName;
|
||||||
sessionStorageManager.playingAppKoreanName = activeApp.KoreanName;
|
sessionStorageManager.playingAppKoreanName = activeApp.KoreanName;
|
||||||
location.href = '../../web/client/typing_practice.html';
|
location.href = '../../web/client/start.html';
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ class MenuTypingPractice {
|
|||||||
sessionStorageManager.playingAppID = activeApp.AppID;
|
sessionStorageManager.playingAppID = activeApp.AppID;
|
||||||
sessionStorageManager.playingAppName = activeApp.AppName;
|
sessionStorageManager.playingAppName = activeApp.AppName;
|
||||||
sessionStorageManager.playingAppKoreanName = activeApp.KoreanName;
|
sessionStorageManager.playingAppKoreanName = activeApp.KoreanName;
|
||||||
location.href = '../../web/client/typing_practice.html';
|
location.href = '../../web/client/start.html';
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,21 +110,24 @@ class RankingBoard {
|
|||||||
|
|
||||||
// rank
|
// rank
|
||||||
style.boundsAlignH = "right";
|
style.boundsAlignH = "right";
|
||||||
game.add.text(this.getPosX(type), this.getPosY(index), data.rank, style)
|
let rankText = game.add.text(this.getPosX(type), this.getPosY(index), data.rank, style);
|
||||||
.setTextBounds(0, 0, 40, 40)
|
// .setTextBounds(0, 0, 40, 40)
|
||||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
rankText.anchor.set(1, 0);
|
||||||
|
rankText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||||
|
|
||||||
// player name
|
// player name
|
||||||
game.add.text(this.getPosX(type) + 60, this.getPosY(index), data.playerName, style)
|
let playerNameText = game.add.text(this.getPosX(type) + 20, this.getPosY(index), data.playerName, style);
|
||||||
.setTextBounds(0, 0, 60, 60)
|
// .setTextBounds(0, 0, 60, 60)
|
||||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
playerNameText.anchor.set(0, 0);
|
||||||
|
playerNameText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||||
|
|
||||||
// bestRecord
|
// bestRecord
|
||||||
let bestRecord = StringUtil.getRecordTextWithoutUnit(data.bestRecord);
|
let bestRecord = StringUtil.getRecordTextWithoutUnit(data.bestRecord);
|
||||||
style.boundsAlignH = "right";
|
style.boundsAlignH = "right";
|
||||||
game.add.text(this.getPosX(type) + 120, this.getPosY(index), bestRecord, style)
|
let recordText = game.add.text(this.getPosX(type) + 180, this.getPosY(index), bestRecord, style);
|
||||||
.setTextBounds(0, 0, 80, 60)
|
// .setTextBounds(0, 0, 80, 60)
|
||||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
recordText.anchor.set(1, 0);
|
||||||
|
recordText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
getPosX(type) {
|
getPosX(type) {
|
||||||
@@ -133,17 +136,17 @@ class RankingBoard {
|
|||||||
switch(type) {
|
switch(type) {
|
||||||
case DBConnectManager.TYPE_MY_RANKING_HOUR:
|
case DBConnectManager.TYPE_MY_RANKING_HOUR:
|
||||||
case DBConnectManager.TYPE_ALL_RANKING_HOUR:
|
case DBConnectManager.TYPE_ALL_RANKING_HOUR:
|
||||||
posX = 320;
|
posX = 330;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DBConnectManager.TYPE_MY_RANKING_DAY:
|
case DBConnectManager.TYPE_MY_RANKING_DAY:
|
||||||
case DBConnectManager.TYPE_ALL_RANKING_DAY:
|
case DBConnectManager.TYPE_ALL_RANKING_DAY:
|
||||||
posX = 540;
|
posX = 560;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DBConnectManager.TYPE_MY_RANKING_MONTH:
|
case DBConnectManager.TYPE_MY_RANKING_MONTH:
|
||||||
case DBConnectManager.TYPE_ALL_RANKING_MONTH:
|
case DBConnectManager.TYPE_ALL_RANKING_MONTH:
|
||||||
posX = 760;
|
posX = 790;
|
||||||
}
|
}
|
||||||
|
|
||||||
return posX;
|
return posX;
|
||||||
|
|||||||
+14
-10
@@ -52,26 +52,30 @@ class Result {
|
|||||||
}
|
}
|
||||||
|
|
||||||
printRecord() {
|
printRecord() {
|
||||||
const style = { font: "64px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" };
|
const style = { font: "bold 38px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" };
|
||||||
game.add.text(0, 0, "결과", style)
|
let titleText = game.add.text(game.world.width / 2, 35, "결과", style);
|
||||||
.setTextBounds(0, 0, game.world.width, 100)
|
titleText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
titleText.anchor.set(0.5);
|
||||||
|
|
||||||
let posY = 120;
|
let posY = 120;
|
||||||
if(sessionStorageManager.record === null)
|
if(sessionStorageManager.record === null)
|
||||||
sessionStorageManager.record = 0;
|
sessionStorageManager.record = 0;
|
||||||
let record = NumberUtil.numberWithCommas(Math.floor(sessionStorageManager.record));
|
let record = NumberUtil.numberWithCommas(Math.floor(sessionStorageManager.record));
|
||||||
style.font = "bold 80px Arial";
|
style.font = "80px Arial";
|
||||||
game.add.text(0, 0, record, style)
|
let scoreText = game.add.text(
|
||||||
.setTextBounds(0, posY, game.world.width, 60)
|
game.world.width / 2, 150,
|
||||||
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
record + StringUtil.getScoreUnit(sessionStorageManager.playingAppID),
|
||||||
|
style
|
||||||
|
);
|
||||||
|
scoreText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||||
|
scoreText.anchor.set(0.5);
|
||||||
|
|
||||||
|
|
||||||
if(sessionStorageManager.isNewBestRecrd === true) {
|
if(sessionStorageManager.isNewBestRecrd === true) {
|
||||||
style.font = "32px Arial";
|
style.font = "32px Arial";
|
||||||
let bestRecordText = game.add.text(0, 0, "!!! 새로운 최고 기록 !!!", style)
|
let bestRecordText = game.add.text(game.world.width / 2, 110, "!!! 새로운 최고 기록 !!!", style);
|
||||||
.setTextBounds(0, posY + 80, game.world.width, 40);
|
|
||||||
// .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
// .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||||
|
bestRecordText.anchor.set(0.5);
|
||||||
bestRecordText.stroke = "#333";
|
bestRecordText.stroke = "#333";
|
||||||
bestRecordText.strokeThickness = 5;
|
bestRecordText.strokeThickness = 5;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ class TypingPractice {
|
|||||||
create() {
|
create() {
|
||||||
self = this;
|
self = this;
|
||||||
|
|
||||||
|
this.isOnStage = false;
|
||||||
|
|
||||||
this.initTypingData();
|
this.initTypingData();
|
||||||
sessionStorageManager.isNewBestRecrd = false;
|
sessionStorageManager.isNewBestRecrd = false;
|
||||||
|
|
||||||
@@ -18,8 +20,15 @@ class TypingPractice {
|
|||||||
location.href = '../../web/client/menu_typing_practice.html';
|
location.href = '../../web/client/menu_typing_practice.html';
|
||||||
});
|
});
|
||||||
|
|
||||||
this.missTypingScoreText = new MissTypingScore();
|
this.typingScore = new TypingScore();
|
||||||
this.contentProgressText = new ContentProgress();
|
|
||||||
|
let STAGE_TIMER_SEC = 5;
|
||||||
|
this.stageTimer = new StageTimer( STAGE_TIMER_SEC, () => {
|
||||||
|
self.isOnStage = false;
|
||||||
|
|
||||||
|
// self.goResult();
|
||||||
|
self.gameOver();
|
||||||
|
});
|
||||||
|
|
||||||
let fullscreenButton = new FullscreenButton(game);
|
let fullscreenButton = new FullscreenButton(game);
|
||||||
|
|
||||||
@@ -48,16 +57,22 @@ class TypingPractice {
|
|||||||
let textDoneColor = [ '#99994d', '#77774d', '#66664d' ];
|
let textDoneColor = [ '#99994d', '#77774d', '#66664d' ];
|
||||||
this.textTypingContentsDone = [];
|
this.textTypingContentsDone = [];
|
||||||
for(let i = 0; i < TypingPractice.TYPING_CONTENT_DONE_COUNT; i++) {
|
for(let i = 0; i < TypingPractice.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||||
this.textTypingContentsDone[i] = game.add.text(game.world.centerX - 200 - i * OFFSET_WORD_X, TYPING_CONTENT_Y, "", textStyleBasic)
|
this.textTypingContentsDone[i] = game.add.text(
|
||||||
.addColor(textDoneColor[0], 0);
|
game.world.centerX - 200 - i * OFFSET_WORD_X, TYPING_CONTENT_Y,
|
||||||
|
"", textStyleBasic
|
||||||
|
);
|
||||||
|
this.textTypingContentsDone[i].addColor(textDoneColor[0], 0);
|
||||||
this.textTypingContentsDone[i].anchor.set(0.5);
|
this.textTypingContentsDone[i].anchor.set(0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
let textPreviewColor = [ '#666666', '#888888', '#777777' ];
|
let textPreviewColor = [ '#666666', '#888888', '#777777' ];
|
||||||
this.textTypingContentPreview = [];
|
this.textTypingContentPreview = [];
|
||||||
for(let i = 0; i < TypingPractice.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
for(let i = 0; i < TypingPractice.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
||||||
this.textTypingContentPreview[i] = game.add.text(game.world.centerX + 200 + i * OFFSET_WORD_X, TYPING_CONTENT_Y, "", textStyleBasic)
|
this.textTypingContentPreview[i] = game.add.text(
|
||||||
.addColor(textPreviewColor[0], 0);
|
game.world.centerX + 200 + i * OFFSET_WORD_X,
|
||||||
|
TYPING_CONTENT_Y, "", textStyleBasic
|
||||||
|
);
|
||||||
|
this.textTypingContentPreview[i].addColor(textPreviewColor[0], 0);
|
||||||
this.textTypingContentPreview[i].anchor.set(0.5);
|
this.textTypingContentPreview[i].anchor.set(0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,6 +85,9 @@ class TypingPractice {
|
|||||||
this.keyboard = new Keyboard(this.keyMapper, Keyboard.ENGLISH);
|
this.keyboard = new Keyboard(this.keyMapper, Keyboard.ENGLISH);
|
||||||
|
|
||||||
game.input.keyboard.processKeyPress = () => {
|
game.input.keyboard.processKeyPress = () => {
|
||||||
|
if(self.isOnStage === false)
|
||||||
|
return;
|
||||||
|
|
||||||
self.checkTypingContents(event);
|
self.checkTypingContents(event);
|
||||||
}
|
}
|
||||||
this.shiftKey = game.input.keyboard.addKey(Phaser.Keyboard.SHIFT);
|
this.shiftKey = game.input.keyboard.addKey(Phaser.Keyboard.SHIFT);
|
||||||
@@ -93,19 +111,17 @@ class TypingPractice {
|
|||||||
}
|
}
|
||||||
|
|
||||||
startGame() {
|
startGame() {
|
||||||
|
this.isOnStage = true;
|
||||||
|
this.stageTimer.start();
|
||||||
|
|
||||||
this.showTypingPracticeContents();
|
this.showTypingPracticeContents();
|
||||||
this.showHighlightKey();
|
this.showHighlightKey();
|
||||||
this.moveHands();
|
this.moveHands();
|
||||||
this.showPlayingWordNumber();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gameOver() {
|
gameOver() {
|
||||||
let gameOverText = new GameOverText();
|
this.isOnStage = false;
|
||||||
|
|
||||||
game.time.events.add(Phaser.Timer.SECOND * 2, this.goResult, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
goResult() {
|
|
||||||
for(let i = 0; i < TypingPractice.TYPING_CONTENT_DONE_COUNT; i++) {
|
for(let i = 0; i < TypingPractice.TYPING_CONTENT_DONE_COUNT; i++) {
|
||||||
this.textTypingContentsDone[i].text = "";
|
this.textTypingContentsDone[i].text = "";
|
||||||
}
|
}
|
||||||
@@ -116,15 +132,23 @@ class TypingPractice {
|
|||||||
this.textTypingContent.addColor(TypingPractice.COLOR_CONTENT_RIGHT, 0);
|
this.textTypingContent.addColor(TypingPractice.COLOR_CONTENT_RIGHT, 0);
|
||||||
this.textTypingContent.text = "= 연습 끝 =";
|
this.textTypingContent.text = "= 연습 끝 =";
|
||||||
|
|
||||||
|
for(let i = 0; i < TypingPractice.TYPING_CONTENT_PREVIEW_COUNT; i++) {
|
||||||
|
this.textTypingContentPreview[i].text = "";
|
||||||
|
}
|
||||||
|
|
||||||
this.leftHand.moveToDefaultPosition();
|
this.leftHand.moveToDefaultPosition();
|
||||||
this.rightHand.moveToDefaultPosition();
|
this.rightHand.moveToDefaultPosition();
|
||||||
/*
|
|
||||||
sessionStorageManager.record = this.typingRecordTotal;
|
let gameOverText = new GameOverText();
|
||||||
|
game.time.events.add(Phaser.Timer.SECOND * 2, this.goResult, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
goResult() {
|
||||||
|
sessionStorageManager.record = this.typingScore.score();
|
||||||
if(sessionStorageManager.record > sessionStorageManager.bestRecord)
|
if(sessionStorageManager.record > sessionStorageManager.bestRecord)
|
||||||
sessionStorageManager.bestRecord = sessionStorageManager.record;
|
sessionStorageManager.bestRecord = sessionStorageManager.record;
|
||||||
|
|
||||||
location.href = '../../web/client/result.html';
|
location.href = '../../web/client/result.html';
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
initTypingData() {
|
initTypingData() {
|
||||||
@@ -132,16 +156,11 @@ class TypingPractice {
|
|||||||
|
|
||||||
let typingPracticeContents = this.loadPracticeContent();
|
let typingPracticeContents = this.loadPracticeContent();
|
||||||
// console.log(typingPracticeContents);
|
// console.log(typingPracticeContents);
|
||||||
typingTextMan.makePracticeContents(typingPracticeContents, 1);
|
typingTextMan.makePracticeContents(typingPracticeContents, 30);
|
||||||
this.typingRandomContents = typingTextMan.getContents();
|
this.typingRandomContents = typingTextMan.getContents();
|
||||||
// console.log(this.typingRandomContents);
|
// console.log(this.typingRandomContents);
|
||||||
this.typingContentLength = this.typingRandomContents.length;
|
this.typingContentLength = this.typingRandomContents.length;
|
||||||
this.typingIndex = 0;
|
this.typingIndex = 0;
|
||||||
|
|
||||||
this.isTyping = false;
|
|
||||||
|
|
||||||
this.typingLetterCountTotal = 0;
|
|
||||||
this.typingRecordTotal = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -328,13 +347,14 @@ class TypingPractice {
|
|||||||
let typingContent = this.typingRandomContents[this.typingIndex];
|
let typingContent = this.typingRandomContents[this.typingIndex];
|
||||||
|
|
||||||
if(this.isKeyPressed(inputContent, typingContent)) {
|
if(this.isKeyPressed(inputContent, typingContent)) {
|
||||||
|
this.typingScore.increase();
|
||||||
this.playNextContent();
|
this.playNextContent();
|
||||||
|
|
||||||
if(this.typingIndex === this.typingContentLength) {
|
if(this.typingIndex === this.typingContentLength) {
|
||||||
this.goResult();
|
// this.goResult();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.missTypingScoreText.increase();
|
this.typingScore.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -346,11 +366,6 @@ class TypingPractice {
|
|||||||
this.showTypingPracticeContents();
|
this.showTypingPracticeContents();
|
||||||
this.showHighlightKey();
|
this.showHighlightKey();
|
||||||
this.moveHands();
|
this.moveHands();
|
||||||
this.showPlayingWordNumber();
|
|
||||||
}
|
|
||||||
|
|
||||||
showPlayingWordNumber() {
|
|
||||||
this.contentProgressText.print(this.typingIndex + 1, this.typingContentLength);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
class MissTypingScore {
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
this.missTypingCount = 0;
|
|
||||||
|
|
||||||
let fontStyle = MissTypingScore.DEFAULT_TEXT_FONT;
|
|
||||||
|
|
||||||
fontStyle.align = "right";
|
|
||||||
fontStyle.boundsAlignH = "right";
|
|
||||||
this.label = game.add.text(0, 0, "오타수 : ", fontStyle)
|
|
||||||
.setTextBounds(0, 0, game.world.width / 2, MissTypingScore.FONT_HEIGHT_PX);
|
|
||||||
|
|
||||||
fontStyle.align = "left";
|
|
||||||
fontStyle.boundsAlignH = "left";
|
|
||||||
this.missTypingText = game.add.text(game.world.width / 2, 0, "0", fontStyle)
|
|
||||||
.setTextBounds(0, 0, game.world.width / 2, MissTypingScore.FONT_HEIGHT_PX);
|
|
||||||
|
|
||||||
// var grd = this.label.context.createLinearGradient(0, 0, 0, MissTypingScore.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;
|
|
||||||
};
|
|
||||||
|
|
||||||
increase() {
|
|
||||||
this.missTypingCount++;
|
|
||||||
this.print(this.missTypingCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
print(missTypingCount) {
|
|
||||||
this.missTypingText.text = missTypingCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
MissTypingScore.FONT_HEIGHT_PX = 70;
|
|
||||||
|
|
||||||
MissTypingScore.DEFAULT_TEXT_FONT = {
|
|
||||||
font: "38px Arial",
|
|
||||||
align: "center",
|
|
||||||
boundsAlignH: "center", // left, center. right
|
|
||||||
boundsAlignV: "middle", // top, middle, bottom
|
|
||||||
fill: "#fff"
|
|
||||||
};
|
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
class StageTimer {
|
||||||
|
|
||||||
|
constructor(stageTimerSec, onTimeOver) {
|
||||||
|
|
||||||
|
this.stageTimerSec = stageTimerSec;
|
||||||
|
this.onTimeOver = onTimeOver;
|
||||||
|
|
||||||
|
let fontStyle = StageTimer.DEFAULT_TEXT_FONT;
|
||||||
|
|
||||||
|
fontStyle.align = "right";
|
||||||
|
fontStyle.boundsAlignH = "right";
|
||||||
|
this.timerText = game.add.text(game.world.width - 300, 0, "", fontStyle)
|
||||||
|
.setTextBounds(0, 0, 200, StageTimer.FONT_HEIGHT_PX);
|
||||||
|
|
||||||
|
// var grd = this.label.context.createLinearGradient(0, 0, 0, StageTimer.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;
|
||||||
|
|
||||||
|
this.timerEvent = null;
|
||||||
|
};
|
||||||
|
|
||||||
|
start() {
|
||||||
|
this.timeLeft = this.stageTimerSec;
|
||||||
|
this.printTime();
|
||||||
|
if(this.timerEvent === null)
|
||||||
|
this.timerEvent = game.time.events.loop(Phaser.Timer.SECOND, this.updateTimer, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
pause() {
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
if(this.timerEvent)
|
||||||
|
this.removeTimer();
|
||||||
|
this.timerText.text = "시간 끝";
|
||||||
|
}
|
||||||
|
|
||||||
|
updateTimer() {
|
||||||
|
this.timeLeft--;
|
||||||
|
if(this.timeLeft === 0) {
|
||||||
|
this.stop();
|
||||||
|
this.onTimeOver();
|
||||||
|
} else {
|
||||||
|
this.printTime();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printTime() {
|
||||||
|
this.timerText.text = this.timeLeft.toString() + "초";
|
||||||
|
}
|
||||||
|
|
||||||
|
removeTimer() {
|
||||||
|
game.time.events.remove(this.timerEvent);
|
||||||
|
this.timerEvent = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
StageTimer.FONT_HEIGHT_PX = 70;
|
||||||
|
|
||||||
|
StageTimer.DEFAULT_TEXT_FONT = {
|
||||||
|
font: "38px Arial",
|
||||||
|
align: "center",
|
||||||
|
boundsAlignH: "center", // left, center. right
|
||||||
|
boundsAlignV: "middle", // top, middle, bottom
|
||||||
|
fill: "#fff"
|
||||||
|
};
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
class TypingScore {
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
this.typingCount = 0;
|
||||||
|
|
||||||
|
let fontStyle = TypingScore.DEFAULT_TEXT_FONT;
|
||||||
|
|
||||||
|
fontStyle.align = "right";
|
||||||
|
fontStyle.boundsAlignH = "right";
|
||||||
|
this.scoreTitleText = game.add.text(game.world.width / 2 - 40, TypingScore.SCORE_POS_Y, "연속 성공 타수 : ", fontStyle)
|
||||||
|
this.scoreTitleText.anchor.set(0.5);
|
||||||
|
|
||||||
|
fontStyle.align = "left";
|
||||||
|
fontStyle.boundsAlignH = "left";
|
||||||
|
this.scoreText = game.add.text(game.world.width / 2 + 100, TypingScore.SCORE_POS_Y, "0", fontStyle)
|
||||||
|
this.scoreText.anchor.set(0.5);
|
||||||
|
|
||||||
|
// var grd = this.scoreText.context.createLinearGradient(0, 0, 0, TypingScore.SCORE_POS_Y);
|
||||||
|
// grd.addColorStop(0, '#8ED6FF');
|
||||||
|
// grd.addColorStop(1, '#004CB3');
|
||||||
|
// this.scoreText.fill = grd;
|
||||||
|
// this.scoreText.fill = grd;
|
||||||
|
|
||||||
|
// this.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||||
|
// this.scoreText.stroke = '#000';
|
||||||
|
// this.scoreText.strokeThickness = 3;
|
||||||
|
};
|
||||||
|
|
||||||
|
score() {
|
||||||
|
return this.typingCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
increase() {
|
||||||
|
this.typingCount++;
|
||||||
|
this.print(this.typingCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
reset() {
|
||||||
|
this.typingCount = 0;
|
||||||
|
this.print(this.typingCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
print(typingCount) {
|
||||||
|
this.scoreText.text = typingCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
TypingScore.SCORE_POS_Y = 35;
|
||||||
|
|
||||||
|
TypingScore.DEFAULT_TEXT_FONT = {
|
||||||
|
font: "38px Arial",
|
||||||
|
align: "center",
|
||||||
|
boundsAlignH: "center", // left, center. right
|
||||||
|
boundsAlignV: "middle", // top, middle, bottom
|
||||||
|
fill: "#fff"
|
||||||
|
};
|
||||||
@@ -49,12 +49,12 @@
|
|||||||
<script src="../../game/typing/alphabet_list/english_word.js"></script>
|
<script src="../../game/typing/alphabet_list/english_word.js"></script>
|
||||||
|
|
||||||
<!-- Test typing : source files -->
|
<!-- Test typing : source files -->
|
||||||
<script src="../../game/typing/lib/content_progress.js"></script>
|
|
||||||
<script src="../../game/typing/lib/typing_text_manager.js"></script>
|
<script src="../../game/typing/lib/typing_text_manager.js"></script>
|
||||||
<script src="../../game/typing/lib/typing_content_bg.js"></script>
|
<script src="../../game/typing/lib/typing_content_bg.js"></script>
|
||||||
|
|
||||||
<script src="../../game/typing/practice/define_variables.js"></script>
|
<script src="../../game/typing/practice/define_variables.js"></script>
|
||||||
<script src="../../game/typing/practice/miss_typing_score.js"></script>
|
<script src="../../game/typing/practice/stage_timer.js"></script>
|
||||||
|
<script src="../../game/typing/practice/typing_score.js"></script>
|
||||||
<script src="../../game/typing/practice/key_mapper.js"></script>
|
<script src="../../game/typing/practice/key_mapper.js"></script>
|
||||||
<script src="../../game/typing/practice/key_button.js"></script>
|
<script src="../../game/typing/practice/key_button.js"></script>
|
||||||
<script src="../../game/typing/practice/hand.js"></script>
|
<script src="../../game/typing/practice/hand.js"></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user