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

  1. package RES.OBJECTS
  2. {
  3.    import ENGINE.CORE.OGlobal;
  4.    import ENGINE.DISPLAY.OBitmap;
  5.    import ENGINE.DISPLAY.ODisplay;
  6.    import ENGINE.DISPLAY.OSprite;
  7.    import flash.display.*;
  8.    import flash.events.*;
  9.    import flash.geom.*;
  10.    
  11.    public class OBubble extends OSprite
  12.    {
  13.       
  14.       public static const stHide:int = 5;
  15.       
  16.       public static const stMove:int = 10;
  17.       
  18.       public static const stInvisible:int = 0;
  19.       
  20.       public static var iColorsCount:int = 7;
  21.       
  22.       public static const stFlyOut:int = 11;
  23.       
  24.       public static const stBeforeShow:int = 1;
  25.       
  26.       public static const stBeforeBang:int = 7;
  27.       
  28.       public static var iCIndexes:Array = [0,60,120,180,240,300,-1];
  29.       
  30.       public static const stBeforeFirework:int = 6;
  31.       
  32.       public static const stNormal:int = 3;
  33.       
  34.       public static const stBeforeHide:int = 4;
  35.       
  36.       public static const stBeforeMove:int = 9;
  37.       
  38.       public static const stBang:int = 8;
  39.       
  40.       public static const stShow:int = 2;
  41.        
  42.       
  43.       private var iDAlpha:Number;
  44.       
  45.       private var iSRadius:Number;
  46.       
  47.       private var iType:int;
  48.       
  49.       private var iRadius:Number;
  50.       
  51.       private var iBMS:OBitmap;
  52.       
  53.       private var iBM:OBitmap;
  54.       
  55.       private var iDRadius:Number;
  56.       
  57.       private var iVel:Point;
  58.       
  59.       private var iBMA:Array;
  60.       
  61.       private var iState:int = 0;
  62.       
  63.       private var iERadius:Number;
  64.       
  65.       private var iBMSA:Array;
  66.       
  67.       private var iBaseP:Point;
  68.       
  69.       private var iDelta:Number;
  70.       
  71.       private var iCInd:int;
  72.       
  73.       public function OBubble(param1:Number = 15, param2:int = 0, param3:Number = 0, param4:Number = 0)
  74.       {
  75.          iState = 0;
  76.          super();
  77.          this.iBMA = ClusterzL.iCache.GetItem("Bubble");
  78.          this.iBMSA = ClusterzL.iCache.GetItem("Shadow");
  79.          this.iBMS = new OBitmap();
  80.          this.addChild(this.iBMS);
  81.          this.iBM = new OBitmap();
  82.          this.iBMS.Pos(5,5);
  83.          this.addChild(this.iBM);
  84.          this.iCInd = param2;
  85.          this.prRadius = param1;
  86.          this.iBaseP = new Point(param3,param4);
  87.          this.Pos(param3,param4);
  88.       }
  89.       
  90.       public static function MakeBubble(param1:Array) : OBitmap
  91.       {
  92.          var _loc2_:Sprite = null;
  93.          var _loc3_:DisplayObject = null;
  94.          var _loc4_:Array = null;
  95.          var _loc5_:Number = NaN;
  96.          var _loc6_:Number = NaN;
  97.          _loc2_ = new (ClusterzL.OBubbleC as Class)();
  98.          _loc5_ = param1[1] / 91;
  99.          _loc6_ = param1[2] * OGlobal.Scale;
  100.          _loc3_ = _loc2_.getChildAt(0);
  101.          (_loc4_ = _loc3_.filters)[0].color = ODisplay.HSBToRGB(iCIndexes[param1[3]],1,0.84);
  102.          _loc4_[0].blurX *= _loc6_;
  103.          _loc4_[0].blurY *= _loc6_;
  104.          _loc4_[0].distance *= _loc6_;
  105.          _loc3_.filters = _loc4_;
  106.          _loc3_ = _loc2_.getChildAt(1);
  107.          (_loc4_ = _loc3_.filters)[0].color = ODisplay.HSBToRGB(iCIndexes[param1[3]],0.42,1);
  108.          _loc4_[0].blurX *= _loc6_;
  109.          _loc4_[0].blurY *= _loc6_;
  110.          _loc4_[0].distance *= _loc6_;
  111.          _loc3_.filters = _loc4_;
  112.          _loc3_ = _loc2_.getChildAt(2);
  113.          (_loc4_ = _loc3_.filters)[0].color = ODisplay.HSBToRGB(iCIndexes[param1[3]],0.33,1);
  114.          _loc4_[0].blurX *= _loc6_;
  115.          _loc4_[0].blurY *= _loc6_;
  116.          _loc4_[0].distance *= _loc6_;
  117.          _loc3_.filters = _loc4_;
  118.          _loc3_ = _loc2_.getChildAt(4);
  119.          (_loc4_ = _loc3_.filters)[0].highlightColor = ODisplay.HSBToRGB(iCIndexes[param1[3]],0.16,1);
  120.          _loc4_[0].blurX *= _loc6_;
  121.          _loc4_[0].blurY *= _loc6_;
  122.          _loc4_[0].distance *= _loc6_;
  123.          _loc3_.filters = _loc4_;
  124.          return OBitmap.MakeTmp(_loc2_,_loc5_,0,0,2);
  125.       }
  126.       
  127.       public static function MakeShadow(param1:Array) : OBitmap
  128.       {
  129.          var _loc2_:Sprite = null;
  130.          var _loc3_:DisplayObject = null;
  131.          var _loc4_:Array = null;
  132.          var _loc5_:Number = NaN;
  133.          _loc2_ = new (ClusterzL.OBubbleShadowC as Class)();
  134.          _loc5_ = param1[1] / 91;
  135.          _loc3_ = _loc2_.getChildAt(0);
  136.          (_loc4_ = _loc3_.filters)[0].color = ODisplay.HSBToRGB(iCIndexes[param1[3]],1,0.33);
  137.          _loc4_[0].alpha = 0.33;
  138.          _loc3_.filters = _loc4_;
  139.          return OBitmap.MakeTmp(_loc2_,_loc5_,0,0,4);
  140.       }
  141.       
  142.       public static function MakeFireworkBubble(param1:Number, param2:Number, param3:Number, param4:Number, param5:int, param6:Number, param7:Number, param8:Number, param9:Number) : OBubble
  143.       {
  144.          var _loc10_:OBubble = null;
  145.          (_loc10_ = new OBubble(param1,param5,param6,param7)).iSRadius = param1;
  146.          _loc10_.iERadius = param2;
  147.          _loc10_.iDRadius = param3;
  148.          _loc10_.iDAlpha = param4;
  149.          _loc10_.iVel = new Point(param8,param9);
  150.          _loc10_.State = stBeforeFirework;
  151.          return _loc10_;
  152.       }
  153.       
  154.       public function get prDAlpha() : Number
  155.       {
  156.          return this.iDAlpha;
  157.       }
  158.       
  159.       public function set prDAlpha(param1:Number) : void
  160.       {
  161.          this.iDAlpha = param1;
  162.       }
  163.       
  164.       public function get prRadius() : Number
  165.       {
  166.          return this.iRadius;
  167.       }
  168.       
  169.       public function get prVel() : Point
  170.       {
  171.          return this.iVel;
  172.       }
  173.       
  174.       public function set prCInd(param1:int) : void
  175.       {
  176.          this.iCInd = param1;
  177.          if(this.iCInd < 0)
  178.          {
  179.             this.State = stInvisible;
  180.          }
  181.          else
  182.          {
  183.             this.State = stNormal;
  184.             this.prRadius = this.iRadius;
  185.          }
  186.       }
  187.       
  188.       public function get prType() : int
  189.       {
  190.          return this.iType;
  191.       }
  192.       
  193.       public function get State() : int
  194.       {
  195.          return this.iState;
  196.       }
  197.       
  198.       public function get prBasePoint() : Point
  199.       {
  200.          return this.iBaseP;
  201.       }
  202.       
  203.       public function set prVel(param1:Point) : void
  204.       {
  205.          this.iVel = param1;
  206.       }
  207.       
  208.       public function set prRadius(param1:Number) : void
  209.       {
  210.          var _loc2_:int = 0;
  211.          this.iRadius = param1;
  212.          if(this.iRadius < 2)
  213.          {
  214.             this.iRadius = 2;
  215.          }
  216.          if(this.iCInd < 0)
  217.          {
  218.             return;
  219.          }
  220.          _loc2_ = Math.round(this.iRadius * 2 - 4) * iColorsCount + this.iCInd;
  221.          this.iBM.Init(this.iBMA[_loc2_].prOBM);
  222.          this.iBMS.Init(this.iBMSA[_loc2_].prOBM);
  223.       }
  224.       
  225.       override public function Free() : void
  226.       {
  227.          this.iBMA = null;
  228.          this.iBMSA = null;
  229.          this.iBM = null;
  230.          this.iBMS = null;
  231.          super.Free();
  232.       }
  233.       
  234.       public function InitHide(param1:int, param2:Number, param3:Number, param4:Number, param5:int) : void
  235.       {
  236.          this.iDelta = param1;
  237.          this.iSRadius = param2;
  238.          this.iERadius = param3;
  239.          this.iDRadius = (param3 - param2) / param5;
  240.          this.iDAlpha = (1 - param4) / param5;
  241.          this.prRadius = param2;
  242.          this.alpha = 1;
  243.          if(param1)
  244.          {
  245.             this.State = stBeforeHide;
  246.          }
  247.          else
  248.          {
  249.             this.State = stHide;
  250.          }
  251.       }
  252.       
  253.       public function set prDelta(param1:int) : void
  254.       {
  255.          this.iDelta = param1;
  256.       }
  257.       
  258.       public function InitShow(param1:int, param2:Number, param3:Number, param4:Number, param5:int) : void
  259.       {
  260.          this.iDelta = param1;
  261.          this.iSRadius = param2;
  262.          this.iERadius = param3;
  263.          this.iDRadius = (param3 - param2) / param5;
  264.          this.iDAlpha = (1 - param4) / param5;
  265.          this.prRadius = param2;
  266.          this.alpha = param4;
  267.          if(param1)
  268.          {
  269.             this.State = stBeforeShow;
  270.          }
  271.          else
  272.          {
  273.             this.State = stShow;
  274.          }
  275.       }
  276.       
  277.       public function set prBasePoint(param1:Point) : void
  278.       {
  279.          this.iBaseP = param1;
  280.       }
  281.       
  282.       public function set prType(param1:int) : void
  283.       {
  284.          this.iType = param1;
  285.       }
  286.       
  287.       public function OnEnterFrame(param1:Event) : void
  288.       {
  289.          switch(this.iState)
  290.          {
  291.             case stBeforeShow:
  292.                if(this.iDelta-- <= 0)
  293.                {
  294.                   this.State = stShow;
  295.                }
  296.                break;
  297.             case stShow:
  298.                this.prRadius += this.iDRadius;
  299.                this.alpha += this.iDAlpha;
  300.                if(this.iDRadius >= 0 && this.iRadius >= this.iERadius || this.iDRadius < 0 && this.iRadius <= this.iERadius)
  301.                {
  302.                   this.prRadius = this.iERadius;
  303.                   this.State = stNormal;
  304.                }
  305.                break;
  306.             case stBeforeHide:
  307.                if(this.iDelta-- <= 0)
  308.                {
  309.                   this.State = stHide;
  310.                }
  311.                break;
  312.             case stHide:
  313.                this.prRadius += this.iDRadius;
  314.                this.alpha -= this.iDAlpha;
  315.                if(this.iDRadius >= 0 && this.iRadius >= this.iERadius || this.iDRadius < 0 && this.iRadius <= this.iERadius)
  316.                {
  317.                   this.prRadius = this.iSRadius;
  318.                   this.alpha = 1;
  319.                   this.State = stInvisible;
  320.                }
  321.                break;
  322.             case stBeforeFirework:
  323.                this.Move(this.iVel.x,this.iVel.y);
  324.                this.prRadius += this.iDRadius;
  325.                this.alpha += this.iDAlpha;
  326.                if(this.iDRadius >= 0 && this.iRadius >= this.iERadius || this.iDRadius < 0 && this.iRadius <= this.iERadius)
  327.                {
  328.                   this.State = stBang;
  329.                }
  330.                break;
  331.             case stBeforeBang:
  332.                if(this.iDelta-- <= 0)
  333.                {
  334.                   this.State = stBang;
  335.                }
  336.                break;
  337.             case stBeforeMove:
  338.                if(this.iDelta-- <= 0)
  339.                {
  340.                   this.State = stMove;
  341.                }
  342.                break;
  343.             case stMove:
  344.                this.Move(this.iVel.x,this.iVel.y);
  345.                this.alpha -= this.iDAlpha;
  346.                if(this.alpha <= 0)
  347.                {
  348.                   this.Pos(this.iBaseP.x,this.iBaseP.y);
  349.                   this.alpha = 1;
  350.                   this.prCInd = -1;
  351.                }
  352.                break;
  353.             case stFlyOut:
  354.                if(this.iDelta-- <= 0)
  355.                {
  356.                   this.State = stBang;
  357.                }
  358.          }
  359.       }
  360.       
  361.       public function get prDelta() : int
  362.       {
  363.          return this.iDelta;
  364.       }
  365.       
  366.       public function get prCInd() : int
  367.       {
  368.          return this.iCInd;
  369.       }
  370.       
  371.       public function set State(param1:int) : void
  372.       {
  373.          this.iState = param1;
  374.          switch(this.iState)
  375.          {
  376.             case stInvisible:
  377.                this.prVisible = false;
  378.                break;
  379.             case stBeforeShow:
  380.                this.prVisible = false;
  381.                break;
  382.             case stShow:
  383.                this.prVisible = true;
  384.                break;
  385.             case stBang:
  386.                this.prVisible = false;
  387.                break;
  388.             case stNormal:
  389.                this.prVisible = true;
  390.          }
  391.       }
  392.    }
  393. }
  394.