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

  1. class org.cove.flade.surfaces.MoveRectangleTile extends org.cove.flade.surfaces.RectangleTile implements org.cove.flade.surfaces.Surface
  2. {
  3.    var MoveCurr;
  4.    var MovePrev;
  5.    var MoveAspect;
  6.    var Moveang;
  7.    var HighShowTime;
  8.    var facedmc;
  9.    var center;
  10.    var rectWidth;
  11.    var rectHeight;
  12.    var timeLastContact;
  13.    var normal;
  14.    function MoveRectangleTile(cx, cy, rw, rh, rootmc, dmc)
  15.    {
  16.       super(cx,cy,rw,rh,rootmc);
  17.       this.MoveCurr = new org.cove.flade.util.Vector(0,0);
  18.       this.MovePrev = new org.cove.flade.util.Vector(0,0);
  19.       this.MoveAspect = true;
  20.       this.Moveang = this.HighShowTime = 0;
  21.       if(dmc != undefined)
  22.       {
  23.          this.facedmc = dmc;
  24.       }
  25.    }
  26.    function MoveLeft(mox)
  27.    {
  28.       this.center.x -= mox;
  29.       this.ReCreateBoundingRect(this.rectWidth,this.rectHeight);
  30.       this.MovePrev.x = this.MoveCurr.x;
  31.       this.MoveCurr.x -= mox;
  32.    }
  33.    function MoveRight(mox)
  34.    {
  35.       this.center.x += mox;
  36.       this.ReCreateBoundingRect(this.rectWidth,this.rectHeight);
  37.       this.MovePrev.x = this.MoveCurr.x;
  38.       this.MoveCurr.x += mox;
  39.    }
  40.    function MoveUp(moy)
  41.    {
  42.       this.center.y -= moy;
  43.       this.ReCreateBoundingRect(this.rectWidth,this.rectHeight);
  44.       this.MovePrev.y = this.MoveCurr.y;
  45.       this.MoveCurr.y -= moy;
  46.    }
  47.    function MoveDown(moy)
  48.    {
  49.       this.center.y += moy;
  50.       this.ReCreateBoundingRect(this.rectWidth,this.rectHeight);
  51.       this.MovePrev.y = this.MoveCurr.y;
  52.       this.MoveCurr.y += moy;
  53.    }
  54.    function ReSet(newx, newy)
  55.    {
  56.       this.center.x = newx;
  57.       this.center.y = newy;
  58.       this.ReCreateBoundingRect(this.rectWidth,this.rectHeight);
  59.       this.MovePrev.x = this.MoveCurr.x;
  60.       this.MoveCurr.x = this.center.x;
  61.       this.MovePrev.y = this.MoveCurr.y;
  62.       this.MoveCurr.y = this.center.y;
  63.    }
  64.    function MoveHide()
  65.    {
  66.       if(this.getVisible())
  67.       {
  68.          this.setVisible(false);
  69.          this.ReCreateBoundingRect(0,0);
  70.          this.onMoveHide();
  71.       }
  72.    }
  73.    function MovieAgreement()
  74.    {
  75.       this.facedmc._x = this.center.x;
  76.       this.facedmc._y = this.center.y;
  77.    }
  78.    function MoveShow()
  79.    {
  80.       if(!this.getVisible())
  81.       {
  82.          this.setVisible(true);
  83.          this.ReCreateBoundingRect(this.rectWidth,this.rectHeight);
  84.          this.onMoveShow();
  85.       }
  86.    }
  87.    function SetMoveAspect(b)
  88.    {
  89.       this.MoveAspect = b;
  90.    }
  91.    function RunLeftRight(mlx, mrx, speed)
  92.    {
  93.       if(this.MoveCurr.x > mrx)
  94.       {
  95.          this.MoveAspect = false;
  96.       }
  97.       if(this.MoveCurr.x < - mlx)
  98.       {
  99.          this.MoveAspect = true;
  100.       }
  101.       if(this.MoveAspect)
  102.       {
  103.          this.MoveRight(speed);
  104.       }
  105.       else
  106.       {
  107.          this.MoveLeft(speed);
  108.       }
  109.       this.MovieAgreement();
  110.    }
  111.    function RunUpDown(muy, mdy, speed)
  112.    {
  113.       if(this.MoveCurr.y > mdy)
  114.       {
  115.          this.MoveAspect = false;
  116.       }
  117.       if(this.MoveCurr.y < - muy)
  118.       {
  119.          this.MoveAspect = true;
  120.       }
  121.       if(this.MoveAspect)
  122.       {
  123.          this.MoveDown(speed);
  124.       }
  125.       else
  126.       {
  127.          this.MoveUp(speed);
  128.       }
  129.       this.MovieAgreement();
  130.    }
  131.    function RunCircle(Runright, r, speed, StartAng)
  132.    {
  133.       if(Runright)
  134.       {
  135.          this.Moveang += 3.141592653589793 * speed / 360;
  136.       }
  137.       else
  138.       {
  139.          this.Moveang -= 3.141592653589793 * speed / 360;
  140.       }
  141.       var _loc3_ = Math.cos(this.Moveang + StartAng) * r;
  142.       var _loc2_ = Math.sin(this.Moveang + StartAng) * r;
  143.       if(_loc3_ > 0)
  144.       {
  145.          this.MoveRight(_loc3_);
  146.       }
  147.       else
  148.       {
  149.          this.MoveLeft(- _loc3_);
  150.       }
  151.       if(_loc2_ > 0)
  152.       {
  153.          this.MoveDown(_loc2_);
  154.       }
  155.       else
  156.       {
  157.          this.MoveUp(- _loc2_);
  158.       }
  159.       this.MovieAgreement();
  160.    }
  161.    function StartRunHide()
  162.    {
  163.       this.timeLastContact = new Date().getTime();
  164.       if(!this.MoveAspect)
  165.       {
  166.          this.HighShowTime = 0;
  167.          this.MoveAspect = true;
  168.       }
  169.    }
  170.    function RunHide(ShowTime, HideTime)
  171.    {
  172.       if(this.MoveAspect)
  173.       {
  174.          if(this.HighShowTime < ShowTime)
  175.          {
  176.             this.MoveShow();
  177.             if(new Date().getTime() - this.timeLastContact > 400)
  178.             {
  179.                this.MoveShow();
  180.                this.HighShowTime = 0;
  181.                this.MoveAspect = false;
  182.             }
  183.          }
  184.          else if(this.HighShowTime < ShowTime + HideTime)
  185.          {
  186.             this.MoveHide();
  187.          }
  188.          else if(this.HighShowTime > ShowTime + HideTime)
  189.          {
  190.             this.MoveAspect = false;
  191.             this.MoveShow();
  192.             this.HighShowTime = 0;
  193.          }
  194.          this.HighShowTime = this.HighShowTime + 1;
  195.       }
  196.    }
  197.    function resolveCircleCollision(p, sysObj)
  198.    {
  199.       if(this.isCircleColliding(p))
  200.       {
  201.          this.onContact();
  202.          p.resolveCollision(this.normal,sysObj);
  203.          p.SetCollision();
  204.          p.curr.x += this.MoveCurr.x - this.MovePrev.x;
  205.          p.prev.x += this.MoveCurr.x - this.MovePrev.x;
  206.       }
  207.    }
  208.    function onMoveHide()
  209.    {
  210.    }
  211.    function onMoveShow()
  212.    {
  213.    }
  214.    function GetCenterY()
  215.    {
  216.       return this.center.y;
  217.    }
  218. }
  219.