home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Puzzle / flag_bricks.swf / scripts / __Packages / com / kaboose / games / flagbricks / GameHud.as next >
Encoding:
Text File  |  2007-03-20  |  3.3 KB  |  121 lines

  1. class com.kaboose.games.flagbricks.GameHud extends MovieClip
  2. {
  3.    var snd;
  4.    var btnPause;
  5.    var btnQuit;
  6.    var currentLevel;
  7.    var score;
  8.    var matchArea;
  9.    var matchPoints;
  10.    var matchesLeft;
  11.    var previewBar;
  12.    static var _instance;
  13.    function GameHud()
  14.    {
  15.       super();
  16.       com.kaboose.games.flagbricks.GameHud._instance = this;
  17.       this.snd = com.kaboose.games.flagbricks.SoundManager._instance;
  18.       AsBroadcaster.initialize(this);
  19.       this.setScore(0);
  20.       this.setMatchPoints(100);
  21.       this.setMatchesLeft(2);
  22.    }
  23.    function introAnimationDone()
  24.    {
  25.       var wait = setInterval(function()
  26.       {
  27.          com.kaboose.games.flagbricks.GameHud._instance.broadcastMessage("startGame");
  28.          clearInterval(wait);
  29.       }
  30.       ,1000,this);
  31.    }
  32.    function enableButtons()
  33.    {
  34.       this.btnPause.onPress = function()
  35.       {
  36.          com.kaboose.games.flagbricks.GameHud._instance.snd.playSound("Maxim");
  37.          com.kaboose.games.flagbricks.GameHud._instance.pauseGame();
  38.       };
  39.       this.btnQuit.onPress = function()
  40.       {
  41.          com.kaboose.games.flagbricks.GameHud._instance.snd.playSound("Maxim");
  42.          com.kaboose.games.flagbricks.GameHud._instance.quitGame();
  43.       };
  44.    }
  45.    function subscribe(obj)
  46.    {
  47.       com.kaboose.games.flagbricks.GameHud._instance.addListener(obj);
  48.    }
  49.    function pauseGame()
  50.    {
  51.       this.attachMovie("pausedScreen","pausedScreen",5);
  52.       com.kaboose.games.flagbricks.KeyEvents._instance.togglePause();
  53.    }
  54.    function quitGame()
  55.    {
  56.       com.kaboose.games.flagbricks.KeyEvents._instance.togglePause();
  57.       this.attachMovie("confirmQuit","gameOverScreen",5);
  58.    }
  59.    function showLevelCompleted()
  60.    {
  61.       this.attachMovie("levelCompleteScreen","levelCompleteScreen",5);
  62.    }
  63.    function showGameOver()
  64.    {
  65.       this.attachMovie("gameOverTextAnim","go",5,{_x:260,_y:280,classRef:com.kaboose.games.flagbricks.GameHud._instance});
  66.    }
  67.    function showGameOverScreen()
  68.    {
  69.       this.attachMovie("gameOverScreen","gameOverScreen",5,this.getFinal());
  70.    }
  71.    function getFinal()
  72.    {
  73.       return {finalScore:this.score,finalLevel:this.currentLevel};
  74.    }
  75.    function setLevel(value)
  76.    {
  77.       this.currentLevel = value;
  78.       this.matchArea.currentLevel = value;
  79.    }
  80.    function setScore(value)
  81.    {
  82.       if(value == 0)
  83.       {
  84.          this.score = 0;
  85.          return undefined;
  86.       }
  87.       this.score += this.matchPoints * value;
  88.       com.kaboose.games.flagbricks.GameHud._instance.broadcastMessage("restartMatchPointTimer");
  89.       this.updateMatches();
  90.    }
  91.    function updateMatches()
  92.    {
  93.       this.matchesLeft -= 1;
  94.       if(this.matchesLeft == 0)
  95.       {
  96.          com.kaboose.games.flagbricks.GameHud._instance.broadcastMessage("levelCompleted");
  97.       }
  98.    }
  99.    function setMatchPoints(value)
  100.    {
  101.       this.matchPoints = value;
  102.    }
  103.    function setMatchesLeft(value)
  104.    {
  105.       this.matchesLeft = value;
  106.    }
  107.    function getPreviewContainer()
  108.    {
  109.       return this.previewBar.container;
  110.    }
  111.    function getMatchContainer()
  112.    {
  113.       return this.matchArea.container;
  114.    }
  115.    function destroy()
  116.    {
  117.       this.removeMovieClip();
  118.       delete com.kaboose.games.flagbricks.GameHud._instance;
  119.    }
  120. }
  121.