Fix: go next word level with timing
This commit is contained in:
@@ -34,6 +34,8 @@ function FlyingSaucer(lineIndex) {
|
|||||||
var shipBody = this.makeShipBody(0, BODY_OFFSET_Y);
|
var shipBody = this.makeShipBody(0, BODY_OFFSET_Y);
|
||||||
this.addChild(shipBody);
|
this.addChild(shipBody);
|
||||||
|
|
||||||
|
this.explodeEmitter = this.makeExplodeEmitter();
|
||||||
|
|
||||||
|
|
||||||
var style = { font: "20px Arial", fill: FlyingSaucer.TEXT_COLOR_NORMAL};
|
var style = { font: "20px Arial", fill: FlyingSaucer.TEXT_COLOR_NORMAL};
|
||||||
this.wordText = game.add.text(0, 0, "text", style);
|
this.wordText = game.add.text(0, 0, "text", style);
|
||||||
@@ -46,7 +48,7 @@ function FlyingSaucer(lineIndex) {
|
|||||||
FlyingSaucer.prototype.initVariables = function() {
|
FlyingSaucer.prototype.initVariables = function() {
|
||||||
this.isActivated = false;
|
this.isActivated = false;
|
||||||
this.wordLevel = 0;
|
this.wordLevel = 0;
|
||||||
this.score = 0;
|
this.wordScore = 0;
|
||||||
this.speed = FlyingSaucer.DEFAULT_SPEED;
|
this.speed = FlyingSaucer.DEFAULT_SPEED;
|
||||||
|
|
||||||
this.scoreManager = null;
|
this.scoreManager = null;
|
||||||
@@ -81,6 +83,17 @@ FlyingSaucer.prototype.makeShipBody = function(posX, posY) {
|
|||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FlyingSaucer.prototype.makeExplodeEmitter = function() {
|
||||||
|
explodeEmitter = game.add.emitter(this.x, this.y, 10);
|
||||||
|
explodeEmitter.makeParticles('star');
|
||||||
|
explodeEmitter.minParticleScale = 1;
|
||||||
|
explodeEmitter.maxParticleScale = 3;
|
||||||
|
explodeEmitter.forEach( function(particle) { particle.tint = 0xadff2f; } );
|
||||||
|
explodeEmitter.gravity = 0;
|
||||||
|
|
||||||
|
return explodeEmitter;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
FlyingSaucer.prototype.update = function() {
|
FlyingSaucer.prototype.update = function() {
|
||||||
if(this.isActivated) {
|
if(this.isActivated) {
|
||||||
@@ -89,7 +102,7 @@ FlyingSaucer.prototype.update = function() {
|
|||||||
|
|
||||||
this.wordText.y = this.y + FlyingSaucer.WORD_TEXT_OFFSET_Y;
|
this.wordText.y = this.y + FlyingSaucer.WORD_TEXT_OFFSET_Y;
|
||||||
|
|
||||||
if(this.y > GAME_SCREEN_SIZE.y - 200)
|
if(this.y > FlyingSaucer.CRASH_POS_Y)
|
||||||
this.crash();
|
this.crash();
|
||||||
} else {
|
} else {
|
||||||
this.stop();
|
this.stop();
|
||||||
@@ -136,28 +149,22 @@ FlyingSaucer.prototype.setActive = function(isActivated) {
|
|||||||
|
|
||||||
FlyingSaucer.prototype.moveInitialPos = function() {
|
FlyingSaucer.prototype.moveInitialPos = function() {
|
||||||
this.x = 100 + this.lineIndex * 200;
|
this.x = 100 + this.lineIndex * 200;
|
||||||
this.y = 100;
|
this.y = FlyingSaucer.START_POS_Y;
|
||||||
|
|
||||||
this.wordText.x = this.x;
|
this.wordText.x = this.x;
|
||||||
this.wordText.y = this.y + FlyingSaucer.WORD_TEXT_OFFSET_Y;
|
this.wordText.y = this.y + FlyingSaucer.WORD_TEXT_OFFSET_Y;
|
||||||
this.wordText.clearColors();
|
this.wordText.clearColors();
|
||||||
this.wordText.addColor(FlyingSaucer.TEXT_COLOR_NORMAL, 0);
|
this.wordText.addColor(FlyingSaucer.TEXT_COLOR_NORMAL, 0);
|
||||||
|
|
||||||
this.explodeEmitter = game.add.emitter(this.x, this.y, 10);
|
|
||||||
this.explodeEmitter.makeParticles('star');
|
|
||||||
this.explodeEmitter.minParticleScale = 1;
|
|
||||||
this.explodeEmitter.maxParticleScale = 3;
|
|
||||||
this.explodeEmitter.forEach( function(particle) { particle.tint = 0xadff2f; } );
|
|
||||||
this.explodeEmitter.gravity = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FlyingSaucer.prototype.startAttack = function() {
|
FlyingSaucer.prototype.startAttack = function() {
|
||||||
this.moveInitialPos();
|
this.moveInitialPos();
|
||||||
var wordLevel = this.gameLevelManager.getWordLevel();
|
this.wordLevel = this.gameLevelManager.getWordLevel();
|
||||||
var word = this.wordManager.getWord(wordLevel);
|
this.word = this.wordManager.getWord(this.wordLevel);
|
||||||
this.setWord(word);
|
this.setWord(this.word);
|
||||||
this.score = this.gameLevelManager.getWordScore();
|
this.wordScore = this.gameLevelManager.getWordScore();
|
||||||
|
// console.log(this.wordScore);
|
||||||
this.setActive(true);
|
this.setActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,13 +197,21 @@ FlyingSaucer.prototype.checkInputText = function(inputText) {
|
|||||||
this.wordText.addColor(FlyingSaucer.TEXT_COLOR_NORMAL, index);
|
this.wordText.addColor(FlyingSaucer.TEXT_COLOR_NORMAL, index);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FlyingSaucer.prototype.getClearTiming = function(inputText) {
|
||||||
|
var heightDown = FlyingSaucer.CRASH_POS_Y - FlyingSaucer.START_POS_Y;
|
||||||
|
var distanceDown = this.y - FlyingSaucer.START_POS_Y;
|
||||||
|
return (heightDown - distanceDown) / heightDown;
|
||||||
|
}
|
||||||
|
|
||||||
FlyingSaucer.prototype.checkWord = function(inputText) {
|
FlyingSaucer.prototype.checkWord = function(inputText) {
|
||||||
// console.log("inputText : " + inputText);
|
// console.log("inputText : " + inputText);
|
||||||
// console.log("this.wordText : " + this.wordText);
|
// console.log("this.wordText : " + this.wordText);
|
||||||
|
|
||||||
var word = this.wordText.text;
|
// var word = this.wordText.text;
|
||||||
|
|
||||||
if(word == inputText) {
|
if(this.word == inputText) {
|
||||||
|
this.gameLevelManager.clearWord(this.wordLevel, this.getClearTiming());
|
||||||
|
this.wordManager.removeWord(this.wordLevel, this.word);
|
||||||
this.setWord("");
|
this.setWord("");
|
||||||
this.setActive(false);
|
this.setActive(false);
|
||||||
|
|
||||||
@@ -207,13 +222,19 @@ FlyingSaucer.prototype.checkWord = function(inputText) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
FlyingSaucer.prototype.explode = function(inputText) {
|
FlyingSaucer.prototype.explode = function(inputText) {
|
||||||
|
this.explodeEmitter.x = this.x;
|
||||||
|
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);
|
this.timerEvent = game.time.events.add(Phaser.Timer.SECOND, this.startAttack, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
FlyingSaucer.prototype.plusScore = function(inputText) {
|
FlyingSaucer.prototype.plusScore = function(inputText) {
|
||||||
this.scoreManager.plusScore(this.score);
|
console.log(this.wordScore);
|
||||||
var scoreText = new ScoreText(this.x, this.y, this.score);
|
console.log(this.getClearTiming());
|
||||||
|
var totalScore = Math.floor(this.wordScore * (this.getClearTiming() * 100));
|
||||||
|
this.scoreManager.plusScore(totalScore);
|
||||||
|
var scoreText = new ScoreText(this.x, this.y, totalScore);
|
||||||
}
|
}
|
||||||
|
|
||||||
FlyingSaucer.prototype.crash = function() {
|
FlyingSaucer.prototype.crash = function() {
|
||||||
@@ -243,7 +264,10 @@ FlyingSaucer.loadResource = function() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
FlyingSaucer.DEFAULT_SPEED = 10; // dot per sec
|
FlyingSaucer.DEFAULT_SPEED = 10; // dot per sec
|
||||||
|
|
||||||
|
FlyingSaucer.START_POS_Y = 100; // px
|
||||||
|
FlyingSaucer.CRASH_POS_Y = GAME_SCREEN_SIZE.y - 200; // px
|
||||||
|
|
||||||
FlyingSaucer.WORD_TEXT_OFFSET_Y = 30; // px
|
FlyingSaucer.WORD_TEXT_OFFSET_Y = 30; // px
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,31 @@
|
|||||||
function GameLevelManager() {
|
function GameLevelManager() {
|
||||||
|
this.wordLevel = 1;
|
||||||
|
this.difficulty = 1;
|
||||||
|
this.clearPoint = 0.1;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLevelManager.prototype.getWordLevel = function() {
|
GameLevelManager.prototype.getWordLevel = function() {
|
||||||
return 0;
|
return this.wordLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameLevelManager.prototype.getWordScore = function() {
|
GameLevelManager.prototype.getWordScore = function() {
|
||||||
return 10;
|
return this.wordLevel * this.difficulty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// GameLevelManager.HEART_MAX_COUNT = 5;
|
GameLevelManager.prototype.clearWord = function(wordLevel, clearTiming) {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GameLevelManager.LEVELUP_TIMING = 0.9;
|
||||||
|
|
||||||
|
GameLevelManager.MAX_KOR_WORD_LEVEL = 7;
|
||||||
@@ -13,6 +13,7 @@ WordManager.prototype.getWord = function(wordLevel) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
WordManager.prototype.removeWord = function(wordLevel, word) {
|
WordManager.prototype.removeWord = function(wordLevel, word) {
|
||||||
|
console.log("remove : " + wordLevel + ", " + word);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user