From 3055fd320178b4448a9dd7a1825c23c1a1b76b85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A2=E1=84=91=E1=85=B3=E1=86=AF=20=E1=84=82?= =?UTF-8?q?=E1=85=A9=E1=84=90=E1=85=B3=E1=84=87=E1=85=AE=E1=86=A8?= Date: Sun, 6 Jan 2019 09:02:52 +0900 Subject: [PATCH] Fix: game level manager --- .../typing/word_flyingsaucer/flyingsaucer.js | 27 +++++++--------- .../word_flyingsaucer/game_level_manager.js | 31 +++++++++++++------ .../typing/word_flyingsaucer/word_manager.js | 2 +- 3 files changed, 34 insertions(+), 26 deletions(-) diff --git a/src/game/typing/word_flyingsaucer/flyingsaucer.js b/src/game/typing/word_flyingsaucer/flyingsaucer.js index 2fc53dd..0579a68 100644 --- a/src/game/typing/word_flyingsaucer/flyingsaucer.js +++ b/src/game/typing/word_flyingsaucer/flyingsaucer.js @@ -48,7 +48,8 @@ function FlyingSaucer(lineIndex) { FlyingSaucer.prototype.initVariables = function() { this.isActivated = false; this.wordLevel = 0; - this.wordScore = 0; + this.difficulty = 0; + this.standardScore = 0; this.speed = FlyingSaucer.DEFAULT_SPEED; this.jetStatus = FlyingSaucer.JET_STATUS_HIGH; @@ -100,7 +101,6 @@ FlyingSaucer.prototype.update = function() { if(this.isActivated) { var deltaTime = game.time.elapsed / 1000; this.y += this.speed * deltaTime; - this.wordText.y = this.y + FlyingSaucer.WORD_TEXT_OFFSET_Y; this.updateJetColor(); @@ -166,11 +166,10 @@ FlyingSaucer.prototype.stop = function() { FlyingSaucer.prototype.setActive = function(isActivated) { this.isActivated = isActivated; - if(this.isActivated) { + if(this.isActivated) this.alpha = 1; - } else { + else this.alpha = 0; - } } FlyingSaucer.prototype.moveInitialPos = function() { @@ -191,10 +190,11 @@ FlyingSaucer.prototype.moveInitialPos = function() { FlyingSaucer.prototype.startAttack = function() { this.wordLevel = this.gameLevelManager.getWordLevel(); - this.word = this.wordManager.getWord(this.wordLevel); + this.difficulty = this.gameLevelManager.getDifficulty(); + this.word = this.wordManager.getWord(this.wordLevel, this.difficulty); this.setWord(this.word); - this.wordScore = this.gameLevelManager.getWordScore(); - // console.log(this.wordScore); + this.standardScore = this.gameLevelManager.getStandardScore(this.wordLevel, this.speed); + // console.log(this.standardScore); this.moveInitialPos(); this.setActive(true); @@ -203,7 +203,6 @@ FlyingSaucer.prototype.startAttack = function() { FlyingSaucer.prototype.checkInputText = function(inputText) { // console.log("inputText : " + inputText); // console.log("this.wordText : " + this.wordText); - this.wordText.clearColors(); this.wordText.addColor(FlyingSaucer.TEXT_COLOR_NORMAL, 0); @@ -217,11 +216,6 @@ FlyingSaucer.prototype.checkInputText = function(inputText) { var index = 0; for(; index < inputTextLength; index++) { - // console.log("i : " + index); - // console.log("inputTextLength : " + inputTextLength); - // console.log("inputText.charAt(i) : " + inputText.charAt(index)); - // console.log("this.wordText.text.charAt(i) : " + this.wordText.text.charAt(index)); - if(index == 0 && word.charAt(index) == inputText.charAt(index)) { this.wordText.addColor(FlyingSaucer.TEXT_COLOR_CORRECT, index); } else if(word.charAt(index) != inputText.charAt(index)) { @@ -266,9 +260,9 @@ FlyingSaucer.prototype.explode = function(inputText) { } FlyingSaucer.prototype.plusScore = function(inputText) { - // console.log(this.wordScore); + // console.log(this.standardScore); // console.log(this.getLandingRatio()); - var totalScore = Math.floor(this.wordScore * (this.getLandingRatio() * 100)); + var totalScore = Math.floor(this.standardScore * this.getLandingRatio()); this.scoreManager.plusScore(totalScore); var scoreText = new ScoreText(this.x, this.y, totalScore); } @@ -284,6 +278,7 @@ FlyingSaucer.prototype.destroy = function() { } + FlyingSaucer.loadResource = function() { if(!game.cache.checkImageKey('alien_normal')) game.load.image('alien_normal', '../../../resources/image/character/alien/green_alien.png'); diff --git a/src/game/typing/word_flyingsaucer/game_level_manager.js b/src/game/typing/word_flyingsaucer/game_level_manager.js index 34021a6..e423d7e 100644 --- a/src/game/typing/word_flyingsaucer/game_level_manager.js +++ b/src/game/typing/word_flyingsaucer/game_level_manager.js @@ -8,21 +8,34 @@ GameLevelManager.prototype.getWordLevel = function() { return this.wordLevel; } -GameLevelManager.prototype.getWordScore = function() { - return this.wordLevel * this.difficulty; +GameLevelManager.prototype.getDifficulty = function() { + return this.difficulty; +} + +GameLevelManager.prototype.getStandardScore = function(wordLevel, speed) { + return wordLevel * speed; } -GameLevelManager.prototype.clearWord = function(wordLevel, clearTiming) { +GameLevelManager.prototype.clearWord = function(wordLevel, landingRatio) { // console.log("wordLevel : " + wordLevel); // console.log("clearTiming : " + clearTiming); - - if(this.wordLevel == wordLevel && clearTiming > 0.9) { - if(this.wordLevel < GameLevelManager.MAX_KOR_WORD_LEVEL) - this.wordLevel++; - - // console.log("this.wordLevel : " + this.wordLevel); + if(this.wordLevel == GameLevelManager.MAX_KOR_WORD_LEVEL || wordLevel < this.wordLevel) { + this.difficulty++; + return; } + + if(landingRatio < GameLevelManager.LEVEL_UP_LANDING_RATIO) { + this.difficulty++; + return; + } + + this.goNextWordLevel(); +} + +GameLevelManager.prototype.goNextWordLevel = function() { + this.wordLevel++; + this.difficulty = 1; } diff --git a/src/game/typing/word_flyingsaucer/word_manager.js b/src/game/typing/word_flyingsaucer/word_manager.js index ff0959c..50938be 100644 --- a/src/game/typing/word_flyingsaucer/word_manager.js +++ b/src/game/typing/word_flyingsaucer/word_manager.js @@ -7,7 +7,7 @@ function WordManager() { this.wordIndex = 0; } -WordManager.prototype.getWord = function(wordLevel) { +WordManager.prototype.getWord = function(wordLevel, difficulty) { this.wordIndex = 1 - this.wordIndex; return this.wordList[this.wordIndex]; }