home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Acao / midnightstrike1.swf / scripts / __Packages / com / neodelight / v2D / GunInterval.as < prev    next >
Encoding:
Text File  |  2007-04-02  |  1.4 KB  |  53 lines

  1. class com.neodelight.v2D.GunInterval extends com.neodelight.v2D.Gun
  2. {
  3.    var timeOn;
  4.    var timeOff;
  5.    var pShoot;
  6.    var ifDirXPlayer;
  7.    var triggerStat;
  8.    var triggerTime;
  9.    var owner;
  10.    function GunInterval(owner, config, canvas)
  11.    {
  12.       super(owner,config,canvas);
  13.       this.timeOn = com.neodelight.std.XMath.toNumber(config.gunIntervalTimeOn);
  14.       this.timeOff = com.neodelight.std.XMath.toNumber(config.gunIntervalTimeOff);
  15.       this.pShoot = com.neodelight.std.XMath.toNumber(config.gunIntervalPShoot);
  16.       if(this.pShoot == 0)
  17.       {
  18.          this.pShoot = 1;
  19.       }
  20.       this.ifDirXPlayer = Boolean(config.gunIfDirXPlayer);
  21.       this.reset();
  22.    }
  23.    function reset()
  24.    {
  25.       this.triggerStat = false;
  26.       this.triggerTime = this.timeOff;
  27.       super.reset();
  28.    }
  29.    function move()
  30.    {
  31.       super.move();
  32.       if(this.triggerStat && (!this.ifDirXPlayer || (_global.plSprite.pos.x - this.owner.pos.x) * this.owner.lookDir > 0))
  33.       {
  34.          if(Math.random() < this.pShoot && this.shoot())
  35.          {
  36.          }
  37.       }
  38.       this.triggerTime = this.triggerTime - 1;
  39.       if(this.triggerTime < 0)
  40.       {
  41.          this.triggerStat = !this.triggerStat;
  42.          if(this.triggerStat)
  43.          {
  44.             this.triggerTime = this.timeOn;
  45.          }
  46.          else
  47.          {
  48.             this.triggerTime = this.timeOff;
  49.          }
  50.       }
  51.    }
  52. }
  53.