home *** CD-ROM | disk | FTP | other *** search
- class FlyingCargo extends GenericObject
- {
- var world;
- var target;
- var linkageID = "Flying Bird";
- var inMotion = true;
- var fixedToCourse = true;
- var offsetX = 0;
- var offsetY = 0;
- var offsetZ = 0;
- var depthGroup = 2;
- var cullDistance = 6000;
- var time = 0;
- var dist = 0;
- function FlyingCargo(watch)
- {
- super();
- this.watch = watch;
- }
- function onAddToWorld()
- {
- this.world.registerForUpdates(this);
- }
- function onAddToScene()
- {
- }
- function onRemoveFromScene()
- {
- this.world.removeFromUpdates(this);
- this.world.removeObject(this);
- }
- function followCourse(elapsed, move)
- {
- var _loc5_ = this.sector;
- var _loc3_ = new Vector(this.x - this.offsetX,this.y - this.offsetY,this.z - this.offsetZ);
- while(move > 0)
- {
- var _loc4_ = new Vector(_loc5_.x - this.x,_loc5_.y - this.y,_loc5_.z - this.z);
- var _loc6_ = _loc4_.length;
- if(_loc6_ > move)
- {
- _loc3_.x += this.sector.direction.x * move;
- _loc3_.y += this.sector.direction.y * move;
- _loc3_.z += this.sector.direction.z * move;
- move = 0;
- }
- else
- {
- _loc3_.x += _loc4_.x;
- _loc3_.y += _loc4_.y;
- _loc3_.z += _loc4_.z;
- _loc5_ = _loc5_.next;
- move -= _loc6_;
- }
- }
- this.x = _loc3_.x + this.offsetX;
- this.y = _loc3_.y + this.offsetY;
- this.z = _loc3_.z + this.offsetZ;
- }
- function dropCargo()
- {
- this.target.cargo._visible = false;
- var _loc2_ = this.sector;
- var _loc3_ = 0;
- var _loc5_ = 0;
- while(_loc5_ < 10)
- {
- var _loc4_ = new GamePoint(GamePoint.HIGH_VALUE);
- this.world.addObject(_loc4_,_loc2_.previous.x + _loc2_.direction.x * _loc3_,_loc2_.previous.y + _loc2_.radius - 25 + _loc2_.direction.y * _loc3_,_loc2_.previous.z + _loc2_.direction.z * _loc3_,_loc2_.index);
- _loc4_.addToScene();
- _loc3_ += 200;
- if(_loc3_ > _loc2_.length)
- {
- _loc3_ %= _loc2_.length;
- _loc2_ = _loc2_.next;
- }
- _loc5_ = _loc5_ + 1;
- }
- this.fixedToCourse = false;
- this.offsetX = !random(2) ? -100 : 100;
- }
- function onUpdate(elapsed)
- {
- this.time += elapsed;
- var _loc3_ = (this.watch.currentSpeed + 400) * elapsed;
- if(this.fixedToCourse)
- {
- this.y += - this.offsetY + (this.offsetY -= 40 * elapsed);
- this.followCourse(elapsed,_loc3_);
- if(this.z > this.watch.z + 1000)
- {
- this.dropCargo();
- }
- }
- else
- {
- this.x += - this.offsetX + (this.offsetX += this.offsetX * elapsed);
- this.y += - this.offsetY + (this.offsetY -= 400 * elapsed);
- this.z += (1000 - Math.abs(this.offsetX * 0.1) - Math.abs(this.offsetY * 0.1)) * elapsed;
- this.target._rotation += ((this.offsetX <= 0 ? -45 : 45) - this.target._rotation) * elapsed;
- }
- if(this.z > this.world.camera.z + this.world.camera.hither)
- {
- this.addToScene();
- }
- this.checkSectorLocation();
- this.updateDepth();
- }
- }
-