Fix: stage timer - add bonus time, smoke particle
This commit is contained in:
@@ -3,6 +3,7 @@ function StageTimer(stageTimerSec, onTimeOver) {
|
||||
this.onTimeOver = onTimeOver;
|
||||
|
||||
this.isPaused = false;
|
||||
this.timeLeft = this.stageTimerSec;
|
||||
|
||||
var fontStyle = StageTimer.DEFAULT_TEXT_FONT;
|
||||
|
||||
@@ -22,6 +23,11 @@ function StageTimer(stageTimerSec, onTimeOver) {
|
||||
// this.label.strokeThickness = 3;
|
||||
|
||||
this.timerEvent = null;
|
||||
|
||||
var textStyle = { font: "bold 64px Arial", fill: "#ff0", align: "center", boundsAlignH: "center", boundsAlignV: "middle" };
|
||||
this.bonusTimeText = game.add.text(game.world.centerX, game.world.centerY, "보너스 타임", textStyle);
|
||||
this.bonusTimeText.anchor.set(0.5);
|
||||
this.bonusTimeText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
};
|
||||
|
||||
StageTimer.prototype.start = function() {
|
||||
@@ -67,11 +73,20 @@ StageTimer.prototype.removeTimer = function() {
|
||||
this.timerEvent = null;
|
||||
}
|
||||
|
||||
StageTimer.prototype.add = function(timeSec) {
|
||||
StageTimer.prototype.addTime = function(timeSec) {
|
||||
this.timeLeft += timeSec;
|
||||
this.printTime();
|
||||
}
|
||||
|
||||
StageTimer.prototype.addBonusTime = function(timeSec) {
|
||||
this.addTime(timeSec);
|
||||
|
||||
game.world.bringToTop(this.bonusTimeText);
|
||||
this.bonusTimeText.text = "+" + timeSec + "초 추가";
|
||||
this.bonusTimeText.alpha = 1;
|
||||
game.add.tween(this.bonusTimeText).to({alpha: 0}, Phaser.Timer.SECOND * 1.5, Phaser.Easing.Quintic.In, true);
|
||||
}
|
||||
|
||||
|
||||
StageTimer.FONT_HEIGHT_PX = 70;
|
||||
|
||||
|
||||
@@ -46,7 +46,6 @@ var Game = {
|
||||
Game.GAME_TIME_SEC,
|
||||
(function() {
|
||||
this.setClickEnable(false);
|
||||
this.showStageNotice("시간 종료");
|
||||
this.gameOver();
|
||||
}).bind(this)
|
||||
);
|
||||
@@ -60,11 +59,6 @@ var Game = {
|
||||
|
||||
this.plusScoreGroup = game.add.group();
|
||||
|
||||
var textStyle = { font: "bold 32px Arial", fill: "#fff", align: "center", boundsAlignH: "center", boundsAlignV: "middle" };
|
||||
this.stageNoticeText = game.add.text(0, 0, "", textStyle);
|
||||
this.stageNoticeText.setShadow(3, 3, 'rgba(0, 0, 0, 0.5)', 2);
|
||||
this.stageNoticeText.setTextBounds(0, 60, 1000, 80);
|
||||
|
||||
var table = game.add.tileSprite(0, 340, GAME_SCREEN_SIZE.x, 660, 'wooden_table');
|
||||
this.meatPlate = game.add.image(220, Game.MEAT_PLATE_POSITION_Y, 'plate');
|
||||
this.meatPlate.anchor.set(0.5);
|
||||
@@ -107,25 +101,12 @@ var Game = {
|
||||
this.activatedMeatCount;
|
||||
this.clearedMeatCount;
|
||||
|
||||
// this.score;
|
||||
// this.scoreText;
|
||||
// this.highscore;
|
||||
// this.highscoreText;
|
||||
this.plusScoreTextGroup;
|
||||
this.stageNoticeText;
|
||||
|
||||
this.popup;
|
||||
this.popupTween = null;
|
||||
this.startButton;
|
||||
|
||||
// this.leftTimeText;
|
||||
// this.leftTimeSec;
|
||||
|
||||
this.timeEvent;
|
||||
this.gameTimeEvents = [];
|
||||
|
||||
this.meatCount;
|
||||
|
||||
},
|
||||
|
||||
|
||||
@@ -170,32 +151,16 @@ var Game = {
|
||||
this.playingStageNo = 1;
|
||||
|
||||
this.startStage();
|
||||
this.stageTimer.start();
|
||||
|
||||
},
|
||||
|
||||
startStage: function() {
|
||||
var bonusTime = this.getBonusTime();
|
||||
this.showStageNotice(this.playingStageNo + "단계 시작 (제한 시간 : " + bonusTime + "초)");
|
||||
|
||||
this.clearedMeatCount = 0;
|
||||
this.activatedMeatCount = this.getStageMeatCount();
|
||||
this.serveMeats();
|
||||
|
||||
this.stageTimer.start();
|
||||
},
|
||||
|
||||
startNextStage: function() {
|
||||
var bonusTime = this.getBonusTime();
|
||||
if(bonusTime == 0)
|
||||
this.showStageNotice(this.playingStageNo + "단계 시작");
|
||||
else
|
||||
this.showStageNotice(this.playingStageNo + "단계 시작 (보너스 +" + bonusTime + "초)");
|
||||
|
||||
this.clearedMeatCount = 0;
|
||||
this.activatedMeatCount = this.getStageMeatCount();
|
||||
this.serveMeats();
|
||||
},
|
||||
|
||||
|
||||
setClickEnable: function(value) {
|
||||
this.isEnableClick = value;
|
||||
},
|
||||
@@ -220,51 +185,11 @@ var Game = {
|
||||
},
|
||||
|
||||
getBonusTime: function() {
|
||||
if(this.playingStageNo == 1)
|
||||
return Game.INIT_LEFT_TIME_MIN * 60;
|
||||
|
||||
var bonusTime = 0;
|
||||
if(this.playingStageNo < 10)
|
||||
bonusTime = Math.floor(10 / this.playingStageNo) * (Game.INIT_LEFT_TIME_MIN * 2);
|
||||
|
||||
return bonusTime;
|
||||
},
|
||||
|
||||
// updateLeftTime: function() {
|
||||
// this.leftTimeSec--;
|
||||
// this.leftTimeText.text = this.leftTimeSec;
|
||||
// if(this.leftTimeSec == 0) {
|
||||
// this.showStageNotice("시간 종료");
|
||||
// this.gameOver();
|
||||
// }
|
||||
// },
|
||||
|
||||
showStageNotice: function(text) {
|
||||
this.stageNoticeText.alpha = 0;
|
||||
this.stageNoticeText.text = text;
|
||||
this.animateTextAlpha(this.stageNoticeText, 1, 0, Phaser.Timer.SECOND * 2, Phaser.Easing.Linear.None);
|
||||
return this.playingStageNo * 4;
|
||||
},
|
||||
|
||||
|
||||
|
||||
// addScore: function() {
|
||||
// // this.score += 10 * this.playingStageNo;
|
||||
// this.scoreManager.addScore(10 * this.playingStageNo);
|
||||
// },
|
||||
|
||||
// updateScore: function() {
|
||||
// this.scoreText.text = this.score;
|
||||
// },
|
||||
|
||||
// updateHighscore: function() {
|
||||
// if(this.score > this.highscore) {
|
||||
// highscore = score;
|
||||
// highscoreText.text = highscore;
|
||||
|
||||
// showStageNotice("!!! 최고 점수 갱신 !!!");
|
||||
// }
|
||||
// },
|
||||
|
||||
isOverHeatPlate: function(x, y, width, height) {
|
||||
var plateHalfWidth = (this.heatPlate.width - Game.HEAT_PLATE_HANDLE_WIDTH) / 2;
|
||||
var plateHalfHeight = this.heatPlate.height / 2;
|
||||
@@ -309,11 +234,10 @@ var Game = {
|
||||
if(meat.getMeatGrade() == Meat.DONENESS_WELLDONE) {
|
||||
this.god.animateHappy(Meat.DONENESS_WELLDONE); // "맛있어♥♡♥");
|
||||
|
||||
// this.addScore();
|
||||
// this.updateScore();
|
||||
this.scoreManager.plusScore(10 * this.playingStageNo);
|
||||
var score = 10 * this.playingStageNo;
|
||||
this.scoreManager.plusScore(score);
|
||||
|
||||
var tempPlusScore = new PlusScore(this.god.x, this.god.y - 180, 10 * this.playingStageNo);
|
||||
var tempPlusScore = new PlusScore(this.god.x, this.god.y - 180, score);
|
||||
this.plusScoreGroup.add(tempPlusScore);
|
||||
} else {
|
||||
if(meat.getMeatGrade() == Meat.DONENESS_RARE) {
|
||||
@@ -331,10 +255,12 @@ var Game = {
|
||||
},
|
||||
|
||||
clearStage: function() {
|
||||
this.showStageNotice(this.playingStageNo + "단계 완료");
|
||||
var bonusTime = this.getBonusTime();
|
||||
this.stageTimer.addBonusTime(bonusTime);
|
||||
|
||||
this.playingStageNo++;
|
||||
|
||||
var startStageTimeEvent = game.time.events.add(Phaser.Timer.SECOND * 1, this.startNextStage, this);
|
||||
var startStageTimeEvent = game.time.events.add(Phaser.Timer.SECOND * 1, this.startStage, this);
|
||||
this.gameTimeEvents[this.gameTimeEvents.length + 1] = startStageTimeEvent;
|
||||
},
|
||||
|
||||
@@ -353,6 +279,10 @@ var Game = {
|
||||
}
|
||||
this.gameTimeEvents = [];
|
||||
|
||||
for(var i = 0; i < Game.MAX_MEAT_COUNT; i++) {
|
||||
this.meatGroup.children[i].hide();
|
||||
}
|
||||
|
||||
var gameOverText = new GameOverText();
|
||||
|
||||
game.time.events.add(Phaser.Timer.SECOND * 2, this.goResult, this);
|
||||
@@ -368,8 +298,6 @@ var Game = {
|
||||
Game.GAME_TIME_SEC = 60;
|
||||
Game.NEXT_STAGE_DELAY_MS = 500;
|
||||
|
||||
Game.INIT_LEFT_TIME_MIN = 2;
|
||||
|
||||
Game.MAX_MEAT_COUNT = 20;
|
||||
|
||||
Game.HEAT_PLATE_HANDLE_WIDTH = 440;
|
||||
|
||||
@@ -1,12 +1,3 @@
|
||||
var ANGLE_NONE = 0;
|
||||
var ANGLE_FRONT = 30;
|
||||
var ANGLE_BACK = -30;
|
||||
|
||||
|
||||
var COOK_TIME_WELLDONE = 200;
|
||||
var COOK_TIME_BURN = 400;
|
||||
|
||||
|
||||
Meat = function(mainGame) {
|
||||
this.mainGame = mainGame;
|
||||
this.cookingSide = Meat.MEAT_NONE;
|
||||
@@ -134,10 +125,8 @@ Meat.prototype.onClickListener = function(pointer) {
|
||||
this.flipToBack()
|
||||
else
|
||||
this.flipToFront();
|
||||
|
||||
// console.log("flip cooking side : " + this.cookingSide);
|
||||
|
||||
// this.stopAnimateSmoke();
|
||||
this.startCook();
|
||||
}
|
||||
}
|
||||
@@ -177,7 +166,7 @@ Meat.prototype.flipToFront = function() {
|
||||
this.cookingSide = Meat.MEAT_BACK;
|
||||
// console.log("flipToFront : " + this.cookingSide);
|
||||
|
||||
this.angle = ANGLE_FRONT;
|
||||
this.angle = Meat.ANGLE_FRONT;
|
||||
// console.log("flipToFront");
|
||||
// console.log("back : " + this.getMeatGradeBySide(Meat.MEAT_BACK) + ", front : " + this.getMeatGradeBySide(Meat.MEAT_FRONT));
|
||||
if(this.getMeatGradeBySide(Meat.MEAT_FRONT) == Meat.DONENESS_BURN_BLACK) {
|
||||
@@ -193,7 +182,7 @@ Meat.prototype.flipToBack = function() {
|
||||
this.cookingSide = Meat.MEAT_FRONT;
|
||||
// console.log("flipToBack : " + this.cookingSide);
|
||||
|
||||
this.angle = ANGLE_BACK;
|
||||
this.angle = Meat.ANGLE_BACK;
|
||||
// console.log("flipToBack");
|
||||
// console.log("back : " + this.getMeatGradeBySide(Meat.MEAT_BACK) + ", front : " + this.getMeatGradeBySide(Meat.MEAT_FRONT));
|
||||
if(this.getMeatGradeBySide(Meat.MEAT_BACK) == Meat.DONENESS_BURN_BLACK) {
|
||||
@@ -266,7 +255,7 @@ Meat.prototype.setActive = function(isActivated, x, y, meat_type) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.loadTexture('meat1');
|
||||
this.angle = ANGLE_NONE;
|
||||
this.angle = Meat.ANGLE_NONE;
|
||||
this.alpha = 1;
|
||||
}
|
||||
|
||||
@@ -274,24 +263,24 @@ Meat.prototype.cooking = function() {
|
||||
this.cookingTime[this.cookingSide] += 1;
|
||||
// console.log("back : " + this.cookingTime[Meat.MEAT_BACK] + ", front : " + this.cookingTime[Meat.MEAT_FRONT]);
|
||||
|
||||
if(this.cookingTime[Meat.MEAT_BACK] > COOK_TIME_BURN) {
|
||||
if(this.cookingTime[Meat.MEAT_BACK] > Meat.COOK_TIME_BURN) {
|
||||
if(this.getMeatGradeBySide(Meat.MEAT_BACK) != Meat.DONENESS_BURN_BLACK) {
|
||||
this.cookingGrade[Meat.MEAT_BACK] = Meat.DONENESS_BURN_BLACK;
|
||||
this.changeAnimateSmokeColor(Meat.DONENESS_BURN_BLACK);
|
||||
}
|
||||
} else if(this.cookingTime[Meat.MEAT_BACK] > COOK_TIME_WELLDONE) {
|
||||
} else if(this.cookingTime[Meat.MEAT_BACK] > Meat.COOK_TIME_WELLDONE) {
|
||||
if(this.getMeatGradeBySide(Meat.MEAT_BACK) != Meat.DONENESS_WELLDONE) {
|
||||
this.cookingGrade[Meat.MEAT_BACK] = Meat.DONENESS_WELLDONE;
|
||||
this.changeAnimateSmokeColor(Meat.DONENESS_WELLDONE);
|
||||
}
|
||||
}
|
||||
|
||||
if(this.cookingTime[Meat.MEAT_FRONT] > COOK_TIME_BURN) {
|
||||
if(this.cookingTime[Meat.MEAT_FRONT] > Meat.COOK_TIME_BURN) {
|
||||
if(this.getMeatGradeBySide(Meat.MEAT_FRONT) != Meat.DONENESS_BURN_BLACK) {
|
||||
this.cookingGrade[Meat.MEAT_FRONT] = Meat.DONENESS_BURN_BLACK;
|
||||
this.changeAnimateSmokeColor(Meat.DONENESS_BURN_BLACK);
|
||||
}
|
||||
} else if(this.cookingTime[Meat.MEAT_FRONT] > COOK_TIME_WELLDONE) {
|
||||
} else if(this.cookingTime[Meat.MEAT_FRONT] > Meat.COOK_TIME_WELLDONE) {
|
||||
if(this.getMeatGradeBySide(Meat.MEAT_FRONT) != Meat.DONENESS_WELLDONE) {
|
||||
this.cookingGrade[Meat.MEAT_FRONT] = Meat.DONENESS_WELLDONE;
|
||||
this.changeAnimateSmokeColor(Meat.DONENESS_WELLDONE);
|
||||
@@ -299,9 +288,6 @@ Meat.prototype.cooking = function() {
|
||||
}
|
||||
}
|
||||
|
||||
Meat.prototype.animateSmoke = function(type) {
|
||||
}
|
||||
|
||||
Meat.prototype.stopAnimateSmoke = function() {
|
||||
this.whiteSmokeParticle.stop();
|
||||
this.redSmokeParticle.stop();
|
||||
@@ -338,9 +324,14 @@ Meat.MEAT_NONE = 0;
|
||||
Meat.MEAT_FRONT = 1;
|
||||
Meat.MEAT_BACK = 2;
|
||||
|
||||
|
||||
|
||||
Meat.DONENESS_RARE = 0;
|
||||
Meat.DONENESS_WELLDONE = 1;
|
||||
Meat.DONENESS_BURN_BLACK = 2;
|
||||
Meat.DONENESS_NONE = 3;
|
||||
Meat.DONENESS_NONE = 3;
|
||||
|
||||
Meat.ANGLE_NONE = 0;
|
||||
Meat.ANGLE_FRONT = 30;
|
||||
Meat.ANGLE_BACK = -30;
|
||||
|
||||
Meat.COOK_TIME_WELLDONE = 200;
|
||||
Meat.COOK_TIME_BURN = 400;
|
||||
@@ -3,13 +3,20 @@ Smoke = function(type, x, y) {
|
||||
// this.emitter = game.add.emitter(game.world.centerX, 500, 200);
|
||||
this.emitter.makeParticles("smoke");
|
||||
|
||||
this.emitter.width = 50;
|
||||
this.emitter.height = 50;
|
||||
this.emitter.setRotation(0, 0);
|
||||
this.emitter.width = 30;
|
||||
this.emitter.height = 30;
|
||||
this.emitter.setRotation(-90, 90);
|
||||
this.emitter.setAlpha(0.3, 0.8);
|
||||
// this.emitter.setScale(0.5, 1);
|
||||
// this.emitter.setScale(0.2, 0.2);
|
||||
this.emitter.minParticleScale = 0.5;
|
||||
this.emitter.maxParticleScale = 1;
|
||||
this.emitter.gravity = -300;
|
||||
this.emitter.start(false, 1000, 100);
|
||||
if(type == Meat.DONENESS_RARE)
|
||||
this.emitter.start(false, 1000, 400);
|
||||
else if(type == Meat.DONENESS_WELLDONE)
|
||||
this.emitter.start(false, 1000, 200);
|
||||
else if(type == Meat.DONENESS_BURN_BLACK)
|
||||
this.emitter.start(false, 1000, 100);
|
||||
this.stop();
|
||||
|
||||
this.changeColor(type);
|
||||
|
||||
Reference in New Issue
Block a user