|
|
@ -1,22 +1,62 @@ |
|
|
|
/* Screens, inheritance would be nice */ |
|
|
|
/* Screens, inheritance would be nice */ |
|
|
|
function LoadingTitleScreen( stage, gameState ){ |
|
|
|
function LoadingScreen( stage, gameState ){ |
|
|
|
var that = this; |
|
|
|
var that = this; |
|
|
|
this.picture = new createjs.Bitmap( "res/Loading-Title.png" ); |
|
|
|
this.lastPercent = -1; |
|
|
|
this.ovenLight = new createjs.Shape(); |
|
|
|
this.picture = new createjs.Bitmap( "res/screens/LoadingScreen/Loading-Title.png" ); |
|
|
|
this.ovenLight.graphics.beginFill( "red" ).drawCircle( 396, 318, 5 ); |
|
|
|
this.pictureFront = new createjs.Bitmap( "res/screens/LoadingScreen/PanFront.png" ); |
|
|
|
|
|
|
|
this.cooking = new createjs.Bitmap( "res/screens/LoadingScreen/TextCooking.png" ); |
|
|
|
|
|
|
|
this.done = new createjs.Bitmap( "res/screens/LoadingScreen/TextDone.png" ); |
|
|
|
|
|
|
|
this.turkeyState = [ new createjs.Bitmap( "res/screens/LoadingScreen/Turkey0.png" ), |
|
|
|
|
|
|
|
new createjs.Bitmap( "res/screens/LoadingScreen/Turkey25.png" ), |
|
|
|
|
|
|
|
new createjs.Bitmap( "res/screens/LoadingScreen/Turkey50.png" ), |
|
|
|
|
|
|
|
new createjs.Bitmap( "res/screens/LoadingScreen/Turkey75.png" ), |
|
|
|
|
|
|
|
new createjs.Bitmap( "res/screens/LoadingScreen/TurkeyDone.png" ) ]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.done.alpha= 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stage.addChild( this.picture ); |
|
|
|
|
|
|
|
stage.addChild( this.cooking ); |
|
|
|
|
|
|
|
stage.addChild( this.done ); |
|
|
|
|
|
|
|
stage.addChild( this.turkeyState[0] ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var textContent = new createjs.Text( "0 %", "25px Arial", "#ffffffff" ); |
|
|
|
|
|
|
|
textContent.x = 500; |
|
|
|
|
|
|
|
textContent.y = 20; |
|
|
|
|
|
|
|
stage.addChild( textContent); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gameState.pubsub.subscribe( "Load", function(percent){ |
|
|
|
|
|
|
|
textContent.text = (percent * 25).toFixed(2) + " %"; |
|
|
|
|
|
|
|
var wholeNum = percent.toFixed(0); |
|
|
|
|
|
|
|
if( that.lastPercent != percent){ |
|
|
|
|
|
|
|
that.lastPercent = percent; |
|
|
|
|
|
|
|
stage.addChild( that.turkeyState[wholeNum] ); |
|
|
|
|
|
|
|
stage.addChild( that.pictureFront ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
stage.addChild( this.picture ); |
|
|
|
//If we're still on image one, don't fade it out, it's the base image!
|
|
|
|
stage.addChild( this.ovenLight ); |
|
|
|
if( wholeNum != 0 ) |
|
|
|
|
|
|
|
that.turkeyState[wholeNum].alpha = percent.toFixed(2) - wholeNum; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Done!
|
|
|
|
|
|
|
|
if( wholeNum == 4 ){ |
|
|
|
|
|
|
|
that.turkeyState[4].alpha = 1; |
|
|
|
|
|
|
|
that.cooking.alpha=0; |
|
|
|
|
|
|
|
that.done.alpha = 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
that.done.addEventListener( "mouseover", function(){ document.body.style.cursor='pointer'; } ); |
|
|
|
|
|
|
|
that.done.addEventListener( "mouseout", function(){ document.body.style.cursor='default'; } ); |
|
|
|
|
|
|
|
that.done.addEventListener( "click", function(){ gameState.pubsub.publish("SwitchScreen", "MainScreen"); }); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
that.turkeyState[4].addEventListener( "mouseover", function(){ document.body.style.cursor='pointer'; } ); |
|
|
|
|
|
|
|
that.turkeyState[4].addEventListener( "mouseout", function(){ document.body.style.cursor='default'; } ); |
|
|
|
|
|
|
|
that.turkeyState[4].addEventListener( "click", function(){ gameState.pubsub.publish("SwitchScreen", "MainScreen"); }); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
stage.addChild( this.pictureFront ); |
|
|
|
|
|
|
|
|
|
|
|
this.uiElems = []; |
|
|
|
|
|
|
|
this.uiElems.push( new DialogUI( stage, gameState ) ); |
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
blit : function(){ |
|
|
|
blit : function(){ |
|
|
|
|
|
|
|
|
|
|
|
// Draw all the uiElements
|
|
|
|
|
|
|
|
for( var index in that.uiElems ){ |
|
|
|
|
|
|
|
that.uiElems[ index ].tick(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -44,7 +84,7 @@ function InfoHelpScreen( stage, gameState ){ |
|
|
|
function MainScreen( stage, gameState ){ |
|
|
|
function MainScreen( stage, gameState ){ |
|
|
|
var that = this; |
|
|
|
var that = this; |
|
|
|
|
|
|
|
|
|
|
|
this.background = new createjs.Bitmap( "res/Main-Screen.png" ); |
|
|
|
this.background = new createjs.Bitmap( "res/screens/MainScreen/Main-Screen.png" ); |
|
|
|
stage.addChild( this.background ); |
|
|
|
stage.addChild( this.background ); |
|
|
|
|
|
|
|
|
|
|
|
var turkeyAnimations = { peck:[14,24,"peck"], ruffle:[0,13,"ruffle"], stare:[25,35,"stare"] }; |
|
|
|
var turkeyAnimations = { peck:[14,24,"peck"], ruffle:[0,13,"ruffle"], stare:[25,35,"stare"] }; |
|
|
@ -68,13 +108,13 @@ function MainScreen( stage, gameState ){ |
|
|
|
} |
|
|
|
} |
|
|
|
stage.addChild(animation); |
|
|
|
stage.addChild(animation); |
|
|
|
|
|
|
|
|
|
|
|
this.grassLayer = new createjs.Bitmap( "res/Grass.png" ); |
|
|
|
this.grassLayer = new createjs.Bitmap( "res/screens/MainScreen/Grass.png" ); |
|
|
|
stage.addChild( this.grassLayer ); |
|
|
|
stage.addChild( this.grassLayer ); |
|
|
|
|
|
|
|
|
|
|
|
// buttons info/credits/start
|
|
|
|
// buttons info/credits/start
|
|
|
|
new ImgButton( stage, gameState, 571,527, "res/MainScreen/ButtonStart.png", "res/MainScreen/ButtonStart.png","SwitchScreen", "DifficultyScreen", "Click" ); |
|
|
|
new ImgButton( stage, gameState, 571,527, "res/screens/MainScreen/ButtonStart.png", "res/screens/MainScreen/ButtonStart.png","SwitchScreen", "DifficultyScreen", "Click" ); |
|
|
|
new ImgButton( stage, gameState, 17,470, "res/MainScreen/ButtonHelp.png", "res/MainScreen/ButtonHelp.png","SwitchScreen", "InfoScreen", "Click" ); |
|
|
|
new ImgButton( stage, gameState, 17,470, "res/screens/MainScreen/ButtonHelp.png", "res/screens/MainScreen/ButtonHelp.png","SwitchScreen", "InfoScreen", "Click" ); |
|
|
|
new ImgButton( stage, gameState, 17,527, "res/MainScreen/ButtonCredits.png", "res/MainScreen/ButtonCredits.png","SwitchScreen", "CreditsScreen", "Click" ); |
|
|
|
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:1} ); |
|
|
|
this.uiElems = []; |
|
|
|
this.uiElems = []; |
|
|
@ -135,7 +175,7 @@ function KitchenScreen( stage, gameState ){ |
|
|
|
gameState.purchasedItems[i].draw( stage, 403+100*i, 350 ); |
|
|
|
gameState.purchasedItems[i].draw( stage, 403+100*i, 350 ); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.uiElems.push( gameState.ovenUI ? gameState.ovenUI : ( gameState.ovenUI = new OvenUI( 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 ClockUI( stage, gameState ) ); |
|
|
|
this.uiElems.push( new WindowUI( stage, gameState ) ) |
|
|
|
this.uiElems.push( new WindowUI( stage, gameState ) ) |
|
|
|
stage.addChild( new Button( stage, gameState, 500, 40, 450, 105, "SwitchScreen", "MarketScreen" ) ); |
|
|
|
stage.addChild( new Button( stage, gameState, 500, 40, 450, 105, "SwitchScreen", "MarketScreen" ) ); |
|
|
@ -159,7 +199,7 @@ function KitchenScreen( stage, gameState ){ |
|
|
|
function MarketScreen( stage, gameState ){ |
|
|
|
function MarketScreen( stage, gameState ){ |
|
|
|
var that = this; |
|
|
|
var that = this; |
|
|
|
|
|
|
|
|
|
|
|
this.background = new createjs.Bitmap( "res/screens/MarketScreen.png" ); |
|
|
|
this.background = new createjs.Bitmap( "res/screens/MarketScreen/MarketScreen.png" ); |
|
|
|
var price = new createjs.Text( "100", "24px Arial", "#00000000" ); |
|
|
|
var price = new createjs.Text( "100", "24px Arial", "#00000000" ); |
|
|
|
price.x = 725; |
|
|
|
price.x = 725; |
|
|
|
price.y = 500; |
|
|
|
price.y = 500; |
|
|
@ -171,7 +211,7 @@ function MarketScreen( stage, gameState ){ |
|
|
|
// Play soundz
|
|
|
|
// Play soundz
|
|
|
|
gameState.pubsub.publish( "Play", {name:"Entrance", volume:0.3} ); |
|
|
|
gameState.pubsub.publish( "Play", {name:"Entrance", volume:0.3} ); |
|
|
|
gameState.pubsub.publish( "BackgroundLoop", {name:"MarketMusic", volume:1} ); |
|
|
|
gameState.pubsub.publish( "BackgroundLoop", {name:"MarketMusic", volume:1} ); |
|
|
|
gameState.pubsub.publish( "BackgroundLoop", {name:"MarketSound", volume:0.4} ); |
|
|
|
gameState.pubsub.publish( "BackgroundLoop", {name:"MarketBackgroundSound", volume:0.4} ); |
|
|
|
|
|
|
|
|
|
|
|
stage.addChild( this.background ); |
|
|
|
stage.addChild( this.background ); |
|
|
|
stage.addChild(price); |
|
|
|
stage.addChild(price); |
|
|
@ -185,7 +225,6 @@ function MarketScreen( stage, gameState ){ |
|
|
|
} |
|
|
|
} |
|
|
|
this.topground = new createjs.Bitmap( "res/screens/MarketTopShelf.png" ); |
|
|
|
this.topground = new createjs.Bitmap( "res/screens/MarketTopShelf.png" ); |
|
|
|
stage.addChild( this.topground ); |
|
|
|
stage.addChild( this.topground ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.showPrice = function( cost ){ |
|
|
|
this.showPrice = function( cost ){ |
|
|
|
price.text = cost; |
|
|
|
price.text = cost; |
|
|
|