Browse Source

Tie cooked condition with visuals

Load_Fix
Robert Chen 11 years ago
parent
commit
6a3de60397
  1. 12
      js/model.js
  2. 37
      js/ui.js
  3. BIN
      res/screens/.DS_Store

12
js/model.js

@ -282,22 +282,22 @@ UtilityFunctions = { @@ -282,22 +282,22 @@ UtilityFunctions = {
cookCondition: function(cookValue,volume){
var multiplier = 1;
if (cookValue>=multiplier*600000) {
return("House Fire")
return ["House Fire", (cookValue-600000)/(multiplier*600000)];
}
else if(cookValue>=multiplier*250000) {
return("Charcoal")
return ["Charcoal", (cookValue-250000)/(multiplier*600000)];
}
else if (cookValue>=multiplier*150000) {
return("Dry")
return ["Dry", (cookValue-150000)/(multiplier*250000)];
}
else if (cookValue>=multiplier*12000) {
return("Cooked")
return ["Cooked", (cookValue-12000)/(multiplier*150000)];
}
else if (cookValue>=multiplier*5000) {
return("Undercooked")
return ["Undercooked", (cookValue-5000)/(multiplier*12000)];
}
else {
return("Raw")
return ["Raw", 1];
}
}
}

37
js/ui.js

@ -300,15 +300,32 @@ function OvenUI( stage, gameState ){ @@ -300,15 +300,32 @@ function OvenUI( stage, gameState ){
}
});
return {
tick: function(){
// IMPORTANT: SECOND TIMER
var diff = Date.now() - gameState.oldTime;
if( diff > 1000 ){
gameState.oldTime = Date.now();
that.secondTick( diff );
console.log(new Date( gameState.currentTime) );
}
if( gameState.turkeyBought ){
// what's the state of the turkey
turkeyState = ovenModel.getTurkeyState();
turkeyStates[0].alpha = 1;
if( turkeyState["skin"]["cond"][0] == "Undercooked" )
turkeyStates[1].alpha = turkeyState["skin"]["cond"][1];
if( turkeyState["skin"]["cond"][0] == "Cooked" )
turkeyStates[2].alpha = turkeyState["skin"]["cond"][1];
if( turkeyState["skin"]["cond"][0] == "Dry" )
turkeyStates[3].alpha = turkeyState["skin"]["cond"][1];
if( turkeyState["skin"]["cond"][0] == "Charcoal" )
turkeyStates[4].alpha = turkeyState["skin"]["cond"][1];
if( turkeyState["skin"]["cond"][0] == "House Fire" )
turkeyStates[4].alpha = 1;
}
}
},
render: function(){
@ -320,7 +337,21 @@ function OvenUI( stage, gameState ){ @@ -320,7 +337,21 @@ function OvenUI( stage, gameState ){
// Turkey goes here
// did the player actually buy a turkey? if so, determine its cooked state
if( gameState.turkeyBought ){
// what's the state of the turkey
turkeyState = ovenModel.getTurkeyState();
turkeyStates[0].alpha = 1;
if( turkeyState["skin"]["cond"] == "Undercooked" )
turkeyStates[1].alpha = turkeyState["skin"]["cond"][1];
if( turkeyState["skin"]["cond"] == "Cooked" )
turkeyStates[2].alpha = turkeyState["skin"]["cond"][1];
if( turkeyState["skin"]["cond"] == "Dry" )
turkeyStates[3].alpha = turkeyState["skin"]["cond"][1];
if( turkeyState["skin"]["cond"] == "Charcoal" )
turkeyStates[4].alpha = turkeyState["skin"]["cond"][1];
if( turkeyState["skin"]["cond"] == "House Fire" )
turkeyStates[4].alpha = 1;
panFront.alpha = 1;
for(i in turkeyStates){
stage.addChild(turkeyStates[i]);
@ -398,8 +429,6 @@ return { @@ -398,8 +429,6 @@ return {
}
else
streetLight.alpha = 0;
}
}
}

BIN
res/screens/.DS_Store vendored

Binary file not shown.
Loading…
Cancel
Save