diff --git a/src/game/lib/text/score_text.js b/src/game/lib/text/score_text.js index 3632d32..cd6d7f9 100644 --- a/src/game/lib/text/score_text.js +++ b/src/game/lib/text/score_text.js @@ -9,6 +9,11 @@ function ScoreText(x, y, score) { else if(scoreValue < 0) Phaser.Text.call(this, game, x, y, NumberUtil.numberWithCommas(score), ScoreText.DEFAULT_TEXT_FONT); + if(this == undefined) { + this.destroy(); + return; + } + this.anchor.set(0.5); this.inputEnabled = false; diff --git a/src/game/typing/word_flyingsaucer/flyingsaucer.js b/src/game/typing/word_flyingsaucer/flyingsaucer.js index 69d6458..5ae505c 100644 --- a/src/game/typing/word_flyingsaucer/flyingsaucer.js +++ b/src/game/typing/word_flyingsaucer/flyingsaucer.js @@ -190,7 +190,7 @@ FlyingSaucer.prototype.moveInitialPos = function() { FlyingSaucer.prototype.startAttack = function() { this.wordLevel = this.gameLevelManager.getWordLevel(); - this.difficultyForLevel = this.gameLevelManager.getDifficultyForLevel(); + this.difficultyForLevel = this.gameLevelManager.getDifficultyForLevel(this.wordLevel); // console.log("===="); // console.log("this.wordLevel : " + this.wordLevel); // console.log("this.difficultyForLevel : " + this.difficultyForLevel); @@ -205,6 +205,9 @@ FlyingSaucer.prototype.startAttack = function() { } FlyingSaucer.prototype.checkInputText = function(inputText) { + if(!this.isActivated) + return; + // console.log("inputText : " + inputText); // console.log("this.wordText : " + this.wordText); this.wordText.clearColors(); @@ -237,6 +240,9 @@ FlyingSaucer.prototype.getLandingRatio = function(inputText) { } FlyingSaucer.prototype.checkWord = function(inputText) { + if(!this.isActivated) + return; + // console.log("inputText : " + inputText); // console.log("this.wordText : " + this.wordText); @@ -260,7 +266,8 @@ FlyingSaucer.prototype.explode = function(inputText) { this.explodeEmitter.y = this.y; this.explodeEmitter.start(true, 1000, null, 100); - this.timerEvent = game.time.events.add(Phaser.Timer.SECOND, this.startAttack, this); + var randomDelayTime = Phaser.Timer.SECOND + Math.random() * Phaser.Timer.SECOND; + this.timerEvent = game.time.events.add(randomDelayTime, this.startAttack, this); } FlyingSaucer.prototype.plusScore = function(inputText) { @@ -277,6 +284,9 @@ FlyingSaucer.prototype.crash = function() { } FlyingSaucer.prototype.destroy = function() { + if(this.timerEvent) + game.time.events.remove(this.timerEvent); + this.setActive(false); this.setWord(""); } diff --git a/src/game/typing/word_flyingsaucer/game_level_manager.js b/src/game/typing/word_flyingsaucer/game_level_manager.js index 495ea46..3c7b2a4 100644 --- a/src/game/typing/word_flyingsaucer/game_level_manager.js +++ b/src/game/typing/word_flyingsaucer/game_level_manager.js @@ -9,11 +9,12 @@ function GameLevelManager() { } GameLevelManager.prototype.getWordLevel = function() { - return this.wordLevel; + var randomLevel = Math.floor(Math.random() * (this.wordLevel + 1)); + return randomLevel; } -GameLevelManager.prototype.getDifficultyForLevel = function() { - return this.difficultyForLevelList[this.wordLevel]; +GameLevelManager.prototype.getDifficultyForLevel = function(wordLevel) { + return this.difficultyForLevelList[wordLevel]; } GameLevelManager.prototype.getStandardScore = function(wordLevel, speed) { @@ -27,15 +28,23 @@ GameLevelManager.prototype.clearWord = function(wordLevel, landingRatio) { // console.log("difficultyForLevelList[" + i + "] : " + this.difficultyForLevelList[i]); // } - // console.log("wordLevel : " + wordLevel); - // console.log("landingRatio : " + landingRatio); - if(this.wordLevel == GameLevelManager.MAX_WORD_LEVEL || wordLevel < this.wordLevel) { - this.increaseClearedWordCountForLevel(wordLevel); + console.log("wordLevel : " + wordLevel); + console.log("landingRatio : " + landingRatio); + + this.increaseClearedWordCountForLevel(wordLevel); + + if(this.wordLevel == GameLevelManager.MAX_WORD_LEVEL) { + console.log("*** no more higher word level"); return; } - if(wordLevel < this.wordLevel || landingRatio < GameLevelManager.LEVEL_UP_LANDING_RATIO) { - this.increaseClearedWordCountForLevel(wordLevel); + if(wordLevel < this.wordLevel) { + console.log("*** already goNextLevel"); + return; + } + + if(landingRatio < GameLevelManager.LEVEL_UP_LANDING_RATIO) { + console.log("*** not enough ratio"); return; } @@ -43,7 +52,12 @@ GameLevelManager.prototype.clearWord = function(wordLevel, landingRatio) { } GameLevelManager.prototype.increaseClearedWordCountForLevel = function(wordLevel) { - this.clearedWordCountForLevel[wordLevel]++; + this.clearedWordCountForLevel[wordLevel] += 1; + + // console.log("===="); + // for(var i = 0; i < this.clearedWordCountForLevel.length; i++) { + // console.log("clearedWordCountForLevel[" + i + "] : " + this.clearedWordCountForLevel[i]); + // } var difficulty = this.difficultyForLevelList[wordLevel]; var clearedWordCount = this.clearedWordCountForLevel[wordLevel]; @@ -58,7 +72,7 @@ GameLevelManager.prototype.increaseClearedWordCountForLevel = function(wordLevel && clearedWordCount >= clearedWordCountForNextLevel) { this.difficultyForLevelList[wordLevel] = ExtractWordManager.DIFFICULTY_HARD; - // console.log("level[" + wordLevel + "] : difficulty -> HARD"); + console.log("level[" + wordLevel + "] : difficulty -> HARD"); } } @@ -68,7 +82,7 @@ GameLevelManager.prototype.goNextWordLevel = function() { } -GameLevelManager.LEVEL_UP_LANDING_RATIO = 0.9; +GameLevelManager.LEVEL_UP_LANDING_RATIO = 0.7; GameLevelManager.WARNING_LANDING_RATIO = 0.1; GameLevelManager.MAX_WORD_LEVEL = 6;