home *** CD-ROM | disk | FTP | other *** search
/ 404 Jogos / CLJG.iso / Aventura / starisland.swf / scripts / __Packages / org / cove / flade / surfaces / AbstractTile.as next >
Encoding:
Text File  |  2007-12-10  |  4.0 KB  |  161 lines

  1. class org.cove.flade.surfaces.AbstractTile
  2. {
  3.    var center;
  4.    var verts;
  5.    var normal;
  6.    var isVisible;
  7.    var isActivated;
  8.    var dmc;
  9.    var minX;
  10.    var maxX;
  11.    var minY;
  12.    var maxY;
  13.    function AbstractTile(cx, cy, rootmc)
  14.    {
  15.       this.center = new org.cove.flade.util.Vector(cx,cy);
  16.       this.verts = new Array();
  17.       this.normal = new org.cove.flade.util.Vector(0,0);
  18.       this.isVisible = true;
  19.       this.isActivated = true;
  20.       if(rootmc == null)
  21.       {
  22.          rootmc = _root;
  23.       }
  24.       this.initializeContainer(rootmc);
  25.    }
  26.    function initializeContainer(rootmc)
  27.    {
  28.       if(_root.__debug__)
  29.       {
  30.          if(rootmc == null)
  31.          {
  32.             rootmc = _root;
  33.          }
  34.          var _loc4_ = rootmc.getNextHighestDepth();
  35.          var _loc5_ = "_" + _loc4_;
  36.          this.dmc = rootmc.createEmptyMovieClip(_loc5_,_loc4_);
  37.       }
  38.       else
  39.       {
  40.          this.dmc = _root;
  41.       }
  42.    }
  43.    function setVisible(v)
  44.    {
  45.       this.isVisible = v;
  46.       if(!v)
  47.       {
  48.          this.dmc.clear();
  49.       }
  50.    }
  51.    function getVisible()
  52.    {
  53.       return this.isVisible;
  54.    }
  55.    function setActiveState(a)
  56.    {
  57.       this.isActivated = a;
  58.    }
  59.    function getActiveState()
  60.    {
  61.       return this.isActivated;
  62.    }
  63.    function createBoundingRect(rw, rh)
  64.    {
  65.       var _loc2_ = this.center.y - rh / 2;
  66.       var _loc3_ = this.center.y + rh / 2;
  67.       var _loc5_ = this.center.x - rw / 2;
  68.       var _loc4_ = this.center.x + rw / 2;
  69.       this.verts.push(new org.cove.flade.util.Vector(_loc4_,_loc3_));
  70.       this.verts.push(new org.cove.flade.util.Vector(_loc4_,_loc2_));
  71.       this.verts.push(new org.cove.flade.util.Vector(_loc5_,_loc2_));
  72.       this.verts.push(new org.cove.flade.util.Vector(_loc5_,_loc3_));
  73.       this.setCardProjections();
  74.    }
  75.    function ReCreateBoundingRect(rw, rh)
  76.    {
  77.       var _loc2_ = this.center.y - rh / 2;
  78.       var _loc3_ = this.center.y + rh / 2;
  79.       var _loc5_ = this.center.x - rw / 2;
  80.       var _loc4_ = this.center.x + rw / 2;
  81.       this.verts = new Array();
  82.       this.verts.push(new org.cove.flade.util.Vector(_loc4_,_loc3_));
  83.       this.verts.push(new org.cove.flade.util.Vector(_loc4_,_loc2_));
  84.       this.verts.push(new org.cove.flade.util.Vector(_loc5_,_loc2_));
  85.       this.verts.push(new org.cove.flade.util.Vector(_loc5_,_loc3_));
  86.       this.setCardProjections();
  87.    }
  88.    function testIntervals(boxMin, boxMax, tileMin, tileMax)
  89.    {
  90.       if(boxMax < tileMin)
  91.       {
  92.          return 0;
  93.       }
  94.       if(tileMax < boxMin)
  95.       {
  96.          return 0;
  97.       }
  98.       var _loc2_ = tileMax - boxMin;
  99.       var _loc1_ = tileMin - boxMax;
  100.       if(Math.abs(_loc2_) < Math.abs(_loc1_))
  101.       {
  102.          return _loc2_;
  103.       }
  104.       return _loc1_;
  105.    }
  106.    function setCardProjections()
  107.    {
  108.       this.getCardXProjection();
  109.       this.getCardYProjection();
  110.    }
  111.    function getCardXProjection()
  112.    {
  113.       this.minX = this.verts[0].x;
  114.       var _loc2_ = 1;
  115.       while(_loc2_ < this.verts.length)
  116.       {
  117.          if(this.verts[_loc2_].x < this.minX)
  118.          {
  119.             this.minX = this.verts[_loc2_].x;
  120.          }
  121.          _loc2_ = _loc2_ + 1;
  122.       }
  123.       this.maxX = this.verts[0].x;
  124.       _loc2_ = 1;
  125.       while(_loc2_ < this.verts.length)
  126.       {
  127.          if(this.verts[_loc2_].x > this.maxX)
  128.          {
  129.             this.maxX = this.verts[_loc2_].x;
  130.          }
  131.          _loc2_ = _loc2_ + 1;
  132.       }
  133.    }
  134.    function getCardYProjection()
  135.    {
  136.       this.minY = this.verts[0].y;
  137.       var _loc2_ = 1;
  138.       while(_loc2_ < this.verts.length)
  139.       {
  140.          if(this.verts[_loc2_].y < this.minY)
  141.          {
  142.             this.minY = this.verts[_loc2_].y;
  143.          }
  144.          _loc2_ = _loc2_ + 1;
  145.       }
  146.       this.maxY = this.verts[0].y;
  147.       _loc2_ = 1;
  148.       while(_loc2_ < this.verts.length)
  149.       {
  150.          if(this.verts[_loc2_].y > this.maxY)
  151.          {
  152.             this.maxY = this.verts[_loc2_].y;
  153.          }
  154.          _loc2_ = _loc2_ + 1;
  155.       }
  156.    }
  157.    function onContact()
  158.    {
  159.    }
  160. }
  161.