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

  1. class Item2 extends MovieClip
  2. {
  3.    var collected = false;
  4.    function Item2()
  5.    {
  6.       super();
  7.    }
  8.    function onLoad()
  9.    {
  10.       var _loc1_ = this;
  11.       var tmpArr = _loc1_._name.split("_");
  12.       var id = Number(tmpArr[1]);
  13.       var tmpArr2 = _loc1_._parent.itemPoints[2][id].split(":");
  14.       _loc1_._x = tmpArr2[0] * _loc1_._parent.cellsize;
  15.       _loc1_._y = tmpArr2[1] * _loc1_._parent.cellsize;
  16.       _loc1_.xCell = Math.floor(_loc1_._x / _loc1_._parent.cellsize + 0.5);
  17.       _loc1_.yCell = Math.floor(_loc1_._y / _loc1_._parent.cellsize + 0.5);
  18.       var _loc2_ = _loc1_._parent.cells[_loc1_.xCell][_loc1_.yCell].gravType;
  19.       if(_loc2_ <= 4)
  20.       {
  21.          if(_loc2_ == 0)
  22.          {
  23.             _loc2_ = 1;
  24.          }
  25.          _loc1_._rotation = 90 * (_loc2_ - 1);
  26.       }
  27.       else
  28.       {
  29.          _loc1_._rotation = 90 * (_loc2_ - 1) + 45;
  30.       }
  31.       _loc1_.createEmptyMovieClip("sprite",1);
  32.       if(_loc1_._parent.cells[_loc1_.xCell][_loc1_.yCell].r != undefined && _loc1_._parent.cells[_loc1_.xCell][_loc1_.yCell].r > 0)
  33.       {
  34.          var _loc3_ = _loc1_._parent.cells[_loc1_.xCell][_loc1_.yCell].r;
  35.       }
  36.       else
  37.       {
  38.          _loc3_ = Math.floor(random(11)) + 1;
  39.       }
  40.       _loc1_.sprite.attachMovie("item2_" + _loc3_,"sprite",1);
  41.       _loc1_._parent.cells[_loc1_.xCell][_loc1_.yCell].r = _loc3_;
  42.    }
  43.    function onEnterFrame()
  44.    {
  45.       var _loc1_ = this;
  46.       var _loc2_ = _root;
  47.       if(_loc1_._parent.cells[_loc1_.xCell][_loc1_.yCell].clip == undefined)
  48.       {
  49.          ┬º┬ºpush(_loc1_.removeMovieClip());
  50.       }
  51.       if(_loc1_.hitTest(_loc1_._parent.player) && _loc1_._parent.cells[_loc1_.xCell][_loc1_.yCell].itemAlive)
  52.       {
  53.          _loc2_.score += 10;
  54.          _loc2_.itemsCollected[1] = _loc2_.itemsCollected[1] + 1;
  55.          if(_loc2_.itemsCollected[1] >= _loc2_.itemsTotalLvl[1] && _loc2_.currLvl == 8)
  56.          {
  57.             _loc2_.score += 100;
  58.             _loc2_.attachMovie("Message","msg",5);
  59.             _loc2_.msg.msgText = "You\'ve collected all cogs and screws!";
  60.             _loc2_.medalsEarned[1] = true;
  61.             _loc2_.kongregateStats.submit("ScrewBall",1);
  62.          }
  63.          _loc1_._parent.cells[_loc1_.xCell][_loc1_.yCell].itemAlive = false;
  64.       }
  65.       if(!_loc1_._parent.cells[_loc1_.xCell][_loc1_.yCell].itemAlive)
  66.       {
  67.          if(!_loc1_.collected)
  68.          {
  69.             _loc1_.soundFX = new Sound(_loc1_);
  70.             _loc1_.soundFX.attachSound("collect_item");
  71.             _loc1_.soundFX.start(0,0);
  72.             _loc1_.soundFX.setVolume(50);
  73.             _loc1_.collected = true;
  74.          }
  75.          _loc1_._alpha += (- _loc1_._alpha) / 3;
  76.          _loc1_._xscale += (150 - _loc1_._xscale) / 3;
  77.          _loc1_._yscale = _loc1_._xscale;
  78.          if(_loc1_._alpha < 5)
  79.          {
  80.             ┬º┬ºpush(_loc1_.removeMovieClip());
  81.          }
  82.       }
  83.    }
  84. }
  85.