|
|
|
@ -1,13 +1,14 @@
@@ -1,13 +1,14 @@
|
|
|
|
|
function ClockUI( stage, gameState ){ |
|
|
|
|
var that = this; |
|
|
|
|
|
|
|
|
|
this.minuteRadius = 40; |
|
|
|
|
this.minuteRadius = 30; |
|
|
|
|
this.hourRadius = 0.7 * this.minuteRadius; |
|
|
|
|
this.clockX = 300; |
|
|
|
|
this.clockY = 100; |
|
|
|
|
this.clockX = 246; |
|
|
|
|
this.clockY = 146; |
|
|
|
|
|
|
|
|
|
this.getClockAngles = function( ){ |
|
|
|
|
var currTime = new Date( gameState.currentTime ); |
|
|
|
|
|
|
|
|
|
var hourAngle = 720 * ( currTime.getHours() / 24 ) - 90; |
|
|
|
|
var minuteAngle = 360 * ( currTime.getMinutes() / 60 ) - 90; |
|
|
|
|
return [ hourAngle, minuteAngle ]; |
|
|
|
@ -43,30 +44,76 @@ function ClockUI( stage, gameState ){
@@ -43,30 +44,76 @@ function ClockUI( stage, gameState ){
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function OvenUI( stage ){ |
|
|
|
|
function OvenUI( stage, gameState ){ |
|
|
|
|
var that = this; |
|
|
|
|
|
|
|
|
|
this.ovenLight = new createjs.Shape(); |
|
|
|
|
this.analogClock = ""; |
|
|
|
|
this.text = new createjs.Text( "325F", "50px Arial", "#ff7700" ); |
|
|
|
|
this.text.x = 70; |
|
|
|
|
this.text.y = 100; |
|
|
|
|
this.text.textBaseline = "alphabetic"; |
|
|
|
|
// Important Model
|
|
|
|
|
var ovenModel = new OvenModel( 8, gameState ); |
|
|
|
|
|
|
|
|
|
var ovenLight = new createjs.Shape(); |
|
|
|
|
ovenLight.graphics.beginFill( "black" ).drawCircle( 181, 126, 2 ); |
|
|
|
|
|
|
|
|
|
// Oven light control
|
|
|
|
|
this.changeOvenLight = function( state ){ |
|
|
|
|
if( state == "On" ){ |
|
|
|
|
ovenLight.visible = false; |
|
|
|
|
} else { |
|
|
|
|
ovenLight.visible = true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
gameState.pubsub.subscribe( "OvenLight", this.changeOvenLight ); |
|
|
|
|
|
|
|
|
|
var temperatureText = new createjs.Text( "325", "40px Arial", "#ff7700" ); |
|
|
|
|
temperatureText.x = 50; |
|
|
|
|
temperatureText.y = 147; |
|
|
|
|
temperatureText.textBaseline = "alphabetic"; |
|
|
|
|
|
|
|
|
|
//Create a Shape DisplayObject.
|
|
|
|
|
this.circle = new createjs.Shape(); |
|
|
|
|
this.circle.graphics.beginFill( "red" ).drawCircle( 0, 0, 40 ); |
|
|
|
|
this.ovenLight.graphics.beginFill( "red" ).drawCircle( 223, 73, 5 ); |
|
|
|
|
this.circle.x = 0; |
|
|
|
|
this.circle.y = 0; |
|
|
|
|
|
|
|
|
|
//Set position of Shape instance.
|
|
|
|
|
this.circle.x = this.circle.y = 50; |
|
|
|
|
|
|
|
|
|
this.picture = new createjs.Bitmap( "res/Base_Game_Screen.png" ); |
|
|
|
|
//this.picture.scaleX = this.picture.scaleY = 0.5;
|
|
|
|
|
stage.addChild( this.picture ); |
|
|
|
|
stage.addChild( this.circle ); |
|
|
|
|
stage.addChild( this.ovenLight ); |
|
|
|
|
stage.addChild( ovenLight ); |
|
|
|
|
stage.addChild( new Button( stage, gameState, 45, 163, 41, 17, "ChangeTemperature", "Up" ) ); |
|
|
|
|
stage.addChild( new Button( stage, gameState, 95, 163, 41, 17, "ChangeTemperature", "Down" ) ); |
|
|
|
|
stage.addChild( temperatureText ); |
|
|
|
|
|
|
|
|
|
this.changeTemperature = function( direction ){ |
|
|
|
|
|
|
|
|
|
if( temperatureText.text == "OFF" && direction == "Up" ) temperatureText.text = "150"; |
|
|
|
|
if( !( temperatureText.text == "OFF" && direction == "Down" ) ){ |
|
|
|
|
|
|
|
|
|
var temp = ( direction == "Up" ? parseInt(temperatureText.text)+25 : parseInt(temperatureText.text)-25); |
|
|
|
|
|
|
|
|
|
// Check lower bound for OFF
|
|
|
|
|
temp = temp < 150 ? temp = "OFF" : temp; |
|
|
|
|
|
|
|
|
|
// Check upper bound
|
|
|
|
|
// Set up to 500, then it's BROIL @ 980
|
|
|
|
|
|
|
|
|
|
temperatureText.text = temp; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Tell our model to set the actual temperature
|
|
|
|
|
ovenModel.changeTemp( UtilityFunctions.F2C( temperatureText.text == "OFF" ? 150 : parseInt( temperatureText.text ) ) ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// change temperature, this one's for the UI
|
|
|
|
|
gameState.pubsub.subscribe( "ChangeTemperature", this.changeTemperature ); |
|
|
|
|
|
|
|
|
|
this.secondTick = function(){ |
|
|
|
|
ovenModel.secondTick(); |
|
|
|
|
gameState.currentTime += 1000; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
setInterval(this.secondTick, 500); |
|
|
|
|
|
|
|
|
|
stage.addChild( this.text ); |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
tick: function(){ |
|
|
|
|
// Circle will move 10 units to the right.
|
|
|
|
@ -77,3 +124,40 @@ function OvenUI( stage ){
@@ -77,3 +124,40 @@ function OvenUI( stage ){
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function WindowUI( stage, gameState ){ |
|
|
|
|
return { |
|
|
|
|
tick: function(){} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function Item(){ |
|
|
|
|
/*img.onPress = function(e) { |
|
|
|
|
document.body.style.cursor='move'; |
|
|
|
|
offset = {x:e.stageX - e.target.x, y:e.stageY - e.target.y}; |
|
|
|
|
|
|
|
|
|
e.onMouseMove = drag; |
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function Button( stage, gameState, x_orig, y_orig, x_dest, y_dest, eventCmd, arg ){ |
|
|
|
|
var that = this; |
|
|
|
|
|
|
|
|
|
var infoButton = new createjs.Shape(); |
|
|
|
|
infoButton.graphics.beginFill("#ffffff").drawRect(x_orig, y_orig, x_dest, y_dest); |
|
|
|
|
infoButton.alpha = 0.5; |
|
|
|
|
infoButton.addEventListener( "click", function(){ gameState.pubsub.publish( eventCmd, arg ) } ); |
|
|
|
|
|
|
|
|
|
infoButton.onMouseOver = function(e) { |
|
|
|
|
alert("mouseover"); |
|
|
|
|
document.body.style.cursor='pointer'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
infoButton.onMouseOut = function(e) { |
|
|
|
|
document.body.style.cursor='default'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return infoButton; |
|
|
|
|
|
|
|
|
|
} |