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

  1. package classes.game
  2. {
  3.    import classes.basic.Button.*;
  4.    import classes.basic.Events.TFEvent;
  5.    import classes.basic.MovieClip.TFMovieClip;
  6.    import classes.basic.Sound.TFSound;
  7.    import classes.global.*;
  8.    import flash.display.MovieClip;
  9.    
  10.    public class ManagerGamePlay
  11.    {
  12.        
  13.       
  14.       private var chairsContainers:Array;
  15.       
  16.       private var stationsContainer:Array;
  17.       
  18.       private var lastTime:Number;
  19.       
  20.       private var started:Boolean;
  21.       
  22.       private var isShowScore:Boolean;
  23.       
  24.       private var countCustomer:Number;
  25.       
  26.       private var supplyClean:MainCharActionButton;
  27.       
  28.       private var mainChar:MainChar;
  29.       
  30.       private var garbagecanClean:MainCharActionButton;
  31.       
  32.       private var numberCustomer:Number;
  33.       
  34.       private var dialog:MovieClip;
  35.       
  36.       private var timeCustomer:Number;
  37.       
  38.       private var time:Number;
  39.       
  40.       private var garbagecanCream:MainCharActionButton;
  41.       
  42.       private var garbagecanTowel:MainCharActionButton;
  43.       
  44.       private var maxCustomers:Number;
  45.       
  46.       private var supplyCream:MainCharActionButton;
  47.       
  48.       private var supplyTowel:MainCharActionButton;
  49.       
  50.       private var customers:Array;
  51.       
  52.       public function ManagerGamePlay(param1:Number, param2:Number, param3:Number)
  53.       {
  54.          var _loc4_:MovieClip = null;
  55.          var _loc5_:CustomerContainer = null;
  56.          var _loc6_:Number = NaN;
  57.          super();
  58.          this.numberCustomer = param3;
  59.          this.countCustomer = 0;
  60.          time = 0;
  61.          this.customers = new Array();
  62.          this.maxCustomers = param1;
  63.          this.timeCustomer = param2;
  64.          this.lastTime = this.timeCustomer - 1000;
  65.          this.chairsContainers = new Array();
  66.          this.mainChar = new MainChar(onFinishWalking);
  67.          this.started = false;
  68.          isShowScore = false;
  69.          _loc6_ = 0;
  70.          while(_loc6_ < 6)
  71.          {
  72.             switch(_loc6_)
  73.             {
  74.                case 0:
  75.                   _loc4_ = Global.main.mcChair1;
  76.                   break;
  77.                case 1:
  78.                   _loc4_ = Global.main.mcChair2;
  79.                   break;
  80.                case 2:
  81.                   _loc4_ = Global.main.mcChair3;
  82.                   break;
  83.                case 3:
  84.                   _loc4_ = Global.main.mcChair4;
  85.                   break;
  86.                case 4:
  87.                   _loc4_ = Global.main.mcChair5;
  88.                   break;
  89.                case 5:
  90.                   _loc4_ = Global.main.mcChair6;
  91.                   break;
  92.             }
  93.             _loc5_ = new WaitingCustomerContainer(_loc4_);
  94.             this.chairsContainers.push(_loc5_);
  95.             _loc6_++;
  96.          }
  97.          this.stationsContainer = new Array();
  98.          createStation();
  99.          supplyClean = new MainCharActionButton(Global.main.mcSupplyClean,onEventSupplyClean);
  100.          supplyTowel = new MainCharActionButton(Global.main.mcSupplyTowel,onEventSupplyTowel);
  101.          supplyCream = new MainCharActionButton(Global.main.mcSupplyCream,onEventSupplyCream);
  102.          garbagecanClean = new MainCharActionButton(Global.main.mcGarbagecanClean,onEventGarbagecanClean);
  103.          garbagecanTowel = new MainCharActionButton(Global.main.mcGarbagecanTowel,onEventGarbagecanTowel);
  104.          garbagecanCream = new MainCharActionButton(Global.main.mcGarbagecanCream,onEventGarbagecanCream);
  105.          Global.main.mcTextGoal.text = Global.xmlLocalization.game.goal;
  106.          Global.main.mcGoal.text = Global.xmlLocalization.symbol_cash + String(Levels.stages.stage[Levels.indexStage].levels.level[Levels.indexLevel].goal);
  107.          Global.cash = 0;
  108.          Global.main.mcTextCash.text = Global.xmlLocalization.game.cash;
  109.          Global.main.mcCash.text = Global.xmlLocalization.symbol_cash + String(Global.cash);
  110.          Global.main.mcLeft.text = String(this.numberCustomer - this.countCustomer);
  111.          switch(Levels.indexStage)
  112.          {
  113.             case 0:
  114.                Global.soundTrackStage1.play();
  115.                break;
  116.             case 1:
  117.                Global.soundTrackStage2.play();
  118.                break;
  119.             case 2:
  120.                Global.soundTrackStage3.play();
  121.                break;
  122.             case 3:
  123.                Global.soundTrackStage4.play();
  124.          }
  125.       }
  126.       
  127.       private function onEventGarbagecanClean(param1:TFEvent) : *
  128.       {
  129.          switch(param1.event)
  130.          {
  131.             case TFEvent.EVENT_MOUSEUP:
  132.                if(Global.mouse.getLastLocal() != null)
  133.                {
  134.                   Global.mouse.getLastLocal().addCustomer(Global.mouse.removeCustomer());
  135.                }
  136.                break;
  137.             case TFEvent.EVENT_MOUSECLICK:
  138.                mainChar.gotoGarbagecanClean();
  139.                garbagecanClean.setQueue(mainChar.getIndexQueue());
  140.                Global.soundsFX["move_mainchar"].play();
  141.          }
  142.       }
  143.       
  144.       private function showScore() : *
  145.       {
  146.          var _loc1_:Class = null;
  147.          mainChar.removeAllItem();
  148.          isShowScore = true;
  149.          Global.main.mcBathtub1.gotoAndStop("empty");
  150.          Global.main.mcBathtub2.gotoAndStop("empty");
  151.          Global.main.mcBathtub3.gotoAndStop("empty");
  152.          Global.main.mcBathtub4.gotoAndStop("empty");
  153.          Global.main.mcRoom1.gotoAndStop("empty");
  154.          Global.main.mcRoom2.gotoAndStop("empty");
  155.          Global.main.mcRoom3.gotoAndStop("empty");
  156.          _loc1_ = Global.main.getAsset("scoreScreen");
  157.          dialog = new _loc1_();
  158.          TFMovieClip.addLabelScript(dialog,"loadScore",onLoadScore);
  159.          Global.main.mcDialogDummy.enabled = true;
  160.          Global.main.mcDialogDummy.mouseEnabled = true;
  161.          Global.main.mcDialogDummy.addChild(dialog);
  162.          dialog.x = 300;
  163.          dialog.y = 225;
  164.          if(Global.cash >= Levels.stages.stage[Levels.indexStage].levels.level[Levels.indexLevel].goal)
  165.          {
  166.             dialog.mcBgCompleted.visible = true;
  167.             dialog.mcBgFail.visible = false;
  168.             dialog.mcTitle.mcText.text = Global.xmlLocalization.scorescreen.title;
  169.             dialog.mcTitleBlink.mcText.text = Global.xmlLocalization.scorescreen.title;
  170.          }
  171.          else
  172.          {
  173.             dialog.mcBgCompleted.visible = false;
  174.             dialog.mcBgFail.visible = true;
  175.             dialog.mcTitle.mcText.text = Global.xmlLocalization.scorescreen.fail;
  176.             dialog.mcTitleBlink.mcText.text = Global.xmlLocalization.scorescreen.fail;
  177.          }
  178.          dialog.play();
  179.          TFMovieClip.addLabelScript(dialog,"levelText",onShowLevelText);
  180.          TFMovieClip.addLabelScript(dialog,"levelValue",onShowLevelValue);
  181.          TFMovieClip.addLabelScript(dialog,"totalText",onShowTotalText);
  182.          TFMovieClip.addLabelScript(dialog,"totalValue",onShowTotalValue);
  183.          if(Global.cash >= Levels.stages.stage[Levels.indexStage].levels.level[Levels.indexLevel].goal)
  184.          {
  185.             Global.soundLevelCompleted.play();
  186.          }
  187.          else
  188.          {
  189.             Global.soundLevelFail.play();
  190.          }
  191.          switch(Levels.indexStage)
  192.          {
  193.             case 0:
  194.                Global.soundTrackStage1.stop();
  195.                break;
  196.             case 1:
  197.                Global.soundTrackStage2.stop();
  198.                break;
  199.             case 2:
  200.                Global.soundTrackStage3.stop();
  201.                break;
  202.             case 3:
  203.                Global.soundTrackStage4.stop();
  204.          }
  205.       }
  206.       
  207.       private function createStation() : *
  208.       {
  209.          var _loc1_:XMLList = null;
  210.          var _loc2_:StationCustomerContainer = null;
  211.          var _loc3_:* = undefined;
  212.          Global.main.mcTreatment1.visible = false;
  213.          Global.main.mcTreatment2.visible = false;
  214.          Global.main.mcTreatment3.visible = false;
  215.          Global.main.mcTreatment4.visible = false;
  216.          Global.main.mcBathtub1.visible = false;
  217.          Global.main.mcBathtub2.visible = false;
  218.          Global.main.mcBathtub3.visible = false;
  219.          Global.main.mcBathtub4.visible = false;
  220.          Global.main.mcRoom1.visible = false;
  221.          Global.main.mcRoom2.visible = false;
  222.          Global.main.mcRoom3.visible = false;
  223.          _loc1_ = Levels.stages.stage[Levels.indexStage].levels.level[Levels.indexLevel].stations.name;
  224.          for each(_loc3_ in _loc1_)
  225.          {
  226.             switch(_loc3_.toString())
  227.             {
  228.                case Desires.MASSAGE:
  229.                   _loc2_ = new TreatmentStation(Global.main.mcTreatment1,Desires.MASSAGE);
  230.                   break;
  231.                case Desires.SOLARIUM:
  232.                   _loc2_ = new TreatmentStation(Global.main.mcTreatment2,Desires.SOLARIUM);
  233.                   break;
  234.                case Desires.ACUPUNCTURE:
  235.                   _loc2_ = new TreatmentStation(Global.main.mcTreatment3,Desires.ACUPUNCTURE);
  236.                   break;
  237.                case Desires.EXFOLIATING:
  238.                   _loc2_ = new TreatmentStation(Global.main.mcTreatment4,Desires.EXFOLIATING);
  239.                   break;
  240.                case Desires.HYDRO:
  241.                   _loc2_ = new BathStation(Global.main.mcBathtub1,Desires.HYDRO);
  242.                   break;
  243.                case Desires.ICE:
  244.                   _loc2_ = new BathStation(Global.main.mcBathtub2,Desires.ICE);
  245.                   break;
  246.                case Desires.HERB:
  247.                   _loc2_ = new BathStation(Global.main.mcBathtub3,Desires.HERB);
  248.                   break;
  249.                case Desires.OFURO:
  250.                   _loc2_ = new BathStation(Global.main.mcBathtub4,Desires.OFURO);
  251.                   break;
  252.                case Desires.SAUNA:
  253.                   _loc2_ = new RoomStation(Global.main.mcRoom1,Desires.SAUNA);
  254.                   break;
  255.                case Desires.SWIMMING:
  256.                   _loc2_ = new RoomStation(Global.main.mcRoom2,Desires.SWIMMING);
  257.                   break;
  258.                case Desires.YOGA:
  259.                   _loc2_ = new RoomStation(Global.main.mcRoom3,Desires.YOGA);
  260.             }
  261.             if(_loc2_ != null)
  262.             {
  263.                _loc2_.addListener(StationCustomerContainer.EVENT_REQUEST_MAINCHAR,onRequestMainChar);
  264.                this.stationsContainer.push(_loc2_);
  265.             }
  266.          }
  267.       }
  268.       
  269.       private function addCustomer() : *
  270.       {
  271.          var _loc1_:Number = NaN;
  272.          var _loc2_:Number = NaN;
  273.          var _loc3_:Number = NaN;
  274.          var _loc4_:Number = NaN;
  275.          var _loc5_:Number = NaN;
  276.          var _loc6_:Customer = null;
  277.          if(this.customers.length >= this.maxCustomers || this.countCustomer >= this.numberCustomer)
  278.          {
  279.             return;
  280.          }
  281.          _loc1_ = 0;
  282.          while(_loc1_ < chairsContainers.length)
  283.          {
  284.             if(chairsContainers[_loc1_].isEmpty() && chairsContainers[_loc1_] != Global.mouse.getLastLocal() && this.countCustomer < this.numberCustomer)
  285.             {
  286.                _loc2_ = Math.random();
  287.                _loc3_ = Math.round((Customers.xml.customer.length() - 1) * _loc2_);
  288.                _loc4_ = (_loc4_ = Math.round(Math.random() * (Levels.stages.stage[Levels.indexStage].levels.level[Levels.indexLevel].maxDesiresCustomer - Levels.stages.stage[Levels.indexStage].levels.level[Levels.indexLevel].minDesiresCustomer))) + Number(Levels.stages.stage[Levels.indexStage].levels.level[Levels.indexLevel].minDesiresCustomer);
  289.                _loc5_ = Number(Levels.stages.stage[Levels.indexStage].levels.level[Levels.indexLevel].stressMeterInitial) + Number(Customers.xml.customer[_loc3_].stress);
  290.                if(Customers.xml.customer[_loc3_].symbol.toString() != "customer8")
  291.                {
  292.                   _loc6_ = new Customer(Customers.xml.customer[_loc3_].name,Customers.xml.customer[_loc3_].symbol,onCustomerIdle,onCustomerError,_loc4_,_loc5_,Customers.xml.customer[_loc3_].increaseRate,Customers.xml.customer[_loc3_].delay);
  293.                }
  294.                else
  295.                {
  296.                   _loc6_ = new CCGCustomer(Customers.xml.customer[_loc3_].name,Customers.xml.customer[_loc3_].symbol,onCustomerIdle,onCustomerError,_loc4_,_loc5_,Customers.xml.customer[_loc3_].increaseRate,Customers.xml.customer[_loc3_].delay);
  297.                }
  298.                _loc6_.onIdle();
  299.                customers.push(_loc6_);
  300.                ++this.countCustomer;
  301.                chairsContainers[_loc1_].addCustomer(_loc6_);
  302.                break;
  303.             }
  304.             _loc1_++;
  305.          }
  306.       }
  307.       
  308.       private function onCustomerError(param1:Customer) : *
  309.       {
  310.          mainChar.action("error");
  311.       }
  312.       
  313.       private function onLoadScore() : *
  314.       {
  315.          dialog.stop();
  316.          TFMovieClip.addLabelScript(dialog,"loadScore",null);
  317.          dialog.ok = new TFTextButton(dialog.btnOk,Global.xmlLocalization.scorescreen.ok,onEventScoreScreenOK);
  318.          dialog.ok.setFxOver(Global.soundsFX["mouse_over"]);
  319.          dialog.ok.setFxClick(Global.soundsFX["mouse_click"]);
  320.       }
  321.       
  322.       private function onEventSupplyClean(param1:TFEvent) : *
  323.       {
  324.          switch(param1.event)
  325.          {
  326.             case TFEvent.EVENT_MOUSEUP:
  327.                if(Global.mouse.getLastLocal() != null)
  328.                {
  329.                   Global.mouse.getLastLocal().addCustomer(Global.mouse.removeCustomer());
  330.                }
  331.                break;
  332.             case TFEvent.EVENT_MOUSECLICK:
  333.                if(mainChar.checkQueue(Desires.CLEAN) < 2)
  334.                {
  335.                   mainChar.gotoClean();
  336.                   supplyClean.setQueue(mainChar.getIndexQueue());
  337.                   Global.soundsFX["move_mainchar"].play();
  338.                }
  339.          }
  340.       }
  341.       
  342.       private function onShowLevelText() : *
  343.       {
  344.          TFMovieClip.addLabelScript(dialog,"levelText",null);
  345.          dialog.mcTextLevel.text = Global.xmlLocalization.scorescreen.levelscore;
  346.       }
  347.       
  348.       private function onShowTotalValue() : *
  349.       {
  350.          TFMovieClip.addLabelScript(dialog,"totalValue",null);
  351.          dialog.mcTotal.text = Global.score;
  352.       }
  353.       
  354.       private function onEventScoreScreenOK(param1:TFEvent) : *
  355.       {
  356.          switch(param1.event)
  357.          {
  358.             case TFEvent.EVENT_MOUSECLICK:
  359.                Global.main.mcDialogDummy.enabled = false;
  360.                Global.main.mcDialogDummy.mouseEnabled = false;
  361.                Global.main.mcDialogDummy.removeChild(dialog);
  362.                dialog = null;
  363.                Global.manager.nextLevel();
  364.          }
  365.       }
  366.       
  367.       public function getTime() : Number
  368.       {
  369.          return time;
  370.       }
  371.       
  372.       private function onEventGarbagecanCream(param1:TFEvent) : *
  373.       {
  374.          switch(param1.event)
  375.          {
  376.             case TFEvent.EVENT_MOUSEUP:
  377.                if(Global.mouse.getLastLocal() != null)
  378.                {
  379.                   Global.mouse.getLastLocal().addCustomer(Global.mouse.removeCustomer());
  380.                }
  381.                break;
  382.             case TFEvent.EVENT_MOUSECLICK:
  383.                mainChar.gotoGarbagecanCream();
  384.                garbagecanCream.setQueue(mainChar.getIndexQueue());
  385.                Global.soundsFX["move_mainchar"].play();
  386.          }
  387.       }
  388.       
  389.       private function onFinishWalking(param1:String) : *
  390.       {
  391.          var _loc2_:Number = NaN;
  392.          var _loc3_:Number = NaN;
  393.          var _loc4_:Number = NaN;
  394.          var _loc5_:Number = NaN;
  395.          var _loc6_:Number = NaN;
  396.          var _loc7_:Number = NaN;
  397.          var _loc8_:Number = NaN;
  398.          var _loc9_:Number = NaN;
  399.          var _loc10_:Number = NaN;
  400.          var _loc11_:Number = NaN;
  401.          switch(param1)
  402.          {
  403.             case Desires.CREAM:
  404.                mainChar.addItem(param1);
  405.                supplyCream.setQueue(0);
  406.                break;
  407.             case Desires.CLEAN:
  408.                mainChar.addItem(param1);
  409.                supplyClean.setQueue(0);
  410.                break;
  411.             case Desires.TOWEL:
  412.                mainChar.addItem(param1);
  413.                supplyTowel.setQueue(0);
  414.                break;
  415.             case Desires.EXFOLIATING:
  416.             case Desires.ACUPUNCTURE:
  417.                _loc2_ = 0;
  418.                while(_loc2_ < stationsContainer.length)
  419.                {
  420.                   if(stationsContainer[_loc2_].getType() == param1)
  421.                   {
  422.                      stationsContainer[_loc2_].setQueue(0);
  423.                      if(stationsContainer[_loc2_].isCash())
  424.                      {
  425.                         _loc3_ = Number(stationsContainer[_loc2_].getCash());
  426.                         mainChar.addCash(_loc3_);
  427.                         return;
  428.                      }
  429.                      if(!stationsContainer[_loc2_].isEmpty() && stationsContainer[_loc2_].isWaiting() && mainChar.isItem(Desires.CREAM))
  430.                      {
  431.                         stationsContainer[_loc2_].start();
  432.                         mainChar.removeItem(Desires.CREAM);
  433.                         Global.soundsFX["treatment"].play();
  434.                         mainChar.action("west");
  435.                      }
  436.                      break;
  437.                   }
  438.                   _loc2_++;
  439.                }
  440.                break;
  441.             case Desires.MASSAGE:
  442.             case Desires.SOLARIUM:
  443.                _loc4_ = 0;
  444.                while(_loc4_ < stationsContainer.length)
  445.                {
  446.                   if(stationsContainer[_loc4_].getType() == param1)
  447.                   {
  448.                      stationsContainer[_loc4_].setQueue(0);
  449.                      if(stationsContainer[_loc4_].isCash())
  450.                      {
  451.                         _loc5_ = Number(stationsContainer[_loc4_].getCash());
  452.                         mainChar.addCash(_loc5_);
  453.                         return;
  454.                      }
  455.                      if(!stationsContainer[_loc4_].isEmpty() && stationsContainer[_loc4_].isWaiting() && mainChar.isItem(Desires.CREAM))
  456.                      {
  457.                         stationsContainer[_loc4_].start();
  458.                         mainChar.removeItem(Desires.CREAM);
  459.                         Global.soundsFX["treatment"].play();
  460.                         mainChar.action("east");
  461.                      }
  462.                      break;
  463.                   }
  464.                   _loc4_++;
  465.                }
  466.                break;
  467.             case Desires.HERB:
  468.             case Desires.OFURO:
  469.                _loc6_ = 0;
  470.                while(_loc6_ < stationsContainer.length)
  471.                {
  472.                   if(stationsContainer[_loc6_].getType() == param1)
  473.                   {
  474.                      stationsContainer[_loc6_].setQueue(0);
  475.                      if(stationsContainer[_loc6_].isCash())
  476.                      {
  477.                         _loc7_ = Number(stationsContainer[_loc6_].getCash());
  478.                         mainChar.addCash(_loc7_);
  479.                         return;
  480.                      }
  481.                      if(Boolean(stationsContainer[_loc6_].isDirty()) && mainChar.isItem(Desires.CLEAN))
  482.                      {
  483.                         stationsContainer[_loc6_].clean();
  484.                         mainChar.removeItem(Desires.CLEAN);
  485.                         mainChar.action("east");
  486.                      }
  487.                      break;
  488.                   }
  489.                   _loc6_++;
  490.                }
  491.                break;
  492.             case Desires.HYDRO:
  493.             case Desires.ICE:
  494.                _loc8_ = 0;
  495.                while(_loc8_ < stationsContainer.length)
  496.                {
  497.                   if(stationsContainer[_loc8_].getType() == param1)
  498.                   {
  499.                      stationsContainer[_loc8_].setQueue(0);
  500.                      if(stationsContainer[_loc8_].isCash())
  501.                      {
  502.                         _loc9_ = Number(stationsContainer[_loc8_].getCash());
  503.                         mainChar.addCash(_loc9_);
  504.                         return;
  505.                      }
  506.                      if(Boolean(stationsContainer[_loc8_].isDirty()) && mainChar.isItem(Desires.CLEAN))
  507.                      {
  508.                         stationsContainer[_loc8_].clean();
  509.                         mainChar.removeItem(Desires.CLEAN);
  510.                         mainChar.action("west");
  511.                      }
  512.                      break;
  513.                   }
  514.                   _loc8_++;
  515.                }
  516.                break;
  517.             case Desires.YOGA:
  518.             case Desires.SWIMMING:
  519.             case Desires.SAUNA:
  520.                _loc10_ = 0;
  521.                while(_loc10_ < stationsContainer.length)
  522.                {
  523.                   if(stationsContainer[_loc10_].getType() == param1)
  524.                   {
  525.                      stationsContainer[_loc10_].setQueue(0);
  526.                      if(stationsContainer[_loc10_].isCash())
  527.                      {
  528.                         _loc11_ = Number(stationsContainer[_loc10_].getCash());
  529.                         mainChar.addCash(_loc11_);
  530.                         return;
  531.                      }
  532.                      if(Boolean(stationsContainer[_loc10_].isDirty()) && mainChar.isItem(Desires.TOWEL))
  533.                      {
  534.                         stationsContainer[_loc10_].clean();
  535.                         mainChar.removeItem(Desires.TOWEL);
  536.                      }
  537.                      break;
  538.                   }
  539.                   _loc10_++;
  540.                }
  541.                break;
  542.             case "GARBAGECAN_TOWEL":
  543.                if(mainChar.isItem(Desires.TOWEL))
  544.                {
  545.                   mainChar.removeItem(Desires.TOWEL);
  546.                }
  547.                garbagecanTowel.setQueue(0);
  548.                break;
  549.             case "GARBAGECAN_CLEAN":
  550.                if(mainChar.isItem(Desires.CLEAN))
  551.                {
  552.                   mainChar.removeItem(Desires.CLEAN);
  553.                }
  554.                garbagecanClean.setQueue(0);
  555.                break;
  556.             case "GARBAGECAN_CREAN":
  557.                if(mainChar.isItem(Desires.CREAM))
  558.                {
  559.                   mainChar.removeItem(Desires.CREAM);
  560.                }
  561.                garbagecanCream.setQueue(0);
  562.          }
  563.          updateQueue();
  564.       }
  565.       
  566.       private function updateQueue() : *
  567.       {
  568.          var _loc1_:Number = NaN;
  569.          var _loc2_:Number = NaN;
  570.          _loc1_ = 0;
  571.          while(_loc1_ < mainChar.getQueueSize())
  572.          {
  573.             switch(mainChar.getQueueType(_loc1_))
  574.             {
  575.                case Desires.CREAM:
  576.                   supplyCream.setQueue(_loc1_ + 1);
  577.                   break;
  578.                case Desires.CLEAN:
  579.                   supplyClean.setQueue(_loc1_ + 1);
  580.                   break;
  581.                case Desires.TOWEL:
  582.                   supplyTowel.setQueue(_loc1_ + 1);
  583.                   break;
  584.                case Desires.EXFOLIATING:
  585.                case Desires.ACUPUNCTURE:
  586.                case Desires.MASSAGE:
  587.                case Desires.SOLARIUM:
  588.                case Desires.HERB:
  589.                case Desires.OFURO:
  590.                case Desires.HYDRO:
  591.                case Desires.ICE:
  592.                case Desires.YOGA:
  593.                case Desires.SWIMMING:
  594.                case Desires.SAUNA:
  595.                   _loc2_ = 0;
  596.                   while(_loc2_ < stationsContainer.length)
  597.                   {
  598.                      if(stationsContainer[_loc2_].getType() == mainChar.getQueueType(_loc1_))
  599.                      {
  600.                         stationsContainer[_loc2_].setQueue(_loc1_ + 1);
  601.                      }
  602.                      _loc2_++;
  603.                   }
  604.                   break;
  605.                case "GARBAGECAN_TOWEL":
  606.                   garbagecanTowel.setQueue(_loc1_ + 1);
  607.                   break;
  608.                case "GARBAGECAN_CLEAN":
  609.                   garbagecanClean.setQueue(_loc1_ + 1);
  610.                   break;
  611.                case "GARBAGECAN_CREAN":
  612.                   garbagecanCream.setQueue(_loc1_ + 1);
  613.                   break;
  614.             }
  615.             _loc1_++;
  616.          }
  617.       }
  618.       
  619.       private function onCustomerIdle(param1:Customer) : *
  620.       {
  621.          var _loc2_:Number = NaN;
  622.          var _loc3_:Number = NaN;
  623.          var _loc4_:Boolean = false;
  624.          var _loc5_:Number = NaN;
  625.          var _loc6_:Number = NaN;
  626.          if(param1.isNextDesire())
  627.          {
  628.             _loc2_ = int(stationsContainer.length * Math.random());
  629.             _loc3_ = _loc2_;
  630.             _loc4_ = false;
  631.             while(_loc4_ == false)
  632.             {
  633.                if(!param1.checkUseDesire(stationsContainer[_loc3_].getType()))
  634.                {
  635.                   _loc5_ = 0;
  636.                   _loc6_ = 0;
  637.                   while(_loc6_ < customers.length)
  638.                   {
  639.                      if(customers[_loc6_].getDesire() == this.stationsContainer[_loc3_].getType())
  640.                      {
  641.                         _loc5_++;
  642.                      }
  643.                      _loc6_++;
  644.                   }
  645.                   if(_loc5_ < 2)
  646.                   {
  647.                      param1.setDesire(this.stationsContainer[_loc3_].getType());
  648.                      return;
  649.                   }
  650.                }
  651.                _loc3_++;
  652.                if(_loc3_ >= stationsContainer.length)
  653.                {
  654.                   _loc3_ = 0;
  655.                }
  656.                if(_loc3_ == _loc2_)
  657.                {
  658.                   param1.setDesire(Desires.CASH);
  659.                   _loc4_ = true;
  660.                }
  661.             }
  662.          }
  663.          else
  664.          {
  665.             param1.setDesire(Desires.CASH);
  666.          }
  667.       }
  668.       
  669.       private function onEventSupplyTowel(param1:TFEvent) : *
  670.       {
  671.          switch(param1.event)
  672.          {
  673.             case TFEvent.EVENT_MOUSEUP:
  674.                if(Global.mouse.getLastLocal() != null)
  675.                {
  676.                   Global.mouse.getLastLocal().addCustomer(Global.mouse.removeCustomer());
  677.                }
  678.                break;
  679.             case TFEvent.EVENT_MOUSECLICK:
  680.                if(mainChar.checkQueue(Desires.TOWEL) < 2)
  681.                {
  682.                   mainChar.gotoTowel();
  683.                   supplyTowel.setQueue(mainChar.getIndexQueue());
  684.                   Global.soundsFX["move_mainchar"].play();
  685.                }
  686.          }
  687.       }
  688.       
  689.       private function onEventGarbagecanTowel(param1:TFEvent) : *
  690.       {
  691.          switch(param1.event)
  692.          {
  693.             case TFEvent.EVENT_MOUSEUP:
  694.                if(Global.mouse.getLastLocal() != null)
  695.                {
  696.                   Global.mouse.getLastLocal().addCustomer(Global.mouse.removeCustomer());
  697.                }
  698.                break;
  699.             case TFEvent.EVENT_MOUSECLICK:
  700.                mainChar.gotoGarbagecanTowel();
  701.                garbagecanTowel.setQueue(mainChar.getIndexQueue());
  702.                Global.soundsFX["move_mainchar"].play();
  703.          }
  704.       }
  705.       
  706.       private function onEventSupplyCream(param1:TFEvent) : *
  707.       {
  708.          switch(param1.event)
  709.          {
  710.             case TFEvent.EVENT_MOUSEUP:
  711.                if(Global.mouse.getLastLocal() != null)
  712.                {
  713.                   Global.mouse.getLastLocal().addCustomer(Global.mouse.removeCustomer());
  714.                }
  715.                break;
  716.             case TFEvent.EVENT_MOUSECLICK:
  717.                if(mainChar.checkQueue(Desires.CREAM) < 2)
  718.                {
  719.                   mainChar.gotoCream();
  720.                   supplyCream.setQueue(mainChar.getIndexQueue());
  721.                   Global.soundsFX["move_mainchar"].play();
  722.                }
  723.          }
  724.       }
  725.       
  726.       public function start() : *
  727.       {
  728.          this.started = true;
  729.       }
  730.       
  731.       private function onShowLevelValue() : *
  732.       {
  733.          var _loc1_:Number = NaN;
  734.          var _loc2_:Number = NaN;
  735.          TFMovieClip.addLabelScript(dialog,"levelValue",null);
  736.          _loc1_ = 300 - int(time / 1000);
  737.          if(_loc1_ < 0)
  738.          {
  739.             _loc1_ = 0;
  740.          }
  741.          if(Global.cash == 0)
  742.          {
  743.             _loc1_ = 0;
  744.          }
  745.          _loc2_ = 0;
  746.          if(Global.cash >= Levels.stages.stage[Levels.indexStage].levels.level[Levels.indexLevel].goal)
  747.          {
  748.             _loc2_ = Global.cash * 10 + _loc1_ * 10;
  749.          }
  750.          Global.score += _loc2_;
  751.          dialog.mcLevel.text = _loc2_;
  752.       }
  753.       
  754.       public function process(param1:Object) : *
  755.       {
  756.          var _loc2_:Array = null;
  757.          var _loc3_:Number = NaN;
  758.          var _loc4_:Number = NaN;
  759.          if(!this.started)
  760.          {
  761.             return;
  762.          }
  763.          _loc2_ = new Array();
  764.          _loc3_ = this.customers.length - 1;
  765.          while(_loc3_ >= 0)
  766.          {
  767.             if(this.customers[_loc3_].isDisable())
  768.             {
  769.                this.customers.splice(_loc3_,1);
  770.             }
  771.             else
  772.             {
  773.                this.customers[_loc3_].process(param1);
  774.             }
  775.             _loc3_--;
  776.          }
  777.          Global.main.mcLeft.text = String(this.numberCustomer - this.countCustomer);
  778.          if(this.countCustomer >= this.numberCustomer && this.customers.length == 0 && !isShowScore)
  779.          {
  780.             showScore();
  781.             return;
  782.          }
  783.          time += param1.time;
  784.          this.lastTime += param1.time;
  785.          if(lastTime > this.timeCustomer)
  786.          {
  787.             this.lastTime = 0;
  788.             addCustomer();
  789.          }
  790.          _loc4_ = 0;
  791.          while(_loc4_ < this.stationsContainer.length)
  792.          {
  793.             this.stationsContainer[_loc4_].process(param1);
  794.             _loc4_++;
  795.          }
  796.          mainChar.processWalking(param1);
  797.       }
  798.       
  799.       private function onShowTotalText() : *
  800.       {
  801.          TFMovieClip.addLabelScript(dialog,"totalText",null);
  802.          dialog.mcTextTotal.text = Global.xmlLocalization.scorescreen.totalscore;
  803.       }
  804.       
  805.       public function pause() : *
  806.       {
  807.          var _loc1_:Number = NaN;
  808.          var _loc2_:TFSound = null;
  809.          var _loc3_:Number = NaN;
  810.          this.started = !this.started;
  811.          if(this.started)
  812.          {
  813.             switch(Levels.indexStage)
  814.             {
  815.                case 0:
  816.                   Global.soundTrackStage1.play();
  817.                   break;
  818.                case 1:
  819.                   Global.soundTrackStage2.play();
  820.                   break;
  821.                case 2:
  822.                   Global.soundTrackStage3.play();
  823.                   break;
  824.                case 3:
  825.                   Global.soundTrackStage4.play();
  826.             }
  827.             _loc1_ = 0;
  828.             while(_loc1_ < stationsContainer.length)
  829.             {
  830.                stationsContainer[_loc1_].playAnima();
  831.                _loc1_++;
  832.             }
  833.          }
  834.          else
  835.          {
  836.             Global.soundTrackStage1.stop();
  837.             Global.soundTrackStage2.stop();
  838.             Global.soundTrackStage3.stop();
  839.             Global.soundTrackStage4.stop();
  840.             for each(_loc2_ in Global.soundsFX)
  841.             {
  842.                _loc2_.stop();
  843.             }
  844.             _loc3_ = 0;
  845.             while(_loc3_ < stationsContainer.length)
  846.             {
  847.                stationsContainer[_loc3_].stopAnima();
  848.                _loc3_++;
  849.             }
  850.          }
  851.       }
  852.       
  853.       private function onRequestMainChar(param1:String, param2:StationCustomerContainer) : *
  854.       {
  855.          if(mainChar.checkQueue(param2.getType()) == 0)
  856.          {
  857.             switch(param2.getType())
  858.             {
  859.                case Desires.ACUPUNCTURE:
  860.                   mainChar.gotoAcupuncture();
  861.                   break;
  862.                case Desires.EXFOLIATING:
  863.                   mainChar.gotoExfoliating();
  864.                   break;
  865.                case Desires.MASSAGE:
  866.                   mainChar.gotoMassage();
  867.                   break;
  868.                case Desires.SOLARIUM:
  869.                   mainChar.gotoSolarium();
  870.                   break;
  871.                case Desires.YOGA:
  872.                   mainChar.gotoYoga();
  873.                   break;
  874.                case Desires.SAUNA:
  875.                   mainChar.gotoSauna();
  876.                   break;
  877.                case Desires.SWIMMING:
  878.                   mainChar.gotoSwimming();
  879.                   break;
  880.                case Desires.HYDRO:
  881.                   mainChar.gotoHydro();
  882.                   break;
  883.                case Desires.HERB:
  884.                   mainChar.gotoHerb();
  885.                   break;
  886.                case Desires.OFURO:
  887.                   mainChar.gotoOfuro();
  888.                   break;
  889.                case Desires.ICE:
  890.                   mainChar.gotoIce();
  891.             }
  892.             Global.soundsFX["move_mainchar"].play();
  893.             param2.setQueue(mainChar.getIndexQueue());
  894.          }
  895.       }
  896.    }
  897. }
  898.