diff --git a/src/game/mouse/grilled_meat/game.js b/src/game/mouse/grilled_meat/game.js index c40a78f..072f9ee 100644 --- a/src/game/mouse/grilled_meat/game.js +++ b/src/game/mouse/grilled_meat/game.js @@ -74,7 +74,7 @@ var Game = { this.meatPlate.smoothed = false; this.heatPlate = new HeatPlate(); - this.stoveDial = new StoveDial(80, Game.HEAT_PLATE_POSITION_Y + 70); + this.stoveDial = new StoveDial(80, HeatPlate.POSITION_Y + 70); this.stoveDial.setOnChangeDialLevelHandler( (function(dialLevel) { this.onChangeDialLevel(dialLevel); }).bind(this) ); @@ -83,14 +83,14 @@ var Game = { // meat this.bonusMeat = new BonusMeat(this); - this.bonusMeat.setActive(false, -100, -100, ""); + 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); var meat = new NormalMeat(this); meat.name = "meat" + i; - meat.setActive(false, -100, -100, ""); + meat.setActive(false, -100, -100); this.meatGroup.add(meat); } @@ -186,20 +186,21 @@ var Game = { startGame: function() { this.playingStageNo = 1; + this.clearedMeatCount = 0; + this.badMeatCount = 0; this.startStage(); - // this.stageTimer.start(); this.realtimeStageTimer.start(); }, startStage: function() { this.clearedMeatCount = 0; - this.badMeatCount = 0; - console.log("badMeatCount : " + this.badMeatCount); this.activatedMeatCount = this.getStageMeatCount(); - this.serveBonusMeat(); this.serveNormalMeats(); + this.serveBonusMeat(); + this.badMeatCount = 0; + if(this.playingStageNo > 1) this.waiter.animateServing(); }, @@ -225,74 +226,31 @@ var Game = { 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, ""); + this.bonusMeat.setActive(true, randX, randY); }, serveNormalMeats: function() { for(var i = 0; i < Game.MAX_MEAT_COUNT; i++) { var meat = this.meatGroup.children[i]; - meat.setActive(false, -100, -100, ""); + meat.setActive(false, -100, -100); } for(var i = 0; i < this.activatedMeatCount; i++) { var meat = this.meatGroup.children[i]; var randX = this.meatPlate.x - game.rnd.integerInRange(-100, 100); var randY = this.meatPlate.y - game.rnd.integerInRange(-30, 30); - meat.setActive(true, randX, randY, ""); + meat.setActive(true, randX, randY); } }, - getScore: function() { - return this.playingStageNo * 10; - }, - - getBonusTime: function() { - if(this.badMeatCount > 0) - return 0; - - if(this.playingStageNo == 1) - return 5; - else if(this.playingStageNo == 2) - return 7; - else - return 6 + this.playingStageNo; - }, - - isOverHeatPlate: function(x, y, width, height) { - var plateHalfWidth = (this.heatPlate.width - Game.HEAT_PLATE_HANDLE_WIDTH) / 2; - var plateHalfHeight = this.heatPlate.height / 2; - - if(x < this.heatPlate.x - plateHalfWidth) { - return false; - } else if(this.heatPlate.x + plateHalfWidth < x) { - return false; - } else if(y < this.heatPlate.y - plateHalfHeight + Game.HEAT_PLATE_START_OFFSET_Y) { - return false; - } else if(this.heatPlate.y + plateHalfHeight + Game.HEAT_PLATE_START_OFFSET_Y - Game.HEAT_PLATE_HEIGHT< y) { - return false; - } - - return true; + isOverHeatPlate: function(x, y) { + return this.heatPlate.isOver(x, y); }, isOverGod: function(x, y) { - // console.log("isOverGod : " + x + ", " + y + ", " + width + ", " + height); - - var godHalfWidth = (this.god.width - Game.GOD_OUT_OF_FACE_WIDTH) / 2; - var godHalfHeight = this.god.height / 2; - if(x < this.god.x - godHalfWidth) { - return false; - } else if(this.god.x + godHalfWidth < x) { - return false; - } else if(y < this.god.y - this.god.height + Game.GOD_OUT_OF_FACE_HEIGHT) { - return false; - } else if(this.god.y - Game.GOD_OUT_OF_FACE_HEIGHT < y) { - return false; - } - - return true; + return this.god.isOver(x, y); }, godEatMeat: function(meat) { @@ -308,11 +266,9 @@ var Game = { this.plusScoreGroup.add(tempPlusScore); } else if(meat.getMeatGrade() == MeatBase.DONENESS_RARE) { this.badMeatCount++; - console.log("badMeatCount : " + this.badMeatCount); this.god.animateAngryWithRare(meat); - // var score = this.getScore(); if(meat.getTotalCookingTime() > 0) { var score = meat.getScore(); this.scoreManager.plusScore(score); @@ -322,14 +278,13 @@ var Game = { } } else { // meat is burn black this.badMeatCount++; - console.log("badMeatCount : " + this.badMeatCount); this.god.animateAngryWithBurnBlack(meat); return; // god doesn't eat burned black meat } - meat.setActive(false, -100, -100, ''); + meat.setActive(false, -100, -100); if(meatClassName == NormalMeat.CLASS_NAME) { this.clearedMeatCount++; @@ -340,20 +295,7 @@ var Game = { }, isOverTrashCan: function(x, y) { - var trashCanHalfWidth = this.trashCan.width / 2; - var trashCanHalfHeight = this.trashCan.height; - - if(x < this.trashCan.x - trashCanHalfWidth) { - return false; - } else if(this.trashCan.x + trashCanHalfWidth < x) { - return false; - } else if(y < this.trashCan.y - this.trashCan.height) { - return false; - } else if(this.trashCan.y < y) { - return false; - } - - return true; + return this.trashCan.isOver(x, y); }, throwAway: function(meat) { @@ -361,10 +303,9 @@ var Game = { return; this.badMeatCount++; - console.log("badMeatCount : " + this.badMeatCount); this.trashCan.animateAngry(); - meat.setActive(false, -100, -100, ''); + meat.setActive(false, -100, -100); var score = meat.getScore(); this.scoreManager.plusScore(score); @@ -381,8 +322,6 @@ var Game = { }, clearStage: function() { - // this.stageTimer.addBonusTime(this.getBonusTime()); - this.playingStageNo++; var startStageTimeEvent = game.time.events.add(Phaser.Timer.SECOND * 1, this.startStage, this); @@ -391,12 +330,6 @@ var Game = { - animateTextAlpha: function(targetText, startAlpha, endAlpha, msTime, effectType) { - targetText.alpha = startAlpha; - game.add.tween(targetText).to({alpha: endAlpha}, msTime, effectType, true); - }, - - timeOver: function() { var timeOverText = new TimeOverText(); if(!isExperienceMaestroAccount()) @@ -436,18 +369,8 @@ var Game = { Game.GAME_TIME_SEC = 90; -Game.NEXT_STAGE_DELAY_MS = 500; Game.MAX_MEAT_COUNT = 20; -Game.HEAT_PLATE_HANDLE_WIDTH = 440; -Game.HEAT_PLATE_START_OFFSET_Y = 80; -Game.HEAT_PLATE_HEIGHT = 220; - -Game.GOD_OUT_OF_FACE_WIDTH = 30; -Game.GOD_OUT_OF_FACE_HEIGHT = 30; - Game.MEAT_PLATE_POSITION_X = 180; -Game.MEAT_PLATE_POSITION_Y = 390; - -Game.HEAT_PLATE_POSITION_Y = GAME_SCREEN_SIZE.y / 2 + 200; \ No newline at end of file +Game.MEAT_PLATE_POSITION_Y = 390; \ No newline at end of file diff --git a/src/game/mouse/grilled_meat/god.js b/src/game/mouse/grilled_meat/god.js index d47e553..fc1c960 100644 --- a/src/game/mouse/grilled_meat/god.js +++ b/src/game/mouse/grilled_meat/god.js @@ -83,19 +83,12 @@ God.prototype.makeParticles = function() { ); } -God.prototype.update = function() { -} - God.prototype.onDown = function(sprite, pointer) { console.log("onDown : " + pointer.x + ", " + pointer.y); this.animateAngry(); } -God.prototype.isInRect = function(x, y) { - return true; -} - God.prototype.onDragStop = function(sprite, pointer) { console.log("onDragStop : " + pointer.x + ", " + pointer.y); } @@ -105,6 +98,21 @@ God.prototype.setScale = function(size) { this.backupScale = size; } +God.prototype.isOver = function(x, y) { + var halfWidth = (this.width - God.OUT_OF_FACE_WIDTH) / 2; + var halfHeight = this.height / 2; + if(x < this.x - halfWidth) + return false; + else if(this.x + halfWidth < x) + return false; + else if(y < this.y - this.height + God.OUT_OF_FACE_HEIGHT) + return false; + else if(this.y - God.OUT_OF_FACE_HEIGHT < y) + return false; + + return true; +} + God.prototype.animateHappy = function(meat) { this.speechBubble.showSpeechBubble(meat); @@ -184,6 +192,10 @@ God.POSITION_Y = 340; God.HEAD_WIDTH = 80; God.HEAD_HEIGHT = 30; +God.OUT_OF_FACE_WIDTH = 30; +God.OUT_OF_FACE_HEIGHT = 30; + + God.EFFECT_LIFE_TIME_MS = 1200; God.REACTION_HAPPY = 0; diff --git a/src/game/mouse/grilled_meat/heat_plate.js b/src/game/mouse/grilled_meat/heat_plate.js index bea0759..c26ebab 100644 --- a/src/game/mouse/grilled_meat/heat_plate.js +++ b/src/game/mouse/grilled_meat/heat_plate.js @@ -4,16 +4,12 @@ HeatPlate.prototype.constructor = HeatPlate; function HeatPlate() { Phaser.Sprite.call(this, game, HeatPlate.POSITION_X, HeatPlate.POSITION_Y, 'heat_plate'); this.anchor.set(0.5); - // this.scale.set(0.5); this.smoothed = false; this.inputEnabled = false; game.add.existing(this); - // add 3 sprites for flame - // this.spriteFlame = game.make.sprite(0, 0, "flame_weak"); this.spriteFlame = game.make.sprite(0, 0, "heat_plate_flame"); this.spriteFlame.anchor.set(0.5, 0.65); - // this.spriteFlame.scale.set(0.5); this.spriteFlame.smoothed = false; this.spriteFlame.alpha = 0.3; @@ -45,10 +41,33 @@ HeatPlate.prototype.onChangeDialLevel = function(dialLevel) { this.setBurnLevel(dialLevel); } +HeatPlate.prototype.isOver = function(x, y) { + var halfWidth = (this.width - HeatPlate.HANDLE_WIDTH) / 2; + var halfHeight = this.height / 2; + + if(x < this.x - halfWidth) { + return false; + } else if(this.x + halfWidth < x) { + return false; + } else if(y < this.y - halfHeight + HeatPlate.START_OFFSET_Y) { + return false; + } else if(this.y + halfHeight + HeatPlate.START_OFFSET_Y - HeatPlate.HEIGHT < y) { + return false; + } + + return true; +} + + HeatPlate.POSITION_X = GAME_SCREEN_SIZE.x / 2 + 70; HeatPlate.POSITION_Y = GAME_SCREEN_SIZE.y / 2 + 200; +HeatPlate.HANDLE_WIDTH = 440; +HeatPlate.START_OFFSET_Y = 80; +HeatPlate.HEIGHT = 220; + + HeatPlate.BURN_LEVEL_WEAK = 0; HeatPlate.BURN_LEVEL_NORMAL = 1; HeatPlate.BURN_LEVEL_STRONG = 2; diff --git a/src/game/mouse/grilled_meat/meat_base.js b/src/game/mouse/grilled_meat/meat_base.js index fdb1da5..26c8738 100644 --- a/src/game/mouse/grilled_meat/meat_base.js +++ b/src/game/mouse/grilled_meat/meat_base.js @@ -250,7 +250,7 @@ MeatBase.prototype.getMeatGradeBySide = function(cookingSide) { return this.cookingGrade[cookingSide]; } -MeatBase.prototype.setActive = function(isActivated, x, y, meat_type) { +MeatBase.prototype.setActive = function(isActivated, x, y) { this.isActivated = isActivated; if(isActivated == false) { diff --git a/src/game/mouse/grilled_meat/speech_bubble.js b/src/game/mouse/grilled_meat/speech_bubble.js index 048b549..225cdc3 100644 --- a/src/game/mouse/grilled_meat/speech_bubble.js +++ b/src/game/mouse/grilled_meat/speech_bubble.js @@ -10,7 +10,6 @@ function SpeechBubble() { 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); diff --git a/src/game/mouse/grilled_meat/trash_can.js b/src/game/mouse/grilled_meat/trash_can.js index caa8c1f..38ace08 100644 --- a/src/game/mouse/grilled_meat/trash_can.js +++ b/src/game/mouse/grilled_meat/trash_can.js @@ -4,26 +4,38 @@ TrashCan.prototype.constructor = TrashCan; function TrashCan() { Phaser.Sprite.call(this, game, TrashCan.POSITION_X, TrashCan.POSITION_Y, 'trash_can'); this.anchor.set(0.5, 1); - // this.scale.set(1); + this.scale.set(1); this.smoothed = false; this.inputEnabled = false; game.add.existing(this); } + +TrashCan.prototype.isOver = function(x, y) { + var halfWidth = this.width / 2; + var halfHeight = this.height; + + if(x < this.x - halfWidth) return false; + else if(this.x + halfWidth < x) return false; + else if(y < this.y - this.height) return false; + else if(this.y < y) return false; + + return true; +} + TrashCan.prototype.animateAngry = function(meat) { var tween = game.add.tween(this.scale); tween.to({x:1.2, y:1.2}, 500, Phaser.Easing.Elastic.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.onComplete.add(this.resetScale, this); tween.start(); } -TrashCan.prototype.smileAgain = function() { +TrashCan.prototype.resetScale = function() { this.scale.set(1); } - TrashCan.POSITION_X = God.POSITION_X - 200; TrashCan.POSITION_Y = God.POSITION_Y + 60; \ No newline at end of file diff --git a/src/game/mouse/grilled_meat/waiter.js b/src/game/mouse/grilled_meat/waiter.js index c4be908..803e2ad 100644 --- a/src/game/mouse/grilled_meat/waiter.js +++ b/src/game/mouse/grilled_meat/waiter.js @@ -25,7 +25,7 @@ Waiter.prototype.animateServing = function() { this.x = Waiter.POSITION_X; this.show(); var tween = game.add.tween(this); - tween.to({x:200}, 500, Phaser.Easing.Linear.In, true, 0); + tween.to({x:200}, 300, Phaser.Easing.Linear.In, 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); @@ -49,5 +49,5 @@ Waiter.prototype.show = function() { -Waiter.POSITION_X = -150; -Waiter.POSITION_Y = 340; \ No newline at end of file +Waiter.POSITION_X = -150; +Waiter.POSITION_Y = 340; \ No newline at end of file