From f77057ed8e066d0a98cabcbe28d86ca8ed80e5df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8B=E1=85=A2=E1=84=91=E1=85=B3=E1=86=AF=20=E1=84=82?= =?UTF-8?q?=E1=85=A9=E1=84=90=E1=85=B3=E1=84=87=E1=85=AE=E1=86=A8?= Date: Tue, 10 Dec 2019 07:49:23 +0900 Subject: [PATCH] Fix: MeatBase - NormalMeat - BonusMeat --- src/game/mouse/grilled_meat/bonus_meat.js | 27 ++++++------ src/game/mouse/grilled_meat/game.js | 5 ++- src/game/mouse/grilled_meat/meat_base.js | 49 +++++++++++----------- src/game/mouse/grilled_meat/normal_meat.js | 14 +++++-- 4 files changed, 51 insertions(+), 44 deletions(-) diff --git a/src/game/mouse/grilled_meat/bonus_meat.js b/src/game/mouse/grilled_meat/bonus_meat.js index 10ae27b..1801766 100644 --- a/src/game/mouse/grilled_meat/bonus_meat.js +++ b/src/game/mouse/grilled_meat/bonus_meat.js @@ -1,36 +1,37 @@ BonusMeat.prototype = MeatBase.prototype; BonusMeat.constructor = BonusMeat; -function BonusMeat() { - MeatBase.call(this); - this.loadTexture("bonus_meat"); +function BonusMeat(mainGame) { + this.mainGame = mainGame; - this.setMeatTypeVariables() + MeatBase.call(this); + + this.setMeatTypeVariables(); + this.setSprite(); } BonusMeat.prototype.setMeatTypeVariables = function() { this.cookingSpeed = BonusMeat.COOKING_SPEED_BURN_LEVEL_WEAK; +} - this.loadTexture('meat_burn1'); - } else if(this.getMeatGradeBySide(Meat.MEAT_FRONT) == Meat.DONENESS_WELLDONE) { - this.loadTexture('meat_welldone1'); - } else { - this.loadTexture('meat1'); +BonusMeat.prototype.setSprite = function() { + this.spriteNameRare = BonusMeat.SPRITE_NAME_RARE; + this.spriteNameWelldone = BonusMeat.SPRITE_NAME_WELLDONE; + this.spriteNameBurnBlack = BonusMeat.SPRITE_NAME_BURN_BLACK; - - this.spriteMeatBurnBlack = + this.loadTexture(this.spriteNameRare); } -BonusMeat.COOKING_SPEED_BURN_LEVEL_WEAK = 0.1; +BonusMeat.COOKING_SPEED_BURN_LEVEL_WEAK = 0.1; BonusMeat.COOKING_SPEED_BURN_LEVEL_NORMAL = 0.2; BonusMeat.COOKING_SPEED_BURN_LEVEL_STRONG = 0.3; BonusMeat.SCORE_NAME_RARE = 10; BonusMeat.SCORE_NAME_WELLDONE = 100; -BonusMeat.SCORE_NAME_BURN_BLACK = 0; +BonusMeat.SCORE_NAME_BURN_BLACK = 0; BonusMeat.SPRITE_NAME_RARE = "bonus_meat"; BonusMeat.SPRITE_NAME_WELLDONE = "bonus_meat_welldone"; diff --git a/src/game/mouse/grilled_meat/game.js b/src/game/mouse/grilled_meat/game.js index 6d2376a..f41b0b9 100644 --- a/src/game/mouse/grilled_meat/game.js +++ b/src/game/mouse/grilled_meat/game.js @@ -80,13 +80,14 @@ var Game = { // meat this.meatGroup = game.add.group(); for(var i = 0; i < Game.MAX_MEAT_COUNT; i++) { - var meat = new Meat(this); + // var meat = new Meat(this); + var meat = new NormalMeat(this); meat.name = "meat" + i; meat.setActive(false, -100, -100, ""); this.meatGroup.add(meat); } - this.normalMeat = new NormalMeat(); + // this.normalMeat = new NormalMeat(this); // this.meatBase = new MeatBase(); diff --git a/src/game/mouse/grilled_meat/meat_base.js b/src/game/mouse/grilled_meat/meat_base.js index b80ce6a..973eb09 100644 --- a/src/game/mouse/grilled_meat/meat_base.js +++ b/src/game/mouse/grilled_meat/meat_base.js @@ -9,29 +9,35 @@ function MeatBase() { this.initMeatTypeVariables(); this.initMouseEventHandler(); + + this.whiteSmokeParticle = new Smoke(Meat.DONENESS_RARE, 0, 0); + this.redSmokeParticle = new Smoke(Meat.DONENESS_WELLDONE, 0, 0); + this.blackSmokeParticle = new Smoke(Meat.DONENESS_BURN_BLACK, 0, 0); } MeatBase.prototype.update = function() { var posY = this.y; if(posY <= God.POSITION_Y) { - this.scale.set(0.4); + this.scale.set(this.baseScale); } else if(posY > God.POSITION_Y && posY < HeatPlate.POSITION_Y) { var scaleRate = (posY - God.POSITION_Y) / (HeatPlate.POSITION_Y - God.POSITION_Y); - this.scale.set(0.4 + 0.3 * scaleRate); + this.scale.set(this.baseScale + 0.3 * scaleRate); } else { - this.scale.set(0.4 + 0.3); + this.scale.set(this.baseScale + 0.3); } - // if(this.isOnHeatPlate == true && game.input.mousePointer.isUp == true) { - // this.cooking(); - // } + if(this.isOnHeatPlate == true && game.input.mousePointer.isUp == true) { + this.cooking(); + } } MeatBase.prototype.initMeatTypeVariables = function() { this.cookingSpeed = 0.0; + this.baseScale = 0.5; + this.rareScore = 0; this.welldoneScore = 0; this.burnBlackScore = 0; @@ -107,15 +113,8 @@ MeatBase.prototype.isInClickArea = function(downX, downY, upX, upY) { } MeatBase.prototype.onClickListener = function(pointer) { - console.log("onClickListener"); + // console.log("onClickListener"); - if(this.isFront() == true) - this.flipToBack() - else - this.flipToFront(); - // console.log("flip cooking side : " + this.cookingSide); - - /* if(this.mainGame.isOverHeatPlate(this.x, this.y, this.width, this.height) == true) { if(this.isFront() == true) this.flipToBack() @@ -125,13 +124,11 @@ MeatBase.prototype.onClickListener = function(pointer) { this.startCook(); } - */ } MeatBase.prototype.onDragStopListener = function(pointer) { - console.log("onDragStop"); + // console.log("onDragStop"); - /* if(this.mainGame.isOverHeatPlate(this.x, this.y, this.width, this.height) == true) { // console.log("isOverHeatPlate : " + isOverHeatPlate(this.x, this.y, this.width, this.height)); this.startCook(); @@ -143,7 +140,6 @@ MeatBase.prototype.onDragStopListener = function(pointer) { // console.log("isOverGod : " + isOverGod(this.x, this.y)); this.mainGame.godEatMeat(this); } - */ } @@ -162,7 +158,7 @@ MeatBase.prototype.flipToFront = function() { this.angle = MeatBase.ANGLE_FRONT; // console.log("flipToFront"); // console.log("back : " + this.getMeatGradeBySide(MeatBase.MEAT_BACK) + ", front : " + this.getMeatGradeBySide(MeatBase.MEAT_FRONT)); - this.updateSprite(); + this.upsideDownSprite(MeatBase.MEAT_FRONT); } MeatBase.prototype.flipToBack = function() { @@ -172,15 +168,18 @@ MeatBase.prototype.flipToBack = function() { this.angle = MeatBase.ANGLE_BACK; // console.log("flipToBack"); // console.log("back : " + this.getMeatGradeBySide(MeatBase.MEAT_BACK) + ", front : " + this.getMeatGradeBySide(MeatBase.MEAT_FRONT)); - this.updateSprite(); + this.upsideDownSprite(MeatBase.MEAT_BACK); } -MeatBase.prototype.updateSprite = function() { - if(this.getMeatGradeBySide(MeatBase.MEAT_FRONT) == MeatBase.DONENESS_BURN_BLACK) { +MeatBase.prototype.upsideDownSprite = function(meatDirection) { + if(this.getMeatGradeBySide(meatDirection) == MeatBase.DONENESS_BURN_BLACK) { + // console.log("sprite burn black"); this.loadTexture(this.spriteNameBurnBlack); - } else if(this.getMeatGradeBySide(MeatBase.MEAT_FRONT) == MeatBase.DONENESS_WELLDONE) { + } else if(this.getMeatGradeBySide(meatDirection) == MeatBase.DONENESS_WELLDONE) { + // console.log("sprite welldone"); this.loadTexture(this.spriteNameWelldone); } else { + // console.log("sprite rare"); this.loadTexture(this.spriteNameRare); } } @@ -248,7 +247,7 @@ MeatBase.prototype.setActive = function(isActivated, x, y, meat_type) { this.x = x; this.y = y; - this.loadTexture('meat1'); + this.loadTexture(this.spriteNameRare); this.angle = MeatBase.ANGLE_NONE; this.alpha = 1; } @@ -327,5 +326,5 @@ MeatBase.ANGLE_NONE = 0; MeatBase.ANGLE_FRONT = 30; MeatBase.ANGLE_BACK = -30; -MeatBase.COOK_TIME_WELLDONE = 200; +MeatBase.COOK_TIME_WELLDONE = 20; MeatBase.COOK_TIME_BURN = 400; \ No newline at end of file diff --git a/src/game/mouse/grilled_meat/normal_meat.js b/src/game/mouse/grilled_meat/normal_meat.js index 9806a95..7eb1b91 100644 --- a/src/game/mouse/grilled_meat/normal_meat.js +++ b/src/game/mouse/grilled_meat/normal_meat.js @@ -1,11 +1,14 @@ NormalMeat.prototype = MeatBase.prototype; NormalMeat.constructor = NormalMeat; -function NormalMeat() { +function NormalMeat(mainGame) { + this.mainGame = mainGame; + MeatBase.call(this); this.setMeatTypeVariables(); this.randomizeMeatType(); + this.setSprite(); } @@ -15,20 +18,23 @@ NormalMeat.prototype.setMeatTypeVariables = function() { NormalMeat.prototype.randomizeMeatType = function() { this.meatType = Math.floor(Math.random() * 3) + 1; +} +NormalMeat.prototype.setSprite = function() { switch(this.meatType) { case 1: - this.scale.set(0.5); + this.baseScale = 0.4; break; case 2: - this.scale.set(0.5); + this.baseScale = 0.4; break; case 3: - this.scale.set(0.5); + this.baseScale = 0.5; break; } + this.scale.set(this.baseScale); this.spriteNameRare = NormalMeat.SPRITE_NAME_RARE + this.meatType; this.spriteNameWelldone = NormalMeat.SPRITE_NAME_WELLDONE + this.meatType;