Fix: MeatBase - NormalMeat - BonusMeat

This commit is contained in:
2019-12-10 07:49:23 +09:00
parent 36298d7621
commit f77057ed8e
4 changed files with 51 additions and 44 deletions
+12 -11
View File
@@ -1,25 +1,26 @@
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);
}
+3 -2
View File
@@ -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();
+24 -25
View File
@@ -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;
+10 -4
View File
@@ -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;