home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Acao / germ_roundup.swf / scripts / __Packages / Germ.as < prev    next >
Encoding:
Text File  |  2007-03-20  |  1.5 KB  |  57 lines

  1. class Germ extends smashing.Renderable
  2. {
  3.    var r = 15;
  4.    var grabbable = true;
  5.    var lowerLimit = 1.5;
  6.    var variation = 1.5;
  7.    var cNoise = 0;
  8.    function Germ()
  9.    {
  10.       var _loc1_ = this;
  11.       super();
  12.       _loc1_.gotoAndStop(Math.ceil(Math.random() * _loc1_._totalframes));
  13.       _loc1_.nNoise = _loc1_.getNoisePeriod();
  14.       _loc1_.aNoise = ["germNoise0","germNoise1","germNoise2","germNoise3"];
  15.    }
  16.    function update(nElapsed)
  17.    {
  18.       var _loc1_ = this;
  19.       _loc1_.cNoise += nElapsed;
  20.       if(_loc1_.cNoise >= _loc1_.nNoise)
  21.       {
  22.          _loc1_.cNoise = 0;
  23.          _loc1_.nNoise = _loc1_.getNoisePeriod();
  24.          _global.oSound.playSnd(_loc1_.aNoise[Math.floor(Math.random() * _loc1_.aNoise.length)]);
  25.       }
  26.       _loc1_.render();
  27.    }
  28.    function render()
  29.    {
  30.       var _loc2_ = this;
  31.       var _loc1_ = smashing.Viewport.getPos(_loc2_);
  32.       _loc2_._x = _loc1_.x + smashing.Viewport.centerX;
  33.       _loc2_._y = _loc1_.y + smashing.Viewport.centerY;
  34.    }
  35.    function react(oPlayer)
  36.    {
  37.       var _loc1_ = this;
  38.       switch(_loc1_.nSegment)
  39.       {
  40.          case 0:
  41.             _loc1_.oData.bGermBot = null;
  42.             break;
  43.          case 1:
  44.             _loc1_.oData.bGermMid = null;
  45.             break;
  46.          case 2:
  47.             _loc1_.oData.bGermTop = null;
  48.       }
  49.       delete _loc1_.mcBuild.mcGerm;
  50.       oPlayer.getGerm(_loc1_);
  51.    }
  52.    function getNoisePeriod()
  53.    {
  54.       return this.lowerLimit + Math.random() * this.variation;
  55.    }
  56. }
  57.