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
+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"
};