home *** CD-ROM | disk | FTP | other *** search
- class GameLasers extends Collectable
- {
- var world;
- var effectTarget;
- var targetObjects;
- var value = 0;
- var collisionGroup = BB.LASERS;
- var linkageID = "Lasers";
- var collectedSound = "VR";
- var power = 1200;
- var drain = 100;
- var range = 1000;
- var strength = 1000;
- function GameLasers()
- {
- super();
- }
- function onAddToWorld()
- {
- if(!_root.PostVR_Lasers)
- {
- this.world.removeObject(this);
- }
- }
- function awardValue(obj)
- {
- obj.setSpecialItem(this);
- obj.vrSound.stop();
- obj.vrSound.attachSound("magnet");
- this.applyDisplay(obj);
- this.effectTarget = this.world.display.createEmptyMovieClip("Effects",BB.calculateDepth(obj.z + 100,this.uniqueID,0));
- }
- function applyDisplay(targetObject, offsetX, offsetY, offsetZ, depthRatio)
- {
- var _loc1_ = targetObject.target.sled;
- _loc1_.lasersLeft._visible = _loc1_.lasersRight._visible = true;
- _loc1_.lasersLeft.gotoAndStop(targetObject.currentTurnFrame);
- _loc1_.lasersRight.gotoAndStop(targetObject.currentTurnFrame);
- }
- function removeDisplay(targetObject)
- {
- this.effectTarget.swapDepths(255);
- this.effectTarget.removeMovieClip();
- targetObject.removeSpecialItem();
- targetObject.vrSound.stop();
- }
- function update(sled, elapsed)
- {
- this.power -= this.drain * elapsed;
- if(this.power <= 0)
- {
- this.removeDisplay(sled);
- return undefined;
- }
- var _loc5_ = undefined;
- var _loc2_ = undefined;
- var _loc4_ = sled.sector;
- this.targetObjects = [];
- while(_loc4_)
- {
- _loc5_ = _loc4_.objects;
- var _loc6_ = _loc5_.length;
- var _loc3_ = 0;
- while(_loc3_ < _loc6_)
- {
- _loc2_ = _loc5_[_loc3_];
- if(_loc2_.collisionGroup & BB.DESTROYABLE && !_loc2_.destroyed)
- {
- if(_loc2_.z - sled.z > this.range)
- {
- break;
- }
- if((_loc2_.power -= this.strength * elapsed) <= 0)
- {
- _loc2_.destroy();
- }
- this.targetObjects.push(_loc2_);
- }
- _loc3_ = _loc3_ + 1;
- }
- if(_loc4_.z > sled.z + this.range)
- {
- break;
- }
- _loc4_ = _loc4_.next;
- }
- if(this.targetObjects.length)
- {
- sled.vrSound.start(0,10000);
- }
- else
- {
- sled.vrSound.stop();
- }
- }
- function renderEffects(object)
- {
- this.effectTarget.clear();
- this.effectTarget.lineStyle(2,16711680);
- var _loc2_ = this.targetObjects.length;
- while((_loc2_ = _loc2_ - 1) > -1)
- {
- this.effectTarget.moveTo(object.screenX,object.screenY);
- this.effectTarget.lineTo(this.targetObjects[_loc2_].screenX,this.targetObjects[_loc2_].screenY);
- }
- this.effectTarget.swapDepths(object.target.getDepth() - 2);
- }
- }
-