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

  1. class Bullet extends MovieClip
  2. {
  3.    var moveX;
  4.    var moveY;
  5.    var _damage;
  6.    var _holdMovement;
  7.    var _type;
  8.    var halfX;
  9.    var halfY;
  10.    var arrEnemiesImmune;
  11.    var starBurstTimer;
  12.    var removeCallback;
  13.    var arrBusted;
  14.    function Bullet()
  15.    {
  16.       super();
  17.       this.moveX = 0;
  18.       this.moveY = 0;
  19.       this._damage = 1;
  20.       this._holdMovement = false;
  21.       this._type = 1;
  22.       this.halfX = this._x;
  23.       this.halfY = this._y;
  24.       this.arrEnemiesImmune = new Array();
  25.       this.starBurstTimer = 45;
  26.    }
  27.    function SetMovement(myX, myY)
  28.    {
  29.       this.moveX = myX;
  30.       this.moveY = myY;
  31.    }
  32.    function onEnterFrame()
  33.    {
  34.       if(this._holdMovement == false)
  35.       {
  36.          this.halfX = this._x + this.moveX / 2;
  37.          this.halfY = this._y + this.moveY / 2;
  38.          this._x += this.moveX;
  39.          this._y += this.moveY;
  40.          if(this.GetDistance() > _root.bg.inside._width / 2)
  41.          {
  42.             if(this._type == 7)
  43.             {
  44.                _root.game.SmallDamageBurst(this._x,this._y);
  45.             }
  46.             else if(this._type == 8)
  47.             {
  48.                this.CleanupBusted();
  49.             }
  50.             this.removeCallback(this._name);
  51.             this.removeMovieClip();
  52.          }
  53.          if(this._type == 4)
  54.          {
  55.             if(this.starBurstTimer > 0)
  56.             {
  57.                this.starBurstTimer = this.starBurstTimer - 1;
  58.             }
  59.             else
  60.             {
  61.                this.PerformStarBurst();
  62.             }
  63.          }
  64.       }
  65.    }
  66.    function EventHitEnemy(enemyName)
  67.    {
  68.       if(this._type == 5)
  69.       {
  70.          _root.game.DamageBurst(this._x,this._y,10);
  71.       }
  72.       else if(this._type == 6)
  73.       {
  74.          _root.game.SmallDamageBurst(this._x,this._y);
  75.       }
  76.       else if(this._type == 7)
  77.       {
  78.          _root.game.SmallDamageBurst(this._x,this._y);
  79.       }
  80.       else if(this._type == 9)
  81.       {
  82.          var _loc3_ = new Vector();
  83.          _loc3_._x = this._x;
  84.          _loc3_._y = this._y;
  85.          _root.game.LeachPickupBubbles(_loc3_);
  86.          _root.game.Effect_Leech(this._x,this._y);
  87.       }
  88.    }
  89.    function GetDistance()
  90.    {
  91.       var _loc4_ = this._x - _root.bg._x;
  92.       var _loc3_ = this._y - _root.bg._y;
  93.       return Math.sqrt(_loc4_ * _loc4_ + _loc3_ * _loc3_);
  94.    }
  95.    function AddImmunity(strName)
  96.    {
  97.       this.arrEnemiesImmune.push(strName);
  98.    }
  99.    function GetImmune(strEnemyName)
  100.    {
  101.       var _loc2_ = 0;
  102.       while(_loc2_ < this.arrEnemiesImmune.length)
  103.       {
  104.          if(this.arrEnemiesImmune[_loc2_] == strEnemyName)
  105.          {
  106.             return true;
  107.          }
  108.          _loc2_ = _loc2_ + 1;
  109.       }
  110.       return false;
  111.    }
  112.    function PerformStarBurst()
  113.    {
  114.       var _loc3_ = 0;
  115.       while(_loc3_ < 360)
  116.       {
  117.          _root.game.SpawnStartBurstShard(this._x,this._y,_loc3_);
  118.          _loc3_ += 10;
  119.       }
  120.       this.removeCallback(this._name);
  121.       this.removeMovieClip();
  122.    }
  123.    function AddBusted(strBulletName)
  124.    {
  125.       this.arrBusted.push(strBulletName);
  126.       _root[strBulletName].SetMovement(this.moveX,this.moveY);
  127.       _root[strBulletName].removeCallback = undefined;
  128.    }
  129.    function PauseUnPauseBusted(blnPause)
  130.    {
  131.       var _loc3_ = 0;
  132.       while(_loc3_ < this.arrBusted.length)
  133.       {
  134.          _root[this.arrBusted[_loc3_]]._holdMovement = blnPause;
  135.          _loc3_ = _loc3_ + 1;
  136.       }
  137.    }
  138.    function CleanupBusted()
  139.    {
  140.       var _loc3_ = 0;
  141.       while(_loc3_ < this.arrBusted.length)
  142.       {
  143.          _root[this.arrBusted[_loc3_]].removeMovieClip();
  144.          _loc3_ = _loc3_ + 1;
  145.       }
  146.    }
  147.    function MoveBusted(vecMoveThis)
  148.    {
  149.       var _loc3_ = 0;
  150.       while(_loc3_ < this.arrBusted.length)
  151.       {
  152.          _root[this.arrBusted[_loc3_]]._x += vecMoveThis._x;
  153.          _root[this.arrBusted[_loc3_]]._y += vecMoveThis._y;
  154.          _loc3_ = _loc3_ + 1;
  155.       }
  156.    }
  157. }
  158.