Browse Source

Working Market, Oven door

Load_Fix
Robert Chen 11 years ago
parent
commit
0376c84100
  1. 8
      js/dialogue.js
  2. 101
      js/main.js
  3. 146
      js/screens.js
  4. 147
      js/ui.js
  5. BIN
      res/items/.DS_Store
  6. BIN
      res/items/Clipboard.png
  7. BIN
      res/items/Price-Tag.png
  8. BIN
      res/items/Wallet.png
  9. BIN
      res/kitchen.png
  10. BIN
      res/screens/.DS_Store
  11. BIN
      res/screens/DifficultyScreen/.DS_Store
  12. BIN
      res/screens/DifficultyScreen/ButtonFemale.png
  13. BIN
      res/screens/DifficultyScreen/ButtonMale.png
  14. BIN
      res/screens/DifficultyScreen/ButtonsandText.png
  15. BIN
      res/screens/DifficultyScreen/Difficulty-Selection.png
  16. BIN
      res/screens/KitchenScreen/.DS_Store
  17. BIN
      res/screens/KitchenScreen/AlarmKitchen.png
  18. BIN
      res/screens/KitchenScreen/AlarmKitchenGlow.png
  19. BIN
      res/screens/KitchenScreen/CookbookKitchen.png
  20. BIN
      res/screens/KitchenScreen/CookbookKitchenGlow.png
  21. BIN
      res/screens/KitchenScreen/DoorClosedLightOff.png
  22. BIN
      res/screens/KitchenScreen/DoorClosedLightOn.png
  23. BIN
      res/screens/KitchenScreen/DoorOpen.png
  24. BIN
      res/screens/KitchenScreen/DoorPeekLightOff.png
  25. BIN
      res/screens/KitchenScreen/DoorPeekLightOn.png
  26. BIN
      res/screens/KitchenScreen/FrillsBoxKitchen.png
  27. BIN
      res/screens/KitchenScreen/FrillsBoxKitchenGlow.png
  28. BIN
      res/screens/KitchenScreen/KitchenScreen.png
  29. BIN
      res/screens/KitchenScreen/KitchenScreenMockup.png
  30. BIN
      res/screens/KitchenScreen/LightButtonDepressed.png
  31. BIN
      res/screens/KitchenScreen/OvenTurnRedState.png
  32. BIN
      res/screens/KitchenScreen/PanFront.png
  33. BIN
      res/screens/KitchenScreen/StoreBrochure.png
  34. BIN
      res/screens/KitchenScreen/StoreBrochureGlow.png
  35. BIN
      res/screens/KitchenScreen/StuffingExquisiteKitchen.png
  36. BIN
      res/screens/KitchenScreen/StuffingExquisiteKitchenGlow.png
  37. BIN
      res/screens/KitchenScreen/StuffingRepurposedKitchen.png
  38. BIN
      res/screens/KitchenScreen/StuffingRepurposedKitchenGlow.png
  39. BIN
      res/screens/KitchenScreen/StuffingSpecialKitchen.png
  40. BIN
      res/screens/KitchenScreen/StuffingSpecialKitchenGlow.png
  41. BIN
      res/screens/KitchenScreen/TempProbeKitchen.png
  42. BIN
      res/screens/KitchenScreen/TempProbeKitchenGlow.png
  43. 7695
      res/screens/KitchenScreen/TurkeyState1.svg
  44. 9288
      res/screens/KitchenScreen/TurkeyState2.svg
  45. 9290
      res/screens/KitchenScreen/TurkeyState3.svg
  46. 10920
      res/screens/KitchenScreen/TurkeyState4.svg
  47. 12955
      res/screens/KitchenScreen/TurkeyState5.svg
  48. BIN
      res/screens/MainScreen/.DS_Store
  49. BIN
      res/screens/MainScreen/ButtonHelp.png

8
js/dialogue.js

