Fix: god and speech bubble

This commit is contained in:
2019-12-10 10:37:04 +09:00
parent 2448c9fd55
commit dfbe501393
5 changed files with 102 additions and 56 deletions
+17 -15
View File
@@ -91,11 +91,6 @@ var Game = {
// this.bonusMeat.setActive(false, -100, -100, ""); // this.bonusMeat.setActive(false, -100, -100, "");
// speech bubble
this.speechBubble = new SpeechBubble(game.world.centerX + 100, game.world.centerY - 160);
this.speechBubble.hideSpeechBubble();
var experienceAppTimer = new ExperienceAppTimer(); var experienceAppTimer = new ExperienceAppTimer();
experienceAppTimer.setTimeOverListener( experienceAppTimer.setTimeOverListener(
(function() { this.timeOver(); }).bind(this) (function() { this.timeOver(); }).bind(this)
@@ -268,28 +263,35 @@ var Game = {
// console.log("god eat : " + meat); // console.log("god eat : " + meat);
// console.log("meat grade : " + meat.getMeatGrade()); // console.log("meat grade : " + meat.getMeatGrade());
var meatClassName = meat.getClassName();
if(meat.getMeatGrade() == Meat.DONENESS_WELLDONE) { if(meat.getMeatGrade() == Meat.DONENESS_WELLDONE) {
this.god.animateHappy(Meat.DONENESS_WELLDONE); // "맛있어♥♡♥"); // this.god.animateHappy(Meat.DONENESS_WELLDONE, meatClassName, meat.getTotalCookingTime());
this.god.animateHappy(meat);
// var score = this.getScore(); // var score = this.getScore();
var score = meat.getScore(Meat.DONENESS_WELLDONE); var score = meat.getScore();
this.scoreManager.plusScore(score); this.scoreManager.plusScore(score);
var tempPlusScore = new PlusScore(this.god.x, this.god.y - 180, score); var tempPlusScore = new PlusScore(this.god.x, this.god.y - 250, score);
this.plusScoreGroup.add(tempPlusScore); this.plusScoreGroup.add(tempPlusScore);
} else if(meat.getMeatGrade() == Meat.DONENESS_RARE) { } else if(meat.getMeatGrade() == Meat.DONENESS_RARE) {
this.god.animateAngry(Meat.DONENESS_RARE); // "날고기 싫어!!!"); // this.god.animateAngryWithRare(Meat.DONENESS_RARE, meatClassName, meat.getTotalCookingTime());
this.god.animateAngryWithRare(meat);
// var score = this.getScore(); // var score = this.getScore();
var score = meat.getScore(Meat.DONENESS_WELLDONE); if(meat.getTotalCookingTime() > 0) {
this.scoreManager.plusScore(score); var score = meat.getScore();
this.scoreManager.plusScore(score);
var tempPlusScore = new PlusScore(this.god.x, this.god.y - 180, score); var tempPlusScore = new PlusScore(this.god.x, this.god.y - 250, score);
this.plusScoreGroup.add(tempPlusScore); this.plusScoreGroup.add(tempPlusScore);
}
} else { } else {
this.badMeatCount++; this.badMeatCount++;
this.god.animateAngry(Meat.DONENESS_BURN_BLACK); // "탄 고기 안먹어!!!"); // this.god.animateAngryWithBurnBlack(Meat.DONENESS_BURN_BLACK, meatClassName, meat.getTotalCookingTime());
this.god.animateAngryWithBurnBlack(meat);
/* /*
if(meat.getMeatGrade() == Meat.DONENESS_RARE) { if(meat.getMeatGrade() == Meat.DONENESS_RARE) {
this.god.animateAngry(Meat.DONENESS_RARE); // "날고기 싫어!!!"); this.god.animateAngry(Meat.DONENESS_RARE); // "날고기 싫어!!!");
@@ -301,7 +303,7 @@ var Game = {
meat.setActive(false, -100, -100, ''); meat.setActive(false, -100, -100, '');
if(meat.getClassName() == NormalMeat.CLASS_NAME) { if(meatClassName == NormalMeat.CLASS_NAME) {
this.clearedMeatCount++; this.clearedMeatCount++;
if(this.clearedMeatCount == this.activatedMeatCount) { if(this.clearedMeatCount == this.activatedMeatCount) {
this.clearStage(); this.clearStage();
+24 -7
View File
@@ -15,6 +15,9 @@ function God(x, y, mainGame) {
game.add.existing(this); game.add.existing(this);
this.speechBubble = new SpeechBubble();
this.speechBubble.hideSpeechBubble();
this.makeParticles(x, y); this.makeParticles(x, y);
} }
@@ -103,10 +106,10 @@ God.prototype.setScale = function(size) {
} }
God.prototype.animateHappy = function(type) { God.prototype.animateHappy = function(meat) {
this.loadTexture('god_happy'); this.speechBubble.showSpeechBubble(meat);
this.mainGame.speechBubble.showSpeechBubble(type);
this.loadTexture('god_happy');
var tween = game.add.tween(this.scale); var tween = game.add.tween(this.scale);
tween.to({x:0.7, y:0.7}, 500, Phaser.Easing.Quadratic.Out, true, 0); tween.to({x:0.7, y:0.7}, 500, Phaser.Easing.Quadratic.Out, true, 0);
// tween.to({x:0.7, y:0.7}, 1000, Phaser.Easing.Elastic.InOut, true, 0, 2, true); // tween.to({x:0.7, y:0.7}, 1000, Phaser.Easing.Elastic.InOut, true, 0, 2, true);
@@ -117,10 +120,25 @@ God.prototype.animateHappy = function(type) {
this.particleBurst(God.REACTION_HAPPY); this.particleBurst(God.REACTION_HAPPY);
} }
God.prototype.animateAngry = function(type) { God.prototype.animateAngryWithRare = function(meat) {
this.loadTexture('god_angry'); this.speechBubble.showSpeechBubble(meat);
this.mainGame.speechBubble.showSpeechBubble(type);
this.loadTexture('god_angry');
var tween = game.add.tween(this.scale);
tween.to({x:0.7, y:0.7}, 1000, Phaser.Easing.Bounce.Out, true, 0);
// tween.to({x:0.7, y:0.7}, 1000, Phaser.Easing.Elastic.InOut, true, 0, 2, true);
// tween.to({x:0.7, y:0.7}, 1000, Phaser.Easing.Linear.None, true, 0);
tween.onComplete.add(this.smileAgain, this);
tween.start();
if(meat.getTotalCookingTime() == 0)
this.particleBurst(God.REACTION_ANGRY);
}
God.prototype.animateAngryWithBurnBlack = function(meat) {
this.speechBubble.showSpeechBubble(meat);
this.loadTexture('god_angry');
var tween = game.add.tween(this.scale); var tween = game.add.tween(this.scale);
tween.to({x:0.7, y:0.7}, 1000, Phaser.Easing.Bounce.Out, true, 0); tween.to({x:0.7, y:0.7}, 1000, Phaser.Easing.Bounce.Out, true, 0);
// tween.to({x:0.7, y:0.7}, 1000, Phaser.Easing.Elastic.InOut, true, 0, 2, true); // tween.to({x:0.7, y:0.7}, 1000, Phaser.Easing.Elastic.InOut, true, 0, 2, true);
@@ -128,7 +146,6 @@ God.prototype.animateAngry = function(type) {
tween.onComplete.add(this.smileAgain, this); tween.onComplete.add(this.smileAgain, this);
tween.start(); tween.start();
// this.particleBurst(God.REACTION_HAPPY);
this.particleBurst(God.REACTION_ANGRY); this.particleBurst(God.REACTION_ANGRY);
} }
+8 -4
View File
@@ -146,11 +146,15 @@ MeatBase.prototype.getClassName = function() {
return this.className; return this.className;
} }
MeatBase.prototype.getScore = function(meatDoneness) { MeatBase.prototype.getTotalCookingTime = function() {
var scoreDoneness = this.scoreArray[meatDoneness]; return this.cookingTime[MeatBase.MEAT_BACK] + this.cookingTime[MeatBase.MEAT_FRONT];
var totalCookingTime = this.cookingTime[MeatBase.MEAT_BACK] + this.cookingTime[MeatBase.MEAT_FRONT]; }
MeatBase.prototype.getScore = function() {
var meatDoneness = this.getMeatGrade();
var scoreDoneness = this.scoreArray[meatDoneness];
var totalCookingTime = this.getTotalCookingTime();
console.log(totalCookingTime);
return scoreDoneness * totalCookingTime; return scoreDoneness * totalCookingTime;
} }
+51 -28
View File
@@ -1,52 +1,75 @@
// SpeechBubble.prototype = Object.create(Phaser.Text.prototype); SpeechBubble.prototype = Object.create(Phaser.Sprite.prototype);
// SpeechBubble.prototype.constructor = SpeechBubble; SpeechBubble.prototype.constructor = SpeechBubble;
SpeechBubble = function(x, y) { function SpeechBubble() {
var textStyle = { font: "normal 24px Arial", fill: "#ff0", boundsAlignH: "center", boundsAlignV: "middle" }; var textStyle = { font: "normal 24px Arial", fill: "#ff0", boundsAlignH: "center", boundsAlignV: "middle" };
this.speechBubbleText = game.add.text(0, 0, "맛없어!!!", textStyle); Phaser.Sprite.call(this, game, SpeechBubble.POSITION_X, SpeechBubble.POSITION_Y, 'speech_bubble_angry');
this.anchor.set(0.5);
this.scale.set(0.7);
this.inputEnabled = false;
game.add.existing(this);
// this.speechBubbleText = game.add.text(-451 / 2, -227 / 2, "맛없어!!!", textStyle);
this.speechBubbleText = game.add.text(0, 0, "", textStyle);
this.speechBubbleText.addColor("#f00", 0); this.speechBubbleText.addColor("#f00", 0);
this.speechBubbleText.anchor.setTo(0.5, 0.4); this.speechBubbleText.anchor.setTo(0.5);
this.speechBubbleText.scale.set(1.7); this.speechBubbleText.scale.set(1.7);
this.addChild(this.speechBubbleText);
this.speechBubble = game.add.image(x, y, 'speech_bubble_angry');
this.speechBubble.addChild(this.speechBubbleText);
this.speechBubble.anchor.set(0.5);
this.speechBubble.scale.set(0.7);
this.speechBubble.inputEnabled = false;
} }
SpeechBubble.prototype.update = function() {
this.y -= 0.3;
}
SpeechBubble.prototype.showSpeechBubble = function(type) { SpeechBubble.prototype.showSpeechBubble = function(meat) {
if(type == Meat.DONENESS_WELLDONE) { var meatDoneness = meat.getMeatGrade();
switch(meatDoneness) {
case Meat.DONENESS_WELLDONE:
this.speechBubbleText.addColor("#33f", 0); this.speechBubbleText.addColor("#33f", 0);
this.speechBubble.loadTexture('speech_bubble_happy'); this.loadTexture('speech_bubble_happy');
this.speechBubbleText.text = "맛있어 ♥♡♥"; this.speechBubbleText.text = "맛있어 ♥♡♥";
} else { break;
this.speechBubble.loadTexture('speech_bubble_angry');
if(type == Meat.DONENESS_RARE) { case Meat.DONENESS_RARE:
if(meat.getTotalCookingTime() == 0) {
this.speechBubbleText.addColor("#f33", 0); this.speechBubbleText.addColor("#f33", 0);
this.speechBubbleText.text = "날고기 싫어!!!"; this.loadTexture('speech_bubble_angry');
} else if(type == Meat.DONENESS_BURN_BLACK) { this.speechBubbleText.text = "하나도\n안익혔짆아!!!";
this.speechBubbleText.addColor("#333", 0); } else {
this.speechBubbleText.text = "탄 고기\n안먹을래!!!"; this.speechBubbleText.addColor("#33f", 0);
this.loadTexture('speech_bubble_happy');
this.speechBubbleText.text = "덜 익은 고기\n맛 없어! ㅠㅠ";
} }
break;
case Meat.DONENESS_BURN_BLACK:
this.speechBubbleText.addColor("#333", 0);
this.loadTexture('speech_bubble_angry');
this.speechBubbleText.text = "탄 고기\n안먹을래!!!";
break;
} }
this.speechBubble.alpha = 1; this.alpha = 1;
this.scale.set(0.6);
this.startAnimation();
}
SpeechBubble.prototype.startAnimation = function() {
var tween = game.add.tween(this.scale);
tween.to({x:0.7, y:0.7}, 200, Phaser.Easing.Linear.None, true, 0);
tween.start();
game.time.events.add(Phaser.Timer.SECOND * 1, this.hideSpeechBubble, this); game.time.events.add(Phaser.Timer.SECOND * 1, this.hideSpeechBubble, this);
}, }
SpeechBubble.prototype.hideSpeechBubble = function() { SpeechBubble.prototype.hideSpeechBubble = function() {
this.speechBubble.alpha = 0; this.alpha = 0;
}, }
SpeechBubble.prototype.destroySelf = function() { SpeechBubble.prototype.destroySelf = function() {
this.destroy(); this.destroy();
} }
SpeechBubble.POSITION_X = God.POSITION_X - 200;
SpeechBubble.POSITION_Y = God.POSITION_Y - 200;
+2 -2
View File
@@ -65,9 +65,9 @@
<script src="../../game/mouse/grilled_meat/loading.js"></script> <script src="../../game/mouse/grilled_meat/loading.js"></script>
<script src="../../game/mouse/grilled_meat/god.js"></script> <script src="../../game/mouse/grilled_meat/god.js"></script>
<script src="../../game/mouse/grilled_meat/plus_score.js"></script>
<script src="../../game/mouse/grilled_meat/speech_bubble.js"></script> <script src="../../game/mouse/grilled_meat/speech_bubble.js"></script>
<script src="../../game/mouse/grilled_meat/plus_score.js"></script>
<script src="../../game/mouse/grilled_meat/heat_plate.js"></script> <script src="../../game/mouse/grilled_meat/heat_plate.js"></script>
<script src="../../game/mouse/grilled_meat/stove_dial.js"></script> <script src="../../game/mouse/grilled_meat/stove_dial.js"></script>
<script src="../../game/mouse/grilled_meat/trash_can.js"></script> <script src="../../game/mouse/grilled_meat/trash_can.js"></script>