home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Acao / bubble_tanks_2.swf / scripts / __Packages / DisassembledBubble.as < prev    next >
Encoding:
Text File  |  2008-09-02  |  2.3 KB  |  86 lines

  1. class DisassembledBubble extends MovieClip
  2. {
  3.    var _id;
  4.    var _holdMovement;
  5.    var _followDelay;
  6.    var intMaxSpeed;
  7.    var _isReady;
  8.    var intFollowCounter;
  9.    var intTargetX;
  10.    var intTargetY;
  11.    function DisassembledBubble()
  12.    {
  13.       super();
  14.       this._id = Number(this._name.substr(0,this._name.length - 3));
  15.       this._holdMovement = false;
  16.       this._followDelay = 0;
  17.       this.intMaxSpeed = this.RandNum(6,10);
  18.       this._isReady = true;
  19.    }
  20.    function onEnterFrame()
  21.    {
  22.       this.UpdateTarget();
  23.       if(this._holdMovement == false)
  24.       {
  25.          if(this.intFollowCounter < 1)
  26.          {
  27.             var _loc3_ = new Vector();
  28.             _loc3_._x = this.intTargetX - this._x;
  29.             _loc3_._y = this.intTargetY - this._y;
  30.             var _loc2_ = _loc3_.GetLength();
  31.             if(_loc2_ <= 4)
  32.             {
  33.                this._isReady = true;
  34.             }
  35.             else
  36.             {
  37.                this._isReady = false;
  38.             }
  39.             if(_loc2_ <= 1)
  40.             {
  41.                this._x = this.intTargetX;
  42.                this._y = this.intTargetY;
  43.                this.intFollowCounter = this._followDelay;
  44.             }
  45.             else
  46.             {
  47.                _loc2_ /= 6;
  48.                if(_loc2_ > this.intMaxSpeed)
  49.                {
  50.                   _loc2_ = this.intMaxSpeed;
  51.                }
  52.                _loc3_.ConvertToUnitVector();
  53.                _loc3_.Scale(_loc2_);
  54.                this._x += _loc3_._x;
  55.                this._y += _loc3_._y;
  56.             }
  57.          }
  58.          else
  59.          {
  60.             this.intFollowCounter = this.intFollowCounter - 1;
  61.          }
  62.       }
  63.    }
  64.    function SetCounter(argAmount)
  65.    {
  66.       this.intFollowCounter = this._followDelay = argAmount;
  67.    }
  68.    function ForceStop()
  69.    {
  70.       this.intFollowCounter = 0;
  71.    }
  72.    function UpdateTarget()
  73.    {
  74.       var targetClip = eval("_root.avatar.gun." + this._id + "_reg");
  75.       var point = {x:targetClip._x,y:targetClip._y};
  76.       _root.avatar.gun.localToGlobal(point);
  77.       var vecStart = new Vector();
  78.       this.intTargetX = point.x;
  79.       this.intTargetY = point.y;
  80.    }
  81.    function RandNum(minVal, maxVal)
  82.    {
  83.       return Math.round(Math.random() * (maxVal - minVal)) + minVal;
  84.    }
  85. }
  86.