Fix: MeatBase - NormalMeat - BonusMeat
This commit is contained in:
@@ -1,36 +1,37 @@
|
|||||||
BonusMeat.prototype = MeatBase.prototype;
|
BonusMeat.prototype = MeatBase.prototype;
|
||||||
BonusMeat.constructor = BonusMeat;
|
BonusMeat.constructor = BonusMeat;
|
||||||
|
|
||||||
function BonusMeat() {
|
function BonusMeat(mainGame) {
|
||||||
MeatBase.call(this);
|
this.mainGame = mainGame;
|
||||||
this.loadTexture("bonus_meat");
|
|
||||||
|
|
||||||
this.setMeatTypeVariables()
|
MeatBase.call(this);
|
||||||
|
|
||||||
|
this.setMeatTypeVariables();
|
||||||
|
this.setSprite();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BonusMeat.prototype.setMeatTypeVariables = function() {
|
BonusMeat.prototype.setMeatTypeVariables = function() {
|
||||||
this.cookingSpeed = BonusMeat.COOKING_SPEED_BURN_LEVEL_WEAK;
|
this.cookingSpeed = BonusMeat.COOKING_SPEED_BURN_LEVEL_WEAK;
|
||||||
|
}
|
||||||
|
|
||||||
this.loadTexture('meat_burn1');
|
BonusMeat.prototype.setSprite = function() {
|
||||||
} else if(this.getMeatGradeBySide(Meat.MEAT_FRONT) == Meat.DONENESS_WELLDONE) {
|
this.spriteNameRare = BonusMeat.SPRITE_NAME_RARE;
|
||||||
this.loadTexture('meat_welldone1');
|
this.spriteNameWelldone = BonusMeat.SPRITE_NAME_WELLDONE;
|
||||||
} else {
|
this.spriteNameBurnBlack = BonusMeat.SPRITE_NAME_BURN_BLACK;
|
||||||
this.loadTexture('meat1');
|
|
||||||
|
|
||||||
|
this.loadTexture(this.spriteNameRare);
|
||||||
this.spriteMeatBurnBlack =
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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_NORMAL = 0.2;
|
||||||
BonusMeat.COOKING_SPEED_BURN_LEVEL_STRONG = 0.3;
|
BonusMeat.COOKING_SPEED_BURN_LEVEL_STRONG = 0.3;
|
||||||
|
|
||||||
BonusMeat.SCORE_NAME_RARE = 10;
|
BonusMeat.SCORE_NAME_RARE = 10;
|
||||||
BonusMeat.SCORE_NAME_WELLDONE = 100;
|
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_RARE = "bonus_meat";
|
||||||
BonusMeat.SPRITE_NAME_WELLDONE = "bonus_meat_welldone";
|
BonusMeat.SPRITE_NAME_WELLDONE = "bonus_meat_welldone";
|
||||||
|
|||||||
@@ -80,13 +80,14 @@ var Game = {
|
|||||||
// meat
|
// meat
|
||||||
this.meatGroup = game.add.group();
|
this.meatGroup = game.add.group();
|
||||||
for(var i = 0; i < Game.MAX_MEAT_COUNT; i++) {
|
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.name = "meat" + i;
|
||||||
meat.setActive(false, -100, -100, "");
|
meat.setActive(false, -100, -100, "");
|
||||||
this.meatGroup.add(meat);
|
this.meatGroup.add(meat);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.normalMeat = new NormalMeat();
|
// this.normalMeat = new NormalMeat(this);
|
||||||
// this.meatBase = new MeatBase();
|
// this.meatBase = new MeatBase();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,29 +9,35 @@ function MeatBase() {
|
|||||||
|
|
||||||
this.initMeatTypeVariables();
|
this.initMeatTypeVariables();
|
||||||
this.initMouseEventHandler();
|
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() {
|
MeatBase.prototype.update = function() {
|
||||||
var posY = this.y;
|
var posY = this.y;
|
||||||
|
|
||||||
if(posY <= God.POSITION_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) {
|
} else if(posY > God.POSITION_Y && posY < HeatPlate.POSITION_Y) {
|
||||||
var scaleRate = (posY - God.POSITION_Y) / (HeatPlate.POSITION_Y - God.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 {
|
} else {
|
||||||
this.scale.set(0.4 + 0.3);
|
this.scale.set(this.baseScale + 0.3);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if(this.isOnHeatPlate == true && game.input.mousePointer.isUp == true) {
|
if(this.isOnHeatPlate == true && game.input.mousePointer.isUp == true) {
|
||||||
// this.cooking();
|
this.cooking();
|
||||||
// }
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MeatBase.prototype.initMeatTypeVariables = function() {
|
MeatBase.prototype.initMeatTypeVariables = function() {
|
||||||
this.cookingSpeed = 0.0;
|
this.cookingSpeed = 0.0;
|
||||||
|
|
||||||
|
this.baseScale = 0.5;
|
||||||
|
|
||||||
this.rareScore = 0;
|
this.rareScore = 0;
|
||||||
this.welldoneScore = 0;
|
this.welldoneScore = 0;
|
||||||
this.burnBlackScore = 0;
|
this.burnBlackScore = 0;
|
||||||
@@ -107,15 +113,8 @@ MeatBase.prototype.isInClickArea = function(downX, downY, upX, upY) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MeatBase.prototype.onClickListener = function(pointer) {
|
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.mainGame.isOverHeatPlate(this.x, this.y, this.width, this.height) == true) {
|
||||||
if(this.isFront() == true)
|
if(this.isFront() == true)
|
||||||
this.flipToBack()
|
this.flipToBack()
|
||||||
@@ -125,13 +124,11 @@ MeatBase.prototype.onClickListener = function(pointer) {
|
|||||||
|
|
||||||
this.startCook();
|
this.startCook();
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MeatBase.prototype.onDragStopListener = function(pointer) {
|
MeatBase.prototype.onDragStopListener = function(pointer) {
|
||||||
console.log("onDragStop");
|
// console.log("onDragStop");
|
||||||
|
|
||||||
/*
|
|
||||||
if(this.mainGame.isOverHeatPlate(this.x, this.y, this.width, this.height) == true) {
|
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));
|
// console.log("isOverHeatPlate : " + isOverHeatPlate(this.x, this.y, this.width, this.height));
|
||||||
this.startCook();
|
this.startCook();
|
||||||
@@ -143,7 +140,6 @@ MeatBase.prototype.onDragStopListener = function(pointer) {
|
|||||||
// console.log("isOverGod : " + isOverGod(this.x, this.y));
|
// console.log("isOverGod : " + isOverGod(this.x, this.y));
|
||||||
this.mainGame.godEatMeat(this);
|
this.mainGame.godEatMeat(this);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -162,7 +158,7 @@ MeatBase.prototype.flipToFront = function() {
|
|||||||
this.angle = MeatBase.ANGLE_FRONT;
|
this.angle = MeatBase.ANGLE_FRONT;
|
||||||
// console.log("flipToFront");
|
// console.log("flipToFront");
|
||||||
// console.log("back : " + this.getMeatGradeBySide(MeatBase.MEAT_BACK) + ", front : " + this.getMeatGradeBySide(MeatBase.MEAT_FRONT));
|
// 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() {
|
MeatBase.prototype.flipToBack = function() {
|
||||||
@@ -172,15 +168,18 @@ MeatBase.prototype.flipToBack = function() {
|
|||||||
this.angle = MeatBase.ANGLE_BACK;
|
this.angle = MeatBase.ANGLE_BACK;
|
||||||
// console.log("flipToBack");
|
// console.log("flipToBack");
|
||||||
// console.log("back : " + this.getMeatGradeBySide(MeatBase.MEAT_BACK) + ", front : " + this.getMeatGradeBySide(MeatBase.MEAT_FRONT));
|
// 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() {
|
MeatBase.prototype.upsideDownSprite = function(meatDirection) {
|
||||||
if(this.getMeatGradeBySide(MeatBase.MEAT_FRONT) == MeatBase.DONENESS_BURN_BLACK) {
|
if(this.getMeatGradeBySide(meatDirection) == MeatBase.DONENESS_BURN_BLACK) {
|
||||||
|
// console.log("sprite burn black");
|
||||||
this.loadTexture(this.spriteNameBurnBlack);
|
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);
|
this.loadTexture(this.spriteNameWelldone);
|
||||||
} else {
|
} else {
|
||||||
|
// console.log("sprite rare");
|
||||||
this.loadTexture(this.spriteNameRare);
|
this.loadTexture(this.spriteNameRare);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -248,7 +247,7 @@ MeatBase.prototype.setActive = function(isActivated, x, y, meat_type) {
|
|||||||
|
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.y = y;
|
this.y = y;
|
||||||
this.loadTexture('meat1');
|
this.loadTexture(this.spriteNameRare);
|
||||||
this.angle = MeatBase.ANGLE_NONE;
|
this.angle = MeatBase.ANGLE_NONE;
|
||||||
this.alpha = 1;
|
this.alpha = 1;
|
||||||
}
|
}
|
||||||
@@ -327,5 +326,5 @@ MeatBase.ANGLE_NONE = 0;
|
|||||||
MeatBase.ANGLE_FRONT = 30;
|
MeatBase.ANGLE_FRONT = 30;
|
||||||
MeatBase.ANGLE_BACK = -30;
|
MeatBase.ANGLE_BACK = -30;
|
||||||
|
|
||||||
MeatBase.COOK_TIME_WELLDONE = 200;
|
MeatBase.COOK_TIME_WELLDONE = 20;
|
||||||
MeatBase.COOK_TIME_BURN = 400;
|
MeatBase.COOK_TIME_BURN = 400;
|
||||||
@@ -1,11 +1,14 @@
|
|||||||
NormalMeat.prototype = MeatBase.prototype;
|
NormalMeat.prototype = MeatBase.prototype;
|
||||||
NormalMeat.constructor = NormalMeat;
|
NormalMeat.constructor = NormalMeat;
|
||||||
|
|
||||||
function NormalMeat() {
|
function NormalMeat(mainGame) {
|
||||||
|
this.mainGame = mainGame;
|
||||||
|
|
||||||
MeatBase.call(this);
|
MeatBase.call(this);
|
||||||
|
|
||||||
this.setMeatTypeVariables();
|
this.setMeatTypeVariables();
|
||||||
this.randomizeMeatType();
|
this.randomizeMeatType();
|
||||||
|
this.setSprite();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -15,20 +18,23 @@ NormalMeat.prototype.setMeatTypeVariables = function() {
|
|||||||
|
|
||||||
NormalMeat.prototype.randomizeMeatType = function() {
|
NormalMeat.prototype.randomizeMeatType = function() {
|
||||||
this.meatType = Math.floor(Math.random() * 3) + 1;
|
this.meatType = Math.floor(Math.random() * 3) + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
NormalMeat.prototype.setSprite = function() {
|
||||||
switch(this.meatType) {
|
switch(this.meatType) {
|
||||||
case 1:
|
case 1:
|
||||||
this.scale.set(0.5);
|
this.baseScale = 0.4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
this.scale.set(0.5);
|
this.baseScale = 0.4;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 3:
|
case 3:
|
||||||
this.scale.set(0.5);
|
this.baseScale = 0.5;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
this.scale.set(this.baseScale);
|
||||||
|
|
||||||
this.spriteNameRare = NormalMeat.SPRITE_NAME_RARE + this.meatType;
|
this.spriteNameRare = NormalMeat.SPRITE_NAME_RARE + this.meatType;
|
||||||
this.spriteNameWelldone = NormalMeat.SPRITE_NAME_WELLDONE + this.meatType;
|
this.spriteNameWelldone = NormalMeat.SPRITE_NAME_WELLDONE + this.meatType;
|
||||||
|
|||||||
Reference in New Issue
Block a user