Add: cookingTimeByGrade

This commit is contained in:
2019-12-12 08:11:49 +09:00
parent 37ba3a2eeb
commit 8dce19a228
6 changed files with 84 additions and 73 deletions
Binary file not shown.
+7 -11
View File
@@ -14,12 +14,9 @@ function BonusMeat(mainGame) {
BonusMeat.prototype.setBonusMeatTypeVariables = function() { BonusMeat.prototype.setBonusMeatTypeVariables = function() {
this.className = BonusMeat.CLASS_NAME; this.className = BonusMeat.CLASS_NAME;
this.cookingSpeedArray = []; this.cookingTimeForGradeArray[MeatBase.DONENESS_WELLDONE] = BonusMeat.COOKING_TIME_WELLDONE_MS;
this.cookingSpeedArray[HeatPlate.BURN_LEVEL_WEAK] = BonusMeat.COOKING_SPEED_BURN_LEVEL_WEAK; this.cookingTimeForGradeArray[MeatBase.DONENESS_BURN_BLACK] = BonusMeat.COOKING_TIME_BURN_BLACK_MS;
this.cookingSpeedArray[HeatPlate.BURN_LEVEL_NORMAL] = BonusMeat.COOKING_SPEED_BURN_LEVEL_NORMAL;
this.cookingSpeedArray[HeatPlate.BURN_LEVEL_STRONG] = BonusMeat.COOKING_SPEED_BURN_LEVEL_STRONG;
this.scoreArray = [];
this.scoreArray[MeatBase.DONENESS_RARE] = BonusMeat.SCORE_NAME_RARE; this.scoreArray[MeatBase.DONENESS_RARE] = BonusMeat.SCORE_NAME_RARE;
this.scoreArray[MeatBase.DONENESS_WELLDONE] = BonusMeat.SCORE_NAME_WELLDONE; this.scoreArray[MeatBase.DONENESS_WELLDONE] = BonusMeat.SCORE_NAME_WELLDONE;
this.scoreArray[MeatBase.DONENESS_BURN_BLACK] = BonusMeat.SCORE_NAME_BURN_BLACK; this.scoreArray[MeatBase.DONENESS_BURN_BLACK] = BonusMeat.SCORE_NAME_BURN_BLACK;
@@ -38,13 +35,12 @@ BonusMeat.prototype.setBonusMeatSprite = function() {
BonusMeat.CLASS_NAME = "BonusMeat"; BonusMeat.CLASS_NAME = "BonusMeat";
BonusMeat.COOKING_SPEED_BURN_LEVEL_WEAK = 0.1; BonusMeat.COOKING_TIME_WELLDONE_MS = 500;
BonusMeat.COOKING_SPEED_BURN_LEVEL_NORMAL = 0.2; BonusMeat.COOKING_TIME_BURN_BLACK_MS = 700;
BonusMeat.COOKING_SPEED_BURN_LEVEL_STRONG = 0.3;
BonusMeat.SCORE_NAME_RARE = 1; BonusMeat.SCORE_NAME_RARE = 2; // cooking time * 2
BonusMeat.SCORE_NAME_WELLDONE = 5; BonusMeat.SCORE_NAME_WELLDONE = 4; // cooking time * 4
BonusMeat.SCORE_NAME_BURN_BLACK = 1; BonusMeat.SCORE_NAME_BURN_BLACK = 10; // 10
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";
+6
View File
@@ -144,6 +144,7 @@ var Game = {
onChangeDialLevel: function(dialLevel) { onChangeDialLevel: function(dialLevel) {
this.burnLevel = dialLevel; this.burnLevel = dialLevel;
// console.log(this.burnLevel);
this.heatPlate.onChangeDialLevel(dialLevel); this.heatPlate.onChangeDialLevel(dialLevel);
}, },
@@ -152,6 +153,11 @@ var Game = {
this.isEnableClick = value; this.isEnableClick = value;
}, },
getBurnLevel: function() {
// console.log(this.burnLevel);
return this.burnLevel;
},
back: function() { back: function() {
sessionStorageManager.resetPlayingAppData(); sessionStorageManager.resetPlayingAppData();
location.href = '../../web/client/main_menu.html'; location.href = '../../web/client/main_menu.html';
+54 -41
View File
@@ -39,14 +39,14 @@ MeatBase.prototype.initMeatTypeVariables = function() {
this.baseScale = 0.5; this.baseScale = 0.5;
this.cookingSide = MeatBase.MEAT_NONE; this.cookingSide = MeatBase.MEAT_NONE;
this.cookingTime = [];
this.cookingGrade = [];
this.cookingTime[MeatBase.MEAT_BACK] = 0; this.cookingTimeBySide = [];
this.cookingTime[MeatBase.MEAT_FRONT] = 0; this.cookingTimeBySide[MeatBase.MEAT_BACK] = 0;
this.cookingTimeBySide[MeatBase.MEAT_FRONT] = 0;
this.cookingGrade[MeatBase.MEAT_BACK] = MeatBase.DONENESS_RARE; this.cookingGradeBySide = [];
this.cookingGrade[MeatBase.MEAT_FRONT] = MeatBase.DONENESS_RARE; this.cookingGradeBySide[MeatBase.MEAT_BACK] = MeatBase.DONENESS_RARE;
this.cookingGradeBySide[MeatBase.MEAT_FRONT] = MeatBase.DONENESS_RARE;
this.isActivated = true; this.isActivated = true;
this.isStartCook = false; this.isStartCook = false;
@@ -58,13 +58,15 @@ MeatBase.prototype.initMeatTypeVariables = function() {
this.initCookingSpeedArray(); this.initCookingSpeedArray();
this.initScoreArray(); this.initScoreArray();
this.initCookingTimeForGradeArray();
} }
MeatBase.prototype.initCookingSpeedArray = function() { MeatBase.prototype.initCookingSpeedArray = function() {
this.cookingSpeedArray = []; this.cookingSpeedArray = [];
this.cookingSpeedArray[HeatPlate.BURN_LEVEL_WEAK] = 1; this.cookingSpeedArray[HeatPlate.BURN_LEVEL_WEAK] = MeatBase.COOKING_SPEED_BURN_LEVEL_WEAK;
this.cookingSpeedArray[HeatPlate.BURN_LEVEL_NORMAL] = 2; this.cookingSpeedArray[HeatPlate.BURN_LEVEL_NORMAL] = MeatBase.COOKING_SPEED_BURN_LEVEL_NORMAL;
this.cookingSpeedArray[HeatPlate.BURN_LEVEL_STRONG] = 3; this.cookingSpeedArray[HeatPlate.BURN_LEVEL_STRONG] = MeatBase.COOKING_SPEED_BURN_LEVEL_STRONG;
} }
MeatBase.prototype.initScoreArray = function() { MeatBase.prototype.initScoreArray = function() {
@@ -74,6 +76,12 @@ MeatBase.prototype.initScoreArray = function() {
this.scoreArray[MeatBase.DONENESS_BURN_BLACK] = 0; this.scoreArray[MeatBase.DONENESS_BURN_BLACK] = 0;
} }
MeatBase.prototype.initCookingTimeForGradeArray = function() {
this.cookingTimeForGradeArray = [];
this.cookingTimeForGradeArray[MeatBase.DONENESS_WELLDONE] = NormalMeat.COOKING_TIME_WELLDONE_MS;
this.cookingTimeForGradeArray[MeatBase.DONENESS_BURN_BLACK] = NormalMeat.COOKING_TIME_BURN_BLACK_MS;
}
MeatBase.prototype.initMouseEventHandler = function() { MeatBase.prototype.initMouseEventHandler = function() {
this.downPositionX; this.downPositionX;
this.downPositionY; this.downPositionY;
@@ -161,17 +169,17 @@ MeatBase.prototype.getClassName = function() {
} }
MeatBase.prototype.getTotalCookingTime = function() { MeatBase.prototype.getTotalCookingTime = function() {
return this.cookingTime[MeatBase.MEAT_BACK] + this.cookingTime[MeatBase.MEAT_FRONT]; return this.cookingTimeBySide[MeatBase.MEAT_BACK] + this.cookingTimeBySide[MeatBase.MEAT_FRONT];
} }
MeatBase.prototype.getScore = function() { MeatBase.prototype.getScore = function() {
var meatDoneness = this.getMeatGrade(); var meatDoneness = this.getMeatGrade();
var scoreDoneness = this.scoreArray[meatDoneness]; var scoreDoneness = this.scoreArray[meatDoneness];
var totalCookingTime = this.getTotalCookingTime();
if(meatDoneness == MeatBase.DONENESS_BURN_BLACK) if(meatDoneness == MeatBase.DONENESS_BURN_BLACK)
return scoreDoneness; return scoreDoneness;
var totalCookingTime = this.getTotalCookingTime();
return scoreDoneness * totalCookingTime; return scoreDoneness * totalCookingTime;
} }
@@ -250,16 +258,22 @@ MeatBase.prototype.stopCook = function() {
} }
MeatBase.prototype.getMeatGrade = function() { MeatBase.prototype.getMeatGrade = function() {
if(this.cookingGrade[MeatBase.MEAT_FRONT] == MeatBase.DONENESS_WELLDONE && this.cookingGrade[MeatBase.MEAT_BACK] == MeatBase.DONENESS_WELLDONE) if(
this.cookingGradeBySide[MeatBase.MEAT_FRONT] == MeatBase.DONENESS_WELLDONE
&& this.cookingGradeBySide[MeatBase.MEAT_BACK] == MeatBase.DONENESS_WELLDONE
) {
return MeatBase.DONENESS_WELLDONE; return MeatBase.DONENESS_WELLDONE;
else if(this.cookingGrade[MeatBase.MEAT_FRONT] == MeatBase.DONENESS_BURN_BLACK || this.cookingGrade[MeatBase.MEAT_BACK] == MeatBase.DONENESS_BURN_BLACK) } else if(
this.cookingGradeBySide[MeatBase.MEAT_FRONT] == MeatBase.DONENESS_BURN_BLACK
|| this.cookingGradeBySide[MeatBase.MEAT_BACK] == MeatBase.DONENESS_BURN_BLACK
) {
return MeatBase.DONENESS_BURN_BLACK; return MeatBase.DONENESS_BURN_BLACK;
else } else
return MeatBase.DONENESS_RARE; return MeatBase.DONENESS_RARE;
} }
MeatBase.prototype.getMeatGradeBySide = function(cookingSide) { MeatBase.prototype.getMeatGradeBySide = function(cookingSide) {
return this.cookingGrade[cookingSide]; return this.cookingGradeBySide[cookingSide];
} }
MeatBase.prototype.setActive = function(isActivated, x, y) { MeatBase.prototype.setActive = function(isActivated, x, y) {
@@ -274,10 +288,10 @@ MeatBase.prototype.setActive = function(isActivated, x, y) {
} }
this.cookingSide = MeatBase.MEAT_NONE; this.cookingSide = MeatBase.MEAT_NONE;
this.cookingTime[MeatBase.MEAT_BACK] = 0; this.cookingTimeBySide[MeatBase.MEAT_BACK] = 0;
this.cookingTime[MeatBase.MEAT_FRONT] = 0; this.cookingTimeBySide[MeatBase.MEAT_FRONT] = 0;
this.cookingGrade[MeatBase.MEAT_BACK] = MeatBase.DONENESS_RARE; this.cookingGradeBySide[MeatBase.MEAT_BACK] = MeatBase.DONENESS_RARE;
this.cookingGrade[MeatBase.MEAT_FRONT] = MeatBase.DONENESS_RARE; this.cookingGradeBySide[MeatBase.MEAT_FRONT] = MeatBase.DONENESS_RARE;
this.x = x; this.x = x;
this.y = y; this.y = y;
@@ -287,32 +301,27 @@ MeatBase.prototype.setActive = function(isActivated, x, y) {
} }
MeatBase.prototype.cooking = function() { MeatBase.prototype.cooking = function() {
this.cookingTime[this.cookingSide] += 1; var burnLevel = this.mainGame.getBurnLevel();
// console.log("back : " + this.cookingTime[MeatBase.MEAT_BACK] + ", front : " + this.cookingTime[MeatBase.MEAT_FRONT]); var cookingSpeed = this.cookingSpeedArray[burnLevel];
this.cookingTimeBySide[this.cookingSide] += 1 * cookingSpeed;
if(this.cookingTime[MeatBase.MEAT_BACK] > MeatBase.COOK_TIME_BURN) { var cookingTimeBurnBlack = this.cookingTimeForGradeArray[MeatBase.DONENESS_BURN_BLACK];
if(this.getMeatGradeBySide(MeatBase.MEAT_BACK) != MeatBase.DONENESS_BURN_BLACK) { var cookingTimeWelldone = this.cookingTimeForGradeArray[MeatBase.DONENESS_WELLDONE];
this.cookingGrade[MeatBase.MEAT_BACK] = MeatBase.DONENESS_BURN_BLACK;
if(this.cookingTimeBySide[this.cookingSide] > cookingTimeBurnBlack) {
if(this.getMeatGradeBySide(this.cookingSide) != MeatBase.DONENESS_BURN_BLACK) {
this.cookingGradeBySide[this.cookingSide] = MeatBase.DONENESS_BURN_BLACK;
this.changeAnimateSmokeColor(MeatBase.DONENESS_BURN_BLACK); this.changeAnimateSmokeColor(MeatBase.DONENESS_BURN_BLACK);
} }
} else if(this.cookingTime[MeatBase.MEAT_BACK] > MeatBase.COOK_TIME_WELLDONE) { } else if(this.cookingTimeBySide[this.cookingSide] > cookingTimeWelldone) {
if(this.getMeatGradeBySide(MeatBase.MEAT_BACK) != MeatBase.DONENESS_WELLDONE) { if(this.getMeatGradeBySide(this.cookingSide) != MeatBase.DONENESS_WELLDONE) {
this.cookingGrade[MeatBase.MEAT_BACK] = MeatBase.DONENESS_WELLDONE; this.cookingGradeBySide[this.cookingSide] = MeatBase.DONENESS_WELLDONE;
this.changeAnimateSmokeColor(MeatBase.DONENESS_WELLDONE); this.changeAnimateSmokeColor(MeatBase.DONENESS_WELLDONE);
} }
} }
}
if(this.cookingTime[MeatBase.MEAT_FRONT] > MeatBase.COOK_TIME_BURN) { MeatBase.prototype.setMeatGrade = function(side, grade) {
if(this.getMeatGradeBySide(MeatBase.MEAT_FRONT) != MeatBase.DONENESS_BURN_BLACK) {
this.cookingGrade[MeatBase.MEAT_FRONT] = MeatBase.DONENESS_BURN_BLACK;
this.changeAnimateSmokeColor(MeatBase.DONENESS_BURN_BLACK);
}
} else if(this.cookingTime[MeatBase.MEAT_FRONT] > MeatBase.COOK_TIME_WELLDONE) {
if(this.getMeatGradeBySide(MeatBase.MEAT_FRONT) != MeatBase.DONENESS_WELLDONE) {
this.cookingGrade[MeatBase.MEAT_FRONT] = MeatBase.DONENESS_WELLDONE;
this.changeAnimateSmokeColor(MeatBase.DONENESS_WELLDONE);
}
}
} }
MeatBase.prototype.stopAnimateSmoke = function() { MeatBase.prototype.stopAnimateSmoke = function() {
@@ -322,7 +331,7 @@ MeatBase.prototype.stopAnimateSmoke = function() {
} }
MeatBase.prototype.startAnimateSmoke = function() { MeatBase.prototype.startAnimateSmoke = function() {
var cookingSideGrade = this.cookingGrade[this.cookingSide]; var cookingSideGrade = this.cookingGradeBySide[this.cookingSide];
this.changeAnimateSmokeColor(cookingSideGrade); this.changeAnimateSmokeColor(cookingSideGrade);
} }
@@ -362,5 +371,9 @@ MeatBase.DONENESS_WELLDONE = 1;
MeatBase.DONENESS_BURN_BLACK = 2; MeatBase.DONENESS_BURN_BLACK = 2;
MeatBase.DONENESS_NONE = 3; MeatBase.DONENESS_NONE = 3;
MeatBase.COOK_TIME_WELLDONE = 200; MeatBase.COOKING_TIME_WELLDONE_MS = 200;
MeatBase.COOK_TIME_BURN = 400; MeatBase.COOKING_TIME_BURN_BLACK_MS = 400;
MeatBase.COOKING_SPEED_BURN_LEVEL_WEAK = 1;
MeatBase.COOKING_SPEED_BURN_LEVEL_NORMAL = 1.5;
MeatBase.COOKING_SPEED_BURN_LEVEL_STRONG = 2;
+7 -11
View File
@@ -15,12 +15,9 @@ function NormalMeat(mainGame) {
NormalMeat.prototype.setNormalMeatTypeVariables = function() { NormalMeat.prototype.setNormalMeatTypeVariables = function() {
this.className = NormalMeat.CLASS_NAME; this.className = NormalMeat.CLASS_NAME;
// this.cookingSpeedArray = []; this.cookingTimeForGradeArray[MeatBase.DONENESS_WELLDONE] = NormalMeat.COOKING_TIME_WELLDONE_MS;
this.cookingSpeedArray[HeatPlate.BURN_LEVEL_WEAK] = NormalMeat.COOKING_SPEED_BURN_LEVEL_WEAK; this.cookingTimeForGradeArray[MeatBase.DONENESS_BURN_BLACK] = NormalMeat.COOKING_TIME_BURN_BLACK_MS;
this.cookingSpeedArray[HeatPlate.BURN_LEVEL_NORMAL] = NormalMeat.COOKING_SPEED_BURN_LEVEL_NORMAL;
this.cookingSpeedArray[HeatPlate.BURN_LEVEL_STRONG] = NormalMeat.COOKING_SPEED_BURN_LEVEL_STRONG;
// this.scoreArray = [];
this.scoreArray[MeatBase.DONENESS_RARE] = NormalMeat.SCORE_NAME_RARE; this.scoreArray[MeatBase.DONENESS_RARE] = NormalMeat.SCORE_NAME_RARE;
this.scoreArray[MeatBase.DONENESS_WELLDONE] = NormalMeat.SCORE_WELLDONE; this.scoreArray[MeatBase.DONENESS_WELLDONE] = NormalMeat.SCORE_WELLDONE;
this.scoreArray[MeatBase.DONENESS_BURN_BLACK] = NormalMeat.SCORE_BURN_BLACK; this.scoreArray[MeatBase.DONENESS_BURN_BLACK] = NormalMeat.SCORE_BURN_BLACK;
@@ -57,13 +54,12 @@ NormalMeat.prototype.setNormalMeatSprite = function() {
NormalMeat.CLASS_NAME = "NormalMeat"; NormalMeat.CLASS_NAME = "NormalMeat";
NormalMeat.COOKING_SPEED_BURN_LEVEL_WEAK = 0.1; NormalMeat.COOKING_TIME_WELLDONE_MS = 200;
NormalMeat.COOKING_SPEED_BURN_LEVEL_NORMAL = 0.2; NormalMeat.COOKING_TIME_BURN_BLACK_MS = 400;
NormalMeat.COOKING_SPEED_BURN_LEVEL_STRONG = 0.3;
NormalMeat.SCORE_RARE = 1; NormalMeat.SCORE_RARE = 1; // cooking time * 1
NormalMeat.SCORE_WELLDONE = 2; NormalMeat.SCORE_WELLDONE = 2; // cooking time * 2
NormalMeat.SCORE_BURN_BLACK = 1; NormalMeat.SCORE_BURN_BLACK = 10; // 10
NormalMeat.SPRITE_NAME_RARE = "meat"; NormalMeat.SPRITE_NAME_RARE = "meat";
NormalMeat.SPRITE_NAME_WELLDONE = "meat_welldone"; NormalMeat.SPRITE_NAME_WELLDONE = "meat_welldone";
+7 -7
View File
@@ -16,7 +16,7 @@ function StoveDial(x, y) {
this.addDotSprite(); this.addDotSprite();
this.state = HeatPlate.BURN_LEVEL_WEAK; this.burnLevel = HeatPlate.BURN_LEVEL_WEAK;
this.setDialLevel(); this.setDialLevel();
} }
@@ -30,22 +30,22 @@ StoveDial.prototype.addDotSprite = function() {
} }
StoveDial.prototype.onDown = function() { StoveDial.prototype.onDown = function() {
switch(this.state) { switch(this.burnLevel) {
case HeatPlate.BURN_LEVEL_WEAK: case HeatPlate.BURN_LEVEL_WEAK:
this.state = HeatPlate.BURN_LEVEL_NORMAL; this.burnLevel = HeatPlate.BURN_LEVEL_NORMAL;
break; break;
case HeatPlate.BURN_LEVEL_NORMAL: case HeatPlate.BURN_LEVEL_NORMAL:
this.state = HeatPlate.BURN_LEVEL_STRONG; this.burnLevel = HeatPlate.BURN_LEVEL_STRONG;
break; break;
case HeatPlate.BURN_LEVEL_STRONG: case HeatPlate.BURN_LEVEL_STRONG:
this.state = HeatPlate.BURN_LEVEL_WEAK; this.burnLevel = HeatPlate.BURN_LEVEL_WEAK;
break; break;
} }
this.setDialLevel(); this.setDialLevel();
this.onChangeDialLevel(this.state); this.onChangeDialLevel(this.burnLevel);
} }
StoveDial.prototype.setOnChangeDialLevelHandler = function(eventHandler) { StoveDial.prototype.setOnChangeDialLevelHandler = function(eventHandler) {
@@ -54,7 +54,7 @@ StoveDial.prototype.setOnChangeDialLevelHandler = function(eventHandler) {
StoveDial.prototype.setDialLevel = function() { StoveDial.prototype.setDialLevel = function() {
switch(this.state) { switch(this.burnLevel) {
case HeatPlate.BURN_LEVEL_WEAK: case HeatPlate.BURN_LEVEL_WEAK:
this.angle = 30; this.angle = 30;
this.dot.tint = StoveDial.BURN_COLOR_WEAK; this.dot.tint = StoveDial.BURN_COLOR_WEAK;