home *** CD-ROM | disk | FTP | other *** search
- class com.neodelight.v2D.GunInterval extends com.neodelight.v2D.Gun
- {
- var timeOn;
- var timeOff;
- var pShoot;
- var ifDirXPlayer;
- var triggerStat;
- var triggerTime;
- var owner;
- function GunInterval(owner, config, canvas)
- {
- super(owner,config,canvas);
- this.timeOn = com.neodelight.std.XMath.toNumber(config.gunIntervalTimeOn);
- this.timeOff = com.neodelight.std.XMath.toNumber(config.gunIntervalTimeOff);
- this.pShoot = com.neodelight.std.XMath.toNumber(config.gunIntervalPShoot);
- if(this.pShoot == 0)
- {
- this.pShoot = 1;
- }
- this.ifDirXPlayer = Boolean(config.gunIfDirXPlayer);
- this.reset();
- }
- function reset()
- {
- this.triggerStat = false;
- this.triggerTime = this.timeOff;
- super.reset();
- }
- function move()
- {
- super.move();
- if(this.triggerStat && (!this.ifDirXPlayer || (_global.plSprite.pos.x - this.owner.pos.x) * this.owner.lookDir > 0))
- {
- if(Math.random() < this.pShoot && this.shoot())
- {
- }
- }
- this.triggerTime = this.triggerTime - 1;
- if(this.triggerTime < 0)
- {
- this.triggerStat = !this.triggerStat;
- if(this.triggerStat)
- {
- this.triggerTime = this.timeOn;
- }
- else
- {
- this.triggerTime = this.timeOff;
- }
- }
- }
- }
-