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:
2018-08-24 15:19:26 +09:00
parent efe101babc
commit 48ae12ed11
13 changed files with 430 additions and 104 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ const LANGUAGE_ENGLISH = "english";
const MODE_RELEASE = "release";
const MODE_DEBUG = "debug";
const runMode = MODE_DEBUG;
const runMode = MODE_RELEASE;
function isDebugMode() {
// console.log("debug mode ? " + runMode);
+108
View File
@@ -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" };
+108
View File
@@ -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" };
+1 -1
View File
@@ -28,7 +28,7 @@ class Chart {
this.drawText(
posX, posY - Chart.CHART_HEIGHT - Chart.CHART_RECORD_OFFSET_Y,
StringUtil.getRecordTextWithUnit(bestRecord)
StringUtil.getRecordTextWithoutUnit(bestRecord) + StringUtil.getScoreUnit(sessionStorageManager.playingAppID),
);
// chart
+6
View File
@@ -86,5 +86,11 @@ class StringUtil {
return alphabetCount;
};
static getScoreUnit(playingAppID) {
if(playingAppID < 100)
return " 타";
else
return " 점";
}
}
+2 -2
View File
@@ -65,7 +65,7 @@ class MenuTypingPractice {
sessionStorageManager.playingAppID = activeApp.AppID;
sessionStorageManager.playingAppName = activeApp.AppName;
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.playingAppName = activeApp.AppName;
sessionStorageManager.playingAppKoreanName = activeApp.KoreanName;
location.href = '../../web/client/typing_practice.html';
location.href = '../../web/client/start.html';
}
);
}
+15 -12
View File
@@ -110,21 +110,24 @@ class RankingBoard {
// rank
style.boundsAlignH = "right";
game.add.text(this.getPosX(type), this.getPosY(index), data.rank, style)
.setTextBounds(0, 0, 40, 40)
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
let rankText = game.add.text(this.getPosX(type), this.getPosY(index), data.rank, style);
// .setTextBounds(0, 0, 40, 40)
rankText.anchor.set(1, 0);
rankText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
// player name
game.add.text(this.getPosX(type) + 60, this.getPosY(index), data.playerName, style)
.setTextBounds(0, 0, 60, 60)
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
let playerNameText = game.add.text(this.getPosX(type) + 20, this.getPosY(index), data.playerName, style);
// .setTextBounds(0, 0, 60, 60)
playerNameText.anchor.set(0, 0);
playerNameText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
// bestRecord
let bestRecord = StringUtil.getRecordTextWithoutUnit(data.bestRecord);
style.boundsAlignH = "right";
game.add.text(this.getPosX(type) + 120, this.getPosY(index), bestRecord, style)
.setTextBounds(0, 0, 80, 60)
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
let recordText = game.add.text(this.getPosX(type) + 180, this.getPosY(index), bestRecord, style);
// .setTextBounds(0, 0, 80, 60)
recordText.anchor.set(1, 0);
recordText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
}
getPosX(type) {
@@ -133,17 +136,17 @@ class RankingBoard {
switch(type) {
case DBConnectManager.TYPE_MY_RANKING_HOUR:
case DBConnectManager.TYPE_ALL_RANKING_HOUR:
posX = 320;
posX = 330;
break;
case DBConnectManager.TYPE_MY_RANKING_DAY:
case DBConnectManager.TYPE_ALL_RANKING_DAY:
posX = 540;
posX = 560;
break;
case DBConnectManager.TYPE_MY_RANKING_MONTH:
case DBConnectManager.TYPE_ALL_RANKING_MONTH:
posX = 760;
posX = 790;
}
return posX;
+14 -10
View File
@@ -52,26 +52,30 @@ class Result {
}
printRecord() {
const style = { font: "64px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" };
game.add.text(0, 0, "결과", style)
.setTextBounds(0, 0, game.world.width, 100)
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
const style = { font: "bold 38px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" };
let 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);
let posY = 120;
if(sessionStorageManager.record === null)
sessionStorageManager.record = 0;
let record = NumberUtil.numberWithCommas(Math.floor(sessionStorageManager.record));
style.font = "bold 80px Arial";
game.add.text(0, 0, record, style)
.setTextBounds(0, posY, game.world.width, 60)
.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
style.font = "80px Arial";
let scoreText = game.add.text(
game.world.width / 2, 150,
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) {
style.font = "32px Arial";
let bestRecordText = game.add.text(0, 0, "!!! 새로운 최고 기록 !!!", style)
.setTextBounds(0, posY + 80, game.world.width, 40);
let bestRecordText = game.add.text(game.world.width / 2, 110, "!!! 새로운 최고 기록 !!!", style);
// .setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
bestRecordText.anchor.set(0.5);
bestRecordText.stroke = "#333";
bestRecordText.strokeThickness = 5;
}
+43 -28
View File
@@ -6,6 +6,8 @@ class TypingPractice {
create() {
self = this;
this.isOnStage = false;
this.initTypingData();
sessionStorageManager.isNewBestRecrd = false;
@@ -18,8 +20,15 @@ class TypingPractice {
location.href = '../../web/client/menu_typing_practice.html';
});
this.missTypingScoreText = new MissTypingScore();
this.contentProgressText = new ContentProgress();
this.typingScore = new TypingScore();
let STAGE_TIMER_SEC = 5;
this.stageTimer = new StageTimer( STAGE_TIMER_SEC, () => {
self.isOnStage = false;
// self.goResult();
self.gameOver();
});
let fullscreenButton = new FullscreenButton(game);
@@ -48,16 +57,22 @@ class TypingPractice {
let textDoneColor = [ '#99994d', '#77774d', '#66664d' ];
this.textTypingContentsDone = [];
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)
.addColor(textDoneColor[0], 0);
this.textTypingContentsDone[i] = game.add.text(
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);
}
let textPreviewColor = [ '#666666', '#888888', '#777777' ];
this.textTypingContentPreview = [];
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)
.addColor(textPreviewColor[0], 0);
this.textTypingContentPreview[i] = game.add.text(
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);
}
@@ -70,6 +85,9 @@ class TypingPractice {
this.keyboard = new Keyboard(this.keyMapper, Keyboard.ENGLISH);
game.input.keyboard.processKeyPress = () => {
if(self.isOnStage === false)
return;
self.checkTypingContents(event);
}
this.shiftKey = game.input.keyboard.addKey(Phaser.Keyboard.SHIFT);
@@ -93,19 +111,17 @@ class TypingPractice {
}
startGame() {
this.isOnStage = true;
this.stageTimer.start();
this.showTypingPracticeContents();
this.showHighlightKey();
this.moveHands();
this.showPlayingWordNumber();
}
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++) {
this.textTypingContentsDone[i].text = "";
}
@@ -116,15 +132,23 @@ class TypingPractice {
this.textTypingContent.addColor(TypingPractice.COLOR_CONTENT_RIGHT, 0);
this.textTypingContent.text = "= 연습 끝 =";
for(let i = 0; i < TypingPractice.TYPING_CONTENT_PREVIEW_COUNT; i++) {
this.textTypingContentPreview[i].text = "";
}
this.leftHand.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)
sessionStorageManager.bestRecord = sessionStorageManager.record;
location.href = '../../web/client/result.html';
*/
}
initTypingData() {
@@ -132,16 +156,11 @@ class TypingPractice {
let typingPracticeContents = this.loadPracticeContent();
// console.log(typingPracticeContents);
typingTextMan.makePracticeContents(typingPracticeContents, 1);
typingTextMan.makePracticeContents(typingPracticeContents, 30);
this.typingRandomContents = typingTextMan.getContents();
// console.log(this.typingRandomContents);
this.typingContentLength = this.typingRandomContents.length;
this.typingIndex = 0;
this.isTyping = false;
this.typingLetterCountTotal = 0;
this.typingRecordTotal = 0;
}
@@ -328,13 +347,14 @@ class TypingPractice {
let typingContent = this.typingRandomContents[this.typingIndex];
if(this.isKeyPressed(inputContent, typingContent)) {
this.typingScore.increase();
this.playNextContent();
if(this.typingIndex === this.typingContentLength) {
this.goResult();
// this.goResult();
}
} else {
this.missTypingScoreText.increase();
this.typingScore.reset();
}
}
@@ -346,11 +366,6 @@ class TypingPractice {
this.showTypingPracticeContents();
this.showHighlightKey();
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"
};
+73
View File
@@ -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"
};
+57
View File
@@ -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"
};