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

  1. class Enemy_Leecher extends MovieClip
  2. {
  3.    var gunFlagOne;
  4.    var flagExplode;
  5.    var guns;
  6.    var haltMovie;
  7.    var safetyTurn;
  8.    var numLife;
  9.    var numSpeed;
  10.    var numFramesToTurn;
  11.    var numAmountToTurn;
  12.    var minFramesToHoldTurning;
  13.    var strCreatedBy;
  14.    var intState;
  15.    var rotateAngle;
  16.    var rotateSpeed;
  17.    var _type;
  18.    var intDamageCounter;
  19.    var blnVoid;
  20.    var enemyOff;
  21.    var numLastAngle;
  22.    function Enemy_Leecher()
  23.    {
  24.       super();
  25.       this.gunFlagOne = true;
  26.       this.flagExplode = false;
  27.       this.guns = new Array();
  28.       this.haltMovie = false;
  29.       this.safetyTurn = false;
  30.       this.numLife = 1;
  31.       this.gotoAndPlay(this.numLife);
  32.       this.numSpeed = 6;
  33.       this.numFramesToTurn = 0;
  34.       this.numAmountToTurn = 0;
  35.       this.minFramesToHoldTurning = 0;
  36.       this.strCreatedBy = "";
  37.       this.intState = 3;
  38.       this.rotateAngle = 0;
  39.       this.rotateSpeed = 0.1;
  40.       this._type = 2;
  41.       this.intDamageCounter = 1;
  42.       this.blnVoid = false;
  43.    }
  44.    function onEnterFrame()
  45.    {
  46.       if(!this.enemyOff)
  47.       {
  48.          if(this.intState == 3 || this.intState == 5)
  49.          {
  50.             if(this.haltMovie == false)
  51.             {
  52.                this.numLastAngle = this.GetAnglePos();
  53.                this.MoveMe();
  54.                var _loc10_ = this.AboutToExit();
  55.             }
  56.             if(this.intState == 3)
  57.             {
  58.                if(this.minFramesToHoldTurning > 0)
  59.                {
  60.                   this.minFramesToHoldTurning = this.minFramesToHoldTurning - 1;
  61.                }
  62.                else
  63.                {
  64.                   var _loc3_ = new Vector();
  65.                   _loc3_._x = _root.avatar._x - this._x;
  66.                   _loc3_._y = _root.avatar._y - this._y;
  67.                   var _loc6_ = Math.atan2(_loc3_._y,_loc3_._x);
  68.                   var _loc7_ = 360 * _loc6_ / 6.283185307179586;
  69.                   this._rotation = _loc7_;
  70.                }
  71.                if(_root.game.intAssembledState == 0)
  72.                {
  73.                   if(this.GetDistance2Avatar() <= 60)
  74.                   {
  75.                      this.gotoAndStop(11);
  76.                      var _loc4_ = new Vector();
  77.                      _loc4_._x = _root.avatar._x;
  78.                      _loc4_._y = _root.avatar._y;
  79.                      _root.game.CreateEffect("effect",_loc4_,true,"avatar");
  80.                      this.intState = 6;
  81.                   }
  82.                }
  83.             }
  84.          }
  85.          else if(this.intState == 6)
  86.          {
  87.             _loc3_ = new Vector();
  88.             _loc3_._x = _root.avatar._x - this._x;
  89.             _loc3_._y = _root.avatar._y - this._y;
  90.             _loc6_ = Math.atan2(_loc3_._y,_loc3_._x);
  91.             _loc7_ = 360 * _loc6_ / 6.283185307179586;
  92.             this._rotation = _loc7_;
  93.             this.startLeeching();
  94.             this.intDamageCounter = this.intDamageCounter - 1;
  95.             if(this.intDamageCounter == 0)
  96.             {
  97.                _root.ReportAvatarDamage(0.66666);
  98.                this.intDamageCounter = 15;
  99.             }
  100.          }
  101.          else if(this.intState == 2)
  102.          {
  103.             var _loc5_ = _root[this.strCreatedBy]._width + 2;
  104.             var _loc9_ = _loc5_ * Math.cos(this.rotateAngle) + _root[this.strCreatedBy]._x;
  105.             var _loc8_ = _loc5_ * Math.sin(this.rotateAngle) + _root[this.strCreatedBy]._y;
  106.             this.rotateAngle += this.rotateSpeed;
  107.             if(this.rotateAngle > 360)
  108.             {
  109.                this.rotateAngle = 0;
  110.             }
  111.             this._x = _loc9_;
  112.             this._y = _loc8_;
  113.             this._rotation = _root[this.strCreatedBy]._rotation;
  114.             if(this.GetDistance2Avatar() <= 85)
  115.             {
  116.                this.intState = 3;
  117.             }
  118.          }
  119.       }
  120.    }
  121.    function Explode()
  122.    {
  123.       this.gotoAndPlay(2);
  124.       this.intState = 4;
  125.    }
  126.    function Terminate()
  127.    {
  128.       this.blnVoid = true;
  129.       this.Explode();
  130.    }
  131.    function KillMe()
  132.    {
  133.       _root[this._name].leechBeam.circMask._width = 0;
  134.       if(this.blnVoid == false)
  135.       {
  136.          _root.ReportAvatarDamage(8);
  137.       }
  138.       _root.ReportDeath(this._name);
  139.       _root[this.strCreatedBy].ReportSeekerDeath(this._name);
  140.       this.removeMovieClip();
  141.    }
  142.    function SetCreatedFrom(strFrom)
  143.    {
  144.       this.strCreatedBy = strFrom;
  145.    }
  146.    function ReceiveDamage(amountDamage)
  147.    {
  148.       var _loc3_ = false;
  149.       this.numLife -= amountDamage;
  150.       if(this.numLife < 1)
  151.       {
  152.          _loc3_ = true;
  153.          _root.ReportDeath(this._name);
  154.          _root[this.strCreatedBy].ReportSeekerDeath(this._name);
  155.          this.removeMovieClip();
  156.       }
  157.       else
  158.       {
  159.          this.gotoAndStop(this.numLife);
  160.       }
  161.       return _loc3_;
  162.    }
  163.    function RemoveGun(strName)
  164.    {
  165.       var _loc2_ = 0;
  166.       while(_loc2_ < this.guns.length)
  167.       {
  168.          if(strName == this.guns[_loc2_].name)
  169.          {
  170.             this.guns.splice(_loc2_,1);
  171.             break;
  172.          }
  173.          _loc2_ = _loc2_ + 1;
  174.       }
  175.    }
  176.    function startLeeching()
  177.    {
  178.       _root[this._name].leechBeam.circMask._width = this.GetDistance2Avatar();
  179.    }
  180.    function MoveMe()
  181.    {
  182.       var _loc2_ = new Vector();
  183.       _loc2_._x = Math.cos(3.141592653589793 * this._rotation / 180) * this.numSpeed + this._x;
  184.       _loc2_._y = Math.sin(3.141592653589793 * this._rotation / 180) * this.numSpeed + this._y;
  185.       this._x = _loc2_._x;
  186.       this._y = _loc2_._y;
  187.    }
  188.    function GetAnglePos()
  189.    {
  190.       var _loc3_ = new Vector();
  191.       _loc3_._x = this._x - _root.bg._x;
  192.       _loc3_._y = this._y - _root.bg._y;
  193.       var _loc4_ = Math.atan2(_loc3_._y,_loc3_._x);
  194.       var _loc5_ = 360 * _loc4_ / 6.283185307179586;
  195.       return _loc5_;
  196.    }
  197.    function GetDistance()
  198.    {
  199.       var _loc4_ = this._x - _root.bg._x;
  200.       var _loc3_ = this._y - _root.bg._y;
  201.       return Math.sqrt(_loc4_ * _loc4_ + _loc3_ * _loc3_);
  202.    }
  203.    function GetDistance2Avatar()
  204.    {
  205.       var _loc4_ = this._x - _root.avatar._x;
  206.       var _loc3_ = this._y - _root.avatar._y;
  207.       return Math.sqrt(_loc4_ * _loc4_ + _loc3_ * _loc3_);
  208.    }
  209.    function GetDistance2Source()
  210.    {
  211.       var _loc4_ = this._x - _root[this.strCreatedBy]._x;
  212.       var _loc3_ = this._y - _root[this.strCreatedBy]._y;
  213.       return Math.sqrt(_loc4_ * _loc4_ + _loc3_ * _loc3_);
  214.    }
  215.    function AboutToExit()
  216.    {
  217.       var _loc5_ = false;
  218.       var _loc6_ = Math.cos(3.141592653589793 * this._rotation / 180) * (this._width + 30 * this.numSpeed) + this._x;
  219.       var _loc7_ = Math.sin(3.141592653589793 * this._rotation / 180) * (this._width + 30 * this.numSpeed) + this._y;
  220.       var _loc4_ = _loc6_ - _root.bg._x;
  221.       var _loc3_ = _loc7_ - _root.bg._y;
  222.       if(Math.sqrt(_loc4_ * _loc4_ + _loc3_ * _loc3_) > _root.bg.inside._width / 2)
  223.       {
  224.          _loc5_ = true;
  225.       }
  226.       return _loc5_;
  227.    }
  228.    function TurnOff()
  229.    {
  230.       this.enemyOff = true;
  231.    }
  232.    function TurnOn()
  233.    {
  234.       this.enemyOff = false;
  235.    }
  236. }
  237.