home *** CD-ROM | disk | FTP | other *** search
- class CourseSector extends BB
- {
- var objects;
- var world;
- var depthRatio;
- var target;
- var screenX;
- var screenY;
- var screenRadius;
- var arcLeft;
- var arcRight;
- var arcTop;
- var arcBottom;
- var outerLeftY;
- var outerRightY;
- var color;
- var outsideColor;
- var previous;
- var next;
- var index;
- var targetTint;
- var hasObjects = false;
- var flipped = false;
- var x = 0;
- var y = 0;
- var z = 0;
- var radius = 200;
- var arcClosed = false;
- var arcClosedFace = false;
- var outsideSlope = 0.4;
- var inScene = false;
- var assetName = "Default Ring";
- var outsideClutter = "CourseHouse";
- var useTint = true;
- var style = 0;
- var xScale = 1;
- var yScale = 1;
- var targetTintTrans = {};
- function CourseSector(world, x, y, z, radius)
- {
- super();
- this.objects = [];
- this.x = x;
- this.y = y;
- this.z = z;
- this.world = world;
- this.radius = radius;
- }
- function setDisplay(x, y, depthRatio, frontDepthRatio, fogRatio)
- {
- this.depthRatio = depthRatio;
- if(!this.target)
- {
- this.addToScene();
- }
- this.target.sprite._x = this.screenX = x * depthRatio;
- this.target.sprite._y = this.screenY = y * depthRatio;
- this.target.sprite._xscale = this.target.sprite._yscale = (this.screenRadius = depthRatio * this.radius) * 2;
- var _loc2_ = this.target.drawClip;
- _loc2_.clear();
- this.arcLeft = this.screenX - this.screenRadius * this.xScale;
- this.arcRight = this.screenX + this.screenRadius * this.xScale;
- this.arcTop = this.screenY - this.screenRadius * this.yScale;
- this.arcBottom = this.screenY + this.screenRadius * this.yScale;
- this.outerLeftY = this.screenY - Math.abs(this.world.halfWidth + this.arcLeft) * this.outsideSlope;
- this.outerRightY = this.screenY - Math.abs(this.world.halfWidth - this.arcRight) * this.outsideSlope;
- var _loc4_ = new RGB(this.color.r + (this.world.fogColor.r - this.color.r) * fogRatio,this.color.g + (this.world.fogColor.g - this.color.g) * fogRatio,this.color.b + (this.world.fogColor.b - this.color.b) * fogRatio);
- var _loc3_ = _loc4_.valueOf();
- var _loc8_ = new RGB(this.outsideColor.r + (this.world.outsideFogColor.r - this.outsideColor.r) * fogRatio,this.outsideColor.g + (this.world.outsideFogColor.g - this.outsideColor.g) * fogRatio,this.outsideColor.b + (this.world.outsideFogColor.b - this.outsideColor.b) * fogRatio);
- var _loc7_ = new RGB(_loc4_.r * 0.9,_loc4_.g * 0.9,_loc4_.b);
- if(this.arcClosedFace)
- {
- var _loc6_ = this.world.camera.depthFocus / (this.z + 1000 - this.world.camera.z);
- var _loc10_ = this.world.camera.depthFocus / (this.z + 750 - this.world.camera.z);
- _loc2_ = this.target;
- _loc2_.clear();
- _loc2_.beginFill(_loc8_);
- _loc2_.moveTo(this.arcLeft,this.screenY);
- _loc2_.curveTo(this.arcLeft,this.arcTop,this.screenX,this.arcTop);
- _loc2_.curveTo(this.arcRight,this.arcTop,this.arcRight,this.screenY);
- _loc2_.lineTo(this.world.halfWidth,this.screenY);
- _loc2_.lineTo(this.world.halfWidth,(this.y - 800 - this.world.camera.y) * _loc6_);
- _loc2_.curveTo((this.x - this.world.camera.x) * _loc10_,(this.y - this.radius - 1600 - this.world.camera.y) * _loc10_,- this.world.halfWidth,(this.y - 800 - this.world.camera.y) * _loc6_);
- _loc2_.lineTo(- this.world.halfWidth,this.screenY);
- _loc2_.endFill();
- }
- if(this.arcClosed && this.previous.arcClosed)
- {
- this.drawClosedPipe(_loc2_,_loc7_,_loc3_,_loc3_,_loc3_,_loc3_);
- }
- else
- {
- this.drawOpenPipe(_loc2_,_loc7_,_loc3_,_loc3_,_loc8_);
- }
- }
- function drawClosedPipe(drawClip, lineColor, topLeftColor, topRightColor, bottomRightColor, bottomLeftColor)
- {
- var _loc5_ = this.world.camera;
- var _loc19_ = !this.previous.target;
- if(!_loc19_)
- {
- var _loc7_ = this.previous.radius;
- var _loc3_ = this.previous.screenX;
- var _loc4_ = this.previous.screenY;
- var _loc11_ = this.previous.arcLeft;
- var _loc12_ = this.previous.arcTop;
- var _loc8_ = this.previous.arcRight;
- var _loc10_ = this.previous.arcBottom;
- if(!this.next.inScene)
- {
- drawClip.beginFill(topLeftColor);
- drawClip.moveTo(_loc11_,_loc4_);
- drawClip.curveTo(_loc11_,_loc12_,_loc3_,_loc12_);
- drawClip.lineTo(this.screenX,this.screenY);
- drawClip.endFill();
- drawClip.beginFill(topRightColor);
- drawClip.moveTo(_loc8_,_loc4_);
- drawClip.curveTo(_loc8_,_loc12_,_loc3_,_loc12_);
- drawClip.lineTo(this.screenX,this.screenY);
- drawClip.endFill();
- drawClip.beginFill(bottomLeftColor);
- drawClip.moveTo(_loc11_,_loc4_);
- drawClip.curveTo(_loc11_,_loc10_,_loc3_,_loc10_);
- drawClip.lineTo(this.screenX,this.screenY);
- drawClip.endFill();
- drawClip.beginFill(bottomRightColor);
- drawClip.moveTo(_loc8_,_loc4_);
- drawClip.curveTo(_loc8_,_loc10_,_loc3_,_loc10_);
- drawClip.lineTo(this.screenX,this.screenY);
- drawClip.endFill();
- }
- else
- {
- drawClip.beginFill(topLeftColor);
- drawClip.moveTo(this.arcLeft,this.screenY);
- drawClip.curveTo(this.arcLeft,this.arcTop,this.screenX,this.arcTop);
- drawClip.lineTo(_loc3_,_loc12_);
- drawClip.curveTo(_loc11_,_loc12_,_loc11_,_loc4_);
- drawClip.endFill();
- drawClip.beginFill(topRightColor);
- drawClip.moveTo(this.arcRight,this.screenY);
- drawClip.curveTo(this.arcRight,this.arcTop,this.screenX,this.arcTop);
- drawClip.lineTo(_loc3_,_loc12_);
- drawClip.curveTo(_loc8_,_loc12_,_loc8_,_loc4_);
- drawClip.endFill();
- drawClip.beginFill(bottomLeftColor);
- drawClip.moveTo(this.arcLeft,this.screenY);
- drawClip.curveTo(this.arcLeft,this.arcBottom,this.screenX,this.arcBottom);
- drawClip.lineTo(_loc3_,_loc10_);
- drawClip.curveTo(_loc11_,_loc10_,_loc11_,_loc4_);
- drawClip.endFill();
- drawClip.beginFill(bottomRightColor);
- drawClip.moveTo(this.arcRight,this.screenY);
- drawClip.curveTo(this.arcRight,this.arcBottom,this.screenX,this.arcBottom);
- drawClip.lineTo(_loc3_,_loc10_);
- drawClip.curveTo(_loc8_,_loc10_,_loc8_,_loc4_);
- drawClip.endFill();
- }
- }
- else
- {
- var _loc6_ = (this.z - _loc5_.z - _loc5_.hither) / (this.z - this.previous.z);
- var _loc9_ = _loc5_.depthFocus / _loc5_.hither;
- var _loc13_ = this.xScale - (this.xScale - this.previous.xScale) * _loc6_;
- var _loc14_ = this.yScale - (this.yScale - this.previous.yScale) * _loc6_;
- _loc7_ = (this.radius - (this.radius - this.previous.radius) * _loc6_) * _loc9_;
- _loc3_ = (this.x - (this.x - this.previous.x) * _loc6_ - _loc5_.x) * _loc9_;
- _loc4_ = (this.y - (this.y - this.previous.y) * _loc6_ - _loc5_.y) * _loc9_;
- _loc11_ = _loc3_ - _loc7_ * _loc13_;
- _loc12_ = _loc4_ - _loc7_ * _loc14_;
- _loc8_ = _loc3_ + _loc7_ * _loc13_;
- _loc10_ = _loc4_ + _loc7_ * _loc14_;
- drawClip.beginFill(topLeftColor);
- drawClip.moveTo(this.arcLeft,this.screenY);
- drawClip.curveTo(this.arcLeft,this.arcTop,this.screenX,this.arcTop);
- drawClip.lineTo(_loc3_,_loc12_);
- drawClip.lineTo(_loc3_,- this.world.halfHeight);
- drawClip.lineTo(- this.world.halfWidth,- this.world.halfHeight);
- drawClip.lineTo(- this.world.halfWidth,_loc4_);
- drawClip.lineTo(_loc11_,_loc4_);
- drawClip.endFill();
- drawClip.beginFill(topRightColor);
- drawClip.moveTo(this.arcRight,this.screenY);
- drawClip.curveTo(this.arcRight,this.arcTop,this.screenX,this.arcTop);
- drawClip.lineTo(_loc3_,_loc12_);
- drawClip.lineTo(_loc3_,- this.world.halfHeight);
- drawClip.lineTo(this.world.halfWidth,- this.world.halfHeight);
- drawClip.lineTo(this.world.halfWidth,_loc4_);
- drawClip.lineTo(_loc8_,_loc4_);
- drawClip.endFill();
- drawClip.beginFill(bottomLeftColor);
- drawClip.moveTo(this.arcLeft,this.screenY);
- drawClip.curveTo(this.arcLeft,this.arcBottom,this.screenX,this.arcBottom);
- drawClip.lineTo(_loc3_,_loc10_);
- drawClip.lineTo(_loc3_,this.world.halfHeight);
- drawClip.lineTo(- this.world.halfWidth,this.world.halfHeight);
- drawClip.lineTo(- this.world.halfWidth,_loc4_);
- drawClip.lineTo(_loc11_,_loc4_);
- drawClip.endFill();
- drawClip.beginFill(bottomRightColor);
- drawClip.moveTo(this.arcRight,this.screenY);
- drawClip.curveTo(this.arcRight,this.arcBottom,this.screenX,this.arcBottom);
- drawClip.lineTo(_loc3_,_loc10_);
- drawClip.lineTo(_loc3_,this.world.halfHeight);
- drawClip.lineTo(this.world.halfWidth,this.world.halfHeight);
- drawClip.lineTo(this.world.halfWidth,_loc4_);
- drawClip.lineTo(_loc8_,_loc4_);
- drawClip.endFill();
- }
- drawClip.lineStyle(0,lineColor);
- drawClip.moveTo(_loc3_,_loc12_);
- drawClip.lineTo(this.screenX,this.arcTop);
- drawClip.moveTo(_loc3_,_loc10_);
- drawClip.lineTo(this.screenX,this.arcBottom);
- drawClip.moveTo(_loc11_,_loc4_);
- drawClip.lineTo(this.arcLeft,this.screenY);
- drawClip.moveTo(_loc8_,_loc4_);
- drawClip.lineTo(this.arcRight,this.screenY);
- }
- function drawOpenPipe(drawClip, lineColor, leftSurfaceColor, rightSurfaceColor, outsideColor)
- {
- var _loc15_ = !this.previous.target;
- if(!_loc15_)
- {
- var _loc9_ = this.previous.radius;
- var _loc4_ = this.previous.screenX;
- var _loc3_ = this.previous.screenY;
- var _loc8_ = this.previous.arcLeft;
- var _loc19_ = this.previous.arcTop;
- var _loc7_ = this.previous.arcRight;
- var _loc11_ = this.previous.arcBottom;
- var _loc14_ = this.previous.outerLeftY;
- var _loc13_ = this.previous.outerRightY;
- drawClip.beginFill(leftSurfaceColor);
- drawClip.moveTo(this.arcLeft,this.screenY);
- drawClip.curveTo(this.arcLeft,this.arcBottom,this.screenX,this.arcBottom);
- drawClip.lineTo(_loc4_,_loc11_);
- drawClip.curveTo(_loc8_,_loc11_,_loc8_,_loc3_);
- drawClip.endFill();
- drawClip.beginFill(rightSurfaceColor);
- drawClip.moveTo(this.arcRight,this.screenY);
- drawClip.curveTo(this.arcRight,this.arcBottom,this.screenX,this.arcBottom);
- drawClip.lineTo(_loc4_,_loc11_);
- drawClip.curveTo(_loc7_,_loc11_,_loc7_,_loc3_);
- drawClip.endFill();
- }
- else
- {
- var _loc5_ = this.world.camera;
- var _loc6_ = (this.z - _loc5_.z - _loc5_.hither) / (this.z - this.previous.z);
- var _loc10_ = _loc5_.depthFocus / _loc5_.hither;
- var _loc12_ = this.xScale - (this.xScale - this.previous.xScale) * _loc6_;
- var _loc16_ = this.yScale - (this.yScale - this.previous.yScale) * _loc6_;
- _loc9_ = (this.radius - (this.radius - this.previous.radius) * _loc6_) * _loc10_;
- _loc4_ = (this.x - (this.x - this.previous.x) * _loc6_ - _loc5_.x) * _loc10_;
- _loc3_ = (this.y - (this.y - this.previous.y) * _loc6_ - _loc5_.y) * _loc10_;
- _loc14_ = _loc3_;
- _loc13_ = _loc3_;
- _loc8_ = _loc4_ - _loc9_ * _loc12_;
- _loc7_ = _loc4_ + _loc9_ * _loc12_;
- _loc11_ = _loc3_ + _loc9_ * _loc16_;
- drawClip.beginFill(leftSurfaceColor);
- drawClip.moveTo(this.arcLeft,this.screenY);
- drawClip.curveTo(this.arcLeft,this.arcBottom,this.screenX,this.arcBottom);
- drawClip.lineTo(_loc4_,_loc11_);
- drawClip.lineTo(_loc4_,this.world.halfHeight);
- drawClip.lineTo(- this.world.halfWidth,this.world.halfHeight);
- drawClip.lineTo(- this.world.halfWidth,_loc3_);
- drawClip.lineTo(_loc8_,_loc3_);
- drawClip.endFill();
- drawClip.beginFill(rightSurfaceColor);
- drawClip.moveTo(this.arcRight,this.screenY);
- drawClip.curveTo(this.arcRight,this.arcBottom,this.screenX,this.arcBottom);
- drawClip.lineTo(_loc4_,_loc11_);
- drawClip.lineTo(_loc4_,this.world.halfHeight);
- drawClip.lineTo(this.world.halfWidth,this.world.halfHeight);
- drawClip.lineTo(this.world.halfWidth,_loc3_);
- drawClip.lineTo(_loc7_,_loc3_);
- drawClip.endFill();
- }
- drawClip.beginFill(outsideColor);
- if(_loc3_ + Math.abs((_loc7_ - this.arcRight) * this.outsideSlope) > this.screenY)
- {
- drawClip.moveTo(this.arcRight,this.screenY);
- drawClip.lineTo(_loc7_,_loc3_);
- drawClip.lineTo(this.world.halfWidth,_loc13_);
- drawClip.lineTo(this.world.halfWidth,this.outerRightY);
- }
- if(_loc3_ + Math.abs((this.arcLeft - _loc8_) * this.outsideSlope) > this.screenY)
- {
- drawClip.moveTo(this.arcLeft,this.screenY);
- drawClip.lineTo(_loc8_,_loc3_);
- drawClip.lineTo(- this.world.halfWidth,_loc14_);
- drawClip.lineTo(- this.world.halfWidth,this.outerLeftY);
- }
- drawClip.endFill();
- drawClip.lineStyle(0,lineColor);
- drawClip.moveTo(_loc4_,_loc11_);
- drawClip.lineTo(this.screenX,this.arcBottom);
- drawClip.moveTo(_loc8_,_loc3_);
- drawClip.lineTo(this.arcLeft,this.screenY);
- drawClip.moveTo(_loc7_,_loc3_);
- drawClip.lineTo(this.arcRight,this.screenY);
- }
- function addObject(object)
- {
- if(!object.trackInSectorGrid)
- {
- return undefined;
- }
- this.hasObjects = true;
- this.objects.push(object);
- }
- function removeObject(object)
- {
- var _loc2_ = this.objects.length - 1;
- while(_loc2_ > -1)
- {
- if(this.objects[_loc2_] == object)
- {
- this.objects.splice(_loc2_,1);
- break;
- }
- _loc2_ = _loc2_ - 1;
- }
- this.hasObjects = this.objects.length > 0;
- }
- function addToScene()
- {
- this.target = this.world.display.attachMovie(this.assetName,"X" + this.index,BB.calculateDepth(this.z,0,0));
- this.inScene = true;
- var _loc2_ = this.objects.length - 1;
- while(_loc2_ > -1)
- {
- this.objects[_loc2_].addToScene();
- _loc2_ = _loc2_ - 1;
- }
- this.onAddToScene();
- }
- function onAddToScene()
- {
- if(this.arcClosedFace)
- {
- this.targetTint = new Color(this.target.sprite.bottom);
- }
- else
- {
- this.targetTint = new Color(this.target.sprite);
- this.target.sprite.cover.swapDepths(255);
- this.target.sprite.cover.removeMovieClip();
- }
- this.target.createEmptyMovieClip("drawClip",10);
- if(!this.arcClosed && random(2) == 0)
- {
- var _loc2_ = this.target.sprite.attachMovie(this.outsideClutter,"house",1000);
- var _loc3_ = Math.random() * 2000;
- _loc2_._x = (!random(2) ? 1 : -1) * (_loc3_ + this.radius);
- _loc2_._y = (- (_loc3_ + 125)) * this.outsideSlope;
- _loc2_._xscale = _loc2_._x <= 0 ? 100 : -100;
- }
- this.target.sprite.top._visible = this.arcClosed;
- }
- function removeFromScene()
- {
- this.target.swapDepths(255);
- this.target.removeMovieClip();
- this.inScene = false;
- var _loc2_ = this.objects.length - 1;
- while(_loc2_ > -1)
- {
- this.objects[_loc2_].removeFromScene();
- _loc2_ = _loc2_ - 1;
- }
- delete this.target;
- }
- function toString()
- {
- return "Course Sector " + this.index;
- }
- }
-