home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / zombietypocalypse.swf / scripts / main / GameManager.as
Encoding:
Text File  |  2008-09-15  |  4.3 KB  |  164 lines

  1. package main
  2. {
  3.    import classes.components.FG_Preloader;
  4.    import classes.dispatchers.GameDispatcher;
  5.    import classes.dispatchers.LoadingComplete;
  6.    import classes.helper.HighscoreElement;
  7.    import flash.display.MovieClip;
  8.    import flash.events.Event;
  9.    import flash.events.MouseEvent;
  10.    
  11.    public class GameManager extends MovieClip
  12.    {
  13.       
  14.       private static var areButtonsEnabled:Boolean;
  15.       
  16.       public static var instance:GameManager;
  17.        
  18.       
  19.       private var gameParameters:Array;
  20.       
  21.       private var delayedWaypoint:String;
  22.       
  23.       private var _fg:FG_Preloader;
  24.       
  25.       private var _preloaderStart:Boolean;
  26.       
  27.       private var _highscoreFields:Array;
  28.       
  29.       public function GameManager()
  30.       {
  31.          super();
  32.          if(instance == null)
  33.          {
  34.             instance = this;
  35.             areButtonsEnabled = false;
  36.             gameParameters = new Array();
  37.             delayedWaypoint = null;
  38.             this.addEventListener(Event.ENTER_FRAME,GMonEnterFrame);
  39.             GameDispatcher.preloaderDispatcher.addEventListener(LoadingComplete.LOADING_COMPLETE,startMenu);
  40.             parent.addEventListener(MouseEvent.MOUSE_DOWN,mousePress);
  41.             parent.addEventListener(MouseEvent.MOUSE_UP,mousePress);
  42.          }
  43.       }
  44.       
  45.       public static function getInstance() : GameManager
  46.       {
  47.          if(instance == null)
  48.          {
  49.          }
  50.          return instance;
  51.       }
  52.       
  53.       public function getParameter(param1:String) : String
  54.       {
  55.          return gameParameters[param1];
  56.       }
  57.       
  58.       public function showHighscores() : void
  59.       {
  60.       }
  61.       
  62.       public function parseFields(param1:String) : void
  63.       {
  64.          if(this._highscoreFields.length == 0)
  65.          {
  66.             this._highscoreFields = param1.split("_");
  67.          }
  68.       }
  69.       
  70.       public function buttonsOn() : void
  71.       {
  72.          GameDispatcher.buttonsDispatcher.unlockButtons();
  73.          areButtonsEnabled = true;
  74.       }
  75.       
  76.       public function setParameter(param1:String, param2:String) : void
  77.       {
  78.          gameParameters[param1] = param2;
  79.       }
  80.       
  81.       public function getHigscore() : Array
  82.       {
  83.          var _loc1_:Array = null;
  84.          var _loc2_:HighscoreElement = null;
  85.          _loc1_ = new Array();
  86.          _loc2_ = new HighscoreElement(1,"Anty",100,12300,5,10,43021);
  87.          _loc1_.push(_loc2_);
  88.          return _loc1_;
  89.       }
  90.       
  91.       private function initPreloader() : void
  92.       {
  93.          this._fg = FG_Preloader(GameManager.getInstance().getChildByName("preloader_elements"));
  94.          if(this._fg != null)
  95.          {
  96.             this._fg.startLoad();
  97.          }
  98.       }
  99.       
  100.       public function readHighscores() : void
  101.       {
  102.          this.showHighscores();
  103.       }
  104.       
  105.       private function GMonEnterFrame(param1:Event) : void
  106.       {
  107.          this._highscoreFields = new Array();
  108.          if(this.currentLabel == "Preloader_Start" && !this._preloaderStart)
  109.          {
  110.             this.initPreloader();
  111.             this._preloaderStart = true;
  112.          }
  113.       }
  114.       
  115.       private function mousePress(param1:MouseEvent) : *
  116.       {
  117.          GameDispatcher.mouseDispatcher.buttonPressed(param1.target);
  118.       }
  119.       
  120.       public function getFields() : Array
  121.       {
  122.          return this._highscoreFields;
  123.       }
  124.       
  125.       public function delayedGoToAndStop() : void
  126.       {
  127.          if(this.delayedWaypoint != null)
  128.          {
  129.             gotoAndStop(this.delayedWaypoint);
  130.             this.delayedWaypoint = null;
  131.          }
  132.       }
  133.       
  134.       public function setDelayedWaypoint(param1:String) : void
  135.       {
  136.          this.delayedWaypoint = param1;
  137.       }
  138.       
  139.       public function get AreButtonsEnabled() : Boolean
  140.       {
  141.          return areButtonsEnabled;
  142.       }
  143.       
  144.       public function lockButtons() : void
  145.       {
  146.          areButtonsEnabled = false;
  147.       }
  148.       
  149.       private function startMenu(param1:Event) : void
  150.       {
  151.          this.gotoAndPlay("Preloader_Outro");
  152.       }
  153.       
  154.       public function delayedGoToAndPlay() : void
  155.       {
  156.          if(this.delayedWaypoint != null)
  157.          {
  158.             gotoAndPlay(this.delayedWaypoint);
  159.             this.delayedWaypoint = null;
  160.          }
  161.       }
  162.    }
  163. }
  164.