Fix: game level manager
This commit is contained in:
@@ -48,7 +48,8 @@ function FlyingSaucer(lineIndex) {
|
|||||||
FlyingSaucer.prototype.initVariables = function() {
|
FlyingSaucer.prototype.initVariables = function() {
|
||||||
this.isActivated = false;
|
this.isActivated = false;
|
||||||
this.wordLevel = 0;
|
this.wordLevel = 0;
|
||||||
this.wordScore = 0;
|
this.difficulty = 0;
|
||||||
|
this.standardScore = 0;
|
||||||
this.speed = FlyingSaucer.DEFAULT_SPEED;
|
this.speed = FlyingSaucer.DEFAULT_SPEED;
|
||||||
this.jetStatus = FlyingSaucer.JET_STATUS_HIGH;
|
this.jetStatus = FlyingSaucer.JET_STATUS_HIGH;
|
||||||
|
|
||||||
@@ -100,7 +101,6 @@ FlyingSaucer.prototype.update = function() {
|
|||||||
if(this.isActivated) {
|
if(this.isActivated) {
|
||||||
var deltaTime = game.time.elapsed / 1000;
|
var deltaTime = game.time.elapsed / 1000;
|
||||||
this.y += this.speed * deltaTime;
|
this.y += this.speed * deltaTime;
|
||||||
|
|
||||||
this.wordText.y = this.y + FlyingSaucer.WORD_TEXT_OFFSET_Y;
|
this.wordText.y = this.y + FlyingSaucer.WORD_TEXT_OFFSET_Y;
|
||||||
|
|
||||||
this.updateJetColor();
|
this.updateJetColor();
|
||||||
@@ -166,11 +166,10 @@ FlyingSaucer.prototype.stop = function() {
|
|||||||
FlyingSaucer.prototype.setActive = function(isActivated) {
|
FlyingSaucer.prototype.setActive = function(isActivated) {
|
||||||
this.isActivated = isActivated;
|
this.isActivated = isActivated;
|
||||||
|
|
||||||
if(this.isActivated) {
|
if(this.isActivated)
|
||||||
this.alpha = 1;
|
this.alpha = 1;
|
||||||
} else {
|
else
|
||||||
this.alpha = 0;
|
this.alpha = 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FlyingSaucer.prototype.moveInitialPos = function() {
|
FlyingSaucer.prototype.moveInitialPos = function() {
|
||||||
@@ -191,10 +190,11 @@ FlyingSaucer.prototype.moveInitialPos = function() {
|
|||||||
|
|
||||||
FlyingSaucer.prototype.startAttack = function() {
|
FlyingSaucer.prototype.startAttack = function() {
|
||||||
this.wordLevel = this.gameLevelManager.getWordLevel();
|
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.setWord(this.word);
|
||||||
this.wordScore = this.gameLevelManager.getWordScore();
|
this.standardScore = this.gameLevelManager.getStandardScore(this.wordLevel, this.speed);
|
||||||
// console.log(this.wordScore);
|
// console.log(this.standardScore);
|
||||||
|
|
||||||
this.moveInitialPos();
|
this.moveInitialPos();
|
||||||
this.setActive(true);
|
this.setActive(true);
|
||||||
@@ -203,7 +203,6 @@ FlyingSaucer.prototype.startAttack = function() {
|
|||||||
FlyingSaucer.prototype.checkInputText = function(inputText) {
|
FlyingSaucer.prototype.checkInputText = function(inputText) {
|
||||||
// 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();
|
||||||
this.wordText.addColor(FlyingSaucer.TEXT_COLOR_NORMAL, 0);
|
this.wordText.addColor(FlyingSaucer.TEXT_COLOR_NORMAL, 0);
|
||||||
|
|
||||||
@@ -217,11 +216,6 @@ FlyingSaucer.prototype.checkInputText = function(inputText) {
|
|||||||
|
|
||||||
var index = 0;
|
var index = 0;
|
||||||
for(; index < inputTextLength; index++) {
|
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)) {
|
if(index == 0 && word.charAt(index) == inputText.charAt(index)) {
|
||||||
this.wordText.addColor(FlyingSaucer.TEXT_COLOR_CORRECT, index);
|
this.wordText.addColor(FlyingSaucer.TEXT_COLOR_CORRECT, index);
|
||||||
} else if(word.charAt(index) != inputText.charAt(index)) {
|
} else if(word.charAt(index) != inputText.charAt(index)) {
|
||||||
@@ -266,9 +260,9 @@ FlyingSaucer.prototype.explode = function(inputText) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FlyingSaucer.prototype.plusScore = function(inputText) {
|
FlyingSaucer.prototype.plusScore = function(inputText) {
|
||||||
// console.log(this.wordScore);
|
// console.log(this.standardScore);
|
||||||
// console.log(this.getLandingRatio());
|
// 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);
|
this.scoreManager.plusScore(totalScore);
|
||||||
var scoreText = new ScoreText(this.x, this.y, totalScore);
|
var scoreText = new ScoreText(this.x, this.y, totalScore);
|
||||||
}
|
}
|
||||||
@@ -284,6 +278,7 @@ FlyingSaucer.prototype.destroy = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FlyingSaucer.loadResource = function() {
|
FlyingSaucer.loadResource = function() {
|
||||||
if(!game.cache.checkImageKey('alien_normal'))
|
if(!game.cache.checkImageKey('alien_normal'))
|
||||||
game.load.image('alien_normal', '../../../resources/image/character/alien/green_alien.png');
|
game.load.image('alien_normal', '../../../resources/image/character/alien/green_alien.png');
|
||||||
|
|||||||
@@ -8,21 +8,34 @@ GameLevelManager.prototype.getWordLevel = function() {
|
|||||||
return this.wordLevel;
|
return this.wordLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLevelManager.prototype.getWordScore = function() {
|
GameLevelManager.prototype.getDifficulty = function() {
|
||||||
return this.wordLevel * this.difficulty;
|
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("wordLevel : " + wordLevel);
|
||||||
// console.log("clearTiming : " + clearTiming);
|
// console.log("clearTiming : " + clearTiming);
|
||||||
|
if(this.wordLevel == GameLevelManager.MAX_KOR_WORD_LEVEL || wordLevel < this.wordLevel) {
|
||||||
if(this.wordLevel == wordLevel && clearTiming > 0.9) {
|
this.difficulty++;
|
||||||
if(this.wordLevel < GameLevelManager.MAX_KOR_WORD_LEVEL)
|
return;
|
||||||
this.wordLevel++;
|
|
||||||
|
|
||||||
// console.log("this.wordLevel : " + this.wordLevel);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
this.wordIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WordManager.prototype.getWord = function(wordLevel) {
|
WordManager.prototype.getWord = function(wordLevel, difficulty) {
|
||||||
this.wordIndex = 1 - this.wordIndex;
|
this.wordIndex = 1 - this.wordIndex;
|
||||||
return this.wordList[this.wordIndex];
|
return this.wordList[this.wordIndex];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user