home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Diversos / dragon.swf / scripts / DefineSprite_147_air_enemy / frame_1 / DoAction.as
Encoding:
Text File  |  2008-09-12  |  1.5 KB  |  89 lines

  1. function step()
  2. {
  3.    m_target_x = _parent._parent.dragon_head._x;
  4.    m_target_y = _parent._parent.dragon_head._y;
  5.    var _loc2_ = 2;
  6.    if(!isDead())
  7.    {
  8.       updateCannon();
  9.       if(m_target_x > _X && vx < _loc2_)
  10.       {
  11.          vx += 0.05;
  12.       }
  13.       else if(m_target_x < _X && vx > - _loc2_)
  14.       {
  15.          vx -= 0.05;
  16.       }
  17.       if(m_target_y > _Y && vy < _loc2_)
  18.       {
  19.          vy += 0.02;
  20.       }
  21.       else if(m_target_y < _Y && vy > - _loc2_)
  22.       {
  23.          vy -= 0.02;
  24.       }
  25.       if(vx > 0)
  26.       {
  27.          _xscale = -100;
  28.       }
  29.       else
  30.       {
  31.          _xscale = 100;
  32.       }
  33.    }
  34.    else
  35.    {
  36.       vy += 0.08;
  37.       _rotation = _rotation - 0.2;
  38.    }
  39.    updatePosition();
  40.    if(_Y > _parent._parent.g_ground + 100)
  41.    {
  42.       destroy();
  43.    }
  44. }
  45. function updateCannon()
  46. {
  47.    if(shootTimer-- < 0)
  48.    {
  49.       shootTimer = 300;
  50.       _parent._parent.shootAtDragon(_X,_Y,2);
  51.    }
  52. }
  53. function updatePosition()
  54. {
  55.    _X = _X + vx;
  56.    _Y = _Y + vy;
  57. }
  58. function takeDamage(amt, xp, yp)
  59. {
  60.    hp -= amt;
  61.    if(hp < 0)
  62.    {
  63.       hp = 0;
  64.    }
  65.    var _loc2_ = _parent._parent.addObj("dmg_text",_parent._parent.score_layer,_parent._parent.getNextScoreLevel());
  66.    _loc2_._x = xp;
  67.    _loc2_._y = yp;
  68.    _loc2_.val = amt;
  69. }
  70. function isDead()
  71. {
  72.    return hp == 0;
  73. }
  74. function setHP(num)
  75. {
  76.    hp = num;
  77. }
  78. function destroy()
  79. {
  80.    _parent._parent.removeEnemy(this);
  81. }
  82. m_target_x = 0;
  83. m_target_y = 0;
  84. vx = -0.6;
  85. vy = 0;
  86. hp = 2;
  87. shootTimer = 300;
  88. etype = "dragon_archer";
  89.