home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Nave / AitchuTheAbduction.swf / scripts / frame_11 / DoAction.as
Encoding:
Text File  |  2005-11-10  |  1.8 KB  |  83 lines

  1. Ennemi = function()
  2. {
  3.    super();
  4.    this.touche = false;
  5.    this.saveToucheTime = -1000;
  6.    this.vie = 100;
  7. };
  8. Ennemi.prototype = new Sprite();
  9. Ennemi.prototype.onEnterFrame = function()
  10. {
  11.    super.onEnterFrame();
  12.    if(this.vie > 0)
  13.    {
  14.       this.tirnormal();
  15.       this.testTirVaisseau();
  16.       this.clignote();
  17.    }
  18. };
  19. Ennemi.prototype.testTirVaisseau = function()
  20. {
  21.    var len = _global.tabTirVaisseau.length;
  22.    var j = 0;
  23.    while(j < len)
  24.    {
  25.       var i = _global.tabTirVaisseau[j];
  26.       clip = this._parent.tirVaisseauClip["tirVaisseau" + i];
  27.       if(clip.touche != true)
  28.       {
  29.          if(this.hitTest(clip._x,clip._y,false))
  30.          {
  31.             clip.touche = true;
  32.             this.vie -= clip.degats;
  33.             this._parent.score += 300;
  34.             if(this.vie < 1)
  35.             {
  36.                this.vitesse = 30;
  37.                this.trajectoire = "droite";
  38.                this.angle = 3.141592653589793;
  39.                this._alpha = 100;
  40.                this.saveToucheTime = -5000;
  41.                this.play();
  42.             }
  43.             else
  44.             {
  45.                this.touche = true;
  46.             }
  47.             clip.angle = 3.141592653589793;
  48.             clip.play();
  49.          }
  50.       }
  51.       j++;
  52.    }
  53. };
  54. Ennemi.prototype.clignote = function()
  55. {
  56.    if(this.touche == true)
  57.    {
  58.       this.saveToucheTime = getTimer();
  59.    }
  60.    if(getTimer() < this.saveToucheTime + 500)
  61.    {
  62.       this._alpha = 50 + 50 * Math.cos(this.tmp++);
  63.       this.touche = false;
  64.    }
  65.    else
  66.    {
  67.       this._alpha = 100;
  68.    }
  69. };
  70. Ennemi.prototype.chercheTirLibre = function()
  71. {
  72.    var i = 0;
  73.    while(this._parent.tirEnnemiClip["tirEnnemi" + i])
  74.    {
  75.       i++;
  76.       if(i == _global.maxTirEnnemi)
  77.       {
  78.          return -1;
  79.       }
  80.    }
  81.    return i;
  82. };
  83.