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

  1. package RES.WINDOWS
  2. {
  3.    import ENGINE.CORE.OGlobal;
  4.    import ENGINE.DISPLAY.OBitmap;
  5.    import ENGINE.DISPLAY.ODisplay;
  6.    import ENGINE.INTERFACE.OButton;
  7.    import ENGINE.INTERFACE.OCounter;
  8.    import ENGINE.INTERFACE.OWindow;
  9.    import RES.OBJECTS.OCursor;
  10.    import RES.OBJECTS.OField;
  11.    import flash.events.Event;
  12.    import flash.geom.Rectangle;
  13.    import flash.utils.getTimer;
  14.    
  15.    public class OWInstructions extends OWindow
  16.    {
  17.       
  18.       private static const iYPos:int = 120;
  19.       
  20.       private static const iXPos:int = 100;
  21.       
  22.       private static const iR:int = 10;
  23.       
  24.       public static const stEndGame:int = 3;
  25.       
  26.       public static const stShowGame:int = 1;
  27.       
  28.       public static const stStartGame:int = 0;
  29.       
  30.       private static const iBubRadius:int = 15;
  31.        
  32.       
  33.       private var iDemo:OField;
  34.       
  35.       private var iCursor:RES.OBJECTS.OCursor;
  36.       
  37.       public var iClose:OButton;
  38.       
  39.       private var iTimer:int;
  40.       
  41.       public var iScore:OCounter;
  42.       
  43.       public var iInstr1:OBitmap;
  44.       
  45.       private const iRecordStr:String = "065S3I009A054y4B00AA06394600A6043d5000C704363n0095032x390075032s2w0075040P4L2049060e541064041t3N0084037W5Y109C041R1Y21K4087Y5y1089057U6B109A080S5j1093053R5L00E703384J0095044n5S00E904543I008A033C3J0086042U3o0094045I2z007A043O2x0076045F2o006A050E3G2046";
  46.       
  47.       private const iLevelMap:Array = [[4,6,0],[0,1,2,3],[5,857455,477020,372779,420140,235998,176169,300672,190670,269648],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],[0,0,0,0,8,4,3,3,2,2,4,8,0,0,0,0],[0,0,0,0,0,4,1,1,4,3,3,4,0,0,0,0],[0,0,0,0,0,3,1,8,8,3,2,0,0,0,0,0],[0,0,0,0,0,0,3,4,8,4,2,0,0,0,0,0],[0,0,0,0,0,0,1,2,2,1,0,0,0,0,0,0],[0,0,0,0,0,0,0,1,2,1,0,0,0,0,0,0],[0,0,0,0,0,0,0,4,4,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0]];
  48.       
  49.       public var iInstr2:OBitmap;
  50.       
  51.       private const iGameIndex:int = 1;
  52.       
  53.       private var iRect:Rectangle;
  54.       
  55.       public function OWInstructions()
  56.       {
  57.          super(ClusterzL.OWInstructions);
  58.       }
  59.       
  60.       override public function Init() : void
  61.       {
  62.          var _loc1_:OBitmap = null;
  63.          super.Init();
  64.          _loc1_ = ODisplay.OBitmapRoundBorder([null,2 * iR * (OField.iFCols + 1),2 * iR * (OField.iFRows - 3),10,4,"GEL","120,0.5,0.7,120,0.5,0.7","border",0.5,OGlobal.ScaleFloor(iXPos - 5),OGlobal.ScaleFloor(iYPos - 5)]);
  65.          this.addChild(_loc1_);
  66.          iCursor = new RES.OBJECTS.OCursor(ODisplay.OBitmapSpriteFillRect([ODisplay.OBitmapSpriteFillRect,20,20,[ODisplay.SpriteLib,ClusterzL.OCursor],"GEL","white","border",1,0,0,null,0,true]));
  67.          State = stStartGame;
  68.       }
  69.       
  70.       override public function OnPress(param1:Event, param2:*) : void
  71.       {
  72.          if(param2 == iClose)
  73.          {
  74.             this.prVisible = false;
  75.          }
  76.       }
  77.       
  78.       override public function Free() : void
  79.       {
  80.          iDemo = null;
  81.          iScore = null;
  82.          super.Free();
  83.       }
  84.       
  85.       override public function OnEnterFrame(param1:Event) : void
  86.       {
  87.          super.OnEnterFrame(param1);
  88.          switch(iState)
  89.          {
  90.             case stStartGame:
  91.                if(Boolean(iDemo) && iDemo.State == OField.stNormal)
  92.                {
  93.                   State = stShowGame;
  94.                }
  95.                break;
  96.             case stShowGame:
  97.                if(getTimer() - iTimer > 10000)
  98.                {
  99.                   if(iInstr1.prVisible)
  100.                   {
  101.                      iInstr1.prVisible = false;
  102.                      iInstr2.prVisible = true;
  103.                   }
  104.                   else
  105.                   {
  106.                      iInstr2.prVisible = false;
  107.                      iInstr1.prVisible = true;
  108.                   }
  109.                   iTimer = getTimer();
  110.                }
  111.                if(Boolean(iDemo) && iDemo.State == OField.stLevelComplete)
  112.                {
  113.                   State = stEndGame;
  114.                }
  115.                break;
  116.             case stEndGame:
  117.                if(getTimer() - iTimer > 500)
  118.                {
  119.                   State = stStartGame;
  120.                }
  121.          }
  122.       }
  123.       
  124.       override public function set State(param1:int) : void
  125.       {
  126.          var _loc2_:Number = NaN;
  127.          iState = param1;
  128.          switch(iState)
  129.          {
  130.             case stStartGame:
  131.                _loc2_ = Math.round(Math.sqrt(3) * iBubRadius);
  132.                this.iRect = new Rectangle(0,0,2 * iBubRadius * OField.iFCols + iBubRadius,_loc2_ * (OField.iFRows - 1) + 2 * iBubRadius);
  133.                iDemo = new OField(iR,iXPos,iYPos,iScore,null,iGameIndex,iRect);
  134.                iDemo.prCursor = iCursor;
  135.                iDemo.prRecord = iRecordStr;
  136.                iDemo.NewLevel(-1,this.iLevelMap);
  137.                this.addChild(iDemo);
  138.                this.addChild(iCursor);
  139.                iCursor.prVisible = false;
  140.                this.iDemo.mouseEnabled = false;
  141.                this.iDemo.mouseChildren = false;
  142.                break;
  143.             case stShowGame:
  144.                iScore.prValue = 0;
  145.                iScore.prVisible = true;
  146.                iCursor.prVisible = true;
  147.                iTimer = getTimer();
  148.                break;
  149.             case stEndGame:
  150.                this.removeChild(iDemo);
  151.                iDemo.Free();
  152.                iCursor.prVisible = false;
  153.                this.removeChild(iCursor);
  154.                iScore.prVisible = false;
  155.                iTimer = getTimer();
  156.          }
  157.       }
  158.    }
  159. }
  160.