Browse Source

clockUI

Load_Fix
Robert Chen 11 years ago
parent
commit
1ceb3f67cd
  1. 4
      index.html
  2. 3
      js/main.js
  3. 5
      js/screens.js
  4. 75
      js/ui.js

4
index.html

@ -22,7 +22,7 @@ @@ -22,7 +22,7 @@
<script src="js/main.js"></script>
<script>
new GameState();
/*
function showXY(e)
{
var mouseX, mouseY;
@ -37,7 +37,7 @@ @@ -37,7 +37,7 @@
}
console.log("x: " + mouseX + "y :" + mouseY);
}*/
}
</script>
<!-- Load all the things! -->
</html>

3
js/main.js

@ -17,6 +17,7 @@ function GameState(){ @@ -17,6 +17,7 @@ function GameState(){
this.peekRecords = [];
this.turkeyCooking = false;
this.turkeyType = "";
this.alarmTimer = 0;
// stats
this.storeVisits = 0;
@ -324,7 +325,7 @@ function GameUI( canvasElem, gameState ){ @@ -324,7 +325,7 @@ function GameUI( canvasElem, gameState ){
var soundManager = new SoundManager( gameState );
this.activeScreenObj = new LoadingScreen( this.stage, gameState );
this.activeScreenObj = new KitchenScreen( this.stage, gameState );
var textContent = new createjs.Text( "", "20px Arial", "#00000000" );
textContent.x = 750;
textContent.y = 30;

5
js/screens.js

@ -97,7 +97,7 @@ function MainScreen( stage, gameState ){ @@ -97,7 +97,7 @@ function MainScreen( stage, gameState ){
new ImgButton( stage, gameState, 17,470, "res/screens/MainScreen/ButtonHelp.png", "res/screens/MainScreen/ButtonHelp.png",null, null, "Click", function(){ gameState.pubsub.publish("ShowHelp",""); } );
new ImgButton( stage, gameState, 17,527, "res/screens/MainScreen/ButtonCredits.png", "res/screens/MainScreen/ButtonCredits.png","SwitchScreen", "CreditsScreen", "Click" );
gameState.pubsub.publish( "BackgroundLoop", {name:"TitleMusic", pos:5650, volume:1} );
gameState.pubsub.publish( "BackgroundLoop", {name:"TitleMusic", pos:5650, volume:0.7} );
this.uiElems = [];
return {
@ -256,6 +256,7 @@ function KitchenScreen( stage, gameState ){ @@ -256,6 +256,7 @@ function KitchenScreen( stage, gameState ){
this.uiElems.push( gameState.ovenUI ? gameState.ovenUI.render() : ( gameState.ovenUI = new OvenUI( stage, gameState ) ).render() );
this.uiElems.push( new ClockUI( stage, gameState ) );
this.uiElems.push( new AlarmUI(stage, gameState) );
stage.addChild( new Button( stage, gameState, 14, 17, 73, 45, null,null, function(){ gameState.pubsub.publish("ShowHelp","");} ) );
@ -392,7 +393,7 @@ function ScoreScreen( stage, gameState ){ @@ -392,7 +393,7 @@ function ScoreScreen( stage, gameState ){
this.background = new createjs.Bitmap( "res/screens/ScoreScreen/Score-Tally.png" );
stage.addChild( this.background );
gameState.pubsub.publish( "BackgroundLoop", {name:"TitleMusic", pos:5650, volume:1} );
gameState.pubsub.publish( "BackgroundLoop", {name:"TitleMusic", pos:5650, volume:0.7} );
//

75
js/ui.js

@ -152,34 +152,55 @@ function AlarmUI(stage, gameState){ @@ -152,34 +152,55 @@ function AlarmUI(stage, gameState){
var that = this;
this.showingConfirm = false;
var finalImg = new createjs.Bitmap("res/screens/KitchenScreen/FinalConfirmation.png");
var yesButton = new Button( stage, gameState, 355, 338, 388, 50, null, null, function(){
gameState.pubsub.publish( "Play", "Ding" );
gameState.pubsub.publish( "SwitchScreen", "ScoreScreen" );
that.hideFinalConfirm();
var finalImg = new createjs.Bitmap("res/screens/KitchenScreen/AlarmKitchen.png");
var timerText = new createjs.Text("00:00", "24px Arial", "#ffffffff" );
timerText.x = 372;
timerText.y = 290;
var clearButton = new Button( stage, gameState, 364, 327, 17, 13, null, null, function(){
gameState.alarmTimer = 0;
that.updateTimer();
} );
var noButton = new Button( stage, gameState, 355, 395, 388, 50, null, null, function(){that.hideFinalConfirm();} );
this.hideFinalConfirm = function(){
stage.removeChild( finalImg );
stage.removeChild( yesButton );
stage.removeChild( noButton );
that.showingConfirm = false;
};
var hourButton = new Button( stage, gameState, 386, 327, 24, 13, null, null, function(){
gameState.alarmTimer +=3600;
that.updateTimer();
} );
var minuteButton = new Button( stage, gameState, 414, 327, 24, 13, null, null, function(){
gameState.alarmTimer +=300;
that.updateTimer();
} );
this.updateTimer = function(){
var colon = gameState.currentTime%2 ? ":" : " ";
var totalSec = gameState.alarmTimer;
var hours = parseInt( totalSec / 3600 ) % 24
var minutes = parseInt( totalSec / 60 ) % 60;
var timeText = ("00"+hours).slice(-2) + colon + ("00"+minutes).slice(-2);
timerText.text = timeText;
}
// Show core temperature
this.showFinalConfirm = function(){
console.log("Showing final confirm");
if( !that.showingConfirm ){
that.showingConfirm = true;
//this.showAlarmUI = function(){
stage.addChild( finalImg );
stage.addChild( noButton );
stage.addChild( yesButton );
stage.addChild( timerText );
stage.addChild( clearButton );
stage.addChild( hourButton );
stage.addChild( minuteButton );
//};
//alarmTimer
this.updateTimer();
return{
secondTick: function(){
that.updateTimer();
},
tick:function(){
}
}
};
// change temperature, this one's for the UI
gameState.pubsub.subscribe( "ShowFinalConfirm", this.showFinalConfirm );
}
function CookbookUI( stage, gameState ){
@ -253,7 +274,7 @@ function OvenUI( stage, gameState ){ @@ -253,7 +274,7 @@ function OvenUI( stage, gameState ){
this.ovenDoor = OVEN_CLOSED;
// Important Model, dummy placeholder
var ovenModel = { secondTick:function(){} };
var ovenModel = { secondTick:function(){}, setRawTemp:function(){}, getRawTemp:function(){} };
var ovenLight = new createjs.Shape();
ovenLight.graphics.beginFill( "black" ).drawCircle( 181, 126, 2 );
@ -387,9 +408,9 @@ function OvenUI( stage, gameState ){ @@ -387,9 +408,9 @@ function OvenUI( stage, gameState ){
var state = ovenModel.getTurkeyState();
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]} );
}
if(ovenModel)
ovenModel.setRawTemp( (ovenModel.getRawTemp() - 25) < 150 ? 150 : ovenModel.getRawTemp() - 25 );
}
gameState.pubsub.publish( "Play", "Oven_Door_Full_Open" );
}else if (that.ovenDoor == OVEN_OPEN ){
that.ovenDoor = OVEN_PEEK;
@ -463,7 +484,6 @@ function OvenUI( stage, gameState ){ @@ -463,7 +484,6 @@ function OvenUI( stage, gameState ){
// incur -25 upon door open and penalty -5 degrees a second for opening the oven.
ovenModel.setRawTemp( (ovenModel.getRawTemp() - 5) < 150 ? 150 : ovenModel.getRawTemp() - 5 );
}
ovenModel.secondTick();
gameState.currentTime += diff;
}
@ -539,12 +559,13 @@ function OvenUI( stage, gameState ){ @@ -539,12 +559,13 @@ function OvenUI( stage, gameState ){
}
stage.addChild(panFront);
}
// Pan front goes here
stage.addChild( panFront );
//finalize button
if( gameState.turkeyBought ){
stage.addChild( new Button( stage, gameState, 45, 250, 250, 175, null, null, function(){
stage.addChild( new Button( stage, gameState, 45, 250, 250, 150, null, null, function(){
gameState.pubsub.publish("Play", "Error");
gameState.pubsub.publish("ShowFinalConfirm","");
} ) );
@ -826,7 +847,7 @@ function Button( stage, gameState, x_orig, y_orig, x_dest, y_dest, eventCmd, arg @@ -826,7 +847,7 @@ function Button( stage, gameState, x_orig, y_orig, x_dest, y_dest, eventCmd, arg
var button = new createjs.Shape();
button.graphics.beginFill("#ffffff").drawRect(x_orig, y_orig, x_dest, y_dest);
button.alpha = 0.01;
button.alpha = 0.5;
button.addEventListener( "click", function(){
gameState.pubsub.publish( "Play", "Click" );
if( !altfunc ){

Loading…
Cancel
Save