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);
}
}