home *** CD-ROM | disk | FTP | other *** search
- package classes.game
- {
- import classes.basic.MovieClip.*;
- import classes.global.Global;
- import flash.display.MovieClip;
- import flash.events.MouseEvent;
-
- public class RoomStation extends StationCustomerContainer
- {
-
-
- private var uses:Number;
-
- private var dirty:Boolean;
-
- private var chanceDirty:Number;
-
- public function RoomStation(param1:MovieClip, param2:String)
- {
- super(param1,5,param2);
- addListener(EVENT_RETURN,onReturnCustomer);
- addListener(EVENT_ADD,onAddCustomer);
- addListener(EVENT_REMOVE,onRemoveCustomer);
- chanceDirty = 0;
- dirty = false;
- uses = 0;
- }
-
- override protected function onEmpty() : *
- {
- super.onEmpty();
- if(customer != null)
- {
- customer.getMovieClip().visible = true;
- }
- }
-
- override protected function onMouseUp() : *
- {
- if(Global.mouse.isEmpty())
- {
- startEvent(EVENT_REQUEST_MAINCHAR);
- }
- else if(!dirty)
- {
- super.onMouseUp();
- }
- else if(Global.mouse.getLastLocal() != null)
- {
- Global.mouse.getLastLocal().addCustomer(Global.mouse.removeCustomer());
- }
- }
-
- override protected function onMCRollOver(param1:MouseEvent) : void
- {
- if(dirty && Global.mouse.isEmpty())
- {
- super.onMCRollOver(param1);
- }
- if(!dirty && !Global.mouse.isEmpty())
- {
- super.onMCRollOver(param1);
- }
- }
-
- protected function onAddCustomer(param1:String, param2:CustomerContainer) : *
- {
- if(getTime() > 0)
- {
- start();
- }
- customer.getMovieClip().visible = false;
- customer.getMovieClip().x = 28;
- customer.getMovieClip().y = 15;
- customer.getMovieClip().mcBody.gotoAndStop("room");
- }
-
- public function clean() : *
- {
- movieClip.gotoAndPlay("towel");
- dirty = false;
- uses = 0;
- chanceDirty = 0;
- Global.soundsFX["cleaningStation"].play();
- }
-
- private function onRemoveCustomer(param1:String, param2:CustomerContainer) : *
- {
- if(dirty)
- {
- movieClip.gotoAndStop("dirty");
- }
- }
-
- override public function onFinish() : *
- {
- var _loc1_:Number = NaN;
- this.lastTime = 0;
- movieClip.gotoAndPlay("enter");
- TFMovieClip.addLabelScript(movieClip,"finishEnter",onFinishBusy);
- ++uses;
- if(this.getType() == Desires.SAUNA)
- {
- Global.soundsFX["sauna"].stop();
- }
- if(this.getType() == Desires.SWIMMING)
- {
- Global.soundsFX["swimming"].stop();
- }
- if(this.getType() == Desires.YOGA)
- {
- Global.soundsFX["yoga"].stop();
- }
- if(uses == 3)
- {
- chanceDirty = 40;
- }
- if(uses > 3)
- {
- chanceDirty += 20;
- }
- if(chanceDirty > 0)
- {
- _loc1_ = Math.random() * 100;
- if(_loc1_ <= chanceDirty)
- {
- dirty = true;
- }
- }
- if(soundTimer != null)
- {
- soundTimer.stop();
- soundTimer = null;
- }
- Global.soundsFX["endingTreatment"].play();
- }
-
- public function isDirty() : *
- {
- return dirty;
- }
-
- private function onStartBusy() : *
- {
- TFMovieClip.addLabelScript(movieClip,"finishEnter",null);
- showBusyAnimation();
- }
-
- override public function start() : *
- {
- this.run = true;
- this.lastTime = 0;
- customer.addUseStation(getType());
- movieClip.gotoAndPlay("enter");
- TFMovieClip.addLabelScript(movieClip,"finishEnter",onStartBusy);
- if(this.getType() == Desires.SAUNA)
- {
- Global.soundsFX["sauna"].play();
- }
- if(this.getType() == Desires.SWIMMING)
- {
- Global.soundsFX["swimming"].play();
- }
- if(this.getType() == Desires.YOGA)
- {
- Global.soundsFX["yoga"].play();
- }
- movieClip.mcClock.visible = true;
- movieClip.mcClock.gotoAndStop(1);
- soundTimer = Global.soundsFX["clockTicking"].play();
- }
-
- private function onFinishBusy() : *
- {
- this.run = false;
- TFMovieClip.addLabelScript(movieClip,"finishEnter",null);
- super.onFinish();
- }
-
- private function onReturnCustomer(param1:String, param2:CustomerContainer) : *
- {
- customer.angry();
- customer.getMovieClip().x = 28;
- customer.getMovieClip().y = 15;
- customer.getMovieClip().mcBody.gotoAndStop("room");
- }
- }
- }
-