home *** CD-ROM | disk | FTP | other *** search
/ Champak 66 / Vol 66.iso / games / bob_espo.swf / scripts / __Packages / EndScreen.as < prev    next >
Encoding:
Text File  |  2013-04-24  |  3.7 KB  |  106 lines

  1. class EndScreen extends State
  2. {
  3.    var bRestartButton;
  4.    var nFinalScore;
  5.    var sUnit;
  6.    var mcRef;
  7.    static var sSTATE_IN = "In";
  8.    static var sSTATE_IDLE = "Idle";
  9.    static var sSTATE_OUT = "Out";
  10.    static var nFIRST_VISIBLE_FRAME = 15;
  11.    function EndScreen(_mcRef)
  12.    {
  13.       super(_mcRef);
  14.       this.setState(EndScreen.sSTATE_IN);
  15.       this.bRestartButton = false;
  16.       this.nFinalScore = CTRLGame.getRef().Score;
  17.       this.sUnit = " points!";
  18.       if(this.nFinalScore == 0 || this.nFinalScore == 1)
  19.       {
  20.          this.sUnit = " point!";
  21.       }
  22.    }
  23.    function doPause()
  24.    {
  25.    }
  26.    function doUnPause()
  27.    {
  28.    }
  29.    function In()
  30.    {
  31.       this.mcRef.mcState.mcScreen.txtScore.text = Utils.styleNumber(this.nFinalScore) + this.sUnit;
  32.       if(this.stateFinished())
  33.       {
  34.          this.setState(EndScreen.sSTATE_IDLE);
  35.          this.initScreen();
  36.          this.mcRef.mcState.txtScore.text = Utils.styleNumber(this.nFinalScore) + this.sUnit;
  37.       }
  38.       else if(this.mcRef.mcState._currentframe == EndScreen.nFIRST_VISIBLE_FRAME)
  39.       {
  40.          Main.getRef().showHighScoreStuff(this.mcRef.mcState.mcScreen.mcSubmit);
  41.          this.mcRef.mcState.mcScreen.txtScore.text = Utils.styleNumber(this.nFinalScore) + this.sUnit;
  42.          if(Main.getRef().sState == Main.sSTATE_WIN)
  43.          {
  44.             Controller.getRef().getSounds().playSound("WinScreen_In",Controller.nSFX_VOLUME,1);
  45.          }
  46.          else if(Main.getRef().sState == Main.sSTATE_LOSE)
  47.          {
  48.             Controller.getRef().getSounds().playSound("LoseScreen_In",Controller.nSFX_VOLUME,1);
  49.          }
  50.       }
  51.    }
  52.    function Idle()
  53.    {
  54.    }
  55.    function Out()
  56.    {
  57.       this.mcRef.mcState.mcScreen.txtScore.text = Utils.styleNumber(this.nFinalScore) + this.sUnit;
  58.       if(this.stateFinished())
  59.       {
  60.          this.mcRef.mcState.stop();
  61.          if(this.bRestartButton)
  62.          {
  63.             Main.getRef().onRestartButton();
  64.          }
  65.          else
  66.          {
  67.             Main.getRef().onHighScoresButton();
  68.          }
  69.       }
  70.    }
  71.    function clickRestartButton()
  72.    {
  73.       Controller.getRef().playClickSound();
  74.       this.bRestartButton = true;
  75.       this.setOut();
  76.    }
  77.    function clickHighScoresButton()
  78.    {
  79.       Controller.getRef().playClickSound();
  80.       this.bRestartButton = false;
  81.       this.setOut();
  82.    }
  83.    function setOut()
  84.    {
  85.       this.setState(EndScreen.sSTATE_OUT);
  86.       Main.getRef().showHighScoreStuff(this.mcRef.mcState.mcScreen.mcSubmit);
  87.       Controller.getRef().getSounds().startFadeOut("WinScreen_In");
  88.       Controller.getRef().getSounds().startFadeOut("LoseScreen_In");
  89.       Controller.getRef().getSounds().playSound("EndScreen_Out",Controller.nSFX_VOLUME,1);
  90.       this.mcRef.mcState.mcScreen.txtScore.text = Utils.styleNumber(this.nFinalScore) + this.sUnit;
  91.    }
  92.    function initScreen()
  93.    {
  94.       this.mcRef.mcState.btnPlayAgain.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  95.       this.mcRef.mcState.btnPlayAgain.onRelease = Delegate.create(this,this.clickRestartButton);
  96.       this.mcRef.mcState.btnHighScores.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  97.       this.mcRef.mcState.btnHighScores.onRelease = Delegate.create(this,this.clickHighScoresButton);
  98.       Main.getRef().showHighScoreStuff(this.mcRef.mcState.mcSubmit);
  99.       if(this.mcRef.mcState.mcSubmit._visible)
  100.       {
  101.          this.mcRef.mcState.mcSubmit.btnSubmit.onRollOver = Delegate.create(Main.getRef(),Main.getRef().rollOverButton);
  102.          this.mcRef.mcState.mcSubmit.btnSubmit.onRelease = Delegate.create(Main.getRef(),Main.getRef().clickSubmitScore);
  103.       }
  104.    }
  105. }
  106.