home *** CD-ROM | disk | FTP | other *** search
/ Champak 48 / cdrom_image.iso / Games / bobsleddin.swf / scripts / __Packages / GameLasers.as < prev    next >
Encoding:
Text File  |  2007-09-28  |  3.0 KB  |  109 lines

  1. class GameLasers extends Collectable
  2. {
  3.    var world;
  4.    var effectTarget;
  5.    var targetObjects;
  6.    var value = 0;
  7.    var collisionGroup = BB.LASERS;
  8.    var linkageID = "Lasers";
  9.    var collectedSound = "VR";
  10.    var power = 1200;
  11.    var drain = 100;
  12.    var range = 1000;
  13.    var strength = 1000;
  14.    function GameLasers()
  15.    {
  16.       super();
  17.    }
  18.    function onAddToWorld()
  19.    {
  20.       if(!_root.PostVR_Lasers)
  21.       {
  22.          this.world.removeObject(this);
  23.       }
  24.    }
  25.    function awardValue(obj)
  26.    {
  27.       obj.setSpecialItem(this);
  28.       obj.vrSound.stop();
  29.       obj.vrSound.attachSound("magnet");
  30.       this.applyDisplay(obj);
  31.       this.effectTarget = this.world.display.createEmptyMovieClip("Effects",BB.calculateDepth(obj.z + 100,this.uniqueID,0));
  32.    }
  33.    function applyDisplay(targetObject, offsetX, offsetY, offsetZ, depthRatio)
  34.    {
  35.       var _loc1_ = targetObject.target.sled;
  36.       _loc1_.lasersLeft._visible = _loc1_.lasersRight._visible = true;
  37.       _loc1_.lasersLeft.gotoAndStop(targetObject.currentTurnFrame);
  38.       _loc1_.lasersRight.gotoAndStop(targetObject.currentTurnFrame);
  39.    }
  40.    function removeDisplay(targetObject)
  41.    {
  42.       this.effectTarget.swapDepths(255);
  43.       this.effectTarget.removeMovieClip();
  44.       targetObject.removeSpecialItem();
  45.       targetObject.vrSound.stop();
  46.    }
  47.    function update(sled, elapsed)
  48.    {
  49.       this.power -= this.drain * elapsed;
  50.       if(this.power <= 0)
  51.       {
  52.          this.removeDisplay(sled);
  53.          return undefined;
  54.       }
  55.       var _loc5_ = undefined;
  56.       var _loc2_ = undefined;
  57.       var _loc4_ = sled.sector;
  58.       this.targetObjects = [];
  59.       while(_loc4_)
  60.       {
  61.          _loc5_ = _loc4_.objects;
  62.          var _loc6_ = _loc5_.length;
  63.          var _loc3_ = 0;
  64.          while(_loc3_ < _loc6_)
  65.          {
  66.             _loc2_ = _loc5_[_loc3_];
  67.             if(_loc2_.collisionGroup & BB.DESTROYABLE && !_loc2_.destroyed)
  68.             {
  69.                if(_loc2_.z - sled.z > this.range)
  70.                {
  71.                   break;
  72.                }
  73.                if((_loc2_.power -= this.strength * elapsed) <= 0)
  74.                {
  75.                   _loc2_.destroy();
  76.                }
  77.                this.targetObjects.push(_loc2_);
  78.             }
  79.             _loc3_ = _loc3_ + 1;
  80.          }
  81.          if(_loc4_.z > sled.z + this.range)
  82.          {
  83.             break;
  84.          }
  85.          _loc4_ = _loc4_.next;
  86.       }
  87.       if(this.targetObjects.length)
  88.       {
  89.          sled.vrSound.start(0,10000);
  90.       }
  91.       else
  92.       {
  93.          sled.vrSound.stop();
  94.       }
  95.    }
  96.    function renderEffects(object)
  97.    {
  98.       this.effectTarget.clear();
  99.       this.effectTarget.lineStyle(2,16711680);
  100.       var _loc2_ = this.targetObjects.length;
  101.       while((_loc2_ = _loc2_ - 1) > -1)
  102.       {
  103.          this.effectTarget.moveTo(object.screenX,object.screenY);
  104.          this.effectTarget.lineTo(this.targetObjects[_loc2_].screenX,this.targetObjects[_loc2_].screenY);
  105.       }
  106.       this.effectTarget.swapDepths(object.target.getDepth() - 2);
  107.    }
  108. }
  109.