home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Aventura / climatechaos.swf / scripts / __Packages / SquareBuilding.as < prev    next >
Encoding:
Text File  |  2008-09-12  |  2.1 KB  |  81 lines

  1. class SquareBuilding extends Building
  2. {
  3.    var radius;
  4.    var nx;
  5.    var zs;
  6.    var z;
  7.    var offscreen;
  8.    var ny;
  9.    var pos_x;
  10.    var pos_y;
  11.    var room;
  12.    var environment;
  13.    function SquareBuilding()
  14.    {
  15.       super();
  16.       this.radius = 85;
  17.    }
  18.    function render(p_env)
  19.    {
  20.       this.posit(p_env);
  21.       if(this.nx < 550 + 150 * this.zs && this.nx > - 150 * this.zs && this.z > -400)
  22.       {
  23.          this.offscreen = false;
  24.          this._x = this.nx;
  25.          this._y = this.ny;
  26.          this._xscale = this._yscale = 60 * this.zs;
  27.          this.blur(this.ny);
  28.          this.depth();
  29.          this.gotoAndStop(17 + Math.round(17 * (p_env.pos_x - this.pos_x) / 520));
  30.          if(this._y > 280)
  31.          {
  32.             this._alpha = 100 - (this.ny - 300) * 5;
  33.          }
  34.       }
  35.       else if(this.offscreen == false)
  36.       {
  37.          this.offscreen = true;
  38.          this._x = -200;
  39.          this._y = -200;
  40.       }
  41.    }
  42.    function collide(p_new_x, p_new_y, p_old_x, p_old_y)
  43.    {
  44.       var _loc5_ = p_new_x;
  45.       var _loc4_ = p_new_y;
  46.       var _loc8_ = p_old_x;
  47.       var _loc6_ = p_old_y;
  48.       var _loc9_ = _loc8_ - this.pos_x;
  49.       var _loc7_ = _loc6_ - this.pos_y + this.radius;
  50.       var _loc3_ = _loc5_ - this.pos_x;
  51.       var _loc2_ = _loc4_ - this.pos_y + this.radius;
  52.       if(this.positive(_loc3_) < 10 && _loc2_ > 0)
  53.       {
  54.          if(_loc2_ < this.radius + 10)
  55.          {
  56.             this.environment.goInside(this,this.room);
  57.          }
  58.       }
  59.       else if(this.positive(_loc7_) > this.positive(_loc9_))
  60.       {
  61.          if(_loc2_ <= this.radius + 30 && _loc2_ > 0)
  62.          {
  63.             _loc4_ = this.pos_y + 30;
  64.          }
  65.          else if(_loc2_ >= - this.radius - 30 && _loc2_ < 0)
  66.          {
  67.             _loc4_ = this.pos_y - this.radius - this.radius - 30;
  68.          }
  69.       }
  70.       else if(_loc3_ <= this.radius + 30 && _loc3_ > 0)
  71.       {
  72.          _loc5_ = this.pos_x + this.radius + 30;
  73.       }
  74.       else if(_loc3_ >= - this.radius - 30 && _loc3_ < 0)
  75.       {
  76.          _loc5_ = this.pos_x - this.radius - 30;
  77.       }
  78.       return [_loc5_,_loc4_];
  79.    }
  80. }
  81.