home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Acao / germ_roundup.swf / scripts / __Packages / BuildingPart.as < prev    next >
Encoding:
Text File  |  2007-03-20  |  2.5 KB  |  69 lines

  1. class BuildingPart extends smashing.Renderable
  2. {
  3.    var mcGerm = null;
  4.    function BuildingPart()
  5.    {
  6.       super();
  7.    }
  8.    function init(oHandler, bObst, nType, oBData, segment)
  9.    {
  10.       var _loc1_ = this;
  11.       var _loc2_ = bObst;
  12.       _loc1_.hasObstacle = _loc2_;
  13.       _loc1_.bhandler = oHandler;
  14.       _loc1_.oData = oBData;
  15.       _loc1_.nSegment = segment;
  16.       if(_loc2_ == true)
  17.       {
  18.          _loc1_.gotoAndStop("obst");
  19.       }
  20.       else
  21.       {
  22.          _loc1_.gotoAndStop("open");
  23.       }
  24.       _loc1_.gfx.gotoAndStop(nType);
  25.       _loc1_.aLines = [];
  26.       if(_loc2_ == true)
  27.       {
  28.          if(_loc1_.gfx.p3 == undefined)
  29.          {
  30.             if(_loc1_.gfx.p2 == undefined)
  31.             {
  32.                _loc1_.aLines.push(new smashing.Line(_loc1_.gfx.p0._x + _loc1_.x,_loc1_.gfx.p0._y + _loc1_.y,_loc1_.gfx.p1._x + _loc1_.x,_loc1_.gfx.p1._y + _loc1_.y));
  33.             }
  34.             else
  35.             {
  36.                _loc1_.aLines.push(new smashing.Line(_loc1_.gfx.p0._x + _loc1_.x,_loc1_.gfx.p0._y + _loc1_.y,_loc1_.gfx.p1._x + _loc1_.x,_loc1_.gfx.p1._y + _loc1_.y));
  37.                _loc1_.aLines.push(new smashing.Line(_loc1_.gfx.p1._x + _loc1_.x,_loc1_.gfx.p1._y + _loc1_.y,_loc1_.gfx.p2._x + _loc1_.x,_loc1_.gfx.p1._y + _loc1_.y));
  38.             }
  39.          }
  40.          else
  41.          {
  42.             _loc1_.aLines.push(new smashing.Line(_loc1_.gfx.p0._x + _loc1_.x,_loc1_.gfx.p0._y + _loc1_.y,_loc1_.gfx.p1._x + _loc1_.x,_loc1_.gfx.p1._y + _loc1_.y));
  43.             _loc1_.aLines.push(new smashing.Line(_loc1_.gfx.p1._x + _loc1_.x,_loc1_.gfx.p1._y + _loc1_.y,_loc1_.gfx.p2._x + _loc1_.x,_loc1_.gfx.p2._y + _loc1_.y));
  44.             _loc1_.aLines.push(new smashing.Line(_loc1_.gfx.p2._x + _loc1_.x,_loc1_.gfx.p2._y + _loc1_.y,_loc1_.gfx.p3._x + _loc1_.x,_loc1_.gfx.p3._y + _loc1_.y));
  45.          }
  46.       }
  47.    }
  48.    function render()
  49.    {
  50.       var _loc1_ = this;
  51.       var _loc2_ = smashing.Viewport.getPos(_loc1_);
  52.       if(_loc2_.x < BuildingHandler.leftEdge || _loc2_.x > smashing.Viewport.halfWidth)
  53.       {
  54.          var _loc3_ = false;
  55.          _loc1_.bhandler.removeBuilding(_loc1_,_loc3_);
  56.       }
  57.       else if(_loc2_.y > smashing.Viewport.halfHeight || _loc2_.y < BuildingHandler.topEdge - _loc1_.spacerY._y)
  58.       {
  59.          _loc1_._visible = false;
  60.       }
  61.       else
  62.       {
  63.          _loc1_._visible = true;
  64.          _loc1_._x = _loc2_.x + smashing.Viewport.centerX;
  65.          _loc1_._y = _loc2_.y + smashing.Viewport.centerY;
  66.       }
  67.    }
  68. }
  69.