home *** CD-ROM | disk | FTP | other *** search
/ Champak 106 / Vol 106.iso / games / rain_for.swf / scripts / __Packages / BuildingPart.as < prev    next >
Encoding:
Text File  |  2010-04-12  |  1.9 KB  |  71 lines

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