Fix: game level manager

This commit is contained in:
2019-01-06 09:02:52 +09:00
parent a89ff91db5
commit 3055fd3201
3 changed files with 34 additions and 26 deletions
@@ -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');
@@ -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;
}
@@ -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];
}