var EHDI = EHDI || Object.create(null); EHDI.components = EHDI.components || Object.create(null); EHDI.components.FishToggle = function() { EHDI.aka.Container.call(this); this.basketCloth = new EHDI.aka.Sprite(EHDI.Assets.images["fish-cloth"]); this.basketCloth.anchor.set(0.5, 0); this.addChild(this.basketCloth); this.glow = new EHDI.aka.Sprite(EHDI.Assets.images["glow"]); this.glow.anchor.set(0.5, 0.5); this.glow.scale.set(0, 0); this.addChild(this.glow); this.basketContainer = new EHDI.aka.Container(); this.addChild(this.basketContainer); this.basketContainer.y = - EHDI.GAME.sceneManager.getStageHeight() * 0.03; this.design = new EHDI.aka.Sprite(EHDI.Assets.images["fish-stuff"]); this.design.anchor.set(0.5, 0.5); this.design.position.y = EHDI.GAME.sceneManager.getStageHeight() * 0.13; this.addChild(this.design); this.basketBack = new EHDI.aka.Sprite(EHDI.Assets.images["fishbread_basketback"]); this.basketBack.anchor.x = 0.5; this.basketBack.anchor.y = 0.5; this.basketContainer.addChild(this.basketBack); this.fish = new EHDI.aka.Sprite(EHDI.Assets.images["fishbread_basketfish"]); this.fish.anchor.x = 0.5; this.fish.anchor.y = 0.5; this.basketContainer.addChild(this.fish); this.basketFront = new EHDI.aka.Sprite(EHDI.Assets.images["fishbread_basketfront"]); this.basketFront.anchor.x = 0.5; this.basketFront.anchor.y = 0.15; this.basketContainer.addChild(this.basketFront); this.interactive = true; }; EHDI.components.FishToggle.prototype = Object.create(EHDI.aka.Container.prototype); EHDI.components.FishToggle.prototype.mousedown = function(mousedata) { if(EHDI.GAME.customerSpawner.current && EHDI.GAME.customerSpawner.interaction && !EHDI.GAME.pauseButton.isPaused) { this.isPressed = true; if(this.animateTimeline) this.animateTimeline.kill(); this.animateTimeline = new TimelineMax(); this.animateTimeline.to(this.basketFront.scale, 0.125, {x : 1.1, y: 1.1}); this.animateTimeline.to(this.basketBack.scale, 0.125, {x : 1.1, y : 1.1}, 0); this.animateTimeline.to(this.glow.scale, 0.15, {x : 1.1, y : 1.1, ease : Power0.easeNone}, 0); this.animateTimeline.to(this.fish, 0.125, {y : -this.fish.width * 0.1}, 0); } }; EHDI.components.FishToggle.prototype.touchstart = function(touchdata) { if(EHDI.GAME.customerSpawner.current && EHDI.GAME.customerSpawner.interaction && !EHDI.GAME.pauseButton.isPaused) { this.isPressed = true; if(this.animateTimeline) this.animateTimeline.kill(); this.animateTimeline = new TimelineMax(); this.animateTimeline.to(this.basketFront.scale, 0.125, {x : 1.1, y: 1.1}); this.animateTimeline.to(this.basketBack.scale, 0.125, {x : 1.1, y : 1.1}, 0); this.animateTimeline.to(this.glow.scale, 0.15, {x : 1.1, y : 1.1, ease : Power0.easeNone}, 0); this.animateTimeline.to(this.fish, 0.125, {y : -this.fish.width * 0.1}, 0); } }; EHDI.components.FishToggle.prototype.touchend = function(touchdata) { if(!this.isPressed) return; this.isPressed = false; this.animateTimeline.to(this.fish, 0.25, {y : 0}, 0.125); this.animateTimeline.to(this.basketFront.scale, 0.125, {x : 1, y : 1}, 0.125); this.animateTimeline.to(this.basketBack.scale, 0.125, {x : 1, y : 1}, 0.125); this.animateTimeline.to(this.glow.scale, 0.15, {x : 0, y : 0, ease : Power0.easeNone}, 0.15); EHDI.GAME.customerSpawner.current.fishToggle(); }; EHDI.components.FishToggle.prototype.mouseup = function(touchdata) { if(!this.isPressed) return; this.isPressed = false; this.animateTimeline.to(this.fish, 0.25, {y : 0}, 0.125); this.animateTimeline.to(this.basketFront.scale, 0.125, {x : 1, y : 1}, 0.125); this.animateTimeline.to(this.basketBack.scale, 0.125, {x : 1, y : 1}, 0.125); this.animateTimeline.to(this.glow.scale, 0.15, {x : 0, y : 0, ease : Power0.easeNone}, 0.15); EHDI.GAME.customerSpawner.current.fishToggle(); }; EHDI.components.FishToggle.prototype.animateFish = function () { if(this.animateTimeline) this.animateTimeline.kill(); this.animateTimeline = new TimelineMax(); this.animateTimeline.to(this.basketFront.scale, 0.125, {x : 1.1, y : 1.1}); this.animateTimeline.to(this.basketBack.scale, 0.125, {x : 1.1, y : 1.1}, 0); this.animateTimeline.to(this.glow.scale, 0.15, {x : 1.1, y : 1.1, ease : Power0.easeNone}, 0); this.animateTimeline.to(this.fish, 0.125, {y : -this.fish.width * 0.1}, 0); this.animateTimeline.to(this.fish, 0.25, {y : 0}, 0.125); this.animateTimeline.to(this.basketFront.scale, 0.125, {x : 1, y : 1}, 0.125); this.animateTimeline.to(this.basketBack.scale, 0.125, {x : 1, y : 1}, 0.125); this.animateTimeline.to(this.glow.scale, 0.15, {x : 0, y : 0, ease : Power0.easeNone}, 0.15); } EHDI.components.FishToggle.prototype.toggleFish = function() { if(EHDI.GAME.customerSpawner.current && EHDI.GAME.customerSpawner.interaction && !EHDI.GAME.pauseButton.isPaused) { this.animateFish(); EHDI.GAME.customerSpawner.current.fishToggle(); } }