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

  1. function updateStickies(sticky)
  2. {
  3.    if(++m_stickyNdx >= m_maxStickies)
  4.    {
  5.       m_stickyNdx = 0;
  6.    }
  7.    var _loc1_ = m_stickies[m_stickyNdx];
  8.    _loc1_.unloadMovie();
  9.    m_stickies[m_stickyNdx] = sticky;
  10. }
  11. function step()
  12. {
  13.    if(hp_bar._alpha > 0)
  14.    {
  15.       hp_bar._alpha -= 5;
  16.    }
  17.    if(timeToTarget-- < 0)
  18.    {
  19.       m_target_x = random(_parent._parent.g_width);
  20.       m_target_y = random(_parent._parent.g_ground);
  21.       timeToTarget = 200;
  22.    }
  23.    var _loc2_ = 2;
  24.    if(!isDead())
  25.    {
  26.       updateCannon();
  27.       if(m_target_x > _X && vx < _loc2_)
  28.       {
  29.          vx += 0.05;
  30.       }
  31.       else if(m_target_x < _X && vx > - _loc2_)
  32.       {
  33.          vx -= 0.05;
  34.       }
  35.       if(m_target_y > _Y && vy < _loc2_)
  36.       {
  37.          vy += 0.02;
  38.       }
  39.       else if(m_target_y < _Y && vy > - _loc2_)
  40.       {
  41.          vy -= 0.02;
  42.       }
  43.       if(vx > 0)
  44.       {
  45.          _xscale = -100;
  46.       }
  47.       else
  48.       {
  49.          _xscale = 100;
  50.       }
  51.    }
  52.    else
  53.    {
  54.       vy += 0.08;
  55.       _rotation = _rotation - 0.2;
  56.    }
  57.    updatePosition();
  58.    if(_Y > _parent._parent.g_ground + 100)
  59.    {
  60.       destroy();
  61.    }
  62. }
  63. function updateCannon()
  64. {
  65.    if(shootTimer-- < 0)
  66.    {
  67.       shootTimer = 300;
  68.       _parent._parent.shootAtDragonProjectile(_X,_Y,2,"proj_enemy_ice");
  69.    }
  70. }
  71. function updatePosition()
  72. {
  73.    _X = _X + vx;
  74.    _Y = _Y + vy;
  75. }
  76. function takeDamage(amt, xp, yp)
  77. {
  78.    if(!killed)
  79.    {
  80.       hp -= amt;
  81.       if(hp <= 0)
  82.       {
  83.          killed = true;
  84.          hp = 0;
  85.          var _loc3_ = _parent._parent.addObj("ammo_box_ice",_parent._parent.ammo_layer,_parent._parent.getNextAmmoLevel());
  86.          _loc3_._x = _X;
  87.          _loc3_._y = _Y;
  88.          _parent._parent.addScore(400,_X,_Y);
  89.       }
  90.       else
  91.       {
  92.          hp_bar.bar._width = hp / max_hp * 100;
  93.          hp_bar._alpha = 100;
  94.       }
  95.       if(_parent._parent.g_dmg_text_on)
  96.       {
  97.          var _loc2_ = _parent._parent.addObj("dmg_text",_parent._parent.score_layer,_parent._parent.getNextScoreLevel());
  98.          _loc2_._x = xp;
  99.          _loc2_._y = yp;
  100.          _loc2_.val = amt;
  101.       }
  102.    }
  103. }
  104. function isDead()
  105. {
  106.    return hp == 0;
  107. }
  108. function setHP(num)
  109. {
  110.    hp = num;
  111. }
  112. function destroy()
  113. {
  114.    _parent._parent.removeEnemy(this);
  115. }
  116. m_target_x = 0;
  117. m_target_y = 0;
  118. vx = -0.6;
  119. vy = 0;
  120. max_hp = Math.floor(50 * (1 + _parent._parent.g_level / 100));
  121. hp = max_hp;
  122. shootTimer = 300;
  123. etype = "ice";
  124. timeToTarget = 0;
  125. killed = false;
  126. var m_maxStickies = 3;
  127. var m_stickies = new Array(m_maxStickies);
  128. var m_stickyNdx = 0;
  129.