home *** CD-ROM | disk | FTP | other *** search
- class com.kaboose.games.flagbricks.GameHud extends MovieClip
- {
- var snd;
- var btnPause;
- var btnQuit;
- var currentLevel;
- var score;
- var matchArea;
- var matchPoints;
- var matchesLeft;
- var previewBar;
- static var _instance;
- function GameHud()
- {
- super();
- com.kaboose.games.flagbricks.GameHud._instance = this;
- this.snd = com.kaboose.games.flagbricks.SoundManager._instance;
- AsBroadcaster.initialize(this);
- this.setScore(0);
- this.setMatchPoints(100);
- this.setMatchesLeft(2);
- }
- function introAnimationDone()
- {
- var wait = setInterval(function()
- {
- com.kaboose.games.flagbricks.GameHud._instance.broadcastMessage("startGame");
- clearInterval(wait);
- }
- ,1000,this);
- }
- function enableButtons()
- {
- this.btnPause.onPress = function()
- {
- com.kaboose.games.flagbricks.GameHud._instance.snd.playSound("Maxim");
- com.kaboose.games.flagbricks.GameHud._instance.pauseGame();
- };
- this.btnQuit.onPress = function()
- {
- com.kaboose.games.flagbricks.GameHud._instance.snd.playSound("Maxim");
- com.kaboose.games.flagbricks.GameHud._instance.quitGame();
- };
- }
- function subscribe(obj)
- {
- com.kaboose.games.flagbricks.GameHud._instance.addListener(obj);
- }
- function pauseGame()
- {
- this.attachMovie("pausedScreen","pausedScreen",5);
- com.kaboose.games.flagbricks.KeyEvents._instance.togglePause();
- }
- function quitGame()
- {
- com.kaboose.games.flagbricks.KeyEvents._instance.togglePause();
- this.attachMovie("confirmQuit","gameOverScreen",5);
- }
- function showLevelCompleted()
- {
- this.attachMovie("levelCompleteScreen","levelCompleteScreen",5);
- }
- function showGameOver()
- {
- this.attachMovie("gameOverTextAnim","go",5,{_x:260,_y:280,classRef:com.kaboose.games.flagbricks.GameHud._instance});
- }
- function showGameOverScreen()
- {
- this.attachMovie("gameOverScreen","gameOverScreen",5,this.getFinal());
- }
- function getFinal()
- {
- return {finalScore:this.score,finalLevel:this.currentLevel};
- }
- function setLevel(value)
- {
- this.currentLevel = value;
- this.matchArea.currentLevel = value;
- }
- function setScore(value)
- {
- if(value == 0)
- {
- this.score = 0;
- return undefined;
- }
- this.score += this.matchPoints * value;
- com.kaboose.games.flagbricks.GameHud._instance.broadcastMessage("restartMatchPointTimer");
- this.updateMatches();
- }
- function updateMatches()
- {
- this.matchesLeft -= 1;
- if(this.matchesLeft == 0)
- {
- com.kaboose.games.flagbricks.GameHud._instance.broadcastMessage("levelCompleted");
- }
- }
- function setMatchPoints(value)
- {
- this.matchPoints = value;
- }
- function setMatchesLeft(value)
- {
- this.matchesLeft = value;
- }
- function getPreviewContainer()
- {
- return this.previewBar.container;
- }
- function getMatchContainer()
- {
- return this.matchArea.container;
- }
- function destroy()
- {
- this.removeMovieClip();
- delete com.kaboose.games.flagbricks.GameHud._instance;
- }
- }
-