home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Puzzle / Clusterz / Clusterz.swf / scripts / RES / WINDOWS / OWResults.as < prev   
Encoding:
Text File  |  2008-09-12  |  5.1 KB  |  178 lines

  1. package RES.WINDOWS
  2. {
  3.    import ENGINE.CORE.OSound;
  4.    import ENGINE.GAME.OGame;
  5.    import ENGINE.INTERFACE.OButton;
  6.    import ENGINE.INTERFACE.ODialog;
  7.    import ENGINE.INTERFACE.OIObject;
  8.    import RES.API.highscores;
  9.    import flash.events.Event;
  10.    import flash.events.TimerEvent;
  11.    import flash.utils.Timer;
  12.    
  13.    public class OWResults extends ODialog
  14.    {
  15.        
  16.       
  17.       public var iGHighScores:OButton;
  18.       
  19.       private var iNewGame:Boolean;
  20.       
  21.       public var iButton:OButton;
  22.       
  23.       private var so:int;
  24.       
  25.       private var iTimer:Timer;
  26.       
  27.       private var iRecord:Boolean;
  28.       
  29.       private var _highscore:highscores;
  30.       
  31.       public var iSubmit:OButton;
  32.       
  33.       public function OWResults(param1:Boolean = false)
  34.       {
  35.          this.iNewGame = param1;
  36.          so = ClusterzL.iGAME.Read(OGame.catTmp,"Score");
  37.          this.iRecord = true;
  38.          if(this.iRecord)
  39.          {
  40.             ClusterzL.iGAME.SetLevelScore(so);
  41.          }
  42.          ClusterzL.iGAME.AddScore(so);
  43.          ClusterzL.iGAME.AddScoreInTable(ClusterzL.iGAME.prScore);
  44.          ClusterzL.iMP.Turn(["wrr",ClusterzL.iGAME.prPlayerName,ClusterzL.iGAME.prScore]);
  45.          if(this.iNewGame)
  46.          {
  47.             ClusterzL.OWResults[0][3] = ClusterzL.strGameOver;
  48.             ClusterzL.OWResults[0][5] = ClusterzL.iPosXLabelGameOver;
  49.          }
  50.          else
  51.          {
  52.             ClusterzL.OWResults[0][3] = ClusterzL.strLevelComplete;
  53.             ClusterzL.OWResults[0][5] = 30;
  54.          }
  55.          ClusterzL.OWResultsLevelScore[1][5] = so.toString();
  56.          ClusterzL.OWResultsReiting[1][4] = ClusterzL.iGAME.prScore;
  57.          if(this.iNewGame || !this.iRecord)
  58.          {
  59.             ClusterzL.OWResults[3][3] = "yellow";
  60.             ClusterzL.OWResults[3][4] = "yellow";
  61.             ClusterzL.OWResults[3][6] = ClusterzL.strReplayLevel;
  62.          }
  63.          else
  64.          {
  65.             ClusterzL.OWResults[3][3] = "yellow1";
  66.             ClusterzL.OWResults[3][4] = "yellow1";
  67.             ClusterzL.OWResults[3][6] = ClusterzL.strNextLevel;
  68.          }
  69.          super(ClusterzL.OWResults);
  70.       }
  71.       
  72.       public function GHighScores() : void
  73.       {
  74.          _highscore = new highscores(this,ClusterzL.cHs_initObj);
  75.          _highscore.openHub("view",0);
  76.          this.addChild(_highscore);
  77.       }
  78.       
  79.       override public function Init() : void
  80.       {
  81.          super.Init();
  82.          this.iGHighScores.prVisible = false;
  83.          this.iTimer = new Timer(750,5);
  84.          this.iTimer.addEventListener(TimerEvent.TIMER,OnTimer);
  85.          this.iTimer.start();
  86.       }
  87.       
  88.       public function Submit() : void
  89.       {
  90.          _highscore = new highscores(this,ClusterzL.cHs_initObj);
  91.          _highscore.openHub("submit",ClusterzL.iGAME.Read(OGame.catTmp,"Score"));
  92.          this.addChild(_highscore);
  93.       }
  94.       
  95.       private function OnITimer(param1:TimerEvent) : void
  96.       {
  97.          playAgain();
  98.       }
  99.       
  100.       override public function OnPress(param1:Event, param2:*) : void
  101.       {
  102.          if(!this.prMouseEnabled)
  103.          {
  104.             return;
  105.          }
  106.          if(param2 == this.iButton)
  107.          {
  108.             this.prVisible = false;
  109.             return;
  110.          }
  111.          if(param2 == this.iSubmit)
  112.          {
  113.             Submit();
  114.             return;
  115.          }
  116.          if(param2 == this.iGHighScores)
  117.          {
  118.             GHighScores();
  119.          }
  120.       }
  121.       
  122.       override public function Free() : void
  123.       {
  124.          this.iTimer.stop();
  125.          this.iTimer.removeEventListener(TimerEvent.TIMER,OnTimer);
  126.          this.iTimer = null;
  127.          this.iButton = null;
  128.          this.iSubmit = null;
  129.          this.iGHighScores = null;
  130.          if(_highscore)
  131.          {
  132.             this.removeChild(_highscore);
  133.          }
  134.          super.Free();
  135.       }
  136.       
  137.       private function OnTimer(param1:TimerEvent) : void
  138.       {
  139.          switch(this.iTimer.currentCount)
  140.          {
  141.             case 1:
  142.                (this.getChildAt(0) as OIObject).prVisible = true;
  143.                OSound.PlaySoundInd(1);
  144.                break;
  145.             case 2:
  146.                (this.getChildAt(1) as OIObject).prVisible = true;
  147.                OSound.PlaySoundInd(1);
  148.                break;
  149.             case 3:
  150.                (this.getChildAt(2) as OIObject).prVisible = true;
  151.                OSound.PlaySoundInd(1);
  152.                break;
  153.             case 4:
  154.                this.iButton.prVisible = true;
  155.                OSound.PlaySoundInd(4);
  156.                break;
  157.             case 5:
  158.                if(so > 0)
  159.                {
  160.                   this.iGHighScores.prVisible = false;
  161.                   this.iSubmit.prVisible = true;
  162.                }
  163.                else
  164.                {
  165.                   this.iSubmit.prVisible = false;
  166.                   this.iGHighScores.prVisible = true;
  167.                }
  168.                OSound.PlaySoundInd(4);
  169.          }
  170.       }
  171.       
  172.       public function playAgain() : void
  173.       {
  174.          this.iSubmit.visible = false;
  175.       }
  176.    }
  177. }
  178.