Browse Source

Fixed market persistence bug

Load_Fix
Robert Chen 11 years ago
parent
commit
02a15f489c
  1. 3
      js/screens.js
  2. 18
      js/ui.js

3
js/screens.js

@ -335,6 +335,7 @@ function MarketScreen( stage, gameState ){
this.uiElems = []; this.uiElems = [];
this.uiElems.push( new ImgButton( stage, gameState, 690,0, "res/items/ExitSign.png", "res/items/ExitGlow.png","SwitchScreen", "KitchenScreen", "Click" ) ); this.uiElems.push( new ImgButton( stage, gameState, 690,0, "res/items/ExitSign.png", "res/items/ExitGlow.png","SwitchScreen", "KitchenScreen", "Click" ) );
var marketItemKeys = Object.keys(gameState.marketItems); var marketItemKeys = Object.keys(gameState.marketItems);
for (var index in marketItemKeys ) { for (var index in marketItemKeys ) {
gameState.marketItems[marketItemKeys[index]].draw( stage ); gameState.marketItems[marketItemKeys[index]].draw( stage );
@ -426,7 +427,7 @@ function EndingScreen( stage, gameState ){
} }
function ScoreScreen( stage, gameState ){ function ScoreScreen( stage, gameState ){
var that = this; var that = this;
this.background = new createjs.Bitmap( "res/Main.png" ); this.background = new createjs.Bitmap( "res/Main.png" );
stage.addChild( this.background ); stage.addChild( this.background );

18
js/ui.js

@ -569,9 +569,6 @@ return {
secondCounter = 0; secondCounter = 0;
} }
// move the overlay
console.log("Mood"+mood.x);
if( dayNight.x < -15583 ) if( dayNight.x < -15583 )
dayNight.x = 0; dayNight.x = 0;
@ -671,6 +668,7 @@ function MarketItem( gameState, name, x, y, cost, mouseOutImg, mouseOverImg, mou
gameState.turkeyBought = true; gameState.turkeyBought = true;
gameState.turkeyWeight = weight; gameState.turkeyWeight = weight;
gameState.marketItems[ that.name ].delete(); gameState.marketItems[ that.name ].delete();
that.bought = true;
gameState.pubsub.publish("Play", {name:"Buy", volume:0.7} ); gameState.pubsub.publish("Play", {name:"Buy", volume:0.7} );
gameState.pubsub.publish("WalletAmount", gameState.wallet - Math.abs(cost)) gameState.pubsub.publish("WalletAmount", gameState.wallet - Math.abs(cost))
gameState.pubsub.publish("StartTurkeyModel",""); gameState.pubsub.publish("StartTurkeyModel","");
@ -703,31 +701,33 @@ function MarketItem( gameState, name, x, y, cost, mouseOutImg, mouseOverImg, mou
gameState.pubsub.publish( "Play", "Error" ); gameState.pubsub.publish( "Play", "Error" );
} }
}); });
mouseOver.visible = false; mouseOver.visible = false;
var objReturn = { var objReturn = {
tick: function(){}, tick: function(){},
getName: function(){return that.name;}, getName: function(){return that.name;},
delete: function( stage ){ delete: function( stage ){
that.visible = false;
gameState.pubsub.publish("RemoveItems", [mouseOut, mouseOver]); gameState.pubsub.publish("RemoveItems", [mouseOut, mouseOver]);
mouseOut.visible = false;
mouseOver.visible = false;
}, },
draw: function( stage, newx, newy ){ draw: function( stage, newx, newy ){
if( newx && newy ){ if( newx && newy ){
mouseOut.x = mouseOver.x = newx; mouseOut.x = mouseOver.x = newx;
mouseOut.y = mouseOver.y = newy; mouseOut.y = mouseOver.y = newy;
} }
console.log("NewScreen for item "+that.name +" is " +gameState.newScreen );
if( gameState.newScreen == "KitchenScreen" ){ if( gameState.newScreen == "KitchenScreen" ){
mouseOutKitchen.visible = true;
stage.addChild( mouseOutKitchen ); stage.addChild( mouseOutKitchen );
mouseOverKitchen.visible = false; mouseOverKitchen.visible = false;
stage.addChild( mouseOverKitchen ); stage.addChild( mouseOverKitchen );
return; return;
} }
stage.addChild( mouseOut ); if( !that.bought ){
stage.addChild( mouseOver ); stage.addChild( mouseOut );
stage.addChild( mouseOver );
}
} }
} }
return objReturn; return objReturn;

Loading…
Cancel
Save