@ -86,12 +86,12 @@ function DialogUI( stage, gameState ){ @@ -86,12 +86,12 @@ function DialogUI( stage, gameState ){
if( that.dialogState == DIALOG_RECEDING ){
that.dialogBox.y+=that.dialogSpeed;
that.textContent.y +=that.dialogSpeed;
console.log( "Receding" + that.dialogBox.y );
//console.log( "Receding" + that.dialogBox.y );
}
if( that.dialogState == DIALOG_SHOWING ){
that.dialogBox.y-=that.dialogSpeed;
that.textContent.y -=that.dialogSpeed;
console.log( "Advancing" + that.dialogBox.y );
//console.log( "Advancing" + that.dialogBox.y );
}
// toggle states
@ -99,14 +99,14 @@ function DialogUI( stage, gameState ){ @@ -99,14 +99,14 @@ function DialogUI( stage, gameState ){
that.dialogBox.y = 675;
that.textContent.y = 735;
that.dialogState = DIALOG_PAUSING;
console.log( "Pausing on recede" + that.dialogBox.y );
//console.log( "Pausing on recede" + that.dialogBox.y );
}
if( that.dialogBox.y < 435 && that.dialogState == DIALOG_SHOWING ){
that.dialogBox.y = 435;
that.textContent.y = 480;
that.dialogState = DIALOG_PAUSING;
console.log( "Pausing on showing" + that.dialogBox.y );
//console.log( "Pausing on showing" + that.dialogBox.y );
}
/* next states if there are any on the queue */

101
js/main.js

@ -7,8 +7,8 @@ function GameState(){ @@ -7,8 +7,8 @@ function GameState(){
this.oldTime = new Date().getTime();
this.name = "";
this.gender = "";
this.wallet = 1000;
this.gender = "Male";
this.wallet = 40.00;
// Load all our resources:
var queue = new createjs.LoadQueue(true);
@ -31,6 +31,11 @@ function GameState(){ @@ -31,6 +31,11 @@ function GameState(){
queue.loadFile( {id:"res/screens/LoadingScreen/Turkey75.png", src: "res/screens/LoadingScreen/Turkey75.png"} );
queue.loadFile( {id:"res/screens/LoadingScreen/TurkeyDone.png", src: "res/screens/LoadingScreen/TurkeyDone.png"} );*/
// Screens
queue.loadFile( {id: "res/screens/DifficultyScreen/Difficulty-Selection.png", src:"res/screens/DifficultyScreen/Difficulty-Selection.png"} );
queue.loadFile( {id: "res/screens/DifficultyScreen/ButtonMale.png", src:"res/screens/DifficultyScreen/ButtonMale.png"} );
queue.loadFile( {id: "res/screens/DifficultyScreen/ButtonFemale.png", src:"res/screens/DifficultyScreen/ButtonFemale.png"} );
//queue.addEventListener("fileload", handleFileComplete);
// Load image assets
queue.loadFile( {id: "TurkeySpriteFile", src:"res/screens/MainScreen/TurkeySprite.png"} );
@ -53,11 +58,59 @@ function GameState(){ @@ -53,11 +58,59 @@ function GameState(){
queue.loadFile( {id: "UIClickFile", src:"res/sound/GUI/click.mp3"} );
queue.loadFile( {id: "UIBuzzFile", src:"res/sound/GUI/buzz.mp3"} );
// Kitchen Items
queue.loadFile( {id: "res/screens/KitchenScreen/TurkeyState1.svg", src:"res/screens/KitchenScreen/TurkeyState1.svg"});
queue.loadFile( {id: "res/screens/KitchenScreen/TurkeyState2.svg", src:"res/screens/KitchenScreen/TurkeyState2.svg"});
queue.loadFile( {id: "res/screens/KitchenScreen/TurkeyState3.svg", src:"res/screens/KitchenScreen/TurkeyState3.svg"});
queue.loadFile( {id: "res/screens/KitchenScreen/TurkeyState4.svg", src:"res/screens/KitchenScreen/TurkeyState4.svg"});
queue.loadFile( {id: "res/screens/KitchenScreen/TurkeyState5.svg", src:"res/screens/KitchenScreen/TurkeyState5.svg"});
queue.loadFile( {id: "res/screens/KitchenScreen/TempProbeKitchenGlow.png", src:"res/screens/KitchenScreen/TempProbeKitchenGlow.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/TempProbeKitchen.png", src:"res/screens/KitchenScreen/TempProbeKitchen.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/StuffingSpecialKitchenGlow.png", src:"res/screens/KitchenScreen/StuffingSpecialKitchenGlow.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/StuffingSpecialKitchen.png", src:"res/screens/KitchenScreen/StuffingSpecialKitchen.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/StuffingRepurposedKitchenGlow.png", src:"res/screens/KitchenScreen/StuffingRepurposedKitchenGlow.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/StuffingRepurposedKitchen.png", src:"res/screens/KitchenScreen/StuffingRepurposedKitchen.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/StuffingExquisiteKitchenGlow.png", src:"res/screens/KitchenScreen/StuffingExquisiteKitchenGlow.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/StuffingExquisiteKitchen.png", src:"res/screens/KitchenScreen/StuffingExquisiteKitchen.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/StoreBrochureGlow.png", src:"res/screens/KitchenScreen/StoreBrochureGlow.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/StoreBrochure.png", src:"res/screens/KitchenScreen/StoreBrochure.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/FrillsBoxKitchenGlow.png", src:"res/screens/KitchenScreen/FrillsBoxKitchenGlow.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/FrillsBoxKitchen.png", src:"res/screens/KitchenScreen/FrillsBoxKitchen.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/DoorPeekLightOn.png", src:"res/screens/KitchenScreen/DoorPeekLightOn.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/DoorPeekLightOff.png", src:"res/screens/KitchenScreen/DoorPeekLightOff.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/DoorOpen.png", src:"res/screens/KitchenScreen/DoorOpen.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/DoorClosedLightOn.png", src:"res/screens/KitchenScreen/DoorClosedLightOn.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/DoorClosedLightOff.png", src:"res/screens/KitchenScreen/DoorClosedLightOff.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/CookbookKitchenGlow.png", src:"res/screens/KitchenScreen/CookbookKitchenGlow.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/CookbookKitchen.png", src:"res/screens/KitchenScreen/CookbookKitchen.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/AlarmKitchenGlow.png", src:"res/screens/KitchenScreen/AlarmKitchenGlow.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/AlarmKitchen.png", src:"res/screens/KitchenScreen/AlarmKitchen.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/PanFront.png", src:"res/screens/KitchenScreen/PanFront.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/OvenTurnRedState.png", src:"res/screens/KitchenScreen/OvenTurnRedState.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/LightButtonDepressed.png", src:"res/screens/KitchenScreen/LightButtonDepressed.png"});
// Market Items
queue.loadFile( {id: "FrillsBox.png", src:"res/items/FrillsBox.png"} );
queue.loadFile( {id: "res/screens/MarketScreen/MarketTopShelf.png", src:"res/screens/MarketScreen/MarketTopShelf.png"});
queue.loadFile( {id: "res/items/Clipboard.png", src:"res/items/Clipboard.png"});
queue.loadFile( {id: "res/items/Wallet.png", src:"res/items/Wallet.png"});
queue.loadFile( {id: "res/items/FrillsBox.png", src:"res/items/ExitSign.png"});
queue.loadFile( {id: "res/items/FrillsBoxGlow.png", src:"res/items/ExitGlow.png"});
queue.loadFile( {id: "res/items/FrillsBox.png", src:"res/items/FrillsBox.png"});
queue.loadFile( {id: "res/items/FrillsBoxGlow.png", src:"res/items/FrillsBoxGlow.png"});
queue.loadFile( {id: "res/items/TempProbe.png", src:"res/items/TempProbe.png"});
queue.loadFile( {id: "res/items/TempProbeGlow.png", src:"res/items/TempProbeGlow.png"});
@ -101,22 +154,30 @@ function GameState(){ @@ -101,22 +154,30 @@ function GameState(){
// Game State flags
this.turkeyBought = false;
this.ovenLightBought = false;
var randomWeight = [ (UtilityFunctions.randRange(10,22)+"."+UtilityFunctions.randRange(10,99)),
(UtilityFunctions.randRange(10,22)+"."+UtilityFunctions.randRange(10,99)),
(UtilityFunctions.randRange(10,22)+"."+UtilityFunctions.randRange(10,99)),
(UtilityFunctions.randRange(10,22)+"."+UtilityFunctions.randRange(10,99)),
(UtilityFunctions.randRange(10,22)+"."+UtilityFunctions.randRange(10,99))
];
this.marketItems = {
"FrillsBox" : new MarketItem( this, "FrillsBox", 133,92, 2000, "res/items/FrillsBox.png", "res/items/FrillsBoxGlow.png" ),
"TuTempProberkey" : new MarketItem( this, "TuTempProberkey", 200, 57, 100, "res/items/TempProbe.png", "res/items/TempProbeGlow.png" ),
"OvenLightBox" : new MarketItem( this, "OvenLightBox", 131,222, 300, "res/items/OvenLightBox.png", "res/items/OvenLightBoxGlow.png" ),
"Alarm" : new MarketItem( this, "Alarm", 173,248, 500, "res/items/Alarm.png", "res/items/AlarmGlow.png" ),
"Cookbook" : new MarketItem( this, "Cookbook", 283,203, 400, "res/items/Cookbook1.png", "res/items/Cookbook1Glow.png" ),
"StuffingRepurposed" : new MarketItem( this, "StuffingRepurposed", 510,197, 200, "res/items/StuffingRepurposed.png", "res/items/StuffingRepurposedGlow.png" ),
"StuffingExquisite" : new MarketItem( this, "StuffingExquisite", 458,210, 300, "res/items/StuffingExquisite.png", "res/items/StuffingExquisiteGlow.png" ),
"StuffingSpecial" : new MarketItem( this, "StuffingSpecial", 390,220, 500, "res/items/StuffingSpecial.png", "res/items/StuffingSpecialGlow.png" ),
"Turkey1" : new MarketItem( this, "Turkey1", 170,350, 100, "res/items/Turkey5.png", "res/items/Turkey5Glow.png" ),
"Turkey2": new MarketItem( this, "Turkey2", 540,320, 100, "res/items/Turkey4.png", "res/items/Turkey4Glow.png" ),
"Turkey3" : new MarketItem( this, "Turkey3", 265,415, 100, "res/items/Turkey3.png", "res/items/Turkey3Glow.png" ),
"Turkey4": new MarketItem( this, "Turkey4", 474,357, 100, "res/items/Turkey2.png", "res/items/Turkey2Glow.png" ),
"Turkey5": new MarketItem( this, "Turkey5", 368,426, 100, "res/items/Turkey1.png", "res/items/Turkey1Glow.png" )
"Frills Box" : new MarketItem( this, "Frills Box", 133,92, 3.00, "res/items/FrillsBox.png", "res/items/FrillsBoxGlow.png", "Some people dress up their dogs. Others dress up their house. Why not dress up your turkey?" ),
"Temperature Probe" : new MarketItem( this, "Temperature Probe", 200, 57, 9.00, "res/items/TempProbe.png", "res/items/TempProbeGlow.png", "Ensure your food is cooked with this handy thermometer. Now with easy to read LED display" ),
"Oven Light in a Box" : new MarketItem( this, "Oven Light in a Box", 131,222, 15.00, "res/items/OvenLightBox.png", "res/items/OvenLightBoxGlow.png", "This will allow checking on your turkey without letting the heat out." ),
"Alarm Clock" : new MarketItem( this, "Alarm Clock", 173,248, 6.00, "res/items/Alarm.png", "res/items/AlarmGlow.png", "Have you ever wanted to control time? Now you can. Digital readout counts down until time of choice. Audible alarm" ),
"Cookbook" : new MarketItem( this, "Cookbook", 283,203, 3.00, "res/items/Cookbook1.png", "res/items/Cookbook1Glow.png", "How do I cook turkey? Handy note space included for writing down temperature measurements" ),
"Repurposed Stuffing" : new MarketItem( this, "Repurposed Stuffing", 510,197, 2.00, "res/items/StuffingRepurposed.png", "res/items/StuffingRepurposedGlow.png","At least 80% original breadcrumb. Guaranteed to contain no avian products" ),
"Exquisite Stuffing" : new MarketItem( this, "Exquisite Stuffing", 458,210, 3.00, "res/items/StuffingExquisite.png", "res/items/StuffingExquisiteGlow.png", "Colonial merchants once traveled the four reaches of the Earth to bring back the ingredients contained in this very box" ),
"Special Stuffing" : new MarketItem( this, "Special Stuffing", 390,220, 6.00, "res/items/StuffingSpecial.png", "res/items/StuffingSpecialGlow.png", "Once rated as the most handsome man in the universe. Scott and his patented special stuffing will set you on the path to food heaven" ),
"Organic Turkey" : new MarketItem( this, "Organic Turkey", 180,360, randomWeight[0]*2.00, "res/items/Turkey5.png", "res/items/Turkey5Glow.png", "All natural. No hormones. No antibiotics. Free Range. Lead Free", parseFloat(randomWeight[0]) ),
"Free Range Turkey": new MarketItem( this, "Free Range Turkey", 540,320, randomWeight[1]*1.25, "res/items/Turkey4.png", "res/items/Turkey4Glow.png", "Our turkeys have wide open spaces to roam and are fed with only the highest quality feed.", parseFloat(randomWeight[1]) ),
"Sunny Farms Turkey" : new MarketItem( this, "Sunny Farms Turkey", 265,415, randomWeight[2]*0.85, "res/items/Turkey3.png", "res/items/Turkey3Glow.png", "100% Turkey product from Sunny Farms Heavy Industries, Ltd.", parseFloat(randomWeight[2]) ),
"Pastured Turkey": new MarketItem( this, "Pastured Turkey", 474,357, randomWeight[3]*1.75, "res/items/Turkey2.png", "res/items/Turkey2Glow.png", "Grassy fields and natural ingredients allow our turkeys to have a better life, and taste great.", parseFloat(randomWeight[3]) ),
"General Turkey": new MarketItem( this, "General Turkey", 378,426, randomWeight[4]*1.00, "res/items/Turkey1.png", "res/items/Turkey1Glow.png", "100% General Satisfaction Guaranteed", parseFloat(randomWeight[4]) )
};
this.purchasedItems = [];
@ -179,7 +240,7 @@ function GameUI( canvasElem, gameState ){ @@ -179,7 +240,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;

146
js/screens.js

@ -13,7 +13,6 @@ function LoadingScreen( stage, gameState ){ @@ -13,7 +13,6 @@ function LoadingScreen( stage, gameState ){
new createjs.Bitmap( "res/screens/LoadingScreen/TurkeyDone.png" ) ];
this.done.alpha= 0;
stage.addChild( this.picture );
stage.addChild( this.cooking );
stage.addChild( this.done );
@ -96,7 +95,7 @@ function MainScreen( stage, gameState ){ @@ -96,7 +95,7 @@ function MainScreen( stage, gameState ){
var spriteSheet = new createjs.SpriteSheet(data);
var animation = new createjs.Sprite(spriteSheet, "stare");
animation.x = 200;
animation.x = 140;
animation.y = 210;
animation.addEventListener("tick", handleTick);
@ -109,6 +108,7 @@ function MainScreen( stage, gameState ){ @@ -109,6 +108,7 @@ function MainScreen( stage, gameState ){
stage.addChild(animation);
this.grassLayer = new createjs.Bitmap( "res/screens/MainScreen/Grass.png" );
this.grassLayer.x = -60;
stage.addChild( this.grassLayer );
// buttons info/credits/start
@ -135,21 +135,74 @@ function MainScreen( stage, gameState ){ @@ -135,21 +135,74 @@ function MainScreen( stage, gameState ){
}
//start button
}
function DifficultyScreen( stage, gameState ){
var that = this;
this.background = new createjs.Bitmap( "res/Difficulty-Selection.png" );
this.background = new createjs.Bitmap( "res/screens/DifficultyScreen/Difficulty-Selection.png" );
stage.addChild( this.background );
// Easy/Hard Button
stage.addChild( new Button( stage, gameState, 170, 40, 450, 105, "SwitchScreen", "KitchenScreen" ) );
stage.addChild( new Button( stage, gameState, 170, 150, 450, 105, "SwitchScreen", "KitchenScreen" ) );
var turkeyAnimations = { peck:[14,24,"peck"], ruffle:[0,13,"ruffle"], stare:[25,35,"stare"] };
var data = {
images: ["res/screens/MainScreen/TurkeySprite.png"],
frames: { width:400, height:350 },
animations: turkeyAnimations
};
var spriteSheet = new createjs.SpriteSheet(data);
var animation = new createjs.Sprite(spriteSheet, "stare");
animation.x = 140;
animation.y = 210;
animation.addEventListener("tick", handleTick);
function handleTick(event) {
if ( turkeyAnimations[event.currentTarget.currentAnimation][1] == event.currentTarget.currentFrame ){
event.currentTarget.paused = true;
}
// Click happened.
}
stage.addChild(animation);
this.grassLayer = new createjs.Bitmap( "res/screens/MainScreen/Grass.png" );
this.grassLayer.x = -60;
stage.addChild( this.grassLayer );
// Difficulty selection UI
this.buttonsAndText = new createjs.Bitmap( "res/screens/DifficultyScreen/ButtonsandText.png" );
stage.addChild( this.buttonsAndText );
this.maleSelection = new createjs.Bitmap( "res/screens/DifficultyScreen/ButtonMale.png" );
stage.addChild( this.maleSelection );
this.femaleSelection = new createjs.Bitmap( "res/screens/DifficultyScreen/ButtonFemale.png" );
this.femaleSelection.alpha = 0;
stage.addChild( this.femaleSelection );
// Easy/Hard Button
stage.addChild( new Button( stage, gameState, 500, 235, 100, 55, "ChangeGender", "Male" ) );
stage.addChild( new Button( stage, gameState, 500, 300, 100, 55, "ChangeGender", "Female" ) );
stage.addChild( new Button( stage, gameState, 503, 370, 200, 55, "SwitchScreen", "KitchenScreen" ) );
stage.addChild( new Button( stage, gameState, 500, 495, 205, 55, "SwitchScreen", "KitchenScreen" ) );
stage.addChild( new Button( stage, gameState, 35, 495, 85, 55, "SwitchScreen", "MainScreen" ) );
gameState.pubsub.subscribe("ChangeGender", function(gender){
gameState.gender=gender;
if( gender == "Male" ){
that.maleSelection.alpha = 1;
that.femaleSelection.alpha = 0;
}else{
that.maleSelection.alpha = 0;
that.femaleSelection.alpha = 1;
}
})
return {
blit : function(){
if( createjs.Ticker.getTicks() %50 == 0 ){
animation.gotoAndPlay(["peck", "ruffle", "stare"][UtilityFunctions.randRange(0,2)]);
}
// Draw all the uiElements
for( var index in that.uiElems ){
@ -165,7 +218,7 @@ function KitchenScreen( stage, gameState ){ @@ -165,7 +218,7 @@ function KitchenScreen( stage, gameState ){
// Fade out any other sounds
gameState.pubsub.publish( "FadeOut", "" );
this.background = new createjs.Bitmap( "res/kitchen.png" );
this.background = new createjs.Bitmap( "res/screens/KitchenScreen/KitchenScreen.png" );
stage.addChild( this.background );
this.uiElems = [];
@ -179,6 +232,7 @@ function KitchenScreen( stage, gameState ){ @@ -179,6 +232,7 @@ function KitchenScreen( stage, gameState ){
this.uiElems.push( new ClockUI( 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, 14, 17, 73, 45, "SwitchScreen", "HelpScreen" ) );
// If player did not buy a turkey, tell them
if( !gameState.turkeyBought ){
@ -200,22 +254,52 @@ function MarketScreen( stage, gameState ){ @@ -200,22 +254,52 @@ function MarketScreen( stage, gameState ){
var that = this;
this.background = new createjs.Bitmap( "res/screens/MarketScreen/MarketScreen.png" );
var price = new createjs.Text( "100", "24px Arial", "#00000000" );
price.x = 725;
price.y = 500;
var price = new createjs.Text( "", "16px Arial", "#00000000" );
price.x = 120;
price.y = 560;
var wallet = new createjs.Text( gameState.wallet, "24px Arial", "#00000000" );
var wallet = new createjs.Text( "$" + parseFloat(gameState.wallet).toFixed(2), "20px Arial", "#00000000" );
wallet.x = 725;
wallet.y = 550;
var walletTag = new createjs.Bitmap("res/items/Wallet.png");
walletTag.x = 670;
walletTag.y = 535;
var clipboardImg = new createjs.Bitmap("res/items/Clipboard.png");
clipboardImg.x = 5;
clipboardImg.y = 315;
var clipboardTitle = new createjs.Text( "Shopping List", "18px Arial", "#00000000" );
clipboardTitle.x = 25;
clipboardTitle.y = 385;
clipboardTitle.lineWidth = 175;
var clipboardText = new createjs.Text( "Turkey", "16px Arial", "#00000000" );
clipboardText.x = 23;
clipboardText.y = 425;
clipboardText.lineWidth = 175;
var clipboardWeight = new createjs.Text( "", "16px Arial", "#00000000" );
clipboardWeight.x = 120;
clipboardWeight.y = 540;
clipboardWeight.lineWidth = 175;
// Play soundz
gameState.pubsub.publish( "Play", {name:"Entrance", volume:0.3} );
gameState.pubsub.publish( "BackgroundLoop", {name:"MarketMusic", volume:1} );
gameState.pubsub.publish( "BackgroundLoop", {name:"MarketBackgroundSound", volume:0.4} );
stage.addChild( this.background );
stage.addChild(price);
stage.addChild(this.background);
stage.addChild(wallet);
stage.addChild(walletTag);
stage.addChild(clipboardImg);
stage.addChild(clipboardTitle);
stage.addChild(clipboardText);
stage.addChild(clipboardWeight);
stage.addChild(price);
this.uiElems = [];
this.uiElems.push( new ImgButton( stage, gameState, 690,0, "res/items/ExitSign.png", "res/items/ExitGlow.png","SwitchScreen", "KitchenScreen", "Click" ) );
@ -223,20 +307,38 @@ function MarketScreen( stage, gameState ){ @@ -223,20 +307,38 @@ function MarketScreen( stage, gameState ){
for (var index in marketItemKeys ) {
gameState.marketItems[marketItemKeys[index]].draw( stage );
}
this.topground = new createjs.Bitmap( "res/screens/MarketTopShelf.png" );
this.topground = new createjs.Bitmap( "res/screens/MarketScreen/MarketTopShelf.png" );
stage.addChild( this.topground );
this.showPrice = function( cost ){
price.text = cost;
}
gameState.pubsub.subscribe( "ShowPrice", this.showPrice );
this.setWalletAmount = function(newAmount){
wallet.text=gameState.wallet=newAmount;
this.showPrice = function( cost ){
price.text = "$ " + ( cost == NaN ? "" : parseFloat(cost).toFixed(2) );
}
this.clearClipboard = function(){
price.text = "";
clipboardTitle.text = "";
clipboardText.text = "";
clipboardWeight.text = "";
}
this.showDesc = function( desc ){
clipboardTitle.text = desc.title;
clipboardText.text = desc.desc;
if( desc.weight ){
clipboardWeight.text = desc.weight.toFixed(2) + " lbs.";
}
}
this.setWalletAmount = function(newAmount){
wallet.text="$" + ( gameState.wallet=newAmount.toFixed(2) );
}
gameState.pubsub.subscribe("ShowDesc", this.showDesc);
gameState.pubsub.subscribe("ShowPrice", this.showPrice );
gameState.pubsub.subscribe("WalletAmount", this.setWalletAmount);
gameState.pubsub.subscribe("ClearClipboard", this.clearClipboard);
return {
blit : function(){

147
js/ui.js

@ -46,6 +46,11 @@ function ClockUI( stage, gameState ){ @@ -46,6 +46,11 @@ function ClockUI( stage, gameState ){
function OvenUI( stage, gameState ){
var that = this;
var OVEN_CLOSED = 0;
var OVEN_PEEK = 1;
var OVEN_OPEN = 2;
this.ovenDoor = OVEN_CLOSED;
// Important Model
var ovenModel = new OvenModel( 8, gameState );
@ -69,13 +74,23 @@ function OvenUI( stage, gameState ){ @@ -69,13 +74,23 @@ function OvenUI( stage, gameState ){
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.circle.x = 0;
this.circle.y = 0;
var lightPressedImg = new createjs.Bitmap( "res/screens/KitchenScreen/LightButtonDepressed.png" );
lightPressedImg.alpha = 0;
var doorClosedLightOff = new createjs.Bitmap( "res/screens/KitchenScreen/DoorClosedLightOff.png" );
doorClosedLightOff.alpha = 1;
var doorClosedLightOn = new createjs.Bitmap( "res/screens/KitchenScreen/DoorClosedLightOn.png" );
doorClosedLightOn.alpha = 0;
var doorPeekLightOff = new createjs.Bitmap( "res/screens/KitchenScreen/DoorPeekLightOff.png" );
doorPeekLightOff.alpha = 0;
var doorPeekLightOn = new createjs.Bitmap( "res/screens/KitchenScreen/DoorPeekLightOn.png" );
doorPeekLightOn.alpha = 0;
var doorOpen = new createjs.Bitmap( "res/screens/KitchenScreen/DoorOpen.png" );
doorOpen.alpha = 0;
this.changeTemperature = function( direction ){
@ -101,8 +116,67 @@ function OvenUI( stage, gameState ){ @@ -101,8 +116,67 @@ function OvenUI( stage, gameState ){
ovenModel.changeTemp( UtilityFunctions.F2C( temperatureText.text == "OFF" ? 125 : parseInt( temperatureText.text ) ) );
}
// change temperature, this one's for the UI
this.ovenLightToggle = function(){
lightPressedImg.alpha = lightPressedImg.alpha == 0 ? 1 : 0;
if( that.ovenDoor == OVEN_CLOSED){
doorClosedLightOn.alpha = lightPressedImg.alpha == 0 ? 0 : 1;
doorClosedLightOff.alpha = lightPressedImg.alpha == 0 ? 1 : 0;
doorOpen.alpha = 0;
}
else if( that.ovenDoor == OVEN_PEEK ){
doorPeekLightOn.alpha = lightPressedImg.alpha == 0 ? 0 : 1;
doorPeekLightOff.alpha = lightPressedImg.alpha == 0 ? 1 : 0;
doorOpen.alpha = 0;
}
}
var handleBar = new createjs.Shape();
handleBar.graphics.beginFill("#ffffff").drawRect(20, 190, 300, 20);
handleBar.alpha = 0.5;
handleBar.addEventListener( "mouseover", function(){ document.body.style.cursor='pointer'; } );
handleBar.addEventListener( "mouseout", function(){ document.body.style.cursor='default'; } );
handleBar.addEventListener( "pressup", handlePress );
// Look for a drag event
function handlePress(event) {
if( event.stageY > 300 && that.ovenDoor != OVEN_OPEN ){
that.ovenDoor = OVEN_OPEN;
doorPeekLightOn.alpha = doorClosedLightOn.alpha = 0;
doorPeekLightOff.alpha = doorClosedLightOff.alpha = 0;
doorOpen.alpha = 1;
handleBar.y = 330;
}else if (that.ovenDoor == OVEN_OPEN ){
that.ovenDoor = OVEN_PEEK;
ovenPeek();
}
}
handleBar.addEventListener( "click", ovenPeek );
function ovenPeek(){
if( that.ovenDoor == OVEN_CLOSED || that.ovenDoor == OVEN_OPEN ){
doorPeekLightOn.alpha = lightPressedImg.alpha == 0 ? 0 : 1;
doorPeekLightOff.alpha = lightPressedImg.alpha == 0 ? 1 : 0;
doorClosedLightOn.alpha = 0;
doorClosedLightOff.alpha = 0;
doorOpen.alpha = 0;
that.ovenDoor = OVEN_PEEK;
handleBar.y = 48;
}
else if (that.ovenDoor == OVEN_PEEK){
doorClosedLightOn.alpha = lightPressedImg.alpha == 0 ? 0 : 1;
doorClosedLightOff.alpha = lightPressedImg.alpha == 0 ? 1 : 0;
doorPeekLightOn.alpha = 0;
doorPeekLightOff.alpha = 0;
that.ovenDoor = OVEN_CLOSED;
doorOpen.alpha = 0;
handleBar.y = 0;
}
}
// change temperature, this one's for the UI
gameState.pubsub.subscribe( "ChangeTemperature", this.changeTemperature );
gameState.pubsub.subscribe( "OvenLightToggle", this.ovenLightToggle );
this.secondTick = function(){
ovenModel.secondTick();
@ -112,21 +186,26 @@ function OvenUI( stage, gameState ){ @@ -112,21 +186,26 @@ function OvenUI( stage, gameState ){
setInterval(this.secondTick, 1000);
stage.addChild( this.text );
stage.addChild(lightPressedImg);
// Turkey goes here
return {
tick: function(){
// Circle will move 10 units to the right.
that.circle.x += 1;
stage.addChild(doorPeekLightOn);
stage.addChild(doorPeekLightOff);
// Will cause the circle to wrap back
if ( that.circle.x > stage.canvas.width ) { that.circle.x = 0; }
},
stage.addChild(doorClosedLightOn);
stage.addChild(doorClosedLightOff);
stage.addChild(doorOpen);
stage.addChild(handleBar);
return {
tick: function(){},
render: function(){
//Set position of Shape instance.
stage.addChild( that.circle );
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( new Button( stage, gameState, 145, 163, 41, 17, "OvenLightToggle", "" ) );
stage.addChild( temperatureText );
return this;
}
@ -139,28 +218,52 @@ return { @@ -139,28 +218,52 @@ return {
}
}
function MarketItem( gameState, name, x, y, cost, mouseOutImg, mouseOverImg ){
function MarketItem( gameState, name, x, y, cost, mouseOutImg, mouseOverImg, funnyDescription, weight ){
var that = this;
console.log("Loading market item" + name);
this.name = name;
this.bought = false;
var mouseOver = new createjs.Bitmap( mouseOverImg );
var mouseOut = new createjs.Bitmap( mouseOutImg );
mouseOver.x = mouseOut.x = x;
mouseOver.y = mouseOut.y = y;
mouseOut.addEventListener( "mouseover", function(){ document.body.style.cursor='pointer'; mouseOver.visible = true; mouseOut.visible = false; gameState.pubsub.publish("ShowPrice", cost ); } );
mouseOut.addEventListener( "mouseout", function(){ document.body.style.cursor='default'; mouseOver.visible = false; mouseOut.visible = true; gameState.pubsub.publish("ShowPrice", "" ); } );
mouseOver.addEventListener( "mouseover", function(){ document.body.style.cursor='pointer'; mouseOver.visible = true; mouseOut.visible = false; gameState.pubsub.publish("ShowPrice", cost ); } );
mouseOver.addEventListener( "mouseout", function(){ document.body.style.cursor='default'; mouseOver.visible = false; mouseOut.visible = true; gameState.pubsub.publish("ShowPrice", "" );} );
mouseOut.addEventListener( "mouseover", function(){
document.body.style.cursor='pointer';
mouseOver.visible = true;
mouseOut.visible = false;
gameState.pubsub.publish("ShowPrice", cost );
gameState.pubsub.publish("ShowDesc", {title:that.name, desc:funnyDescription, weight:weight} );
});
mouseOut.addEventListener( "mouseout", function(){
document.body.style.cursor='default';
mouseOver.visible = false;
mouseOut.visible = true;
gameState.pubsub.publish("ClearClipboard", {});
} );
mouseOver.addEventListener( "mouseover", function(){
document.body.style.cursor='pointer';
mouseOver.visible = true;
mouseOut.visible = false;
gameState.pubsub.publish("ShowPrice", cost );
gameState.pubsub.publish("ShowDesc", {title:that.name, desc:funnyDescription, weight:weight} );
});
mouseOver.addEventListener( "mouseout", function(){
document.body.style.cursor='default';
mouseOver.visible = false;
mouseOut.visible = true;
gameState.pubsub.publish("ClearClipboard", {});
} );
mouseOver.addEventListener( "click", function(){
if(!that.bought && cost <= gameState.wallet ){
if( that.name.indexOf("Turkey") == 0 && gameState.turkeyBought != true){
console.log(that.name);
if( that.name.indexOf("Turkey") != -1 && gameState.turkeyBought != true){
gameState.turkeyBought = true;
gameState.marketItems[ that.name ].delete();
gameState.pubsub.publish("Play", {name:"Buy", volume:0.7} );
gameState.pubsub.publish("WalletAmount", gameState.wallet - Math.abs(cost))
}
// can we buy this? Only possible if you already bought a turkey
else if( !that.name.indexOf("Turkey") == 0 && gameState.turkeyBought == true ){
else if( !that.name.indexOf("Turkey") != -1 && gameState.turkeyBought == true ){
gameState.purchasedItems.push( objReturn );
gameState.marketItems[ that.name ].delete();
that.bought = true;
@ -168,7 +271,7 @@ function MarketItem( gameState, name, x, y, cost, mouseOutImg, mouseOverImg ){ @@ -168,7 +271,7 @@ function MarketItem( gameState, name, x, y, cost, mouseOutImg, mouseOverImg ){
gameState.pubsub.publish("WalletAmount", gameState.wallet - Math.abs(cost));
}
// One turkey only
else if( that.name.indexOf("Turkey") == 0 && gameState.turkeyBought == true ){
else if( that.name.indexOf("Turkey") != -1 && gameState.turkeyBought == true ){
gameState.pubsub.publish( "ShowDialog", {seq:"CannotBuyTurkey", autoAdvance:false} );
gameState.pubsub.publish( "Play", "Error" );
}

BIN
res/items/.DS_Store vendored

Binary file not shown.

BIN
res/items/Clipboard.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

BIN
res/items/Price-Tag.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

BIN
res/items/Wallet.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

BIN
res/kitchen.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 341 KiB

BIN
res/screens/.DS_Store vendored

Binary file not shown.

BIN
res/screens/DifficultyScreen/.DS_Store vendored

Binary file not shown.

BIN
res/screens/DifficultyScreen/ButtonFemale.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
res/screens/DifficultyScreen/ButtonMale.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

BIN
res/screens/DifficultyScreen/ButtonsandText.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

BIN
res/screens/DifficultyScreen/Difficulty-Selection.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 566 KiB

BIN
res/screens/KitchenScreen/.DS_Store vendored

Binary file not shown.

BIN
res/screens/KitchenScreen/AlarmKitchen.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
res/screens/KitchenScreen/AlarmKitchenGlow.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
res/screens/KitchenScreen/CookbookKitchen.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

BIN
res/screens/KitchenScreen/CookbookKitchenGlow.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

BIN
res/screens/KitchenScreen/DoorClosedLightOff.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
res/screens/KitchenScreen/DoorClosedLightOn.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
res/screens/KitchenScreen/DoorOpen.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

BIN
res/screens/KitchenScreen/DoorPeekLightOff.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
res/screens/KitchenScreen/DoorPeekLightOn.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

BIN
res/screens/KitchenScreen/FrillsBoxKitchen.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
res/screens/KitchenScreen/FrillsBoxKitchenGlow.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
res/screens/KitchenScreen/KitchenScreen.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 370 KiB

BIN
res/screens/KitchenScreen/KitchenScreenMockup.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 463 KiB

BIN
res/screens/KitchenScreen/LightButtonDepressed.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

BIN
res/screens/KitchenScreen/OvenTurnRedState.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

BIN
res/screens/KitchenScreen/PanFront.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

BIN
res/screens/KitchenScreen/StoreBrochure.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

BIN
res/screens/KitchenScreen/StoreBrochureGlow.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

BIN
res/screens/KitchenScreen/StuffingExquisiteKitchen.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

BIN
res/screens/KitchenScreen/StuffingExquisiteKitchenGlow.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

BIN
res/screens/KitchenScreen/StuffingRepurposedKitchen.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
res/screens/KitchenScreen/StuffingRepurposedKitchenGlow.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

BIN
res/screens/KitchenScreen/StuffingSpecialKitchen.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
res/screens/KitchenScreen/StuffingSpecialKitchenGlow.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
res/screens/KitchenScreen/TempProbeKitchen.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
res/screens/KitchenScreen/TempProbeKitchenGlow.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

7695
res/screens/KitchenScreen/TurkeyState1.svg

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 807 KiB

9288
res/screens/KitchenScreen/TurkeyState2.svg

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 968 KiB

9290
res/screens/KitchenScreen/TurkeyState3.svg

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 973 KiB

10920
res/screens/KitchenScreen/TurkeyState4.svg

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 1.1 MiB

12955
res/screens/KitchenScreen/TurkeyState5.svg

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 1.3 MiB

BIN
res/screens/MainScreen/.DS_Store vendored

Binary file not shown.

BIN
res/screens/MainScreen/ButtonHelp.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Loading…
Cancel
Save