home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Aventura / MindScape.swf / scripts / __Packages / Enemy8.as < prev    next >
Encoding:
Text File  |  2007-12-04  |  6.3 KB  |  201 lines

  1. class Enemy8 extends MovieClip
  2. {
  3.    var gravType = 1;
  4.    var outside = false;
  5.    function Enemy8()
  6.    {
  7.       super();
  8.    }
  9.    function onLoad()
  10.    {
  11.       var _loc1_ = this;
  12.       _root.bonusScore = 2500;
  13.       var _loc3_ = _loc1_._name.split("_");
  14.       _loc1_.id = Number(_loc3_[1]);
  15.       var _loc2_ = _loc1_._parent.spawnPoints[8][_loc1_.id].split(":");
  16.       _loc1_._x = _loc2_[0] * _loc1_._parent.cellsize;
  17.       _loc1_._y = _loc2_[1] * _loc1_._parent.cellsize;
  18.       _loc1_._parent.cells[_loc2_[0]][_loc2_[1]].spawn = undefined;
  19.       if(_loc1_._parent.cells[_loc2_[0]][_loc2_[1]].gravType > 0)
  20.       {
  21.          _loc1_.gravType = _loc1_._parent.cells[_loc2_[0]][_loc2_[1]].gravType;
  22.          _loc1_._rotation = 90 * (_loc1_.gravType - 1);
  23.       }
  24.       else
  25.       {
  26.          _loc1_.gravType = 1;
  27.       }
  28.       _loc1_.xCell = Math.floor(_loc1_._x / _loc1_._parent.cellsize + 0.5);
  29.       _loc1_.yCell = Math.floor(_loc1_._y / _loc1_._parent.cellsize + 0.5);
  30.       if(_loc1_._parent.triggers[_loc1_.id] == undefined)
  31.       {
  32.          _loc1_._parent.triggers[_loc1_.id] = new Object();
  33.       }
  34.       _loc1_._parent.triggers[_loc1_.id].clip = _loc1_;
  35.       _loc1_.createEmptyMovieClip("sprite",1);
  36.       _loc1_.sprite._y = _loc1_._parent.cellsize / 2;
  37.       if(!_loc1_._parent.triggers[_loc1_.id].pushed)
  38.       {
  39.          _loc1_.enemyStatus = "boss2_off";
  40.       }
  41.       else
  42.       {
  43.          _loc1_.enemyStatus = "boss2_on";
  44.       }
  45.       _loc1_.sprite.attachMovie(_loc1_.enemyStatus,"sprite",1);
  46.    }
  47.    function onEnterFrame()
  48.    {
  49.       var _loc1_ = this;
  50.       if(_loc1_.sprite.hitTest(_loc1_._parent.player) && _global.ctrlStatus[_global.ctrlAction])
  51.       {
  52.          if(_loc1_._parent._parent.triggerMemory != _loc1_.id + 1)
  53.          {
  54.             _loc1_.switchTrigger();
  55.             _loc1_._parent._parent.triggerMemory = _loc1_.id + 1;
  56.          }
  57.       }
  58.       else if(_loc1_._parent._parent.triggerMemory == _loc1_.id + 1)
  59.       {
  60.          _loc1_._parent._parent.triggerMemory = 0;
  61.       }
  62.       if(_loc1_._parent.cells[_loc1_.xCell][_loc1_.yCell].clip == undefined)
  63.       {
  64.          if(_loc1_._parent.cells[_loc1_.xCell][_loc1_.yCell].tile == 2)
  65.          {
  66.             _loc1_.yCell = _loc1_.yCell + 1;
  67.          }
  68.          else if(_loc1_._parent.cells[_loc1_.xCell][_loc1_.yCell].tile == 3)
  69.          {
  70.             _loc1_.xCell = _loc1_.xCell - 1;
  71.          }
  72.          else if(_loc1_._parent.cells[_loc1_.xCell][_loc1_.yCell].tile == 4)
  73.          {
  74.             _loc1_.yCell = _loc1_.yCell - 1;
  75.          }
  76.          else if(_loc1_._parent.cells[_loc1_.xCell][_loc1_.yCell].tile == 5)
  77.          {
  78.             _loc1_.xCell = _loc1_.xCell + 1;
  79.          }
  80.          _loc1_._parent.spawnPoints[8][_loc1_.id] = _loc1_.xCell + ":" + _loc1_.yCell;
  81.          _loc1_._parent.cells[_loc1_.xCell][_loc1_.yCell].spawn = 8;
  82.          _loc1_._parent.cells[_loc1_.xCell][_loc1_.yCell].spawnId = _loc1_.id;
  83.          ┬º┬ºpush(_loc1_.removeMovieClip());
  84.       }
  85.    }
  86.    function switchTrigger()
  87.    {
  88.       var _loc1_ = this;
  89.       _loc1_.soundFX = new Sound(_loc1_);
  90.       _loc1_.soundFX.attachSound("switchTrigger");
  91.       _loc1_.soundFX.start(0,0);
  92.       _loc1_.soundFX.setVolume(20);
  93.       if(_root.bonusScore >= 25)
  94.       {
  95.          _root.bonusScore -= 25;
  96.       }
  97.       if((_loc1_.id == 0 || _loc1_.id == 2 || _loc1_.id == 3 || _loc1_.id == 6) && !_loc1_._parent.triggerPile[0])
  98.       {
  99.          var _loc2_ = true;
  100.       }
  101.       else if((_loc1_.id == 1 || _loc1_.id == 4 || _loc1_.id == 5 || _loc1_.id == 7) && !_loc1_._parent.triggerPile[1])
  102.       {
  103.          _loc2_ = true;
  104.       }
  105.       else if((_loc1_.id == 9 || _loc1_.id == 12 || _loc1_.id == 13 || _loc1_.id == 15) && !_loc1_._parent.triggerPile[2])
  106.       {
  107.          _loc2_ = true;
  108.       }
  109.       else if((_loc1_.id == 8 || _loc1_.id == 10 || _loc1_.id == 11 || _loc1_.id == 14) && !_loc1_._parent.triggerPile[3])
  110.       {
  111.          _loc2_ = true;
  112.       }
  113.       else
  114.       {
  115.          _loc2_ = false;
  116.       }
  117.       if(_loc2_)
  118.       {
  119.          if(_loc1_.enemyStatus != "boss2_on")
  120.          {
  121.             _loc1_.enemyStatus = "boss2_on";
  122.             _loc1_._parent.triggers[_loc1_.id].pushed = true;
  123.          }
  124.          else
  125.          {
  126.             _loc1_.enemyStatus = "boss2_off";
  127.             _loc1_._parent.triggers[_loc1_.id].pushed = false;
  128.          }
  129.          if(_loc1_.id == 0)
  130.          {
  131.             _loc1_._parent.triggers[3].clip.remoteSwitch();
  132.          }
  133.          if(_loc1_.id == 2)
  134.          {
  135.             _loc1_._parent.triggers[0].clip.remoteSwitch();
  136.          }
  137.          if(_loc1_.id == 1)
  138.          {
  139.             _loc1_._parent.triggers[4].clip.remoteSwitch();
  140.          }
  141.          if(_loc1_.id == 4)
  142.          {
  143.             _loc1_._parent.triggers[5].clip.remoteSwitch();
  144.          }
  145.          if(_loc1_.id == 5)
  146.          {
  147.             _loc1_._parent.triggers[7].clip.remoteSwitch();
  148.          }
  149.          if(_loc1_.id == 9)
  150.          {
  151.             _loc1_._parent.triggers[12].clip.remoteSwitch();
  152.          }
  153.          if(_loc1_.id == 12)
  154.          {
  155.             _loc1_._parent.triggers[9].clip.remoteSwitch();
  156.          }
  157.          if(_loc1_.id == 13)
  158.          {
  159.             _loc1_._parent.triggers[15].clip.remoteSwitch();
  160.          }
  161.          if(_loc1_.id == 15)
  162.          {
  163.             _loc1_._parent.triggers[9].clip.remoteSwitch();
  164.          }
  165.          if(_loc1_.id == 8)
  166.          {
  167.             _loc1_._parent.triggers[10].clip.remoteSwitch();
  168.          }
  169.          if(_loc1_.id == 10)
  170.          {
  171.             _loc1_._parent.triggers[8].clip.remoteSwitch();
  172.             _loc1_._parent.triggers[11].clip.remoteSwitch();
  173.          }
  174.          if(_loc1_.id == 11)
  175.          {
  176.             _loc1_._parent.triggers[14].clip.remoteSwitch();
  177.          }
  178.          if(_loc1_.id == 14)
  179.          {
  180.             _loc1_._parent.triggers[8].clip.remoteSwitch();
  181.          }
  182.          _loc1_.sprite.attachMovie(_loc1_.enemyStatus,"sprite",1);
  183.       }
  184.    }
  185.    function remoteSwitch()
  186.    {
  187.       var _loc1_ = this;
  188.       if(_loc1_.enemyStatus != "boss2_on")
  189.       {
  190.          _loc1_.enemyStatus = "boss2_on";
  191.          _loc1_._parent.triggers[_loc1_.id].pushed = true;
  192.       }
  193.       else
  194.       {
  195.          _loc1_.enemyStatus = "boss2_off";
  196.          _loc1_._parent.triggers[_loc1_.id].pushed = false;
  197.       }
  198.       _loc1_.sprite.attachMovie(_loc1_.enemyStatus,"sprite",1);
  199.    }
  200. }
  201.