home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Classicos / invaders.swf / scripts / frame_14 / DoAction.as
Encoding:
Text File  |  2007-03-20  |  6.1 KB  |  287 lines

  1. tellTarget("Spaceship")
  2. {
  3.    if(_visible)
  4.    {
  5.       if(_root.SsSound._currentframe == 1 && _currentframe == 1)
  6.       {
  7.          _root.SsSound.play();
  8.       }
  9.       if(_root.shipScore == 0 || _X < 0)
  10.       {
  11.          _root.shipScore = 50;
  12.          _visible = false;
  13.          _X = 540;
  14.          gotoAndStop(1);
  15.       }
  16.       if(_root.shipScore >= 50)
  17.       {
  18.          _X = _X - 4;
  19.       }
  20.    }
  21. }
  22. if(800 - 3 * alienHeight - 5 * aliensDead < getTimer() - time)
  23. {
  24.    if(newLife == 1)
  25.    {
  26.       tellTarget("LaserBase")
  27.       {
  28.          gotoAndStop(1);
  29.          _X = 95;
  30.       }
  31.       newLife = 0;
  32.       tonePos = 1;
  33.    }
  34.    else if(newLife)
  35.    {
  36.       newLife--;
  37.    }
  38.    else
  39.    {
  40.       Sound.gotoAndPlay("Tone" + tonePos);
  41.       tonePos++;
  42.       if(tonePos == 5)
  43.       {
  44.          tonePos = 1;
  45.       }
  46.       tellTarget("Spaceship")
  47.       {
  48.          if(!_visible && random(40) < 1)
  49.          {
  50.             _visible = true;
  51.          }
  52.       }
  53.       if(0 < shipScore && shipScore < 50)
  54.       {
  55.          shipScore -= 10;
  56.       }
  57.       allGone = true;
  58.       if(shifts == 1 && (497 < xMax || xMin < 23))
  59.       {
  60.          shifts = 0;
  61.          dir *= -1;
  62.          alienHeight += 14;
  63.       }
  64.       xMin = 400;
  65.       xMax = 0;
  66.       var i = 0;
  67.       while(i < 11)
  68.       {
  69.          var j = 1;
  70.          while(j < 6)
  71.          {
  72.             thisAlien = eval("Row" + j + i);
  73.             if(thisAlien._visible)
  74.             {
  75.                allGone = false;
  76.                tellTarget(thisAlien)
  77.                {
  78.                   if(_root.shifts == 0)
  79.                   {
  80.                      _Y = _root.alienHeight + 30 * this.j;
  81.                   }
  82.                   else
  83.                   {
  84.                      _X = _X + _root.dir;
  85.                      if(_currentframe == 1)
  86.                      {
  87.                         gotoAndStop(2);
  88.                      }
  89.                      else
  90.                      {
  91.                         gotoAndStop(1);
  92.                      }
  93.                   }
  94.                   if(320 < _Y)
  95.                   {
  96.                      _root.lives = 0;
  97.                   }
  98.                   if(_X < _root.xMin)
  99.                   {
  100.                      _root.xMin = _X;
  101.                   }
  102.                   if(_root.xMax < _X)
  103.                   {
  104.                      _root.xMax = _X;
  105.                   }
  106.                }
  107.             }
  108.             j++;
  109.          }
  110.          i++;
  111.       }
  112.       if(shifts == 0)
  113.       {
  114.          xMin = 400;
  115.          xMax = 0;
  116.          shifts = 1;
  117.       }
  118.       if(allGone)
  119.       {
  120.          score += 1000;
  121.          if(lives < 9)
  122.          {
  123.             lives++;
  124.          }
  125.          gotoAndPlay(6);
  126.       }
  127.    }
  128.    time = getTimer();
  129. }
  130. var i = 0;
  131. while(i < 11)
  132. {
  133.    var j = 1;
  134.    while(j < 6)
  135.    {
  136.       thisAlien = eval("Row" + j + i);
  137.       if(LaserFire.hitTest(thisAlien))
  138.       {
  139.          Sound.gotoAndPlay("Kill");
  140.          aliensDead++;
  141.          LaserFire._y = -20;
  142.          Explode._x = thisAlien._X;
  143.          Explode._y = thisAlien._y;
  144.          Explode.gotoAndPlay(2);
  145.          removeMovieClip(thisAlien);
  146.          if(j == 5 || j == 4)
  147.          {
  148.             score += 10;
  149.          }
  150.          else if(j == 3 || j == 2)
  151.          {
  152.             score += 20;
  153.          }
  154.          else
  155.          {
  156.             score += 40;
  157.          }
  158.       }
  159.       j++;
  160.    }
  161.    i++;
  162. }
  163. tellTarget("LaserFire")
  164. {
  165.    if(_visible)
  166.    {
  167.       _Y = _Y - 12;
  168.       if(280 < _Y)
  169.       {
  170.          var b = 10;
  171.          while(b < 50)
  172.          {
  173.             block = eval("_root.Block" + b);
  174.             if(block._visible && hitTest(block))
  175.             {
  176.                _Y = 0;
  177.                if(block._currentframe == 4)
  178.                {
  179.                   block._visible = false;
  180.                }
  181.                else
  182.                {
  183.                   block.nextFrame();
  184.                }
  185.             }
  186.             b++;
  187.          }
  188.       }
  189.       if(_Y < 40)
  190.       {
  191.          _visible = false;
  192.          _Y = 392;
  193.       }
  194.    }
  195. }
  196. if(LaserFire.hitTest(Spaceship) && Spaceship._currentframe == 1)
  197. {
  198.    stopAllSounds();
  199.    Sound.gotoAndPlay("KillSS");
  200.    setProperty("LaserFire", _Y, -20);
  201.    shipScore = random(6) + 1;
  202.    score += 50 * shipScore;
  203.    Spaceship.gotoAndStop(shipScore + 1);
  204.    SsSound.gotoAndStop(1);
  205.    shipScore = 40;
  206. }
  207. var fire = 4;
  208. while(0 < fire)
  209. {
  210.    if(!AlienFire4._visible && 1 < random(20) && fire == 4)
  211.    {
  212.       fire = 3;
  213.    }
  214.    alienFire = eval("AlienFire" + fire);
  215.    tellTarget(alienFire)
  216.    {
  217.       if(_visible)
  218.       {
  219.          if(this.fire == 4)
  220.          {
  221.             _Y = _Y + 12;
  222.          }
  223.          else
  224.          {
  225.             _Y = _Y + 8;
  226.          }
  227.          if(412 < _Y)
  228.          {
  229.             _visible = false;
  230.          }
  231.       }
  232.       else if(!_root.newLife && random(170 - _root.alienHeight) < 1)
  233.       {
  234.          var i = random(11);
  235.          var j = 5;
  236.          while(0 < j)
  237.          {
  238.             firePos = eval("_root.Row" + j + i);
  239.             if(firePos._visible)
  240.             {
  241.                _X = firePos._x;
  242.                _Y = firePos._y + 16;
  243.                _visible = true;
  244.                j = 0;
  245.             }
  246.             j--;
  247.          }
  248.       }
  249.       if(290 < _Y && _visible)
  250.       {
  251.          var b = 10;
  252.          while(b < 50)
  253.          {
  254.             block = eval("_root.Block" + b);
  255.             if(block._visible && hitTest(block))
  256.             {
  257.                _visible = false;
  258.                if(block._currentframe == 4)
  259.                {
  260.                   block._visible = false;
  261.                }
  262.                else
  263.                {
  264.                   block.nextFrame();
  265.                }
  266.             }
  267.             b++;
  268.          }
  269.       }
  270.    }
  271.    if(!newLife && alienFire._visible && alienFire.hitTest(LaserBase))
  272.    {
  273.       Sound.gotoAndPlay("Boom");
  274.       alienFire._visible = false;
  275.       setProperty("Life" + lives, _visible, false);
  276.       LaserBase.gotoAndStop(2);
  277.       newLife = 3;
  278.       lives--;
  279.    }
  280.    fire--;
  281. }
  282. if(lives == 0)
  283. {
  284.    LaserBase.gotoAndStop(2);
  285.    gotoAndPlay(16);
  286. }
  287.