home *** CD-ROM | disk | FTP | other *** search
- class PlayFieldRangeHandler
- {
- var origin;
- var length;
- var width;
- var topLeftPoint;
- var topRightPoint;
- var bottomRightPoint;
- var bottomLeftPoint;
- var centerX;
- var centerY;
- var leftCage_origin;
- var leftCage_length;
- var leftCage_width;
- var leftCage_topLeft;
- var leftCage_topRight;
- var leftCage_bottomRight;
- var leftCage_bottomLeft;
- var leftCage_centerX;
- var leftCage_centerY;
- var rightCage_origin;
- var rightCage_length;
- var rightCage_width;
- var rightCage_topLeft;
- var rightCage_topRight;
- var rightCage_bottomRight;
- var rightCage_bottomLeft;
- var rightCage_centerX;
- var rightCage_centerY;
- function PlayFieldRangeHandler(origin, length, width)
- {
- this.origin = origin;
- this.length = length;
- this.width = width;
- this.topLeftPoint = new Point2D(this.origin.getX(),this.origin.getY());
- this.topRightPoint = new Point2D(this.origin.getX() + this.length,this.origin.getY());
- this.bottomRightPoint = new Point2D(this.origin.getX() + this.length,this.origin.getY() + this.width);
- this.bottomLeftPoint = new Point2D(this.origin.getX(),this.origin.getY() + this.width);
- this.centerX = Math.floor(this.origin.getX() + this.length / 2);
- this.centerY = Math.floor(this.origin.getY() + this.width / 2);
- }
- function initLeftCage(origin, length, width)
- {
- this.leftCage_origin = origin;
- this.leftCage_length = length;
- this.leftCage_width = width;
- this.leftCage_topLeft = new Point2D(this.leftCage_origin.getX(),this.leftCage_origin.getY());
- this.leftCage_topRight = new Point2D(this.leftCage_origin.getX() + this.leftCage_length,this.leftCage_origin.getY());
- this.leftCage_bottomRight = new Point2D(this.leftCage_origin.getX() + this.leftCage_length,this.leftCage_origin.getY() + this.leftCage_width);
- this.leftCage_bottomLeft = new Point2D(this.leftCage_origin.getX(),this.leftCage_origin.getY() + this.leftCage_width);
- this.leftCage_centerX = Math.floor(this.leftCage_origin.getX() + this.leftCage_length / 2);
- this.leftCage_centerY = Math.floor(this.leftCage_origin.getY() + this.leftCage_width / 2);
- }
- function initRightCage(origin, length, width)
- {
- this.rightCage_origin = origin;
- this.rightCage_length = length;
- this.rightCage_width = width;
- this.rightCage_topLeft = new Point2D(this.rightCage_origin.getX(),this.rightCage_origin.getY());
- this.rightCage_topRight = new Point2D(this.rightCage_origin.getX() + this.rightCage_length,this.rightCage_origin.getY());
- this.rightCage_bottomRight = new Point2D(this.rightCage_origin.getX() + this.rightCage_length,this.rightCage_origin.getY() + this.rightCage_width);
- this.rightCage_bottomLeft = new Point2D(this.rightCage_origin.getX(),this.rightCage_origin.getY() + this.rightCage_width);
- this.rightCage_centerX = Math.floor(this.rightCage_origin.getX() + this.rightCage_length / 2);
- this.rightCage_centerY = Math.floor(this.rightCage_origin.getY() + this.rightCage_width / 2);
- }
- function getMinX()
- {
- return this.origin.getX();
- }
- function getMaxX()
- {
- return this.origin.getX() + this.length;
- }
- function getMinY()
- {
- return this.origin.getY();
- }
- function getMaxY()
- {
- return this.origin.getY() + this.width;
- }
- function getCenterX()
- {
- return this.centerX;
- }
- function getCenterY()
- {
- return this.centerY;
- }
- function getLenth()
- {
- return this.length;
- }
- function getWidth()
- {
- return this.width;
- }
- function testObjectInPlayField(x, y)
- {
- if(this.rightCage_origin == undefined)
- {
- trace("rightCage no initialised !");
- }
- var _loc2_ = Math.floor(x);
- var _loc3_ = Math.floor(y);
- if(_loc2_ > this.getMinX() && _loc2_ < this.getMaxX() && _loc3_ > this.getMinY() && _loc3_ < this.getMaxY())
- {
- return true;
- }
- return false;
- }
- function testObjectInRightCage(x, y)
- {
- if(this.rightCage_origin == undefined)
- {
- trace("rightCage no initialised !");
- }
- var _loc2_ = Math.floor(x);
- var _loc3_ = Math.floor(y);
- if(_loc2_ > this.rightCage_origin.getX() && _loc2_ < this.rightCage_origin.getX() + this.rightCage_length)
- {
- if(_loc3_ > this.rightCage_origin.getY() && _loc3_ < this.rightCage_origin.getY() + this.rightCage_width)
- {
- return true;
- }
- }
- return false;
- }
- function testObjectInLeftCage(x, y)
- {
- if(this.leftCage_origin == undefined)
- {
- trace("leftCage no initialised !");
- }
- var _loc2_ = Math.floor(x);
- var _loc3_ = Math.floor(y);
- if(_loc2_ > this.leftCage_origin.getX() && _loc2_ < this.leftCage_origin.getX() + this.leftCage_length && _loc3_ > this.leftCage_origin.getY() && _loc3_ < this.leftCage_origin.getY() + this.leftCage_width)
- {
- return true;
- }
- return false;
- }
- function testObjectInTheDepthOfRightCage(x, y)
- {
- var _loc2_ = Math.floor(x);
- var _loc3_ = Math.floor(y);
- if(this.testObjectInRightCage(_loc2_,_loc3_) == false)
- {
- return false;
- }
- if(_loc2_ > this.rightCage_origin.getX() + 20)
- {
- return true;
- }
- return false;
- }
- function testObjectInTheDepthOfLeftCage(x, y)
- {
- var _loc2_ = Math.floor(x);
- var _loc3_ = Math.floor(y);
- if(this.testObjectInLeftCage(_loc2_,_loc3_) == false)
- {
- return false;
- }
- if(_loc2_ < this.leftCage_origin.getX() + 5)
- {
- return true;
- }
- return false;
- }
- function trace()
- {
- trace("Play Field Range:");
- this.topLeftPoint.trace();
- this.topRightPoint.trace();
- this.bottomRightPoint.trace();
- this.bottomLeftPoint.trace();
- trace("Center(x,y) = (" + this.centerX + ", " + this.centerY + ")");
- trace("-----------------");
- }
- function traceRightCage()
- {
- trace("---------------------------------");
- trace("Right Cage:");
- trace("Origine: ");
- this.rightCage_origin.trace();
- trace("Length: " + this.rightCage_length);
- trace("Width: " + this.rightCage_width);
- trace("Top Left: ");
- this.rightCage_topLeft.trace();
- trace("Top Right: ");
- this.rightCage_topRight.trace();
- trace("Bottom Right: ");
- this.rightCage_bottomRight.trace();
- trace("Bottom Left: ");
- this.rightCage_bottomLeft.trace();
- trace("Center X: " + this.rightCage_centerX);
- trace("Center Y: " + this.rightCage_centerY);
- trace("---------------------------------");
- }
- }
-