diff --git a/js/main.js b/js/main.js index 991ab5b..a4b67f8 100644 --- a/js/main.js +++ b/js/main.js @@ -119,7 +119,8 @@ function GameState(){ queue.loadFile( {id: "res/sound/Kitchen/Oven_Door_Full_Close.mp3", src:"res/sound/Kitchen/Oven_Door_Full_Close.mp3"}); queue.loadFile( {id: "res/sound/Kitchen/Oven_Door_Peek_Close.mp3", src:"res/sound/Kitchen/Oven_Door_Peek_Close.mp3"}); queue.loadFile( {id: "res/sound/Kitchen/Oven_Door_Peek_Open.mp3", src:"res/sound/Kitchen/Oven_Door_Peek_Open.mp3"}); - + queue.loadFile( {id: "res/sound/Kitchen/Close_Cookbook.mp3", src:"res/sound/Kitchen/Close_Cookbook.mp3"}); + queue.loadFile( {id: "res/sound/Kitchen/Open_Cookbook.mp3", src:"res/sound/Kitchen/Open_Cookbook.mp3"}); // Market Items queue.loadFile( {id: "res/screens/MarketScreen/MarketTopShelf.png", src:"res/screens/MarketScreen/MarketTopShelf.png"}); @@ -208,6 +209,7 @@ function GameState(){ queue.loadFile( {id: "res/screens/Window/Test4-217.png", src:"res/screens/Window/Test4TransparencyFull.png"}); + this.screenState = 0; this.newScreen = ""; diff --git a/js/screens.js b/js/screens.js index b558d0a..927f245 100644 --- a/js/screens.js +++ b/js/screens.js @@ -268,7 +268,8 @@ function KitchenScreen( stage, gameState ){ this.background = new createjs.Bitmap( "res/screens/KitchenScreen/KitchenScreen.png" ); stage.addChild( this.background ); - + console.log(gameState.purchasedItems); + console.log("KitchenScreen") for(var i in gameState.purchasedItems ){ console.log(gameState.purchasedItems); gameState.purchasedItems[i].draw( stage ); diff --git a/js/soundmanager.js b/js/soundmanager.js index 54fcd0f..2e424d4 100644 --- a/js/soundmanager.js +++ b/js/soundmanager.js @@ -28,6 +28,9 @@ function SoundManager( gameState ){ createjs.Sound.registerSound("res/sound/Kitchen/Oven_Door_Peek_Close.mp3", "Oven_Door_Peek_Close"); createjs.Sound.registerSound("res/sound/Kitchen/Oven_Door_Peek_Open.mp3", "Oven_Door_Peek_Open"); + createjs.Sound.registerSound("res/sound/Kitchen/Open_Cookbook.mp3", "Open_Cookbook"); + createjs.Sound.registerSound("res/sound/Kitchen/Close_Cookbook.mp3", "Close_Cookbook"); + this.backgroundSounds = []; this.backgroundSoundsQueue = []; diff --git a/js/ui.js b/js/ui.js index 691fb79..8f9d5ab 100644 --- a/js/ui.js +++ b/js/ui.js @@ -52,13 +52,14 @@ function CookbookUI( stage, gameState ){ var closeButton = new Button( stage, gameState, 710, 10, 100, 50, null, null, function(){that.hideCookbook();} ); var logEntries = []; this.hideCookbook = function(){ - console.log("hide cookbook"); + stage.removeChild( closeButton ); stage.removeChild( cookbookImg ); for( i in logEntries ){ stage.removeChild(logEntries[i]); } that.showingCookbook = false; + gameState.pubsub.publish("Play", "Close_Cookbook"); } // Show core temperature @@ -288,15 +289,27 @@ function OvenUI( stage, gameState ){ gameState.pubsub.subscribe( "StartTurkeyModel", this.startTurkeyModel ); - this.secondTick = function(){ + this.secondTick = function(diff){ ovenModel.secondTick(); - gameState.currentTime += 1000; + gameState.currentTime += diff; } - setInterval(this.secondTick, 1000); + gameState.pubsub.subscribe( "SkipTime", function(){ + for(var i = 0; i < 1200; i++){ + that.secondTick( 1000 ); + } + }); + return { - tick: function(){}, + tick: function(){ + var diff = Date.now() - gameState.oldTime; + if( diff > 1000 ){ + gameState.oldTime = Date.now(); + that.secondTick( diff ); + console.log(new Date( gameState.currentTime) ); + } + }, render: function(){ stage.addChild( ovenLight ); @@ -462,6 +475,7 @@ function MarketItem( gameState, name, x, y, cost, mouseOutImg, mouseOverImg, mou if ( that.name.indexOf("Cookbook") != -1 ){ console.log("click, show cookbook"); gameState.pubsub.publish("ShowCookbook",""); + gameState.pubsub.publish("Play", "Open_Cookbook"); } }); @@ -566,7 +580,7 @@ function ImgButton( stage, gameState, x, y, mouseOutImg, mouseOverImg, eventCmd, function Button( stage, gameState, x_orig, y_orig, x_dest, y_dest, eventCmd, arg, altfunc ){ var that = this; - console.log("button clicked with "+ altfunc); + console.log("button clicked with "+ arg); var button = new createjs.Shape(); button.graphics.beginFill("#ffffff").drawRect(x_orig, y_orig, x_dest, y_dest); diff --git a/res/screens/.DS_Store b/res/screens/.DS_Store index 001a0e3..905b0f0 100644 Binary files a/res/screens/.DS_Store and b/res/screens/.DS_Store differ diff --git a/res/sound/.DS_Store b/res/sound/.DS_Store index 555850e..a50f82c 100644 Binary files a/res/sound/.DS_Store and b/res/sound/.DS_Store differ diff --git a/res/sound/Kitchen/.DS_Store b/res/sound/Kitchen/.DS_Store index 29d6dcc..c5c59bc 100644 Binary files a/res/sound/Kitchen/.DS_Store and b/res/sound/Kitchen/.DS_Store differ diff --git a/res/sound/Kitchen/Close_Cookbook.mp3 b/res/sound/Kitchen/Close_Cookbook.mp3 new file mode 100644 index 0000000..a015e8f Binary files /dev/null and b/res/sound/Kitchen/Close_Cookbook.mp3 differ diff --git a/res/sound/Kitchen/Open_Cookbook.mp3 b/res/sound/Kitchen/Open_Cookbook.mp3 new file mode 100644 index 0000000..a6ab7f1 Binary files /dev/null and b/res/sound/Kitchen/Open_Cookbook.mp3 differ