home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / beauty_resort.swf / scripts / classes / game / RoomStation.as < prev    next >
Encoding:
Text File  |  2008-09-04  |  5.1 KB  |  189 lines

  1. package classes.game
  2. {
  3.    import classes.basic.MovieClip.*;
  4.    import classes.global.Global;
  5.    import flash.display.MovieClip;
  6.    import flash.events.MouseEvent;
  7.    
  8.    public class RoomStation extends StationCustomerContainer
  9.    {
  10.        
  11.       
  12.       private var uses:Number;
  13.       
  14.       private var dirty:Boolean;
  15.       
  16.       private var chanceDirty:Number;
  17.       
  18.       public function RoomStation(param1:MovieClip, param2:String)
  19.       {
  20.          super(param1,5,param2);
  21.          addListener(EVENT_RETURN,onReturnCustomer);
  22.          addListener(EVENT_ADD,onAddCustomer);
  23.          addListener(EVENT_REMOVE,onRemoveCustomer);
  24.          chanceDirty = 0;
  25.          dirty = false;
  26.          uses = 0;
  27.       }
  28.       
  29.       override protected function onEmpty() : *
  30.       {
  31.          super.onEmpty();
  32.          if(customer != null)
  33.          {
  34.             customer.getMovieClip().visible = true;
  35.          }
  36.       }
  37.       
  38.       override protected function onMouseUp() : *
  39.       {
  40.          if(Global.mouse.isEmpty())
  41.          {
  42.             startEvent(EVENT_REQUEST_MAINCHAR);
  43.          }
  44.          else if(!dirty)
  45.          {
  46.             super.onMouseUp();
  47.          }
  48.          else if(Global.mouse.getLastLocal() != null)
  49.          {
  50.             Global.mouse.getLastLocal().addCustomer(Global.mouse.removeCustomer());
  51.          }
  52.       }
  53.       
  54.       override protected function onMCRollOver(param1:MouseEvent) : void
  55.       {
  56.          if(dirty && Global.mouse.isEmpty())
  57.          {
  58.             super.onMCRollOver(param1);
  59.          }
  60.          if(!dirty && !Global.mouse.isEmpty())
  61.          {
  62.             super.onMCRollOver(param1);
  63.          }
  64.       }
  65.       
  66.       protected function onAddCustomer(param1:String, param2:CustomerContainer) : *
  67.       {
  68.          if(getTime() > 0)
  69.          {
  70.             start();
  71.          }
  72.          customer.getMovieClip().visible = false;
  73.          customer.getMovieClip().x = 28;
  74.          customer.getMovieClip().y = 15;
  75.          customer.getMovieClip().mcBody.gotoAndStop("room");
  76.       }
  77.       
  78.       public function clean() : *
  79.       {
  80.          movieClip.gotoAndPlay("towel");
  81.          dirty = false;
  82.          uses = 0;
  83.          chanceDirty = 0;
  84.          Global.soundsFX["cleaningStation"].play();
  85.       }
  86.       
  87.       private function onRemoveCustomer(param1:String, param2:CustomerContainer) : *
  88.       {
  89.          if(dirty)
  90.          {
  91.             movieClip.gotoAndStop("dirty");
  92.          }
  93.       }
  94.       
  95.       override public function onFinish() : *
  96.       {
  97.          var _loc1_:Number = NaN;
  98.          this.lastTime = 0;
  99.          movieClip.gotoAndPlay("enter");
  100.          TFMovieClip.addLabelScript(movieClip,"finishEnter",onFinishBusy);
  101.          ++uses;
  102.          if(this.getType() == Desires.SAUNA)
  103.          {
  104.             Global.soundsFX["sauna"].stop();
  105.          }
  106.          if(this.getType() == Desires.SWIMMING)
  107.          {
  108.             Global.soundsFX["swimming"].stop();
  109.          }
  110.          if(this.getType() == Desires.YOGA)
  111.          {
  112.             Global.soundsFX["yoga"].stop();
  113.          }
  114.          if(uses == 3)
  115.          {
  116.             chanceDirty = 40;
  117.          }
  118.          if(uses > 3)
  119.          {
  120.             chanceDirty += 20;
  121.          }
  122.          if(chanceDirty > 0)
  123.          {
  124.             _loc1_ = Math.random() * 100;
  125.             if(_loc1_ <= chanceDirty)
  126.             {
  127.                dirty = true;
  128.             }
  129.          }
  130.          if(soundTimer != null)
  131.          {
  132.             soundTimer.stop();
  133.             soundTimer = null;
  134.          }
  135.          Global.soundsFX["endingTreatment"].play();
  136.       }
  137.       
  138.       public function isDirty() : *
  139.       {
  140.          return dirty;
  141.       }
  142.       
  143.       private function onStartBusy() : *
  144.       {
  145.          TFMovieClip.addLabelScript(movieClip,"finishEnter",null);
  146.          showBusyAnimation();
  147.       }
  148.       
  149.       override public function start() : *
  150.       {
  151.          this.run = true;
  152.          this.lastTime = 0;
  153.          customer.addUseStation(getType());
  154.          movieClip.gotoAndPlay("enter");
  155.          TFMovieClip.addLabelScript(movieClip,"finishEnter",onStartBusy);
  156.          if(this.getType() == Desires.SAUNA)
  157.          {
  158.             Global.soundsFX["sauna"].play();
  159.          }
  160.          if(this.getType() == Desires.SWIMMING)
  161.          {
  162.             Global.soundsFX["swimming"].play();
  163.          }
  164.          if(this.getType() == Desires.YOGA)
  165.          {
  166.             Global.soundsFX["yoga"].play();
  167.          }
  168.          movieClip.mcClock.visible = true;
  169.          movieClip.mcClock.gotoAndStop(1);
  170.          soundTimer = Global.soundsFX["clockTicking"].play();
  171.       }
  172.       
  173.       private function onFinishBusy() : *
  174.       {
  175.          this.run = false;
  176.          TFMovieClip.addLabelScript(movieClip,"finishEnter",null);
  177.          super.onFinish();
  178.       }
  179.       
  180.       private function onReturnCustomer(param1:String, param2:CustomerContainer) : *
  181.       {
  182.          customer.angry();
  183.          customer.getMovieClip().x = 28;
  184.          customer.getMovieClip().y = 15;
  185.          customer.getMovieClip().mcBody.gotoAndStop("room");
  186.       }
  187.    }
  188. }
  189.