Fix: move burn black meat to the trash can

This commit is contained in:
2019-12-10 20:46:43 +09:00
parent fd13296cdf
commit f1c4d918a8
9 changed files with 147 additions and 64 deletions
+58 -48
View File
@@ -40,10 +40,16 @@ var Game = {
);
this.setClickEnable(false);
this.stageTimer = new StageTimer(
Game.GAME_TIME_SEC,
this.makeStageTimerText();
this.realtimeStageTimer = new RealtimeStageTimer(Game.GAME_TIME_SEC);
this.realtimeStageTimer.setTimeUpdateEvent(
(function(timeLeftSec) {
this.textTimer.text = TimeUtil.printHHMMSSFromSec(timeLeftSec);
}).bind(this)
);
this.realtimeStageTimer.setTimeOverEvent(
(function() {
this.setClickEnable(false);
this.textTimer.text = "타임 오버";
this.timeOver();
}).bind(this)
);
@@ -62,11 +68,6 @@ var Game = {
this.meatPlate.anchor.set(0.5);
this.meatPlate.smoothed = false;
// this.heatPlate = game.add.image(game.world.centerX, HeatPlate.POSITION_Y, 'heat_plate');
// this.heatPlate.anchor.set(0.5);
// this.heatPlate.smoothed = false;
// this.heatPlate.scale.set(1);
this.heatPlate = new HeatPlate();
this.stoveDial = new StoveDial(80, Game.HEAT_PLATE_POSITION_Y + 70);
this.stoveDial.setOnChangeDialLevelHandler(
@@ -75,9 +76,12 @@ var Game = {
this.trashCan = new TrashCan();
this.god = new God(God.POSITION_X, God.POSITION_Y, this);
this.god = new God(this);
// meat
this.bonusMeat = new BonusMeat(this);
this.bonusMeat.setActive(false, -100, -100, "");
this.meatGroup = game.add.group();
for(var i = 0; i < Game.MAX_MEAT_COUNT; i++) {
// var meat = new Meat(this);
@@ -87,8 +91,6 @@ var Game = {
this.meatGroup.add(meat);
}
this.bonusMeat = new BonusMeat(this);
// this.bonusMeat.setActive(false, -100, -100, "");
var experienceAppTimer = new ExperienceAppTimer();
@@ -124,6 +126,19 @@ var Game = {
this.burnLevel = HeatPlate.BURN_LEVEL_WEAK;
},
makeStageTimerText: function() {
var fontStyle = {
font: "38px Arial",
align: "right",
boundsAlignH: "right", // left, center. right
boundsAlignV: "middle", // top, middle, bottom
fill: "#fff"
};
this.textTimer = game.add.text(game.world.width - 300, 0, "", fontStyle)
.setTextBounds(0, 0, 200, 70);
this.textTimer.text = "";
},
onChangeDialLevel: function(dialLevel) {
this.burnLevel = dialLevel;
@@ -170,13 +185,14 @@ var Game = {
this.playingStageNo = 1;
this.startStage();
this.stageTimer.start();
// this.stageTimer.start();
this.realtimeStageTimer.start();
},
startStage: function() {
this.clearedMeatCount = 0;
this.badMeatCount = 0;
console.log("badMeatCount : " + this.badMeatCount);
this.activatedMeatCount = this.getStageMeatCount();
this.serveMeats();
},
@@ -191,6 +207,12 @@ var Game = {
},
serveMeats: function() {
if(this.playingStageNo > 1 && this.badMeatCount == 0 && this.bonusMeat.isActivate() == false) {
var randX = this.meatPlate.x - game.rnd.integerInRange(-100, 100);
var randY = this.meatPlate.y - game.rnd.integerInRange(-30, 30);
this.bonusMeat.setActive(true, randX, randY, "");
}
for(var i = 0; i < Game.MAX_MEAT_COUNT; i++) {
var meat = this.meatGroup.children[i];
meat.setActive(false, -100, -100, "");
@@ -258,25 +280,20 @@ var Game = {
},
godEatMeat: function(meat) {
// console.log("isOverGod : " + x + ", " + y + ", " + width + ", " + height);
// console.log("god eat : " + meat);
// console.log("meat grade : " + meat.getMeatGrade());
var meatClassName = meat.getClassName();
if(meat.getMeatGrade() == MeatBase.DONENESS_WELLDONE) {
// this.god.animateHappy(MeatBase.DONENESS_WELLDONE, meatClassName, meat.getTotalCookingTime());
this.god.animateHappy(meat);
// var score = this.getScore();
var score = meat.getScore();
this.scoreManager.plusScore(score);
var tempPlusScore = new PlusScore(this.god.x, this.god.y - 250, score);
this.plusScoreGroup.add(tempPlusScore);
} else if(meat.getMeatGrade() == MeatBase.DONENESS_RARE) {
// this.god.animateAngryWithRare(MeatBase.DONENESS_RARE, meatClassName, meat.getTotalCookingTime());
this.badMeatCount++;
console.log("badMeatCount : " + this.badMeatCount);
this.god.animateAngryWithRare(meat);
// var score = this.getScore();
@@ -287,18 +304,11 @@ var Game = {
var tempPlusScore = new PlusScore(this.god.x, this.god.y - 250, score);
this.plusScoreGroup.add(tempPlusScore);
}
} else {
} else { // meat is burn black
this.badMeatCount++;
console.log("badMeatCount : " + this.badMeatCount);
// this.god.animateAngryWithBurnBlack(MeatBase.DONENESS_BURN_BLACK, meatClassName, meat.getTotalCookingTime());
this.god.animateAngryWithBurnBlack(meat);
/*
if(meat.getMeatGrade() == MeatBase.DONENESS_RARE) {
this.god.animateAngry(MeatBase.DONENESS_RARE); // "날고기 싫어!!!");
} else { // MeatBase.DONENESS_BURN_BLACK
this.god.animateAngry(MeatBase.DONENESS_BURN_BLACK); // "탄 고기 안먹어!!!");
}
*/
return; // god doesn't eat burned black meat
}
@@ -314,8 +324,6 @@ var Game = {
},
isOverTrashCan: function(x, y) {
// console.log("isOverTrashCan : " + x + ", " + y + ", " + width + ", " + height);
var trashCanHalfWidth = this.trashCan.width / 2;
var trashCanHalfHeight = this.trashCan.height;
@@ -333,29 +341,31 @@ var Game = {
},
throwAway: function(meat) {
// console.log("throw meat");
if(meat.getMeatGrade() == MeatBase.DONENESS_BURN_BLACK) {
this.trashCan.animateAngry();
meat.setActive(false, -100, -100, '');
if(meat.getMeatGrade() != MeatBase.DONENESS_BURN_BLACK)
return;
var score = meat.getScore();
this.scoreManager.plusScore(score);
this.badMeatCount++;
console.log("badMeatCount : " + this.badMeatCount);
var tempPlusScore = new PlusScore(this.trashCan.x, this.trashCan.y - 250, score);
this.plusScoreGroup.add(tempPlusScore);
this.trashCan.animateAngry();
meat.setActive(false, -100, -100, '');
var meatClassName = meat.getClassName();
if(meatClassName == NormalMeat.CLASS_NAME) {
this.clearedMeatCount++;
if(this.clearedMeatCount == this.activatedMeatCount) {
this.clearStage();
}
var score = meat.getScore();
this.scoreManager.plusScore(score);
var tempPlusScore = new PlusScore(this.trashCan.x, this.trashCan.y - 180, score);
this.plusScoreGroup.add(tempPlusScore);
if(meat.getClassName() == NormalMeat.CLASS_NAME) {
this.clearedMeatCount++;
if(this.clearedMeatCount == this.activatedMeatCount) {
this.clearStage();
}
}
},
clearStage: function() {
this.stageTimer.addBonusTime(this.getBonusTime());
// this.stageTimer.addBonusTime(this.getBonusTime());
this.playingStageNo++;
@@ -409,7 +419,7 @@ var Game = {
}
Game.GAME_TIME_SEC = 60;
Game.GAME_TIME_SEC = 90;
Game.NEXT_STAGE_DELAY_MS = 500;
Game.MAX_MEAT_COUNT = 20;