Fix: apply random word level

This commit is contained in:
2019-01-06 21:41:46 +09:00
parent 113fb37f04
commit 6806410780
3 changed files with 43 additions and 14 deletions
+5
View File
@@ -9,6 +9,11 @@ function ScoreText(x, y, score) {
else if(scoreValue < 0) else if(scoreValue < 0)
Phaser.Text.call(this, game, x, y, NumberUtil.numberWithCommas(score), ScoreText.DEFAULT_TEXT_FONT); 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.anchor.set(0.5);
this.inputEnabled = false; this.inputEnabled = false;
@@ -190,7 +190,7 @@ FlyingSaucer.prototype.moveInitialPos = function() {
FlyingSaucer.prototype.startAttack = function() { FlyingSaucer.prototype.startAttack = function() {
this.wordLevel = this.gameLevelManager.getWordLevel(); this.wordLevel = this.gameLevelManager.getWordLevel();
this.difficultyForLevel = this.gameLevelManager.getDifficultyForLevel(); this.difficultyForLevel = this.gameLevelManager.getDifficultyForLevel(this.wordLevel);
// console.log("===="); // console.log("====");
// console.log("this.wordLevel : " + this.wordLevel); // console.log("this.wordLevel : " + this.wordLevel);
// console.log("this.difficultyForLevel : " + this.difficultyForLevel); // console.log("this.difficultyForLevel : " + this.difficultyForLevel);
@@ -205,6 +205,9 @@ FlyingSaucer.prototype.startAttack = function() {
} }
FlyingSaucer.prototype.checkInputText = function(inputText) { FlyingSaucer.prototype.checkInputText = function(inputText) {
if(!this.isActivated)
return;
// console.log("inputText : " + inputText); // console.log("inputText : " + inputText);
// console.log("this.wordText : " + this.wordText); // console.log("this.wordText : " + this.wordText);
this.wordText.clearColors(); this.wordText.clearColors();
@@ -237,6 +240,9 @@ FlyingSaucer.prototype.getLandingRatio = function(inputText) {
} }
FlyingSaucer.prototype.checkWord = function(inputText) { FlyingSaucer.prototype.checkWord = function(inputText) {
if(!this.isActivated)
return;
// console.log("inputText : " + inputText); // console.log("inputText : " + inputText);
// console.log("this.wordText : " + this.wordText); // console.log("this.wordText : " + this.wordText);
@@ -260,7 +266,8 @@ FlyingSaucer.prototype.explode = function(inputText) {
this.explodeEmitter.y = this.y; this.explodeEmitter.y = this.y;
this.explodeEmitter.start(true, 1000, null, 100); 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) { FlyingSaucer.prototype.plusScore = function(inputText) {
@@ -277,6 +284,9 @@ FlyingSaucer.prototype.crash = function() {
} }
FlyingSaucer.prototype.destroy = function() { FlyingSaucer.prototype.destroy = function() {
if(this.timerEvent)
game.time.events.remove(this.timerEvent);
this.setActive(false); this.setActive(false);
this.setWord(""); this.setWord("");
} }
@@ -9,11 +9,12 @@ function GameLevelManager() {
} }
GameLevelManager.prototype.getWordLevel = function() { GameLevelManager.prototype.getWordLevel = function() {
return this.wordLevel; var randomLevel = Math.floor(Math.random() * (this.wordLevel + 1));
return randomLevel;
} }
GameLevelManager.prototype.getDifficultyForLevel = function() { GameLevelManager.prototype.getDifficultyForLevel = function(wordLevel) {
return this.difficultyForLevelList[this.wordLevel]; return this.difficultyForLevelList[wordLevel];
} }
GameLevelManager.prototype.getStandardScore = function(wordLevel, speed) { 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("difficultyForLevelList[" + i + "] : " + this.difficultyForLevelList[i]);
// } // }
// console.log("wordLevel : " + wordLevel); console.log("wordLevel : " + wordLevel);
// console.log("landingRatio : " + landingRatio); console.log("landingRatio : " + landingRatio);
if(this.wordLevel == GameLevelManager.MAX_WORD_LEVEL || wordLevel < this.wordLevel) {
this.increaseClearedWordCountForLevel(wordLevel); this.increaseClearedWordCountForLevel(wordLevel);
if(this.wordLevel == GameLevelManager.MAX_WORD_LEVEL) {
console.log("*** no more higher word level");
return; return;
} }
if(wordLevel < this.wordLevel || landingRatio < GameLevelManager.LEVEL_UP_LANDING_RATIO) { if(wordLevel < this.wordLevel) {
this.increaseClearedWordCountForLevel(wordLevel); console.log("*** already goNextLevel");
return;
}
if(landingRatio < GameLevelManager.LEVEL_UP_LANDING_RATIO) {
console.log("*** not enough ratio");
return; return;
} }
@@ -43,7 +52,12 @@ GameLevelManager.prototype.clearWord = function(wordLevel, landingRatio) {
} }
GameLevelManager.prototype.increaseClearedWordCountForLevel = function(wordLevel) { 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 difficulty = this.difficultyForLevelList[wordLevel];
var clearedWordCount = this.clearedWordCountForLevel[wordLevel]; var clearedWordCount = this.clearedWordCountForLevel[wordLevel];
@@ -58,7 +72,7 @@ GameLevelManager.prototype.increaseClearedWordCountForLevel = function(wordLevel
&& clearedWordCount >= clearedWordCountForNextLevel) { && clearedWordCount >= clearedWordCountForNextLevel) {
this.difficultyForLevelList[wordLevel] = ExtractWordManager.DIFFICULTY_HARD; 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.WARNING_LANDING_RATIO = 0.1;
GameLevelManager.MAX_WORD_LEVEL = 6; GameLevelManager.MAX_WORD_LEVEL = 6;