home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Esportes / CrossingCup.swf / scripts / __Packages / CNavigationStateManager.as < prev    next >
Text File  |  2007-12-11  |  18KB  |  440 lines

  1. class CNavigationStateManager
  2. {
  3.    static var AS_IDLE = 0;
  4.    static var AS_INTRO = 1;
  5.    static var AS_MENU = 2;
  6.    static var AS_NEWGAME = 3;
  7.    static var AS_CONTINUEGAME1 = 4;
  8.    static var AS_CONTINUEGAME2 = 5;
  9.    static var AS_PREGAME = 6;
  10.    static var AS_GAME = 7;
  11.    static var AS_RESULT = 8;
  12.    static var AS_OPTIONS = 9;
  13.    static var AS_HELP = 10;
  14.    static var AS_HIGHSCORE = 11;
  15.    static var AS_CREDITS = 12;
  16.    static var AS_QUIT = 13;
  17.    static var AS_GAMEOVER = 14;
  18.    static var AS_DIALOG = 15;
  19.    static var AS_PRELOADER = 16;
  20.    function CNavigationStateManager(_mcroot)
  21.    {
  22.       this.AppState = CNavigationStateManager.AS_IDLE;
  23.       this.mcRoot = _mcroot;
  24.       this.modalscreen = 0;
  25.       EventCenter.access().addEventListener("endScreen",this);
  26.       EventCenter.access().addEventListener("menuAccess",this);
  27.    }
  28.    function menuAccess(event)
  29.    {
  30.       var _loc2_ = false;
  31.       if(event.tembus != undefined)
  32.       {
  33.          _loc2_ = true;
  34.       }
  35.       switch(event.name)
  36.       {
  37.          case "AddThisGames":
  38.             getUrl("http://www.net-games.biz/downloads.php", "_blank");
  39.             break;
  40.          case "PlayMoreGames":
  41.             getUrl("http://www.net-games.biz", "_blank");
  42.             break;
  43.          case "StartNewGame":
  44.             SoundManager.ins().playMousedown();
  45.             if(CTournament.ins().tournamentPhase != -1)
  46.             {
  47.                if(!_loc2_)
  48.                {
  49.                   this.visibleScreen(false,this.AppState);
  50.                }
  51.                this.changeAppState(CNavigationStateManager.AS_DIALOG);
  52.                return undefined;
  53.             }
  54.             SoundManager.ins().playMousedown();
  55.             this.changeAppState(CNavigationStateManager.AS_NEWGAME);
  56.             break;
  57.          case "ContinueGame1":
  58.             this.changeAppState(CNavigationStateManager.AS_CONTINUEGAME1);
  59.             break;
  60.          case "ContinueGame2":
  61.             this.changeAppState(CNavigationStateManager.AS_CONTINUEGAME2);
  62.             break;
  63.          case "Options":
  64.             SoundManager.ins().playMousedown();
  65.             if(!_loc2_)
  66.             {
  67.                this.visibleScreen(false,this.AppState);
  68.             }
  69.             this.changeAppState(CNavigationStateManager.AS_OPTIONS);
  70.             break;
  71.          case "Help":
  72.             SoundManager.ins().playMousedown();
  73.             if(!_loc2_)
  74.             {
  75.                this.visibleScreen(false,this.AppState);
  76.             }
  77.             this.changeAppState(CNavigationStateManager.AS_HELP);
  78.             break;
  79.          case "HighScore":
  80.             SoundManager.ins().playMousedown();
  81.             if(!_loc2_)
  82.             {
  83.                this.visibleScreen(false,this.AppState);
  84.             }
  85.             this.changeAppState(CNavigationStateManager.AS_HIGHSCORE);
  86.             break;
  87.          case "Credits":
  88.             SoundManager.ins().playMousedown();
  89.             if(!_loc2_)
  90.             {
  91.                this.visibleScreen(false,this.AppState);
  92.             }
  93.             this.changeAppState(CNavigationStateManager.AS_CREDITS);
  94.             break;
  95.          case "Quit":
  96.             SoundManager.ins().playMousedown();
  97.             this.changeAppState(CNavigationStateManager.AS_QUIT);
  98.             break;
  99.          case "Menu":
  100.             SoundManager.ins().playMousedown();
  101.             this.changeAppState(CNavigationStateManager.AS_MENU);
  102.       }
  103.    }
  104.    function endScreen(event)
  105.    {
  106.       switch(event.name)
  107.       {
  108.          case "ScreenIntro":
  109.             this.removeScreen(CNavigationStateManager.AS_INTRO);
  110.             this.changeAppState(CNavigationStateManager.AS_MENU);
  111.             break;
  112.          case "ScreenNewGame":
  113.             SoundManager.ins().playMousedown();
  114.             this.removeScreen(CNavigationStateManager.AS_NEWGAME);
  115.             this.changeAppState(CNavigationStateManager.AS_CONTINUEGAME1);
  116.             break;
  117.          case "ScreenContinueGame1":
  118.             SoundManager.ins().playMousedown();
  119.             this.removeScreen(CNavigationStateManager.AS_CONTINUEGAME1);
  120.             this.removeScreen(CNavigationStateManager.AS_CONTINUEGAME2);
  121.             if(event.tonew)
  122.             {
  123.                this.changeAppState(CNavigationStateManager.AS_NEWGAME);
  124.             }
  125.             else
  126.             {
  127.                this.changeAppState(CNavigationStateManager.AS_PREGAME);
  128.             }
  129.             break;
  130.          case "ScreenContinueGame2":
  131.             SoundManager.ins().playMousedown();
  132.             this.removeScreen(CNavigationStateManager.AS_CONTINUEGAME1);
  133.             this.removeScreen(CNavigationStateManager.AS_CONTINUEGAME2);
  134.             if(event.tonew)
  135.             {
  136.                this.changeAppState(CNavigationStateManager.AS_NEWGAME);
  137.             }
  138.             else
  139.             {
  140.                this.changeAppState(CNavigationStateManager.AS_PREGAME);
  141.             }
  142.             break;
  143.          case "ScreenPreGame":
  144.             SoundManager.ins().playMousedown();
  145.             this.removeScreen(CNavigationStateManager.AS_PREGAME);
  146.             this.removeScreen(CNavigationStateManager.AS_MENU);
  147.             this.changeAppState(CNavigationStateManager.AS_GAME);
  148.             break;
  149.          case "ScreenGame":
  150.             this.removeScreen(CNavigationStateManager.AS_GAME);
  151.             this.changeAppState(CNavigationStateManager.AS_RESULT);
  152.             break;
  153.          case "ScreenResult":
  154.             SoundManager.ins().playMousedown();
  155.             this.removeScreen(CNavigationStateManager.AS_RESULT);
  156.             if(event.round == 1)
  157.             {
  158.                this.changeAppState(CNavigationStateManager.AS_PREGAME);
  159.             }
  160.             else if(CTournament.ins().gameover)
  161.             {
  162.                this.changeAppState(CNavigationStateManager.AS_GAMEOVER);
  163.             }
  164.             else
  165.             {
  166.                this.setScreen(CNavigationStateManager.AS_MENU);
  167.                if(CTournament.ins().tournamentPhase >= 4)
  168.                {
  169.                   this.changeAppState(CNavigationStateManager.AS_CONTINUEGAME2);
  170.                }
  171.                else
  172.                {
  173.                   this.changeAppState(CNavigationStateManager.AS_CONTINUEGAME1);
  174.                }
  175.             }
  176.             break;
  177.          case "ScreenGameOver":
  178.             SoundManager.ins().playMousedown();
  179.             this.removeScreen(CNavigationStateManager.AS_GAMEOVER);
  180.             this.setScreen(CNavigationStateManager.AS_MENU);
  181.             this.changeAppState(CNavigationStateManager.AS_CONTINUEGAME1);
  182.             break;
  183.          case "ScreenCredits":
  184.             SoundManager.ins().playMousedown();
  185.             this.removeScreen(CNavigationStateManager.AS_CREDITS);
  186.             this.visibleScreen(true,this.AppState);
  187.             this.changeAppState(CNavigationStateManager.AS_MENU);
  188.             break;
  189.          case "ScreenOptions":
  190.             SoundManager.ins().playMousedown();
  191.             this.removeScreen(CNavigationStateManager.AS_OPTIONS);
  192.             this.visibleScreen(true,this.AppState);
  193.             this.changeAppState(CNavigationStateManager.AS_MENU);
  194.             break;
  195.          case "ScreenHighScore":
  196.             SoundManager.ins().playMousedown();
  197.             this.removeScreen(CNavigationStateManager.AS_HIGHSCORE);
  198.             this.visibleScreen(true,this.AppState);
  199.             this.changeAppState(CNavigationStateManager.AS_MENU);
  200.             break;
  201.          case "ScreenHelp":
  202.             SoundManager.ins().playMousedown();
  203.             this.removeScreen(CNavigationStateManager.AS_HELP);
  204.             this.visibleScreen(true,this.AppState);
  205.             this.changeAppState(CNavigationStateManager.AS_MENU);
  206.             break;
  207.          case "ScreenDialog":
  208.             SoundManager.ins().playMousedown();
  209.             this.visibleScreen(true,this.AppState);
  210.             this.removeScreen(CNavigationStateManager.AS_DIALOG);
  211.             if(event.select)
  212.             {
  213.                this.removeScreen(CNavigationStateManager.AS_CONTINUEGAME1);
  214.                this.removeScreen(CNavigationStateManager.AS_CONTINUEGAME2);
  215.                this.removeScreen(CNavigationStateManager.AS_PREGAME);
  216.                CTournament.ins().endTournament();
  217.                this.changeAppState(CNavigationStateManager.AS_NEWGAME);
  218.             }
  219.             else
  220.             {
  221.                this.changeAppState(CNavigationStateManager.AS_MENU);
  222.             }
  223.             break;
  224.          case "ScreenPreloader":
  225.             SoundManager.ins().playMousedown();
  226.             this.removeScreen(CNavigationStateManager.AS_PRELOADER);
  227.             this.changeAppState(CNavigationStateManager.AS_INTRO);
  228.       }
  229.    }
  230.    function removeScreen(screen)
  231.    {
  232.       this.modalscreen = 0;
  233.       switch(screen)
  234.       {
  235.          case CNavigationStateManager.AS_INTRO:
  236.             this.mcsIntro.removeMovieClip();
  237.             SoundManager.ins().playBGM();
  238.             break;
  239.          case CNavigationStateManager.AS_MENU:
  240.             this.mcsMenu.removeMovieClip();
  241.             break;
  242.          case CNavigationStateManager.AS_NEWGAME:
  243.             this.mcsNewGame.removeMovieClip();
  244.             break;
  245.          case CNavigationStateManager.AS_CONTINUEGAME1:
  246.             this.mcsContinueGame1.removeMovieClip();
  247.             this.mcsContinueGame2.removeMovieClip();
  248.             break;
  249.          case CNavigationStateManager.AS_CONTINUEGAME2:
  250.             this.mcsContinueGame1.removeMovieClip();
  251.             this.mcsContinueGame2.removeMovieClip();
  252.             break;
  253.          case CNavigationStateManager.AS_PREGAME:
  254.             this.mcsPreGame.removeMovieClip();
  255.             break;
  256.          case CNavigationStateManager.AS_GAME:
  257.             this.mcsGame.hide();
  258.             break;
  259.          case CNavigationStateManager.AS_RESULT:
  260.             this.mcsResult.removeMovieClip();
  261.             break;
  262.          case CNavigationStateManager.AS_GAMEOVER:
  263.             this.mcsGameOver.removeMovieClip();
  264.             break;
  265.          case CNavigationStateManager.AS_OPTIONS:
  266.             this.mcsOptions.removeMovieClip();
  267.             break;
  268.          case CNavigationStateManager.AS_HIGHSCORE:
  269.             this.mcsHighScore.removeMovieClip();
  270.             break;
  271.          case CNavigationStateManager.AS_CREDITS:
  272.             this.mcsCredits.removeMovieClip();
  273.             break;
  274.          case CNavigationStateManager.AS_HELP:
  275.             this.mcsHelp.removeMovieClip();
  276.             break;
  277.          case CNavigationStateManager.AS_DIALOG:
  278.             this.mcsDialog.removeMovieClip();
  279.             break;
  280.          case CNavigationStateManager.AS_PRELOADER:
  281.             this.mcsPreloader.removeMovieClip();
  282.       }
  283.    }
  284.    function setScreen(screen)
  285.    {
  286.       switch(screen)
  287.       {
  288.          case CNavigationStateManager.AS_PRELOADER:
  289.             var _loc2_ = {_x:0,_y:0};
  290.             this.mcsPreloader = this.mcRoot.attachMovie("mcCPreloaderScreen","ScreenPreloader",0,_loc2_);
  291.             this.mcsPreloader.show();
  292.             break;
  293.          case CNavigationStateManager.AS_INTRO:
  294.             _loc2_ = {_x:385.9,_y:287.6};
  295.             this.mcsIntro = this.mcRoot.attachMovie("mcCIntroScreen","ScreenIntro",0,_loc2_);
  296.             this.mcsIntro.show();
  297.             break;
  298.          case CNavigationStateManager.AS_MENU:
  299.             SoundManager.ins().addSpeaker();
  300.             _loc2_ = {_x:0,_y:0};
  301.             this.mcsMenu = this.mcRoot.attachMovie("mcCMenuScreen","ScreenMenu",1,_loc2_);
  302.             this.mcsMenu.show();
  303.             break;
  304.          case CNavigationStateManager.AS_NEWGAME:
  305.             _loc2_ = {_x:0,_y:0};
  306.             this.mcsNewGame = this.mcRoot.attachMovie("mcCNewGameScreen","ScreenNewGame",2,_loc2_);
  307.             this.mcsNewGame.show();
  308.             this.AppState = CNavigationStateManager.AS_NEWGAME;
  309.             break;
  310.          case CNavigationStateManager.AS_CONTINUEGAME1:
  311.             _loc2_ = {_x:0,_y:0};
  312.             this.mcsContinueGame1 = this.mcRoot.attachMovie("mcCContinueGameScreen1","ScreenContinueGame1",3,_loc2_);
  313.             this.mcsContinueGame1.show();
  314.             this.AppState = CNavigationStateManager.AS_CONTINUEGAME1;
  315.             break;
  316.          case CNavigationStateManager.AS_CONTINUEGAME2:
  317.             _loc2_ = {_x:0,_y:0};
  318.             this.mcsContinueGame2 = this.mcRoot.attachMovie("mcCContinueGameScreen2","ScreenContinueGame2",3,_loc2_);
  319.             this.mcsContinueGame2.show();
  320.             this.AppState = CNavigationStateManager.AS_CONTINUEGAME2;
  321.             break;
  322.          case CNavigationStateManager.AS_PREGAME:
  323.             _loc2_ = {_x:0,_y:0};
  324.             this.mcsPreGame = this.mcRoot.attachMovie("mcCPreGameScreen","ScreenPreGame",4,_loc2_);
  325.             this.mcsPreGame.show();
  326.             this.AppState = CNavigationStateManager.AS_PREGAME;
  327.             break;
  328.          case CNavigationStateManager.AS_GAME:
  329.             SoundManager.ins().fadeBGM(false);
  330.             this.AppState = CNavigationStateManager.AS_GAME;
  331.             _loc2_ = {_x:0,_y:0};
  332.             if(this.mcsGame == undefined)
  333.             {
  334.                this.mcsGame = this.mcRoot.attachMovie("mcCGameScreen","ScreenGame",5,_loc2_);
  335.             }
  336.             this.mcsGame.show();
  337.             break;
  338.          case CNavigationStateManager.AS_RESULT:
  339.             SoundManager.ins().playBGM();
  340.             _loc2_ = {_x:0,_y:0};
  341.             this.mcsResult = this.mcRoot.attachMovie("mcCResultScreen","ScreenResult",6,_loc2_);
  342.             this.mcsResult.show();
  343.             this.AppState = CNavigationStateManager.AS_RESULT;
  344.             break;
  345.          case CNavigationStateManager.AS_GAMEOVER:
  346.             _loc2_ = {_x:0,_y:0};
  347.             this.mcsGameOver = this.mcRoot.attachMovie("mcCGameOverScreen","ScreenGameOver",7,_loc2_);
  348.             this.mcsGameOver.show();
  349.             this.AppState = CNavigationStateManager.AS_GAMEOVER;
  350.             break;
  351.          case CNavigationStateManager.AS_OPTIONS:
  352.             _loc2_ = {_x:0,_y:0};
  353.             this.mcsOptions = this.mcRoot.attachMovie("mcCOptionsScreen","ScreenOptions",8,_loc2_);
  354.             this.mcsOptions.show();
  355.             this.modalscreen = CNavigationStateManager.AS_OPTIONS;
  356.             break;
  357.          case CNavigationStateManager.AS_HIGHSCORE:
  358.             _loc2_ = {_x:0,_y:0};
  359.             this.mcsHighScore = this.mcRoot.attachMovie("mcCHighScoreScreen","ScreenHighScore",9,_loc2_);
  360.             this.mcsHighScore.show();
  361.             this.modalscreen = CNavigationStateManager.AS_HIGHSCORE;
  362.             break;
  363.          case CNavigationStateManager.AS_CREDITS:
  364.             _loc2_ = {_x:0,_y:0};
  365.             this.mcsCredits = this.mcRoot.attachMovie("mcCCreditsScreen","ScreenCredits",10,_loc2_);
  366.             this.mcsCredits.show();
  367.             this.modalscreen = CNavigationStateManager.AS_CREDITS;
  368.             break;
  369.          case CNavigationStateManager.AS_HELP:
  370.             _loc2_ = {_x:0,_y:0};
  371.             this.mcsHelp = this.mcRoot.attachMovie("mcCHelpScreen","ScreenHelp",11,_loc2_);
  372.             this.mcsHelp.show();
  373.             this.modalscreen = CNavigationStateManager.AS_HELP;
  374.             break;
  375.          case CNavigationStateManager.AS_DIALOG:
  376.             _loc2_ = {_x:0,_y:0};
  377.             this.mcsDialog = this.mcRoot.attachMovie("mcCDialogScreen","ScreenDialog",12,_loc2_);
  378.             this.mcsDialog.show();
  379.             this.modalscreen = CNavigationStateManager.AS_DIALOG;
  380.       }
  381.    }
  382.    function changeAppState(tostate)
  383.    {
  384.       if(this.modalscreen != 0)
  385.       {
  386.          this.removeScreen(this.modalscreen);
  387.       }
  388.       this.setScreen(tostate);
  389.    }
  390.    function visibleScreen(visibility, screen)
  391.    {
  392.       switch(screen)
  393.       {
  394.          case CNavigationStateManager.AS_PRELOADER:
  395.             this.mcsPreloader._visible = visibility;
  396.             break;
  397.          case CNavigationStateManager.AS_INTRO:
  398.             this.mcsIntro._visible = visibility;
  399.             break;
  400.          case CNavigationStateManager.AS_MENU:
  401.             this.mcsMenu._visible = visibility;
  402.             break;
  403.          case CNavigationStateManager.AS_NEWGAME:
  404.             this.mcsNewGame._visible = visibility;
  405.             break;
  406.          case CNavigationStateManager.AS_CONTINUEGAME1:
  407.             this.mcsContinueGame1._visible = visibility;
  408.             break;
  409.          case CNavigationStateManager.AS_CONTINUEGAME2:
  410.             this.mcsContinueGame2._visible = visibility;
  411.             break;
  412.          case CNavigationStateManager.AS_PREGAME:
  413.             this.mcsPreGame._visible = visibility;
  414.             break;
  415.          case CNavigationStateManager.AS_GAME:
  416.             this.mcsGame._visible = visibility;
  417.             break;
  418.          case CNavigationStateManager.AS_RESULT:
  419.             this.mcsResult._visible = visibility;
  420.             break;
  421.          case CNavigationStateManager.AS_GAMEOVER:
  422.             this.mcsGameOver._visible = visibility;
  423.             break;
  424.          case CNavigationStateManager.AS_OPTIONS:
  425.             this.mcsOptions._visible = visibility;
  426.             break;
  427.          case CNavigationStateManager.AS_HIGHSCORE:
  428.             this.mcsHighScore._visible = visibility;
  429.             break;
  430.          case CNavigationStateManager.AS_CREDITS:
  431.             this.mcsCredits._visible = visibility;
  432.             break;
  433.          case CNavigationStateManager.AS_HELP:
  434.             this.mcsHelp._visible = visibility;
  435.          case CNavigationStateManager.AS_DIALOG:
  436.             this.mcsDialog._visible = visibility;
  437.       }
  438.    }
  439. }
  440.