home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / beauty_resort.swf / scripts / classes / manager / ManagerGAME.as < prev   
Encoding:
Text File  |  2008-09-04  |  60.8 KB  |  1,450 lines

  1. package classes.manager
  2. {
  3.    import classes.basic.Button.*;
  4.    import classes.basic.Events.TFEvent;
  5.    import classes.basic.MovieClip.*;
  6.    import classes.basic.SceneLoader.*;
  7.    import classes.basic.StateMachine.*;
  8.    import classes.basic.Utils.*;
  9.    import classes.game.ManagerGamePlay;
  10.    import classes.game.ProgressMainChar;
  11.    import classes.global.*;
  12.    import flash.display.Bitmap;
  13.    import flash.display.BitmapData;
  14.    import flash.display.MovieClip;
  15.    import flash.display.StageQuality;
  16.    import flash.events.*;
  17.    
  18.    public class ManagerGAME
  19.    {
  20.       
  21.       internal static var EVENT_GO_TO_GAME:String = "EVENT_GO_TO_GAME";
  22.       
  23.       internal static var ST_MAIN_MENU:String = "ST_MAIN_MENU";
  24.       
  25.       internal static var ST_HOW_TO_PLAY:String = "ST_HOW_TO_PLAY";
  26.       
  27.       internal static var ST_GAME:String = "ST_GAME";
  28.       
  29.       internal static var ST_VICTORY:String = "ST_VICTORY";
  30.       
  31.       internal static var EVENT_GO_TO_HOW_TO_PLAY:String = "EVENT_GO_TO_HOW_TO_PLAY";
  32.       
  33.       internal static var ST_PROGRESS_SCREEN:String = "ST_PROGRESS_SCREEN";
  34.       
  35.       internal static var ST_GAME_OVER:String = "ST_GAME_OVER";
  36.       
  37.       internal static var EVENT_GO_TO_PROGRESS_SCREEN:String = "EVENT_GO_TO_PROGRESS_SCREEN";
  38.       
  39.       internal static var EVENT_GO_TO_GAME_OVER:String = "EVENT_GO_TO_GAME_OVER";
  40.       
  41.       internal static var EVENT_GO_TO_MENU:String = "EVENT_GO_TO_MENU";
  42.       
  43.       internal static var ST_HIGH_SCORE:String = "ST_HIGH_SCORE";
  44.       
  45.       internal static var EVENT_GO_TO_HIGH_SCORE:String = "EVENT_GO_TO_HIGH_SCORE";
  46.       
  47.       internal static var EVENT_GO_TO_VICTORY:String = "EVENT_GO_TO_VICTORY";
  48.        
  49.       
  50.       private var progressMainChar:ProgressMainChar;
  51.       
  52.       private var buttons:Array;
  53.       
  54.       private var stMachine:TFStateMachine;
  55.       
  56.       private var stopSound:Boolean;
  57.       
  58.       private var gamePlay:ManagerGamePlay;
  59.       
  60.       private var scenary:Bitmap;
  61.       
  62.       private var stage:MovieClip;
  63.       
  64.       public function ManagerGAME(param1:MovieClip)
  65.       {
  66.          super();
  67.          this.buttons = new Array();
  68.          this.stage = param1;
  69.          stMachine = new TFStateMachine(null);
  70.          stopSound = true;
  71.          stMachine.createEvent(EVENT_GO_TO_MENU,null);
  72.          stMachine.createEvent(EVENT_GO_TO_GAME,null);
  73.          stMachine.createEvent(EVENT_GO_TO_PROGRESS_SCREEN,null);
  74.          stMachine.createEvent(EVENT_GO_TO_GAME_OVER,null);
  75.          stMachine.createEvent(EVENT_GO_TO_HOW_TO_PLAY,null);
  76.          stMachine.createEvent(EVENT_GO_TO_VICTORY,null);
  77.          stMachine.createEvent(EVENT_GO_TO_HIGH_SCORE,null);
  78.          stMachine.createState(ST_MAIN_MENU,false,this,startMainMenu,null,stopMainMenu);
  79.          stMachine.createState(ST_GAME,false,this,startGame,processGame,stopGame);
  80.          stMachine.createState(ST_PROGRESS_SCREEN,false,this,startProgressScreen,processProgress,stopProgressScreen);
  81.          stMachine.createState(ST_GAME_OVER,false,this,startGameOver,null,stopGameOver);
  82.          stMachine.createState(ST_HOW_TO_PLAY,false,this,startHowToPlay,null,stopHowToPlay);
  83.          stMachine.createState(ST_VICTORY,false,this,startVictory,null,stopVictory);
  84.          stMachine.createState(ST_HIGH_SCORE,false,this,startHighScore,null,stopHighScore);
  85.          stMachine.createTransition(ST_MAIN_MENU,EVENT_GO_TO_PROGRESS_SCREEN,ST_PROGRESS_SCREEN);
  86.          stMachine.createTransition(ST_MAIN_MENU,EVENT_GO_TO_HOW_TO_PLAY,ST_HOW_TO_PLAY);
  87.          stMachine.createTransition(ST_HOW_TO_PLAY,EVENT_GO_TO_MENU,ST_MAIN_MENU);
  88.          stMachine.createTransition(ST_GAME,EVENT_GO_TO_MENU,ST_MAIN_MENU);
  89.          stMachine.createTransition(ST_GAME,EVENT_GO_TO_PROGRESS_SCREEN,ST_PROGRESS_SCREEN);
  90.          stMachine.createTransition(ST_PROGRESS_SCREEN,EVENT_GO_TO_GAME,ST_GAME);
  91.          stMachine.createTransition(ST_GAME,EVENT_GO_TO_GAME_OVER,ST_GAME_OVER);
  92.          stMachine.createTransition(ST_GAME,EVENT_GO_TO_VICTORY,ST_VICTORY);
  93.          stMachine.createTransition(ST_VICTORY,EVENT_GO_TO_HIGH_SCORE,ST_HIGH_SCORE);
  94.          stMachine.createTransition(ST_GAME_OVER,EVENT_GO_TO_HIGH_SCORE,ST_HIGH_SCORE);
  95.          stMachine.createTransition(ST_MAIN_MENU,EVENT_GO_TO_HIGH_SCORE,ST_HIGH_SCORE);
  96.          stMachine.createTransition(ST_HIGH_SCORE,EVENT_GO_TO_MENU,ST_MAIN_MENU);
  97.          stMachine.initialize(ST_MAIN_MENU);
  98.       }
  99.       
  100.       public function dispatchGameOver() : *
  101.       {
  102.          try
  103.          {
  104.             return stMachine.receiveEvent(EVENT_GO_TO_GAME_OVER);
  105.          }
  106.          catch(e:Error)
  107.          {
  108.          }
  109.       }
  110.       
  111.       private function onEventHowToPlay(param1:TFEvent) : *
  112.       {
  113.          switch(param1.event)
  114.          {
  115.             case TFEvent.EVENT_MOUSECLICK:
  116.                dispatchHowToPlay();
  117.                break;
  118.             case TFEvent.EVENT_INIT:
  119.             case TFEvent.EVENT_MOUSEOUT:
  120.             case TFEvent.EVENT_MOUSEOVER:
  121.          }
  122.       }
  123.       
  124.       private function onHowToPlayPage1LoadFrame() : *
  125.       {
  126.          TFMovieClip.addLabelScript(stage,"page1",null);
  127.          stage.stop();
  128.          if(buttons["button1"] == null)
  129.          {
  130.             buttons["button1"] = new TFTextButton(stage.mcMainMenu,Global.xmlLocalization.howToPlay.mainmenu,onEventButton1);
  131.             buttons["button1"].setFxOver(Global.soundsFX["mouse_over"]);
  132.             buttons["button1"].setFxClick(Global.soundsFX["mouse_click"]);
  133.          }
  134.          if(buttons["button2"] == null)
  135.          {
  136.             buttons["button2"] = new TFTextButton(stage.mcNext,Global.xmlLocalization.howToPlay.next,onEventButton2);
  137.             buttons["button2"].setFxOver(Global.soundsFX["mouse_over"]);
  138.             buttons["button2"].setFxClick(Global.soundsFX["mouse_click"]);
  139.          }
  140.          buttons["button1"].setText(Global.xmlLocalization.howToPlay.mainmenu);
  141.          buttons["button2"].setText(Global.xmlLocalization.howToPlay.next);
  142.          stage.mcText1.text = Global.xmlLocalization.howToPlay.text1;
  143.          stage.mcText2.text = Global.xmlLocalization.howToPlay.text2;
  144.          stage.mcLogo.gotoAndStop(Global.localization_branding_nr);
  145.          stage.mcLogo.mcHitArea.addEventListener(MouseEvent.CLICK,onMCClick,false,0,true);
  146.       }
  147.       
  148.       private function onEventBackground(param1:TFEvent) : *
  149.       {
  150.          switch(param1.event)
  151.          {
  152.             case TFEvent.EVENT_MOUSEUP:
  153.                if(Global.mouse.getLastLocal() != null)
  154.                {
  155.                   Global.mouse.getLastLocal().addCustomer(Global.mouse.removeCustomer());
  156.                }
  157.          }
  158.       }
  159.       
  160.       private function onEventQuality(param1:TFEvent) : *
  161.       {
  162.          switch(param1.event)
  163.          {
  164.             case TFEvent.EVENT_MOUSECLICK:
  165.                switch(Global.main.stage.quality)
  166.                {
  167.                   case "HIGH":
  168.                      Global.main.stage.quality = StageQuality.LOW;
  169.                      break;
  170.                   case "MEDIUM":
  171.                      Global.main.stage.quality = StageQuality.HIGH;
  172.                      break;
  173.                   case "LOW":
  174.                      Global.main.stage.quality = StageQuality.MEDIUM;
  175.                }
  176.                buttons["quality"].setText(Global.xmlLocalization.mainmenu.quality + " " + Global.xmlLocalization.mainmenu.child(Global.main.stage.quality.toLowerCase())[0].toString());
  177.                break;
  178.             case TFEvent.EVENT_INIT:
  179.             case TFEvent.EVENT_MOUSEOUT:
  180.             case TFEvent.EVENT_MOUSEOVER:
  181.          }
  182.       }
  183.       
  184.       private function onEventFX(param1:TFEvent) : *
  185.       {
  186.          switch(param1.event)
  187.          {
  188.             case TFEvent.EVENT_ON:
  189.                Global.soundManager.setSFXVolume(100);
  190.                break;
  191.             case TFEvent.EVENT_OFF:
  192.                Global.soundManager.setSFXVolume(0);
  193.          }
  194.       }
  195.       
  196.       private function processGame(param1:Object) : *
  197.       {
  198.          if(gamePlay != null)
  199.          {
  200.             gamePlay.process(param1);
  201.          }
  202.       }
  203.       
  204.       public function dispatchGame() : *
  205.       {
  206.          try
  207.          {
  208.             return stMachine.receiveEvent(EVENT_GO_TO_GAME);
  209.          }
  210.          catch(e:Error)
  211.          {
  212.          }
  213.       }
  214.       
  215.       private function stopGame() : *
  216.       {
  217.          gamePlay = null;
  218.       }
  219.       
  220.       public function onCheatNextLevel() : *
  221.       {
  222.          var _loc1_:Number = NaN;
  223.          var _loc2_:Number = NaN;
  224.          Global.soundTrackStage1.stop();
  225.          Global.soundTrackStage2.stop();
  226.          Global.soundTrackStage3.stop();
  227.          Global.soundTrackStage4.stop();
  228.          Global.cash = Levels.stages.stage[Levels.indexStage].levels.level[Levels.indexLevel].goal;
  229.          _loc1_ = 300 - int(gamePlay.getTime() / 1000);
  230.          if(_loc1_ < 0)
  231.          {
  232.             _loc1_ = 0;
  233.          }
  234.          if(Global.cash == 0)
  235.          {
  236.             _loc1_ = 0;
  237.          }
  238.          _loc2_ = Global.cash * 10 + _loc1_ * 10;
  239.          Global.score += _loc2_;
  240.          nextLevel();
  241.       }
  242.       
  243.       private function stopGameOver() : *
  244.       {
  245.          delete buttons["moregames"];
  246.          buttons["moregames"] = undefined;
  247.          delete buttons["submit"];
  248.          buttons["submit"] = undefined;
  249.       }
  250.       
  251.       public function dispatchProgressScreen() : *
  252.       {
  253.          try
  254.          {
  255.             return stMachine.receiveEvent(EVENT_GO_TO_PROGRESS_SCREEN);
  256.          }
  257.          catch(e:Error)
  258.          {
  259.          }
  260.       }
  261.       
  262.       private function stopProgressScreen() : *
  263.       {
  264.          delete buttons["play"];
  265.          buttons["play"] = undefined;
  266.          delete buttons["fx"];
  267.          buttons["fx"] = undefined;
  268.          delete buttons["music"];
  269.          buttons["music"] = undefined;
  270.          Global.soundTrackMenu.stop();
  271.          this.progressMainChar = null;
  272.       }
  273.       
  274.       private function onEventSubmitVictory(param1:TFEvent) : *
  275.       {
  276.          var _loc2_:Object = null;
  277.          switch(param1.event)
  278.          {
  279.             case TFEvent.EVENT_MOUSECLICK:
  280.                if(stage.mcPainel.mcName.length)
  281.                {
  282.                   _loc2_ = new Object();
  283.                   _loc2_.name = stage.mcPainel.mcName.text;
  284.                   _loc2_.score = Global.score;
  285.                   Global.cookie.data.highScore.push(_loc2_);
  286.                   Global.cookie.data.highScore.sortOn("score",Array.NUMERIC | Array.DESCENDING);
  287.                   if(Global.cookie.data.highScore.length > 9)
  288.                   {
  289.                      Global.cookie.data.highScore.splice(9,Global.cookie.data.highScore.length - 9);
  290.                   }
  291.                   Global.cookie.flush();
  292.                   Global.cash = 0;
  293.                   Global.score = 0;
  294.                   dispatchHighScore();
  295.                }
  296.          }
  297.       }
  298.       
  299.       private function onFinishGameLoadFrame() : *
  300.       {
  301.          TFMovieClip.addLabelScript(stage,"finishGame",null);
  302.          Global.main.mcUpgradeView.visible = false;
  303.          Global.main.mcNewStage.visible = false;
  304.          stage.stop();
  305.          buttons["start"] = new TFTextButton(Global.main.mcUpgradeView.mcStart,Global.xmlLocalization.game.play,onEventStart);
  306.          buttons["start"].setFxOver(Global.soundsFX["mouse_over"]);
  307.          buttons["start"].setFxClick(Global.soundsFX["mouse_click"]);
  308.          Global.main.mcUpgradeView.mcMsgBlink.mcText.text = Global.xmlLocalization.update.msg;
  309.          Global.main.mcUpgradeView.mcMsg.mcText.text = Global.xmlLocalization.update.msg;
  310.          if(Levels.indexStage == 0)
  311.          {
  312.             Global.main.mcStatue.visible = true;
  313.          }
  314.          else
  315.          {
  316.             Global.main.mcStatue.visible = false;
  317.          }
  318.          if(Levels.indexStage == 1)
  319.          {
  320.             Global.main.mcTropicalDeco.visible = true;
  321.          }
  322.          else
  323.          {
  324.             Global.main.mcTropicalDeco.visible = false;
  325.          }
  326.          if(Levels.indexStage == 0 && Levels.indexLevel == 0)
  327.          {
  328.             buttons["startStage"] = new TFTextButton(Global.main.mcNewStage.btnPlay,Global.xmlLocalization.game.play,onEventStart);
  329.             buttons["startStage"].setFxOver(Global.soundsFX["mouse_over"]);
  330.             buttons["startStage"].setFxClick(Global.soundsFX["mouse_click"]);
  331.             Global.main.mcNewStage.visible = true;
  332.             TFMovieClip.setTextBalloon(Global.xmlLocalization.game.msg1,Global.main.mcNewStage);
  333.             return;
  334.          }
  335.          if(Levels.indexStage == 0 && Levels.indexLevel == 1)
  336.          {
  337.             Global.main.mcUpgradeView.mcRoom2.visible = false;
  338.             Global.main.mcUpgradeView.mcRoom3.visible = false;
  339.             Global.main.mcUpgradeView.mcBath1.visible = false;
  340.             Global.main.mcUpgradeView.mcBath2.visible = false;
  341.             Global.main.mcUpgradeView.mcBath3.visible = false;
  342.             Global.main.mcUpgradeView.mcBath4.visible = false;
  343.             Global.main.mcUpgradeView.mcTreatment1.visible = false;
  344.             Global.main.mcUpgradeView.mcTreatment2.visible = false;
  345.             Global.main.mcUpgradeView.mcTreatment3.visible = false;
  346.             Global.main.mcUpgradeView.mcTreatment4.visible = false;
  347.             Global.main.mcUpgradeView.gotoAndPlay("anima");
  348.             Global.main.mcUpgradeView.visible = true;
  349.             return;
  350.          }
  351.          if(Levels.indexStage == 0 && Levels.indexLevel == 3)
  352.          {
  353.             Global.main.mcUpgradeView.mcRoom1.visible = false;
  354.             Global.main.mcUpgradeView.mcRoom2.visible = false;
  355.             Global.main.mcUpgradeView.mcRoom3.visible = false;
  356.             Global.main.mcUpgradeView.mcBath1.visible = false;
  357.             Global.main.mcUpgradeView.mcBath3.visible = false;
  358.             Global.main.mcUpgradeView.mcBath4.visible = false;
  359.             Global.main.mcUpgradeView.mcTreatment1.visible = false;
  360.             Global.main.mcUpgradeView.mcTreatment2.visible = false;
  361.             Global.main.mcUpgradeView.mcTreatment3.visible = false;
  362.             Global.main.mcUpgradeView.mcTreatment4.visible = false;
  363.             Global.main.mcUpgradeView.gotoAndPlay("anima");
  364.             Global.main.mcUpgradeView.visible = true;
  365.             return;
  366.          }
  367.          if(Levels.indexStage == 0 && Levels.indexLevel == 5)
  368.          {
  369.             Global.main.mcUpgradeView.mcRoom1.visible = false;
  370.             Global.main.mcUpgradeView.mcRoom2.visible = false;
  371.             Global.main.mcUpgradeView.mcRoom3.visible = false;
  372.             Global.main.mcUpgradeView.mcBath1.visible = false;
  373.             Global.main.mcUpgradeView.mcBath2.visible = false;
  374.             Global.main.mcUpgradeView.mcBath3.visible = false;
  375.             Global.main.mcUpgradeView.mcBath4.visible = false;
  376.             Global.main.mcUpgradeView.mcTreatment1.visible = false;
  377.             Global.main.mcUpgradeView.mcTreatment3.visible = false;
  378.             Global.main.mcUpgradeView.mcTreatment4.visible = false;
  379.             Global.main.mcUpgradeView.gotoAndPlay("anima");
  380.             Global.main.mcUpgradeView.visible = true;
  381.             return;
  382.          }
  383.          if(Levels.indexStage == 1 && Levels.indexLevel == 0)
  384.          {
  385.             buttons["startStage"] = new TFTextButton(Global.main.mcNewStage.btnPlay,Global.xmlLocalization.game.play,onEventStart);
  386.             buttons["startStage"].setFxOver(Global.soundsFX["mouse_over"]);
  387.             buttons["startStage"].setFxClick(Global.soundsFX["mouse_click"]);
  388.             Global.main.mcNewStage.visible = true;
  389.             TFMovieClip.setTextBalloon(Global.xmlLocalization.game.msg2,Global.main.mcNewStage);
  390.             return;
  391.          }
  392.          if(Levels.indexStage == 1 && Levels.indexLevel == 2)
  393.          {
  394.             Global.main.mcUpgradeView.mcRoom1.visible = false;
  395.             Global.main.mcUpgradeView.mcRoom3.visible = false;
  396.             Global.main.mcUpgradeView.mcBath1.visible = false;
  397.             Global.main.mcUpgradeView.mcBath2.visible = false;
  398.             Global.main.mcUpgradeView.mcBath3.visible = false;
  399.             Global.main.mcUpgradeView.mcBath4.visible = false;
  400.             Global.main.mcUpgradeView.mcTreatment1.visible = false;
  401.             Global.main.mcUpgradeView.mcTreatment2.visible = false;
  402.             Global.main.mcUpgradeView.mcTreatment3.visible = false;
  403.             Global.main.mcUpgradeView.mcTreatment4.visible = false;
  404.             Global.main.mcUpgradeView.gotoAndPlay("anima");
  405.             Global.main.mcUpgradeView.visible = true;
  406.             return;
  407.          }
  408.          if(Levels.indexStage == 1 && Levels.indexLevel == 5)
  409.          {
  410.             Global.main.mcUpgradeView.mcRoom1.visible = false;
  411.             Global.main.mcUpgradeView.mcRoom2.visible = false;
  412.             Global.main.mcUpgradeView.mcRoom3.visible = false;
  413.             Global.main.mcUpgradeView.mcBath1.visible = false;
  414.             Global.main.mcUpgradeView.mcBath2.visible = false;
  415.             Global.main.mcUpgradeView.mcBath4.visible = false;
  416.             Global.main.mcUpgradeView.mcTreatment1.visible = false;
  417.             Global.main.mcUpgradeView.mcTreatment2.visible = false;
  418.             Global.main.mcUpgradeView.mcTreatment3.visible = false;
  419.             Global.main.mcUpgradeView.mcTreatment4.visible = false;
  420.             Global.main.mcUpgradeView.gotoAndPlay("anima");
  421.             Global.main.mcUpgradeView.visible = true;
  422.             return;
  423.          }
  424.          if(Levels.indexStage == 2 && Levels.indexLevel == 0)
  425.          {
  426.             buttons["startStage"] = new TFTextButton(Global.main.mcNewStage.btnPlay,Global.xmlLocalization.game.play,onEventStart);
  427.             buttons["startStage"].setFxOver(Global.soundsFX["mouse_over"]);
  428.             buttons["startStage"].setFxClick(Global.soundsFX["mouse_click"]);
  429.             Global.main.mcNewStage.visible = true;
  430.             TFMovieClip.setTextBalloon(Global.xmlLocalization.game.msg3,Global.main.mcNewStage);
  431.             return;
  432.          }
  433.          if(Levels.indexStage == 2 && Levels.indexLevel == 2)
  434.          {
  435.             Global.main.mcUpgradeView.mcRoom1.visible = false;
  436.             Global.main.mcUpgradeView.mcRoom2.visible = false;
  437.             Global.main.mcUpgradeView.mcRoom3.visible = false;
  438.             Global.main.mcUpgradeView.mcBath1.visible = false;
  439.             Global.main.mcUpgradeView.mcBath2.visible = false;
  440.             Global.main.mcUpgradeView.mcBath3.visible = false;
  441.             Global.main.mcUpgradeView.mcBath4.visible = false;
  442.             Global.main.mcUpgradeView.mcTreatment1.visible = false;
  443.             Global.main.mcUpgradeView.mcTreatment2.visible = false;
  444.             Global.main.mcUpgradeView.mcTreatment4.visible = false;
  445.             Global.main.mcUpgradeView.gotoAndPlay("anima");
  446.             Global.main.mcUpgradeView.visible = true;
  447.             return;
  448.          }
  449.          if(Levels.indexStage == 2 && Levels.indexLevel == 5)
  450.          {
  451.             Global.main.mcUpgradeView.mcRoom1.visible = false;
  452.             Global.main.mcUpgradeView.mcRoom2.visible = false;
  453.             Global.main.mcUpgradeView.mcRoom3.visible = false;
  454.             Global.main.mcUpgradeView.mcBath1.visible = false;
  455.             Global.main.mcUpgradeView.mcBath2.visible = false;
  456.             Global.main.mcUpgradeView.mcBath3.visible = false;
  457.             Global.main.mcUpgradeView.mcTreatment1.visible = false;
  458.             Global.main.mcUpgradeView.mcTreatment2.visible = false;
  459.             Global.main.mcUpgradeView.mcTreatment3.visible = false;
  460.             Global.main.mcUpgradeView.mcTreatment4.visible = false;
  461.             Global.main.mcUpgradeView.gotoAndPlay("anima");
  462.             Global.main.mcUpgradeView.visible = true;
  463.             return;
  464.          }
  465.          if(Levels.indexStage == 3 && Levels.indexLevel == 0)
  466.          {
  467.             buttons["startStage"] = new TFTextButton(Global.main.mcNewStage.btnPlay,Global.xmlLocalization.game.play,onEventStart);
  468.             buttons["startStage"].setFxOver(Global.soundsFX["mouse_over"]);
  469.             buttons["startStage"].setFxClick(Global.soundsFX["mouse_click"]);
  470.             Global.main.mcNewStage.visible = true;
  471.             TFMovieClip.setTextBalloon(Global.xmlLocalization.game.msg4,Global.main.mcNewStage);
  472.             return;
  473.          }
  474.          if(Levels.indexStage == 3 && Levels.indexLevel == 2)
  475.          {
  476.             Global.main.mcUpgradeView.mcRoom1.visible = false;
  477.             Global.main.mcUpgradeView.mcRoom2.visible = false;
  478.             Global.main.mcUpgradeView.mcBath1.visible = false;
  479.             Global.main.mcUpgradeView.mcBath2.visible = false;
  480.             Global.main.mcUpgradeView.mcBath3.visible = false;
  481.             Global.main.mcUpgradeView.mcBath4.visible = false;
  482.             Global.main.mcUpgradeView.mcTreatment1.visible = false;
  483.             Global.main.mcUpgradeView.mcTreatment2.visible = false;
  484.             Global.main.mcUpgradeView.mcTreatment3.visible = false;
  485.             Global.main.mcUpgradeView.mcTreatment4.visible = false;
  486.             Global.main.mcUpgradeView.gotoAndPlay("anima");
  487.             Global.main.mcUpgradeView.visible = true;
  488.             return;
  489.          }
  490.          if(Levels.indexStage == 3 && Levels.indexLevel == 5)
  491.          {
  492.             Global.main.mcUpgradeView.mcRoom1.visible = false;
  493.             Global.main.mcUpgradeView.mcRoom2.visible = false;
  494.             Global.main.mcUpgradeView.mcRoom3.visible = false;
  495.             Global.main.mcUpgradeView.mcBath1.visible = false;
  496.             Global.main.mcUpgradeView.mcBath2.visible = false;
  497.             Global.main.mcUpgradeView.mcBath3.visible = false;
  498.             Global.main.mcUpgradeView.mcBath4.visible = false;
  499.             Global.main.mcUpgradeView.mcTreatment1.visible = false;
  500.             Global.main.mcUpgradeView.mcTreatment2.visible = false;
  501.             Global.main.mcUpgradeView.mcTreatment3.visible = false;
  502.             Global.main.mcUpgradeView.gotoAndPlay("anima");
  503.             Global.main.mcUpgradeView.visible = true;
  504.             return;
  505.          }
  506.          gamePlay.start();
  507.          buttons["pause"].enable();
  508.       }
  509.       
  510.       private function onHowToPlayPage2LoadFrame() : *
  511.       {
  512.          TFMovieClip.addLabelScript(stage,"page2",null);
  513.          stage.stop();
  514.          stage.mcText3.text = Global.xmlLocalization.howToPlay.text3;
  515.          stage.mcText4.text = Global.xmlLocalization.howToPlay.text4;
  516.          stage.mcLogo.gotoAndStop(Global.localization_branding_nr);
  517.          stage.mcLogo.mcHitArea.addEventListener(MouseEvent.CLICK,onMCClick,false,0,true);
  518.          buttons["button1"].setText(Global.xmlLocalization.howToPlay.back);
  519.          buttons["button2"].setText(Global.xmlLocalization.howToPlay.next);
  520.       }
  521.       
  522.       private function onEventStart(param1:TFEvent) : *
  523.       {
  524.          switch(param1.event)
  525.          {
  526.             case TFEvent.EVENT_MOUSECLICK:
  527.                Global.main.mcUpgradeView.visible = false;
  528.                Global.main.mcNewStage.visible = false;
  529.                buttons["pause"].enable();
  530.                gamePlay.start();
  531.          }
  532.       }
  533.       
  534.       private function onEventMusicGame(param1:TFEvent) : *
  535.       {
  536.          switch(param1.event)
  537.          {
  538.             case TFEvent.EVENT_MOUSEUP:
  539.                if(Global.mouse.getLastLocal() != null)
  540.                {
  541.                   Global.mouse.getLastLocal().addCustomer(Global.mouse.removeCustomer());
  542.                }
  543.                break;
  544.             case TFEvent.EVENT_ON:
  545.                Global.soundManager.setMusicVolume(50);
  546.                break;
  547.             case TFEvent.EVENT_OFF:
  548.                Global.soundManager.setMusicVolume(0);
  549.          }
  550.       }
  551.       
  552.       private function stopHighScore() : *
  553.       {
  554.          delete buttons["moregames"];
  555.          buttons["moregames"] = undefined;
  556.          delete buttons["mainmenu"];
  557.          buttons["mainmenu"] = undefined;
  558.       }
  559.       
  560.       private function onInitHowToPlayLoadFrame() : *
  561.       {
  562.          TFMovieClip.addLabelScript(stage,"initNowToPlay",null);
  563.          stage.mcText1.text = Global.xmlLocalization.howToPlay.text1;
  564.          stage.mcText2.text = Global.xmlLocalization.howToPlay.text2;
  565.          stage.mcLogo.gotoAndStop(Global.localization_branding_nr);
  566.          stage.mcLogo.mcHitArea.addEventListener(MouseEvent.CLICK,onMCClick,false,0,true);
  567.       }
  568.       
  569.       private function stopVictory() : *
  570.       {
  571.          delete buttons["moregames"];
  572.          buttons["moregames"] = undefined;
  573.          delete buttons["submit"];
  574.          buttons["submit"] = undefined;
  575.          Global.soundVictory.stop();
  576.       }
  577.       
  578.       private function onEventMoreGames(param1:TFEvent) : *
  579.       {
  580.          switch(param1.event)
  581.          {
  582.             case TFEvent.EVENT_MOUSECLICK:
  583.                TFURLNavigator.changePage(Global.localization_url1,"_blank");
  584.                break;
  585.             case TFEvent.EVENT_INIT:
  586.             case TFEvent.EVENT_MOUSEOUT:
  587.             case TFEvent.EVENT_MOUSEOVER:
  588.          }
  589.       }
  590.       
  591.       private function onVictoryLoadFrame() : *
  592.       {
  593.          TFMovieClip.addLabelScript(this.stage,"victory",null);
  594.          TFMovieClip.addLabelScript(this.stage,"buttons",onButtonsVictoryLoadFrame);
  595.          stage.mcTitle.mcText.text = Global.xmlLocalization.victory.title;
  596.          stage.mcTitleBlink.mcText.text = Global.xmlLocalization.victory.title;
  597.          Global.soundVictory.play();
  598.       }
  599.       
  600.       private function onHighScoreLoadFrame() : *
  601.       {
  602.          var _loc1_:Number = NaN;
  603.          TFMovieClip.addLabelScript(stage,"highscore",null);
  604.          stage.mcRank.text = Global.xmlLocalization.highscore.rank;
  605.          stage.mcName.text = Global.xmlLocalization.highscore.name;
  606.          stage.mcScore.text = Global.xmlLocalization.highscore.score;
  607.          stage.mcTitle.mcText.text = Global.xmlLocalization.highscore.title;
  608.          stage.mcTitleBlink.mcText.text = Global.xmlLocalization.highscore.title;
  609.          buttons["moregames"] = new TFTextButton(stage.mcMore,Global.xmlLocalization.highscore.moregames,onEventMoreGames);
  610.          buttons["moregames"].setFxOver(Global.soundsFX["mouse_over"]);
  611.          buttons["moregames"].setFxClick(Global.soundsFX["mouse_click"]);
  612.          buttons["mainmenu"] = new TFTextButton(stage.mcMenu,Global.xmlLocalization.highscore.menu,onEventMainMenu);
  613.          buttons["mainmenu"].setFxOver(Global.soundsFX["mouse_over"]);
  614.          buttons["mainmenu"].setFxClick(Global.soundsFX["mouse_click"]);
  615.          _loc1_ = 0;
  616.          while(true)
  617.          {
  618.             if(_loc1_ < Global.cookie.data.highScore.length)
  619.             {
  620.                if(_loc1_ > 9)
  621.                {
  622.                   break;
  623.                }
  624.                switch(_loc1_)
  625.                {
  626.                   case 0:
  627.                      stage.mcName1.text = Global.cookie.data.highScore[_loc1_].name;
  628.                      stage.mcScore1.text = Global.cookie.data.highScore[_loc1_].score;
  629.                      break;
  630.                   case 1:
  631.                      stage.mcName2.text = Global.cookie.data.highScore[_loc1_].name;
  632.                      stage.mcScore2.text = Global.cookie.data.highScore[_loc1_].score;
  633.                      break;
  634.                   case 2:
  635.                      stage.mcName3.text = Global.cookie.data.highScore[_loc1_].name;
  636.                      stage.mcScore3.text = Global.cookie.data.highScore[_loc1_].score;
  637.                      break;
  638.                   case 3:
  639.                      stage.mcName4.text = Global.cookie.data.highScore[_loc1_].name;
  640.                      stage.mcScore4.text = Global.cookie.data.highScore[_loc1_].score;
  641.                      break;
  642.                   case 4:
  643.                      stage.mcName5.text = Global.cookie.data.highScore[_loc1_].name;
  644.                      stage.mcScore5.text = Global.cookie.data.highScore[_loc1_].score;
  645.                      break;
  646.                   case 5:
  647.                      stage.mcName6.text = Global.cookie.data.highScore[_loc1_].name;
  648.                      stage.mcScore6.text = Global.cookie.data.highScore[_loc1_].score;
  649.                      break;
  650.                   case 6:
  651.                      stage.mcName7.text = Global.cookie.data.highScore[_loc1_].name;
  652.                      stage.mcScore7.text = Global.cookie.data.highScore[_loc1_].score;
  653.                      break;
  654.                   case 7:
  655.                      stage.mcName8.text = Global.cookie.data.highScore[_loc1_].name;
  656.                      stage.mcScore8.text = Global.cookie.data.highScore[_loc1_].score;
  657.                      break;
  658.                   case 8:
  659.                      stage.mcName9.text = Global.cookie.data.highScore[_loc1_].name;
  660.                      stage.mcScore9.text = Global.cookie.data.highScore[_loc1_].score;
  661.                      break;
  662.                }
  663.             }
  664.             break;
  665.             _loc1_++;
  666.          }
  667.       }
  668.       
  669.       private function onMainMenuLoadFrame() : *
  670.       {
  671.          TFMovieClip.addLabelScript(stage,"menu",null);
  672.          stage.stop();
  673.          stage.mcLogo.gotoAndStop(Global.localization_branding_nr);
  674.          stage.mcLogo.mcHitArea.addEventListener(MouseEvent.CLICK,onMCClick,false,0,true);
  675.          buttons["startgame"] = new TFTextButton(stage.btnStartGame,Global.xmlLocalization.mainmenu.startgame,onEventStartGame);
  676.          buttons["startgame"].setFxOver(Global.soundsFX["mouse_over"]);
  677.          buttons["startgame"].setFxClick(Global.soundsFX["mouse_click"]);
  678.          buttons["howtoplay"] = new TFTextButton(stage.btnHowToPlay,Global.xmlLocalization.mainmenu.howtoplay,onEventHowToPlay);
  679.          buttons["howtoplay"].setFxOver(Global.soundsFX["mouse_over"]);
  680.          buttons["howtoplay"].setFxClick(Global.soundsFX["mouse_click"]);
  681.          buttons["highscore"] = new TFTextButton(stage.btnHighScore,Global.xmlLocalization.mainmenu.highscore,onEventHighScore);
  682.          buttons["highscore"].setFxOver(Global.soundsFX["mouse_over"]);
  683.          buttons["highscore"].setFxClick(Global.soundsFX["mouse_click"]);
  684.          buttons["moregames"] = new TFTextButton(stage.btnMoreGames,Global.xmlLocalization.mainmenu.moregames,onEventMoreGames);
  685.          buttons["moregames"].setFxOver(Global.soundsFX["mouse_over"]);
  686.          buttons["moregames"].setFxClick(Global.soundsFX["mouse_click"]);
  687.          buttons["quality"] = new TFTextButton(stage.btnQuality,Global.xmlLocalization.mainmenu.quality + " " + Global.xmlLocalization.mainmenu.child(Global.main.stage.quality.toLowerCase())[0].toString(),onEventQuality);
  688.          buttons["quality"].setFxOver(Global.soundsFX["mouse_over"]);
  689.          buttons["quality"].setFxClick(Global.soundsFX["mouse_click"]);
  690.          buttons["fx"] = new TFSwitchButton(stage.btnFX,onEventFX);
  691.          buttons["fx"].setFxOver(Global.soundsFX["mouse_over"]);
  692.          buttons["fx"].setFxClick(Global.soundsFX["mouse_click"]);
  693.          buttons["music"] = new TFSwitchButton(stage.btnMusic,onEventMusic);
  694.          buttons["music"].setFxOver(Global.soundsFX["mouse_over"]);
  695.          buttons["music"].setFxClick(Global.soundsFX["mouse_click"]);
  696.          if(Global.soundManager.getSFXVolume() == 0)
  697.          {
  698.             buttons["fx"].off();
  699.          }
  700.          if(Global.soundManager.getMusicVolume() == 0)
  701.          {
  702.             buttons["music"].off();
  703.          }
  704.          buttons.length = 6;
  705.          if(stopSound)
  706.          {
  707.             Global.soundTrackMenu.play();
  708.          }
  709.          stopSound = true;
  710.       }
  711.       
  712.       public function dispatchVictory() : *
  713.       {
  714.          try
  715.          {
  716.             return stMachine.receiveEvent(EVENT_GO_TO_VICTORY);
  717.          }
  718.          catch(e:Error)
  719.          {
  720.          }
  721.       }
  722.       
  723.       private function onEventStartGame(param1:TFEvent) : *
  724.       {
  725.          switch(param1.event)
  726.          {
  727.             case TFEvent.EVENT_MOUSECLICK:
  728.                dispatchProgressScreen();
  729.                break;
  730.             case TFEvent.EVENT_INIT:
  731.             case TFEvent.EVENT_MOUSEOUT:
  732.             case TFEvent.EVENT_MOUSEOVER:
  733.          }
  734.       }
  735.       
  736.       private function startMainMenu() : *
  737.       {
  738.          stage.gotoAndPlay("menu");
  739.          TFMovieClip.addLabelScript(this.stage,"menu",onMainMenuLoadFrame);
  740.       }
  741.       
  742.       private function onEventPause(param1:TFEvent) : *
  743.       {
  744.          switch(param1.event)
  745.          {
  746.             case TFEvent.EVENT_MOUSECLICK:
  747.                buttons["pause"].on();
  748.                break;
  749.             case TFEvent.EVENT_MOUSEUP:
  750.                if(Global.mouse.getLastLocal() != null)
  751.                {
  752.                   Global.mouse.getLastLocal().addCustomer(Global.mouse.removeCustomer());
  753.                }
  754.                break;
  755.             case TFEvent.EVENT_ON:
  756.             case TFEvent.EVENT_OFF:
  757.                gamePlay.pause();
  758.                stage.mcDialogPause.visible = !stage.mcDialogPause.visible;
  759.          }
  760.       }
  761.       
  762.       private function processProgress(param1:Object) : *
  763.       {
  764.          if(progressMainChar != null)
  765.          {
  766.             progressMainChar.processWalking(param1);
  767.          }
  768.       }
  769.       
  770.       public function dispatchHighScore() : *
  771.       {
  772.          stopSound = false;
  773.          try
  774.          {
  775.             return stMachine.receiveEvent(EVENT_GO_TO_HIGH_SCORE);
  776.          }
  777.          catch(e:Error)
  778.          {
  779.          }
  780.       }
  781.       
  782.       private function onEventFXGame(param1:TFEvent) : *
  783.       {
  784.          switch(param1.event)
  785.          {
  786.             case TFEvent.EVENT_MOUSEUP:
  787.                if(Global.mouse.getLastLocal() != null)
  788.                {
  789.                   Global.mouse.getLastLocal().addCustomer(Global.mouse.removeCustomer());
  790.                }
  791.                break;
  792.             case TFEvent.EVENT_ON:
  793.                Global.soundManager.setSFXVolume(100);
  794.                break;
  795.             case TFEvent.EVENT_OFF:
  796.                Global.soundManager.setSFXVolume(0);
  797.          }
  798.       }
  799.       
  800.       private function onGameOverLoadFrame() : *
  801.       {
  802.          TFMovieClip.addLabelScript(stage,"gameOver",null);
  803.          stage.mcLogo.gotoAndStop(Global.localization_branding_nr);
  804.          stage.mcLogo.mcHitArea.addEventListener(MouseEvent.CLICK,onMCClick,false,0,true);
  805.          stage.mcTitle.mcText.text = Global.xmlLocalization.gameOver.title;
  806.          stage.mcTitleBlink.mcText.text = Global.xmlLocalization.gameOver.title;
  807.          stage.mcTextScore.text = Global.xmlLocalization.gameOver.score;
  808.          stage.mcName.text = Global.xmlLocalization.sarah;
  809.          stage.mcTextName.text = Global.xmlLocalization.gameOver.name;
  810.          stage.mcScore.text = Global.score.toString();
  811.          buttons["moregames"] = new TFTextButton(stage.mcBtnMore,Global.xmlLocalization.mainmenu.moregames,onEventMoreGames);
  812.          buttons["moregames"].setFxOver(Global.soundsFX["mouse_over"]);
  813.          buttons["moregames"].setFxClick(Global.soundsFX["mouse_click"]);
  814.          buttons["submit"] = new TFTextButton(stage.mcBtnSubmit,Global.xmlLocalization.gameOver.submit,onEventSubmit);
  815.          buttons["submit"].setFxOver(Global.soundsFX["mouse_over"]);
  816.          buttons["submit"].setFxClick(Global.soundsFX["mouse_click"]);
  817.       }
  818.       
  819.       private function onHowToPlayPage3LoadFrame() : *
  820.       {
  821.          TFMovieClip.addLabelScript(stage,"page3",null);
  822.          stage.stop();
  823.          stage.mcText5.text = Global.xmlLocalization.howToPlay.text5;
  824.          stage.mcText6.text = Global.xmlLocalization.howToPlay.text6;
  825.          stage.mcText7.text = Global.xmlLocalization.howToPlay.text7;
  826.          stage.mcLogo.gotoAndStop(Global.localization_branding_nr);
  827.          stage.mcLogo.mcHitArea.addEventListener(MouseEvent.CLICK,onMCClick,false,0,true);
  828.          buttons["button1"].setText(Global.xmlLocalization.howToPlay.back);
  829.          buttons["button2"].setText(Global.xmlLocalization.howToPlay.mainmenu);
  830.       }
  831.       
  832.       private function onEventButton1(param1:TFEvent) : *
  833.       {
  834.          switch(param1.event)
  835.          {
  836.             case TFEvent.EVENT_MOUSECLICK:
  837.                switch(stage.currentFrame)
  838.                {
  839.                   case 102:
  840.                      dispatchMainMenu();
  841.                      break;
  842.                   case 103:
  843.                      stage.gotoAndStop("page1");
  844.                      TFMovieClip.addLabelScript(stage,"page1",onHowToPlayPage1LoadFrame);
  845.                      break;
  846.                   case 104:
  847.                      stage.gotoAndStop("page2");
  848.                      TFMovieClip.addLabelScript(stage,"page2",onHowToPlayPage2LoadFrame);
  849.                }
  850.          }
  851.       }
  852.       
  853.       private function onEventButton2(param1:TFEvent) : *
  854.       {
  855.          switch(param1.event)
  856.          {
  857.             case TFEvent.EVENT_MOUSECLICK:
  858.                switch(stage.currentFrame)
  859.                {
  860.                   case 102:
  861.                      stage.gotoAndStop("page2");
  862.                      TFMovieClip.addLabelScript(stage,"page2",onHowToPlayPage2LoadFrame);
  863.                      break;
  864.                   case 103:
  865.                      stage.gotoAndStop("page3");
  866.                      TFMovieClip.addLabelScript(stage,"page3",onHowToPlayPage3LoadFrame);
  867.                      break;
  868.                   case 104:
  869.                      dispatchMainMenu();
  870.                }
  871.          }
  872.       }
  873.       
  874.       private function startHighScore() : *
  875.       {
  876.          stage.gotoAndPlay("highscore");
  877.          TFMovieClip.addLabelScript(stage,"highscore",onHighScoreLoadFrame);
  878.       }
  879.       
  880.       private function startVictory() : *
  881.       {
  882.          stage.gotoAndPlay("victory");
  883.          TFMovieClip.addLabelScript(this.stage,"victory",onVictoryLoadFrame);
  884.       }
  885.       
  886.       public function nextLevel() : *
  887.       {
  888.          var _loc1_:Class = null;
  889.          var _loc2_:BitmapData = null;
  890.          if(Global.cash >= Levels.stages.stage[Levels.indexStage].levels.level[Levels.indexLevel].goal)
  891.          {
  892.             ++Levels.indexLevel;
  893.             Global.cookie.data.currentLevel = Levels.indexLevel;
  894.             Global.cookie.data.currentStage = Levels.indexStage;
  895.             Global.cookie.data.currentScore = Global.score;
  896.             Global.cookie.flush();
  897.             if(Levels.indexLevel >= Levels.stages.stage[Levels.indexStage].levels.level.length())
  898.             {
  899.                Levels.indexLevel = 0;
  900.                ++Levels.indexStage;
  901.                Global.cookie.data.currentLevel = 0;
  902.                Global.cookie.data.currentStage = 0;
  903.                Global.cookie.flush();
  904.                if(Levels.indexStage >= Levels.stages.stage.length())
  905.                {
  906.                   Global.cookie.data.currentLevel = 0;
  907.                   Global.cookie.data.currentStage = 0;
  908.                   Global.cookie.data.currentScore = 0;
  909.                   Global.cookie.flush();
  910.                   Levels.indexLevel = 0;
  911.                   Levels.indexStage = 0;
  912.                   scenary = null;
  913.                   dispatchVictory();
  914.                   return;
  915.                }
  916.                _loc1_ = Global.main.getAsset(Levels.stages.stage[Levels.indexStage].scenary);
  917.                _loc2_ = new _loc1_(600,450);
  918.                scenary = new Bitmap(_loc2_);
  919.                Global.main.mcBackground.addChild(scenary);
  920.             }
  921.          }
  922.          else
  923.          {
  924.             --Global.life;
  925.          }
  926.          if(Global.life <= 0)
  927.          {
  928.             Global.cookie.data.currentLevel = 0;
  929.             Global.cookie.data.currentStage = 0;
  930.             Global.cookie.data.currentScore = 0;
  931.             Global.cookie.flush();
  932.             Levels.indexLevel = 0;
  933.             Levels.indexStage = 0;
  934.             dispatchGameOver();
  935.          }
  936.          else
  937.          {
  938.             dispatchProgressScreen();
  939.          }
  940.       }
  941.       
  942.       public function dispatchMainMenu() : *
  943.       {
  944.          try
  945.          {
  946.             return stMachine.receiveEvent(EVENT_GO_TO_MENU);
  947.          }
  948.          catch(e:Error)
  949.          {
  950.          }
  951.       }
  952.       
  953.       private function onMCClick(param1:MouseEvent) : void
  954.       {
  955.          TFURLNavigator.changePage(Global.localization_url1,"_blank");
  956.       }
  957.       
  958.       private function onEventHighScore(param1:TFEvent) : *
  959.       {
  960.          switch(param1.event)
  961.          {
  962.             case TFEvent.EVENT_MOUSECLICK:
  963.                dispatchHighScore();
  964.                break;
  965.             case TFEvent.EVENT_INIT:
  966.             case TFEvent.EVENT_MOUSEOUT:
  967.             case TFEvent.EVENT_MOUSEOVER:
  968.          }
  969.       }
  970.       
  971.       private function onEventPlay(param1:TFEvent) : *
  972.       {
  973.          switch(param1.event)
  974.          {
  975.             case TFEvent.EVENT_MOUSECLICK:
  976.                dispatchGame();
  977.          }
  978.       }
  979.       
  980.       private function onGameLoadFrame() : *
  981.       {
  982.          var _loc1_:Class = null;
  983.          var _loc2_:BitmapData = null;
  984.          var _loc3_:Number = NaN;
  985.          stage.mcDialogDummy.enabled = false;
  986.          stage.mcDialogDummy.mouseEnabled = false;
  987.          stage.mcGoalReached.visible = false;
  988.          stage.mcGoalReached.enabled = false;
  989.          stage.mcGoalReached.mouseEnabled = false;
  990.          stage.mcGoalReached.mcGoal.enabled = false;
  991.          stage.mcGoalReached.mcGoal.mouseEnabled = false;
  992.          stage.mcGoalReached.mcGoalBlink.enabled = false;
  993.          stage.mcGoalReached.mcGoalBlink.mouseEnabled = false;
  994.          stage.mcDialogPause.enabled = false;
  995.          stage.mcDialogPause.mouseEnabled = false;
  996.          stage.mcDialogPause.visible = false;
  997.          stage.mcDialogPause.mcText.text = Global.xmlLocalization.pause.msg;
  998.          buttons["continue"] = new TFTextButton(stage.mcDialogPause.btnContinue,Global.xmlLocalization.pause.msgContinue,onEventPause);
  999.          buttons["continue"].setFxOver(Global.soundsFX["mouse_over"]);
  1000.          buttons["continue"].setFxClick(Global.soundsFX["mouse_click"]);
  1001.          buttons["continue"].setVertAlign(5,57);
  1002.          stage.mcLogo.gotoAndStop(Global.localization_branding_nr);
  1003.          stage.mcLogo.mcHitArea.addEventListener(MouseEvent.CLICK,onMCClick,false,0,true);
  1004.          if(scenary == null)
  1005.          {
  1006.             _loc1_ = Global.main.getAsset(Levels.stages.stage[Levels.indexStage].scenary);
  1007.             _loc2_ = new _loc1_(600,450);
  1008.             scenary = new Bitmap(_loc2_);
  1009.          }
  1010.          Global.main.mcBackground.addChild(scenary);
  1011.          if(gamePlay == null)
  1012.          {
  1013.             _loc3_ = Number(Levels.stages.stage[Levels.indexStage].levels.level[Levels.indexLevel].maxTimeCustomer) - Number(Levels.stages.stage[Levels.indexStage].levels.level[Levels.indexLevel].minTimeCustomer);
  1014.             _loc3_ *= 1000;
  1015.             _loc3_ *= Math.random();
  1016.             _loc3_ += Number(Levels.stages.stage[Levels.indexStage].levels.level[Levels.indexLevel].minTimeCustomer * 1000);
  1017.             _loc3_ = Math.round(_loc3_);
  1018.             gamePlay = new ManagerGamePlay(Levels.stages.stage[Levels.indexStage].levels.level[Levels.indexLevel].simultaneousClients,_loc3_,Levels.stages.stage[Levels.indexStage].levels.level[Levels.indexLevel].numberCustomer);
  1019.          }
  1020.          TFMovieClip.addLabelScript(stage,"game",null);
  1021.          TFMovieClip.addLabelScript(stage,"finishGame",onFinishGameLoadFrame);
  1022.          buttons["fx"] = new TFSwitchButton(stage.btnFX,onEventFXGame);
  1023.          buttons["fx"].setFxOver(Global.soundsFX["mouse_over"]);
  1024.          buttons["fx"].setFxClick(Global.soundsFX["mouse_click"]);
  1025.          buttons["music"] = new TFSwitchButton(stage.btnMusic,onEventMusicGame);
  1026.          buttons["music"].setFxOver(Global.soundsFX["mouse_over"]);
  1027.          buttons["music"].setFxClick(Global.soundsFX["mouse_click"]);
  1028.          if(Global.soundManager.getSFXVolume() == 0)
  1029.          {
  1030.             buttons["fx"].off();
  1031.          }
  1032.          if(Global.soundManager.getMusicVolume() == 0)
  1033.          {
  1034.             buttons["music"].off();
  1035.          }
  1036.          buttons["pause"] = new TFSwitchButton(stage.btnPause,onEventPause);
  1037.          buttons["pause"].setFxOver(Global.soundsFX["mouse_over"]);
  1038.          buttons["pause"].setFxClick(Global.soundsFX["mouse_click"]);
  1039.          buttons["pause"].disable();
  1040.          buttons["background"] = new TFButton(stage.mcBackground,onEventBackground);
  1041.       }
  1042.       
  1043.       private function onProgressLoadFrame() : *
  1044.       {
  1045.          var _loc1_:Number = NaN;
  1046.          TFMovieClip.addLabelScript(stage,"progress",null);
  1047.          buttons["play"] = new TFTextButton(stage.btnPlay,Global.xmlLocalization.progress.play,onEventPlay);
  1048.          buttons["play"].setFxOver(Global.soundsFX["mouse_over"]);
  1049.          buttons["play"].setFxClick(Global.soundsFX["mouse_click"]);
  1050.          buttons["fx"] = new TFSwitchButton(stage.btnProgressFX,onEventFX);
  1051.          buttons["fx"].setFxOver(Global.soundsFX["mouse_over"]);
  1052.          buttons["fx"].setFxClick(Global.soundsFX["mouse_click"]);
  1053.          if(Global.soundManager.getSFXVolume() == 0)
  1054.          {
  1055.             buttons["fx"].off();
  1056.          }
  1057.          buttons["music"] = new TFSwitchButton(stage.btnProgressMusic,onEventMusic);
  1058.          buttons["music"].setFxOver(Global.soundsFX["mouse_over"]);
  1059.          buttons["music"].setFxClick(Global.soundsFX["mouse_click"]);
  1060.          if(Global.soundManager.getMusicVolume() == 0)
  1061.          {
  1062.             buttons["music"].off();
  1063.          }
  1064.          Global.main.txtLife.text = "x" + Global.life;
  1065.          Global.main.mcTextCash.text = Global.xmlLocalization.progress.score;
  1066.          Global.main.mcCash.text = String(Global.score);
  1067.          Global.main.mcSpa2.visible = false;
  1068.          Global.main.mcSpa3.visible = false;
  1069.          Global.main.mcSpa4.visible = false;
  1070.          Global.soundTrackMenu.play();
  1071.          this.progressMainChar = new ProgressMainChar();
  1072.          switch(Levels.indexStage)
  1073.          {
  1074.             case 3:
  1075.                switch(Levels.indexLevel)
  1076.                {
  1077.                   case 0:
  1078.                      this.progressMainChar.setCurrentNode(ProgressMainChar.STAGE3_PATHNODE);
  1079.                      this.progressMainChar.goto(ProgressMainChar.STAGE4_PATHNODE);
  1080.                      Global.main.mcMark41.gotoAndStop("current");
  1081.                      break;
  1082.                   case 1:
  1083.                      this.progressMainChar.setCurrentNode(ProgressMainChar.STAGE4_PATHNODE);
  1084.                      this.progressMainChar.action();
  1085.                      Global.main.mcMark42.gotoAndStop("current");
  1086.                      break;
  1087.                   case 2:
  1088.                      this.progressMainChar.setCurrentNode(ProgressMainChar.STAGE4_PATHNODE);
  1089.                      this.progressMainChar.action();
  1090.                      Global.main.mcMark43.gotoAndStop("current");
  1091.                      break;
  1092.                   case 3:
  1093.                      this.progressMainChar.setCurrentNode(ProgressMainChar.STAGE4_PATHNODE);
  1094.                      this.progressMainChar.action();
  1095.                      Global.main.mcMark44.gotoAndStop("current");
  1096.                      break;
  1097.                   case 4:
  1098.                      this.progressMainChar.setCurrentNode(ProgressMainChar.STAGE4_PATHNODE);
  1099.                      this.progressMainChar.action();
  1100.                      Global.main.mcMark45.gotoAndStop("current");
  1101.                      break;
  1102.                   case 5:
  1103.                      this.progressMainChar.setCurrentNode(ProgressMainChar.STAGE4_PATHNODE);
  1104.                      this.progressMainChar.action();
  1105.                      Global.main.mcMark46.gotoAndStop("current");
  1106.                      break;
  1107.                   case 6:
  1108.                      this.progressMainChar.setCurrentNode(ProgressMainChar.STAGE4_PATHNODE);
  1109.                      this.progressMainChar.action();
  1110.                      Global.main.mcMark47.gotoAndStop("current");
  1111.                }
  1112.                break;
  1113.             case 2:
  1114.                switch(Levels.indexLevel)
  1115.                {
  1116.                   case 0:
  1117.                      this.progressMainChar.setCurrentNode(ProgressMainChar.STAGE2_PATHNODE);
  1118.                      this.progressMainChar.goto(ProgressMainChar.STAGE3_PATHNODE);
  1119.                      Global.main.mcMark31.gotoAndStop("current");
  1120.                      break;
  1121.                   case 1:
  1122.                      this.progressMainChar.setCurrentNode(ProgressMainChar.STAGE3_PATHNODE);
  1123.                      this.progressMainChar.action();
  1124.                      Global.main.mcMark32.gotoAndStop("current");
  1125.                      break;
  1126.                   case 2:
  1127.                      this.progressMainChar.setCurrentNode(ProgressMainChar.STAGE3_PATHNODE);
  1128.                      this.progressMainChar.action();
  1129.                      Global.main.mcMark33.gotoAndStop("current");
  1130.                      break;
  1131.                   case 3:
  1132.                      this.progressMainChar.setCurrentNode(ProgressMainChar.STAGE3_PATHNODE);
  1133.                      this.progressMainChar.action();
  1134.                      Global.main.mcMark34.gotoAndStop("current");
  1135.                      break;
  1136.                   case 4:
  1137.                      this.progressMainChar.setCurrentNode(ProgressMainChar.STAGE3_PATHNODE);
  1138.                      this.progressMainChar.action();
  1139.                      Global.main.mcMark35.gotoAndStop("current");
  1140.                      break;
  1141.                   case 5:
  1142.                      this.progressMainChar.setCurrentNode(ProgressMainChar.STAGE3_PATHNODE);
  1143.                      this.progressMainChar.action();
  1144.                      Global.main.mcMark36.gotoAndStop("current");
  1145.                      break;
  1146.                   case 6:
  1147.                      this.progressMainChar.setCurrentNode(ProgressMainChar.STAGE3_PATHNODE);
  1148.                      this.progressMainChar.action();
  1149.                      Global.main.mcMark37.gotoAndStop("current");
  1150.                }
  1151.                break;
  1152.             case 1:
  1153.                switch(Levels.indexLevel)
  1154.                {
  1155.                   case 0:
  1156.                      this.progressMainChar.setCurrentNode(ProgressMainChar.STAGE1_PATHNODE);
  1157.                      this.progressMainChar.goto(ProgressMainChar.STAGE2_PATHNODE);
  1158.                      Global.main.mcMark21.gotoAndStop("current");
  1159.                      break;
  1160.                   case 1:
  1161.                      this.progressMainChar.setCurrentNode(ProgressMainChar.STAGE2_PATHNODE);
  1162.                      this.progressMainChar.action();
  1163.                      Global.main.mcMark22.gotoAndStop("current");
  1164.                      break;
  1165.                   case 2:
  1166.                      this.progressMainChar.setCurrentNode(ProgressMainChar.STAGE2_PATHNODE);
  1167.                      this.progressMainChar.action();
  1168.                      Global.main.mcMark23.gotoAndStop("current");
  1169.                      break;
  1170.                   case 3:
  1171.                      this.progressMainChar.setCurrentNode(ProgressMainChar.STAGE2_PATHNODE);
  1172.                      this.progressMainChar.action();
  1173.                      Global.main.mcMark24.gotoAndStop("current");
  1174.                      break;
  1175.                   case 4:
  1176.                      this.progressMainChar.setCurrentNode(ProgressMainChar.STAGE2_PATHNODE);
  1177.                      this.progressMainChar.action();
  1178.                      Global.main.mcMark25.gotoAndStop("current");
  1179.                      break;
  1180.                   case 5:
  1181.                      this.progressMainChar.setCurrentNode(ProgressMainChar.STAGE2_PATHNODE);
  1182.                      this.progressMainChar.action();
  1183.                      Global.main.mcMark26.gotoAndStop("current");
  1184.                      break;
  1185.                   case 6:
  1186.                      this.progressMainChar.setCurrentNode(ProgressMainChar.STAGE2_PATHNODE);
  1187.                      this.progressMainChar.action();
  1188.                      Global.main.mcMark27.gotoAndStop("current");
  1189.                }
  1190.                break;
  1191.             case 0:
  1192.                this.progressMainChar.setCurrentNode(ProgressMainChar.STAGE1_PATHNODE);
  1193.                this.progressMainChar.action();
  1194.                switch(Levels.indexLevel)
  1195.                {
  1196.                   case 0:
  1197.                      Global.main.mcMark11.gotoAndStop("current");
  1198.                      break;
  1199.                   case 1:
  1200.                      Global.main.mcMark12.gotoAndStop("current");
  1201.                      break;
  1202.                   case 2:
  1203.                      Global.main.mcMark13.gotoAndStop("current");
  1204.                      break;
  1205.                   case 3:
  1206.                      Global.main.mcMark14.gotoAndStop("current");
  1207.                      break;
  1208.                   case 4:
  1209.                      Global.main.mcMark15.gotoAndStop("current");
  1210.                      break;
  1211.                   case 5:
  1212.                      Global.main.mcMark16.gotoAndStop("current");
  1213.                      break;
  1214.                   case 6:
  1215.                      Global.main.mcMark17.gotoAndStop("current");
  1216.                }
  1217.          }
  1218.          _loc1_ = Levels.indexLevel;
  1219.          switch(Levels.indexStage)
  1220.          {
  1221.             case 3:
  1222.                Global.main.mcSpa4.visible = true;
  1223.                switch(_loc1_)
  1224.                {
  1225.                   case 7:
  1226.                      Global.main.mcMark47.gotoAndStop("completed");
  1227.                   case 6:
  1228.                      Global.main.mcMark46.gotoAndStop("completed");
  1229.                   case 5:
  1230.                      Global.main.mcMark45.gotoAndStop("completed");
  1231.                   case 4:
  1232.                      Global.main.mcMark44.gotoAndStop("completed");
  1233.                   case 3:
  1234.                      Global.main.mcMark43.gotoAndStop("completed");
  1235.                   case 2:
  1236.                      Global.main.mcMark42.gotoAndStop("completed");
  1237.                   case 1:
  1238.                      Global.main.mcMark41.gotoAndStop("completed");
  1239.                   case 0:
  1240.                      _loc1_ = 7;
  1241.                }
  1242.             case 2:
  1243.                Global.main.mcSpa3.visible = true;
  1244.                switch(_loc1_)
  1245.                {
  1246.                   case 7:
  1247.                      Global.main.mcMark37.gotoAndStop("completed");
  1248.                   case 6:
  1249.                      Global.main.mcMark36.gotoAndStop("completed");
  1250.                   case 5:
  1251.                      Global.main.mcMark35.gotoAndStop("completed");
  1252.                   case 4:
  1253.                      Global.main.mcMark34.gotoAndStop("completed");
  1254.                   case 3:
  1255.                      Global.main.mcMark33.gotoAndStop("completed");
  1256.                   case 2:
  1257.                      Global.main.mcMark32.gotoAndStop("completed");
  1258.                   case 1:
  1259.                      Global.main.mcMark31.gotoAndStop("completed");
  1260.                   case 0:
  1261.                      _loc1_ = 7;
  1262.                }
  1263.             case 1:
  1264.                Global.main.mcSpa2.visible = true;
  1265.                switch(_loc1_)
  1266.                {
  1267.                   case 7:
  1268.                      Global.main.mcMark27.gotoAndStop("completed");
  1269.                   case 6:
  1270.                      Global.main.mcMark26.gotoAndStop("completed");
  1271.                   case 5:
  1272.                      Global.main.mcMark25.gotoAndStop("completed");
  1273.                   case 4:
  1274.                      Global.main.mcMark24.gotoAndStop("completed");
  1275.                   case 3:
  1276.                      Global.main.mcMark23.gotoAndStop("completed");
  1277.                   case 2:
  1278.                      Global.main.mcMark22.gotoAndStop("completed");
  1279.                   case 1:
  1280.                      Global.main.mcMark21.gotoAndStop("completed");
  1281.                   case 0:
  1282.                      _loc1_ = 7;
  1283.                }
  1284.             case 0:
  1285.                switch(_loc1_)
  1286.                {
  1287.                   case 7:
  1288.                      Global.main.mcMark17.gotoAndStop("completed");
  1289.                   case 6:
  1290.                      Global.main.mcMark16.gotoAndStop("completed");
  1291.                   case 5:
  1292.                      Global.main.mcMark15.gotoAndStop("completed");
  1293.                   case 4:
  1294.                      Global.main.mcMark14.gotoAndStop("completed");
  1295.                   case 3:
  1296.                      Global.main.mcMark13.gotoAndStop("completed");
  1297.                   case 2:
  1298.                      Global.main.mcMark12.gotoAndStop("completed");
  1299.                   case 1:
  1300.                      Global.main.mcMark11.gotoAndStop("completed");
  1301.                   case 0:
  1302.                }
  1303.          }
  1304.       }
  1305.       
  1306.       private function stopHowToPlay() : *
  1307.       {
  1308.          delete buttons["button1"];
  1309.          buttons["button1"] = undefined;
  1310.          delete buttons["button2"];
  1311.          buttons["button2"] = undefined;
  1312.       }
  1313.       
  1314.       private function stopMainMenu() : *
  1315.       {
  1316.          delete buttons["startgame"];
  1317.          buttons["startgame"] = undefined;
  1318.          delete buttons["howtoplay"];
  1319.          buttons["howtoplay"] = undefined;
  1320.          delete buttons["highscore"];
  1321.          buttons["highscore"] = undefined;
  1322.          delete buttons["freegames"];
  1323.          buttons["freegames"] = undefined;
  1324.          delete buttons["quality"];
  1325.          buttons["quality"] = undefined;
  1326.          delete buttons["fx"];
  1327.          buttons["fx"] = undefined;
  1328.          delete buttons["music"];
  1329.          buttons["music"] = undefined;
  1330.          if(stopSound)
  1331.          {
  1332.             Global.soundTrackMenu.stop();
  1333.          }
  1334.       }
  1335.       
  1336.       private function onEventMainMenu(param1:TFEvent) : *
  1337.       {
  1338.          switch(param1.event)
  1339.          {
  1340.             case TFEvent.EVENT_MOUSECLICK:
  1341.                dispatchMainMenu();
  1342.          }
  1343.       }
  1344.       
  1345.       public function dispatchHowToPlay() : *
  1346.       {
  1347.          stopSound = false;
  1348.          try
  1349.          {
  1350.             return stMachine.receiveEvent(EVENT_GO_TO_HOW_TO_PLAY);
  1351.          }
  1352.          catch(e:Error)
  1353.          {
  1354.          }
  1355.       }
  1356.       
  1357.       private function onHowToPlayLoadFrame() : *
  1358.       {
  1359.          TFMovieClip.addLabelScript(stage,"howToPlay",null);
  1360.          stage.mcTitle.mcText.text = Global.xmlLocalization.howToPlay.title;
  1361.          stage.mcTitleBlink.mcText.text = Global.xmlLocalization.howToPlay.title;
  1362.       }
  1363.       
  1364.       private function startGameOver() : *
  1365.       {
  1366.          stage.gotoAndPlay("gameOver");
  1367.          TFMovieClip.addLabelScript(stage,"gameOver",onGameOverLoadFrame);
  1368.       }
  1369.       
  1370.       private function onEventMusic(param1:TFEvent) : *
  1371.       {
  1372.          switch(param1.event)
  1373.          {
  1374.             case TFEvent.EVENT_ON:
  1375.                Global.soundManager.setMusicVolume(50);
  1376.                break;
  1377.             case TFEvent.EVENT_OFF:
  1378.                Global.soundManager.setMusicVolume(0);
  1379.          }
  1380.       }
  1381.       
  1382.       public function process(param1:Object) : *
  1383.       {
  1384.          stMachine.process(param1);
  1385.       }
  1386.       
  1387.       private function onEventSubmit(param1:TFEvent) : *
  1388.       {
  1389.          var _loc2_:Object = null;
  1390.          switch(param1.event)
  1391.          {
  1392.             case TFEvent.EVENT_MOUSECLICK:
  1393.                if(stage.mcName.length)
  1394.                {
  1395.                   _loc2_ = new Object();
  1396.                   _loc2_.name = stage.mcName.text;
  1397.                   _loc2_.score = Global.score;
  1398.                   Global.cookie.data.highScore.push(_loc2_);
  1399.                   Global.cookie.data.highScore.sortOn("score",Array.NUMERIC | Array.DESCENDING);
  1400.                   if(Global.cookie.data.highScore.length > 9)
  1401.                   {
  1402.                      Global.cookie.data.highScore.splice(9,Global.cookie.data.highScore.length - 8);
  1403.                   }
  1404.                   Global.cookie.flush();
  1405.                   Global.cash = 0;
  1406.                   Global.score = 0;
  1407.                   dispatchHighScore();
  1408.                }
  1409.          }
  1410.       }
  1411.       
  1412.       private function startGame() : *
  1413.       {
  1414.          stage.gotoAndPlay("game");
  1415.          TFMovieClip.addLabelScript(stage,"game",onGameLoadFrame);
  1416.       }
  1417.       
  1418.       private function onButtonsVictoryLoadFrame() : *
  1419.       {
  1420.          TFMovieClip.addLabelScript(this.stage,"buttons",null);
  1421.          stage.mcPainel.mcLogo.gotoAndStop(Global.localization_branding_nr);
  1422.          stage.mcPainel.mcLogo.mcHitArea.addEventListener(MouseEvent.CLICK,onMCClick,false,0,true);
  1423.          stage.mcPainel.mcTextScore.text = Global.xmlLocalization.victory.score;
  1424.          stage.mcPainel.mcName.text = Global.xmlLocalization.sarah;
  1425.          stage.mcPainel.mcTextName.text = Global.xmlLocalization.victory.name;
  1426.          stage.mcPainel.mcScore.text = Global.score.toString();
  1427.          buttons["moregames"] = new TFTextButton(stage.mcPainel.mcMore,Global.xmlLocalization.mainmenu.moregames,onEventMoreGames);
  1428.          buttons["moregames"].setFxOver(Global.soundsFX["mouse_over"]);
  1429.          buttons["moregames"].setFxClick(Global.soundsFX["mouse_click"]);
  1430.          buttons["submit"] = new TFTextButton(stage.mcPainel.mcSubimit,Global.xmlLocalization.gameOver.submit,onEventSubmitVictory);
  1431.          buttons["submit"].setFxOver(Global.soundsFX["mouse_over"]);
  1432.          buttons["submit"].setFxClick(Global.soundsFX["mouse_click"]);
  1433.       }
  1434.       
  1435.       private function startProgressScreen() : *
  1436.       {
  1437.          stage.gotoAndStop("progress");
  1438.          TFMovieClip.addLabelScript(stage,"progress",onProgressLoadFrame);
  1439.       }
  1440.       
  1441.       private function startHowToPlay() : *
  1442.       {
  1443.          stage.gotoAndPlay("howToPlay");
  1444.          TFMovieClip.addLabelScript(stage,"howToPlay",onHowToPlayLoadFrame);
  1445.          TFMovieClip.addLabelScript(stage,"initHowToPlay",onInitHowToPlayLoadFrame);
  1446.          TFMovieClip.addLabelScript(stage,"page1",onHowToPlayPage1LoadFrame);
  1447.       }
  1448.    }
  1449. }
  1450.