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

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