diff --git a/src/game/mouse/grilled_meat/game.js b/src/game/mouse/grilled_meat/game.js index 4cf9f08..40d361e 100644 --- a/src/game/mouse/grilled_meat/game.js +++ b/src/game/mouse/grilled_meat/game.js @@ -91,11 +91,6 @@ var Game = { // 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(); experienceAppTimer.setTimeOverListener( (function() { this.timeOver(); }).bind(this) @@ -268,28 +263,35 @@ var Game = { // console.log("god eat : " + meat); // console.log("meat grade : " + meat.getMeatGrade()); + var meatClassName = meat.getClassName(); + 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 = meat.getScore(Meat.DONENESS_WELLDONE); + 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); } 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 = meat.getScore(Meat.DONENESS_WELLDONE); - this.scoreManager.plusScore(score); + if(meat.getTotalCookingTime() > 0) { + var score = meat.getScore(); + this.scoreManager.plusScore(score); - var tempPlusScore = new PlusScore(this.god.x, this.god.y - 180, score); - this.plusScoreGroup.add(tempPlusScore); + var tempPlusScore = new PlusScore(this.god.x, this.god.y - 250, score); + this.plusScoreGroup.add(tempPlusScore); + } } else { 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) { this.god.animateAngry(Meat.DONENESS_RARE); // "날고기 싫어!!!"); @@ -301,7 +303,7 @@ var Game = { meat.setActive(false, -100, -100, ''); - if(meat.getClassName() == NormalMeat.CLASS_NAME) { + if(meatClassName == NormalMeat.CLASS_NAME) { this.clearedMeatCount++; if(this.clearedMeatCount == this.activatedMeatCount) { this.clearStage(); diff --git a/src/game/mouse/grilled_meat/god.js b/src/game/mouse/grilled_meat/god.js index 879d07f..02a3ed7 100644 --- a/src/game/mouse/grilled_meat/god.js +++ b/src/game/mouse/grilled_meat/god.js @@ -15,6 +15,9 @@ function God(x, y, mainGame) { game.add.existing(this); + this.speechBubble = new SpeechBubble(); + this.speechBubble.hideSpeechBubble(); + this.makeParticles(x, y); } @@ -103,10 +106,10 @@ God.prototype.setScale = function(size) { } -God.prototype.animateHappy = function(type) { - this.loadTexture('god_happy'); - this.mainGame.speechBubble.showSpeechBubble(type); +God.prototype.animateHappy = function(meat) { + this.speechBubble.showSpeechBubble(meat); + this.loadTexture('god_happy'); 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}, 1000, Phaser.Easing.Elastic.InOut, true, 0, 2, true); @@ -117,10 +120,25 @@ God.prototype.animateHappy = function(type) { this.particleBurst(God.REACTION_HAPPY); } -God.prototype.animateAngry = function(type) { - this.loadTexture('god_angry'); - this.mainGame.speechBubble.showSpeechBubble(type); +God.prototype.animateAngryWithRare = function(meat) { + this.speechBubble.showSpeechBubble(meat); + 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); 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); @@ -128,7 +146,6 @@ God.prototype.animateAngry = function(type) { tween.onComplete.add(this.smileAgain, this); tween.start(); - // this.particleBurst(God.REACTION_HAPPY); this.particleBurst(God.REACTION_ANGRY); } diff --git a/src/game/mouse/grilled_meat/meat_base.js b/src/game/mouse/grilled_meat/meat_base.js index 9c2678f..8ed2888 100644 --- a/src/game/mouse/grilled_meat/meat_base.js +++ b/src/game/mouse/grilled_meat/meat_base.js @@ -146,11 +146,15 @@ MeatBase.prototype.getClassName = function() { return this.className; } -MeatBase.prototype.getScore = function(meatDoneness) { - var scoreDoneness = this.scoreArray[meatDoneness]; - var totalCookingTime = this.cookingTime[MeatBase.MEAT_BACK] + this.cookingTime[MeatBase.MEAT_FRONT]; +MeatBase.prototype.getTotalCookingTime = function() { + return 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; } diff --git a/src/game/mouse/grilled_meat/speech_bubble.js b/src/game/mouse/grilled_meat/speech_bubble.js index 2be20e7..8d1c08d 100644 --- a/src/game/mouse/grilled_meat/speech_bubble.js +++ b/src/game/mouse/grilled_meat/speech_bubble.js @@ -1,52 +1,75 @@ -// SpeechBubble.prototype = Object.create(Phaser.Text.prototype); -// SpeechBubble.prototype.constructor = SpeechBubble; +SpeechBubble.prototype = Object.create(Phaser.Sprite.prototype); +SpeechBubble.prototype.constructor = SpeechBubble; -SpeechBubble = function(x, y) { +function SpeechBubble() { 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.anchor.setTo(0.5, 0.4); + this.speechBubbleText.anchor.setTo(0.5); this.speechBubbleText.scale.set(1.7); - - 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; + this.addChild(this.speechBubbleText); } -SpeechBubble.prototype.update = function() { - this.y -= 0.3; -} -SpeechBubble.prototype.showSpeechBubble = function(type) { - if(type == Meat.DONENESS_WELLDONE) { +SpeechBubble.prototype.showSpeechBubble = function(meat) { + var meatDoneness = meat.getMeatGrade(); + switch(meatDoneness) { + case Meat.DONENESS_WELLDONE: this.speechBubbleText.addColor("#33f", 0); - this.speechBubble.loadTexture('speech_bubble_happy'); + this.loadTexture('speech_bubble_happy'); this.speechBubbleText.text = "맛있어 ♥♡♥"; - } else { - this.speechBubble.loadTexture('speech_bubble_angry'); + break; - if(type == Meat.DONENESS_RARE) { + case Meat.DONENESS_RARE: + if(meat.getTotalCookingTime() == 0) { this.speechBubbleText.addColor("#f33", 0); - this.speechBubbleText.text = "날고기 싫어!!!"; - } else if(type == Meat.DONENESS_BURN_BLACK) { - this.speechBubbleText.addColor("#333", 0); - this.speechBubbleText.text = "탄 고기\n안먹을래!!!"; + this.loadTexture('speech_bubble_angry'); + this.speechBubbleText.text = "하나도\n안익혔짆아!!!"; + } else { + 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); -}, +} SpeechBubble.prototype.hideSpeechBubble = function() { - this.speechBubble.alpha = 0; -}, + this.alpha = 0; +} SpeechBubble.prototype.destroySelf = function() { this.destroy(); } +SpeechBubble.POSITION_X = God.POSITION_X - 200; +SpeechBubble.POSITION_Y = God.POSITION_Y - 200; \ No newline at end of file diff --git a/src/web/client/grilled_meat.html b/src/web/client/grilled_meat.html index 81637b2..65635a7 100644 --- a/src/web/client/grilled_meat.html +++ b/src/web/client/grilled_meat.html @@ -65,9 +65,9 @@ - - + +