home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Acao / fwg_knight.swf / scripts / __Packages / fwg / Enemy.as < prev    next >
Encoding:
Text File  |  2008-08-28  |  1.9 KB  |  80 lines

  1. class fwg.Enemy extends MovieClip
  2. {
  3.    var nR;
  4.    var nSpeed_x;
  5.    var nSpeed_y;
  6.    var nMoment;
  7.    var bFall;
  8.    var nDir;
  9.    var pTarget;
  10.    var __nHealth;
  11.    var mHealth;
  12.    var nHealth_max;
  13.    function Enemy()
  14.    {
  15.       super();
  16.       this.nR = 0;
  17.       this.nSpeed_x = 0;
  18.       this.nSpeed_y = 0;
  19.       this.nMoment = 0;
  20.       this.bFall = true;
  21.       this.nDir = 1;
  22.       this.pTarget = Global.GAME.pKnight;
  23.       Global.GAME.aEnemy.push(this);
  24.    }
  25.    function init()
  26.    {
  27.    }
  28.    function get nHealth()
  29.    {
  30.       return this.__nHealth;
  31.    }
  32.    function set nHealth(_nHealth)
  33.    {
  34.       this.__nHealth = _nHealth;
  35.       if(this.__nHealth <= 0)
  36.       {
  37.          this.mHealth._visible = false;
  38.       }
  39.       else
  40.       {
  41.          this.mHealth.mClip._xscale = this.__nHealth / this.nHealth_max * 100;
  42.       }
  43.    }
  44.    function setPos_0()
  45.    {
  46.       this._y = (Game.getBetween(this._x,this._y,this._parent,Global.GAME.mClip.mMid) + this._y) / 2 - 1;
  47.    }
  48.    function setPos_2(_n)
  49.    {
  50.       var _loc3_ = Game.getBetween(this._x - _n,this._y,this._parent,Global.GAME.mClip.mMid);
  51.       var _loc2_ = Game.getBetween(this._x + _n,this._y,this._parent,Global.GAME.mClip.mMid);
  52.       this._y = (Game.getBetween(this._x,this._y,this._parent,Global.GAME.mClip.mMid) + this._y) / 2 - 1;
  53.       this.nR = (Math.atan2(_loc3_ - _loc2_,_n * 2) + this.nR) / 2;
  54.    }
  55.    function falling()
  56.    {
  57.       if(this.bFall)
  58.       {
  59.          this.nSpeed_y += Game.nG;
  60.          if(Game.hitGround(this._x,this._y + this.nSpeed_y,this._parent,Global.GAME.mClip.mMid))
  61.          {
  62.             this.bFall = false;
  63.             this.nSpeed_y = 0;
  64.             this.fallEnd();
  65.          }
  66.          else
  67.          {
  68.             this._y += this.nSpeed_y;
  69.          }
  70.       }
  71.    }
  72.    function fallEnd()
  73.    {
  74.    }
  75.    function remove()
  76.    {
  77.       Common.removeArray(Global.GAME.aEnemy,this);
  78.    }
  79. }
  80.