Browse Source

working score screen, fixes

Load_Fix
Robert Chen 11 years ago
parent
commit
b26e68474f
  1. 1
      js/dialogue.js
  2. 2
      js/main.js
  3. 2
      js/model.js
  4. 113
      js/screens.js
  5. 3
      js/ui.js
  6. BIN
      res/screens/.DS_Store
  7. BIN
      res/screens/KitchenScreen/.DS_Store
  8. BIN
      res/screens/KitchenScreen/Cookbook-Open.png

1
js/dialogue.js

@ -114,6 +114,7 @@ function DialogUI( stage, gameState ){
console.log("random story"); console.log("random story");
this.showDialog( {seq: dialogueList[ randomKey ] || "Dad Tells a bad Joke", autoAdvance:true } ); this.showDialog( {seq: dialogueList[ randomKey ] || "Dad Tells a bad Joke", autoAdvance:true } );
delete story[ dialogueList[ randomKey ] ]; delete story[ dialogueList[ randomKey ] ];
gameState.dialogueHeard++;
} }
} }

2
js/main.js

@ -24,7 +24,7 @@ function GameState(){
// stats // stats
this.storeVisits = 0; this.storeVisits = 0;
this.dialogHeard = 0; this.dialogueHeard = 0;
this.ovenOpened = 0; this.ovenOpened = 0;
// modifiers // modifiers

2
js/model.js

@ -293,7 +293,7 @@ UtilityFunctions = {
cookCondition: function(cookValue,volume){ cookCondition: function(cookValue,volume){
var multiplier = 1; var multiplier = 1;
if (cookValue>=multiplier*600000) { if (cookValue>=multiplier*600000) {
return ["Fire", (cookValue-600000)/(multiplier*600000),"like it's on fire"]; return ["Fire", (cookValue-600000)/(multiplier*600000),"fire"];
} }
else if(cookValue>=multiplier*250000) { else if(cookValue>=multiplier*250000) {
return ["Burnt", (cookValue-250000)/(multiplier*600000), "burnt"]; return ["Burnt", (cookValue-250000)/(multiplier*600000), "burnt"];

113
js/screens.js

@ -206,8 +206,8 @@ function DifficultyScreen( stage, gameState ){
stage.addChild( new Button( stage, gameState, 500, 235, 100, 55, "ChangeGender", "Male" ) ); stage.addChild( new Button( stage, gameState, 500, 235, 100, 55, "ChangeGender", "Male" ) );
stage.addChild( new Button( stage, gameState, 500, 300, 100, 55, "ChangeGender", "Female" ) ); stage.addChild( new Button( stage, gameState, 500, 300, 100, 55, "ChangeGender", "Female" ) );
stage.addChild( new Button( stage, gameState, 503, 370, 200, 55, null, null, function(){ gameState.hard = false; gameState.gameStarted = true; gameState.pubsub.publish("SwitchScreen", "KitchenScreen"); } ) ); stage.addChild( new Button( stage, gameState, 503, 370, 200, 55, null, null, function(){ gameState.hard = false; gameState.gameStarted = true; gameState.hardcoreModifier=20; gameState.pubsub.publish("SwitchScreen", "KitchenScreen"); } ) );
stage.addChild( new Button( stage, gameState, 500, 495, 205, 55, null, null, function(){ gameState.hard = true; gameState.gameStarted = true; gameState.pubsub.publish("SwitchScreen", "KitchenScreen"); } ) ); stage.addChild( new Button( stage, gameState, 500, 495, 205, 55, null, null, function(){ gameState.hard = true; gameState.gameStarted = true; gameState.hardcoreModifier=1; gameState.pubsub.publish("SwitchScreen", "KitchenScreen"); } ) );
stage.addChild( new Button( stage, gameState, 35, 495, 85, 55, "SwitchScreen", "MainScreen" ) ); stage.addChild( new Button( stage, gameState, 35, 495, 85, 55, "SwitchScreen", "MainScreen" ) );
@ -396,17 +396,43 @@ function ScoreScreen( stage, gameState ){
var realTimeElapsed = Date.now() - gameState.startTime; var realTimeElapsed = Date.now() - gameState.startTime;
var turkeyState = gameState.ovenModel.getTurkeyState(); var turkeyState = gameState.ovenModel.getTurkeyState();
var finalCoreTemperature; var totalScore = 0;
var totalScore;
var skinScoreChart = {
"raw": 0,
"undercooked": -100,
"slightly cooked": 75,
"cooked": 500,
"overcooked": 200,
"dry": -300,
"burnt": -500
};
var coreScoreChart = {
"raw": 0,
"undercooked": 125,
"slightly cooked": 750,
"cooked": 1000,
"overcooked": 1000,
"dry": 400,
"burnt": 0
}
// Optimal Temperature to be served at
this.scoreDistribution= function(inputTemp) {
desiredAverage = 162;
variance = 1000; //Std Deviation 31.62
return(Math.exp(-(Math.pow((inputTemp-desiredAverage),2)/(2*variance))))
};
gameState.pubsub.publish( "FadeOut", "" ); gameState.pubsub.publish( "FadeOut", "" );
this.background = new createjs.Bitmap( "res/screens/ScoreScreen/Score-Evaluation-1.png" ); this.background = new createjs.Bitmap( "res/screens/ScoreScreen/Score-Evaluation-1.png" );
this.background.alpha = 0; this.background.alpha = 1;
stage.addChild( this.background ); stage.addChild( this.background );
background1 = new createjs.Bitmap( "res/screens/ScoreScreen/Score-Evaluation-2.png" ); background1 = new createjs.Bitmap( "res/screens/ScoreScreen/Score-Evaluation-2.png" );
background1.alpha = 1; background1.alpha = 0;
stage.addChild( background1 ); stage.addChild( background1 );
for (i in gameState.turkeyStates){ for (i in gameState.turkeyStates){
@ -421,24 +447,23 @@ function ScoreScreen( stage, gameState ){
gameState.pubsub.publish( "ShowDialog", {seq:"NoMoney", autoAdvance:true, endFunc:function(){ gameState.pubsub.publish( "ShowDialog", {seq:"NoMoney", autoAdvance:true, endFunc:function(){
background1.alpha=1; background1.alpha=1;
}} );
stage.addChild( new Button( stage, gameState, 590, 540, 190, 50, null, null, function(){ document.location.reload(); } ) ); stage.addChild( new Button( stage, gameState, 590, 540, 190, 50, null, null, function(){ document.location.reload(); } ) );
// Cooking stats // Cooking stats
var hours = parseInt( totalCookTime / 3600 ) % 24 var hours = parseInt( totalCookTime / 3600 ) % 24;
var minutes = parseInt( totalCookTime / 60 ) % 60; var minutes = parseInt( totalCookTime / 60 ) % 60;
var timeText = hours + ":" + minutes; var seconds = totalCookTime % 60;
var timeText = ("00"+hours).slice(-2) + ":" + ("00"+minutes).slice(-2) + ":" + ("00"+seconds).slice(-2);
var totalCookTimeText = new createjs.Text( timeText, "20px Arial", "#00000000" ); var totalCookTimeText = new createjs.Text( timeText, "20px Arial", "#00000000" );
totalCookTimeText.x = 270; totalCookTimeText.x = 270;
totalCookTimeText.y = 107; totalCookTimeText.y = 107;
realTimeElapsed /= 1000; realTimeElapsed /= 1000;
hours = parseInt( realTimeElapsed / 3600 ) % 24 hours = parseInt( realTimeElapsed / 3600 ) % 24;
minutes = parseInt( realTimeElapsed / 60 ) % 60; minutes = parseInt( realTimeElapsed / 60 ) % 60;
timeText = hours + ":" + minutes; seconds = realTimeElapsed % 60;
timeText = ("00"+hours).slice(-2) + ":" + ("00"+minutes).slice(-2) + ":" + ("00"+seconds).slice(-2);
var realtimeElapsedText = new createjs.Text( timeText, "20px Arial", "#00000000" ); var realtimeElapsedText = new createjs.Text( timeText, "20px Arial", "#00000000" );
realtimeElapsedText.x = 270; realtimeElapsedText.x = 270;
@ -448,7 +473,7 @@ function ScoreScreen( stage, gameState ){
ovenOpenedText.x = 270; ovenOpenedText.x = 270;
ovenOpenedText.y = 147; ovenOpenedText.y = 147;
var dialogueHeardText = new createjs.Text( gameState.dialogHeard, "20px Arial", "#00000000" ); var dialogueHeardText = new createjs.Text( gameState.dialogueHeard, "20px Arial", "#00000000" );
dialogueHeardText.x = 270; dialogueHeardText.x = 270;
dialogueHeardText.y = 167; dialogueHeardText.y = 167;
@ -459,22 +484,28 @@ function ScoreScreen( stage, gameState ){
stage.addChild( dialogueHeardText ); stage.addChild( dialogueHeardText );
// Cookedness Score // Cookedness Score
var outerConditionText = new createjs.Text( "100", "20px Arial", "#00000000" );
outerConditionText.x = 310;
outerConditionText.y = 320;
var coreConditionText = new createjs.Text( "200", "20px Arial", "#00000000" ); var outerConditionDesc = new createjs.Text( turkeyState.skin.cond[2], "20px Arial", "#00000000" );
coreConditionText.x = 310;
coreConditionText.y = 340;
var outerConditionDesc = new createjs.Text( "RAW", "20px Arial", "#00000000" );
outerConditionDesc.x = 150; outerConditionDesc.x = 150;
outerConditionDesc.y = 320; outerConditionDesc.y = 320;
var coreConditionDesc = new createjs.Text( "COOKED", "20px Arial", "#00000000" ); totalScore += parseInt(skinScoreChart[ turkeyState.skin.cond[2]]);
var coreConditionDesc = new createjs.Text( turkeyState.core.cond[2], "20px Arial", "#00000000" );
coreConditionDesc.x = 150; coreConditionDesc.x = 150;
coreConditionDesc.y = 340; coreConditionDesc.y = 340;
totalScore += parseInt(skinScoreChart[ turkeyState.core.cond[2]]);
var outerConditionText = new createjs.Text( skinScoreChart[ turkeyState.skin.cond[2] ], "20px Arial", "#00000000" );
outerConditionText.x = 310;
outerConditionText.y = 320;
var coreConditionText = new createjs.Text( coreScoreChart[ turkeyState.skin.cond[2] ], "20px Arial", "#00000000" );
coreConditionText.x = 310;
coreConditionText.y = 340;
stage.addChild( coreConditionText ); stage.addChild( coreConditionText );
stage.addChild( outerConditionText ); stage.addChild( outerConditionText );
@ -485,11 +516,14 @@ function ScoreScreen( stage, gameState ){
var outerTemp = UtilityFunctions.C2F(turkeyState.skin.temp).toFixed(2); var outerTemp = UtilityFunctions.C2F(turkeyState.skin.temp).toFixed(2);
var coreTemp = UtilityFunctions.C2F(turkeyState.core.temp).toFixed(2); var coreTemp = UtilityFunctions.C2F(turkeyState.core.temp).toFixed(2);
var outerTemperatureText = new createjs.Text( "100", "20px Arial", "#00000000" ); var outerTempScore = that.scoreDistribution( outerTemp ) * 200;
var coreTempScore = that.scoreDistribution( coreTemp ) * 200;
var outerTemperatureText = new createjs.Text( outerTempScore.toFixed(0), "20px Arial", "#00000000" );
outerTemperatureText.x = 680; outerTemperatureText.x = 680;
outerTemperatureText.y = 320; outerTemperatureText.y = 320;
var coreTemperatureText = new createjs.Text( "200", "20px Arial", "#00000000" ); var coreTemperatureText = new createjs.Text( coreTempScore.toFixed(0), "20px Arial", "#00000000" );
coreTemperatureText.x = 680; coreTemperatureText.x = 680;
coreTemperatureText.y = 340; coreTemperatureText.y = 340;
@ -497,45 +531,60 @@ function ScoreScreen( stage, gameState ){
outerTemperatureDesc.x = 530; outerTemperatureDesc.x = 530;
outerTemperatureDesc.y = 320; outerTemperatureDesc.y = 320;
totalScore += parseInt(outerTempScore.toFixed(0));
var coreTemperatureDesc = new createjs.Text( coreTemp + " F", "20px Arial", "#00000000" ); var coreTemperatureDesc = new createjs.Text( coreTemp + " F", "20px Arial", "#00000000" );
coreTemperatureDesc.x = 530; coreTemperatureDesc.x = 530;
coreTemperatureDesc.y = 340; coreTemperatureDesc.y = 340;
totalScore += parseInt(coreTempScore.toFixed(0));
stage.addChild( outerTemperatureText ); stage.addChild( outerTemperatureText );
stage.addChild( coreTemperatureText ); stage.addChild( coreTemperatureText );
stage.addChild( coreTemperatureDesc ); stage.addChild( coreTemperatureDesc );
stage.addChild( outerTemperatureDesc ); stage.addChild( outerTemperatureDesc );
console.log(totalScore);
// Modifiers // Modifiers
var turkeyTypeModifierText = new createjs.Text( "x"+"1", "20px Arial", "#00000000" ); var turkeyTypeModifierText = new createjs.Text( "x"+"1", "20px Arial", "#00000000" );
turkeyTypeModifierText.x = 310; turkeyTypeModifierText.x = 310;
turkeyTypeModifierText.y = 437; turkeyTypeModifierText.y = 437;
totalScore *= 1;
var stuffingTypeModifierText = new createjs.Text( "x"+"1", "20px Arial", "#00000000" ); var stuffingTypeModifierText = new createjs.Text( "x"+"1", "20px Arial", "#00000000" );
stuffingTypeModifierText.x = 310 stuffingTypeModifierText.x = 310
stuffingTypeModifierText.y = 457; stuffingTypeModifierText.y = 457;
totalScore *= 1;
var frillsModifierText = new createjs.Text( "x"+"1", "20px Arial", "#00000000" ); var frillsModifierText = new createjs.Text( "x"+"1", "20px Arial", "#00000000" );
frillsModifierText.x = 310 frillsModifierText.x = 310
frillsModifierText.y = 477; frillsModifierText.y = 477;
var hardcoreModifierText = new createjs.Text( "x"+"10", "20px Arial", "#00000000" ); totalScore *= 1;
var hardcoreModifierText = new createjs.Text( "x"+gameState.hardcoreModifier, "20px Arial", "#00000000" );
hardcoreModifierText.x = 310 hardcoreModifierText.x = 310
hardcoreModifierText.y = 497; hardcoreModifierText.y = 497;
totalScore *= gameState.hardcoreModifier;
var totalText = new createjs.Text( totalScore, "32px Arial", "#00000000" );
totalText.x = 250
totalText.y = 550;
stage.addChild( totalText );
stage.addChild( stuffingTypeModifierText ); stage.addChild( stuffingTypeModifierText );
stage.addChild( turkeyTypeModifierText ); stage.addChild( turkeyTypeModifierText );
stage.addChild( frillsModifierText ); stage.addChild( frillsModifierText );
stage.addChild( hardcoreModifierText ); stage.addChild( hardcoreModifierText );
// Optimal Temperature to be served at
this.scoreDistribution= function(inputTemp) { }} );
desiredAverage = 162;
variance = 1000; //Std Deviation 31.62
return(Math.exp(-(Math.pow((inputTemp-desiredAverage),2)/(2*variance))))
};
return { return {
blit : function(){} blit : function(){}

3
js/ui.js

@ -421,6 +421,7 @@ function OvenUI( stage, gameState ){
gameState.pubsub.publish( "ShowDialog", {seq:"custom", autoAdvance:true, customText:"Hmm... Looks " + turkeyState["skin"]["cond"][2] + "." } ); gameState.pubsub.publish( "ShowDialog", {seq:"custom", autoAdvance:true, customText:"Hmm... Looks " + turkeyState["skin"]["cond"][2] + "." } );
gameState.pubsub.publish( "AddRecord", {type:"Open ", text:"The turkey looked " + turkeyState["skin"]["cond"][2]} ); gameState.pubsub.publish( "AddRecord", {type:"Open ", text:"The turkey looked " + turkeyState["skin"]["cond"][2]} );
gameState.ovenModel.setRawTemp( (gameState.ovenModel.getRawTemp() - 25) < 150 ? 150 : gameState.ovenModel.getRawTemp() - 25 ); gameState.ovenModel.setRawTemp( (gameState.ovenModel.getRawTemp() - 25) < 150 ? 150 : gameState.ovenModel.getRawTemp() - 25 );
gameState.ovenOpened++;
} }
gameState.pubsub.publish( "Play", "Oven_Door_Full_Open" ); gameState.pubsub.publish( "Play", "Oven_Door_Full_Open" );
@ -451,7 +452,6 @@ function OvenUI( stage, gameState ){
var state = gameState.ovenModel.getTurkeyState(); var state = gameState.ovenModel.getTurkeyState();
gameState.pubsub.publish( "ShowDialog", {seq:"custom", autoAdvance:true, customText:"Looks " + turkeyState["skin"]["cond"][2] } ); gameState.pubsub.publish( "ShowDialog", {seq:"custom", autoAdvance:true, customText:"Looks " + turkeyState["skin"]["cond"][2] } );
gameState.pubsub.publish( "AddRecord", {type:"Peek ", text:"The turkey looked " + turkeyState["skin"]["cond"][2]} ); gameState.pubsub.publish( "AddRecord", {type:"Peek ", text:"The turkey looked " + turkeyState["skin"]["cond"][2]} );
that.ovenOpened++;
} }
} }
else if (that.ovenDoor == OVEN_PEEK){ else if (that.ovenDoor == OVEN_PEEK){
@ -475,7 +475,6 @@ function OvenUI( stage, gameState ){
state = gameState.ovenModel.getTurkeyState(); state = gameState.ovenModel.getTurkeyState();
gameState.pubsub.publish( "ShowDialog", {seq:"custom", autoAdvance:true, customText:"The core temperature of the turkey reads " + UtilityFunctions.C2F(state.core.temp).toFixed(2) + " F" } ); gameState.pubsub.publish( "ShowDialog", {seq:"custom", autoAdvance:true, customText:"The core temperature of the turkey reads " + UtilityFunctions.C2F(state.core.temp).toFixed(2) + " F" } );
gameState.pubsub.publish( "AddRecord", {type:"Probe", text:"Core temperature measured: " + UtilityFunctions.C2F(state.core.temp).toFixed(2) + " F"} ); gameState.pubsub.publish( "AddRecord", {type:"Probe", text:"Core temperature measured: " + UtilityFunctions.C2F(state.core.temp).toFixed(2) + " F"} );
that.ovenOpened++;
} }
} }

BIN
res/screens/.DS_Store vendored

Binary file not shown.

BIN
res/screens/KitchenScreen/.DS_Store vendored

Binary file not shown.

BIN
res/screens/KitchenScreen/Cookbook-Open.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 283 KiB

After

Width:  |  Height:  |  Size: 333 KiB

Loading…
Cancel
Save