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

  1. Boss1 = function()
  2. {
  3.    super();
  4.    this._x = 800;
  5.    this._y = 200;
  6.    this.vie = 5000;
  7.    this.tombe = false;
  8.    this.trajectoire = "cercle";
  9.    this.vitesse = 5;
  10.    this.savex = this._x;
  11.    this.savey = this._y;
  12.    this.rayonx = 0;
  13.    this.rayony = 20;
  14.    this.attachMovie("LifeBossBarClip","lifeBossBar",1);
  15.    this.lifeBossBar.init(-100,130,100,10,"0xFF0000","0xFFFFFF");
  16. };
  17. Boss1.prototype = new Ennemi();
  18. Object.registerClass("Boss1ClipHaut",Boss1);
  19. Boss1.prototype.onEnterFrame = function()
  20. {
  21.    if(this._x == 400 && !this.bossStop)
  22.    {
  23.       this.bossStop = this.bossStop + 1;
  24.       this.vitesse = 0;
  25.    }
  26.    if(this.vie > 0)
  27.    {
  28.       this.move();
  29.       this.tirnormal();
  30.       this.testTirVaisseau();
  31.       this.clignote();
  32.    }
  33.    else
  34.    {
  35.       this.explose();
  36.       this._parent.score += 500;
  37.       if(this.tombe)
  38.       {
  39.          this._x += -5;
  40.          this._rotation -= 0.2;
  41.          this._y += 1;
  42.          if(this._x < -250)
  43.          {
  44.             this.removeMovieClip();
  45.          }
  46.       }
  47.    }
  48. };
  49. Boss1.prototype.testTirVaisseau = function(bool)
  50. {
  51.    var j = 0;
  52.    while(j < _global.tabTirVaisseau.length)
  53.    {
  54.       var i = _global.tabTirVaisseau[j];
  55.       clip = this._parent.tirVaisseauClip["tirVaisseau" + i];
  56.       if(clip._currentframe < 3)
  57.       {
  58.          if(this.hitTest(clip._x,clip._y,true))
  59.          {
  60.             this.vie -= clip.degats;
  61.             clip.vitesse = 0;
  62.             this._parent.score += 500;
  63.             this.touche = true;
  64.             clip.play();
  65.          }
  66.       }
  67.       j++;
  68.    }
  69. };
  70. Boss1.prototype.explose = function()
  71. {
  72.    this._alpha = 100;
  73.    this.numExp = this.numExp + 1;
  74.    this.attachMovie("ExplosionClip","explosion" + this.numExp,this.numExp);
  75.    clip = this["explosion" + this.numExp];
  76.    clip._x = random(250) * Math.cos(Math.random() * 3.141592653589793 * 2);
  77.    clip._y = random(150) * Math.sin(Math.random() * 3.141592653589793 * 2);
  78.    clip._xscale = random(100) + 50;
  79.    clip._yscale = clip._xscale;
  80.    clip._rotation = random(500);
  81.    if(this.numExp > 40)
  82.    {
  83.       this.savey = this._y;
  84.       this.tombe = true;
  85.    }
  86. };
  87. Boss1.prototype.tirnormal = function()
  88. {
  89.    if(random(5) == 0)
  90.    {
  91.       var r = random(6);
  92.       if(r < 4)
  93.       {
  94.          i = this.chercheTirLibre();
  95.          if(i == -1)
  96.          {
  97.             return 0;
  98.          }
  99.          this._parent.tirEnnemiClip.attachMovie("TirDirigeClip","tirEnnemi" + i,_global.tirEnnemiDepth + i);
  100.          var clip = this._parent.tirEnnemiClip["tirEnnemi" + i];
  101.          if(r == 0)
  102.          {
  103.             clip._x = this._x - 170;
  104.             clip._y = this._y + 50;
  105.          }
  106.          else if(r == 1)
  107.          {
  108.             clip._x = this._x + 100;
  109.             clip._y = this._y - 90;
  110.          }
  111.          else if(r == 2)
  112.          {
  113.             clip._x = this._x - 95;
  114.             clip._y = this._y + 40;
  115.          }
  116.          else if(r == 3)
  117.          {
  118.             clip._x = this._x + 40;
  119.             clip._y = this._y - 50;
  120.          }
  121.          clip.angle = Math.atan2(this._parent.vesso._y - clip._y,this._parent.vesso._x - clip._x);
  122.          clip.vitesse = 15;
  123.       }
  124.       else
  125.       {
  126.          var angle = Math.atan2(this._parent.vesso._y - this._y,this._parent.vesso._x - this._x);
  127.          var j = 0;
  128.          while(j < 3)
  129.          {
  130.             i = this.chercheTirLibre();
  131.             if(i == -1)
  132.             {
  133.                return 0;
  134.             }
  135.             this._parent.tirEnnemiClip.attachMovie("TirDirigeClip","tirEnnemi" + i,_global.tirEnnemiDepth + i);
  136.             var clip = this._parent.tirEnnemiClip["tirEnnemi" + i];
  137.             if(r == 4)
  138.             {
  139.                if(j == 0)
  140.                {
  141.                   clip._x = this._x - 25;
  142.                   clip._y = this._y + 10;
  143.                }
  144.                if(j == 1)
  145.                {
  146.                   clip._x = this._x - 25;
  147.                   clip._y = this._y + 25;
  148.                }
  149.                if(j == 2)
  150.                {
  151.                   clip._x = this._x - 25;
  152.                   clip._y = this._y + 40;
  153.                }
  154.             }
  155.             else if(r == 5)
  156.             {
  157.                if(j == 0)
  158.                {
  159.                   clip._x = this._x + 55;
  160.                   clip._y = this._y + 5;
  161.                }
  162.                if(j == 1)
  163.                {
  164.                   clip._x = this._x + 70;
  165.                   clip._y = this._y - 5;
  166.                }
  167.                if(j == 2)
  168.                {
  169.                   clip._x = this._x + 85;
  170.                   clip._y = this._y - 10;
  171.                }
  172.             }
  173.             clip.angle = angle;
  174.             clip.vitesse = 15;
  175.             j++;
  176.          }
  177.       }
  178.    }
  179. };
  180.