public override void OnPressAction() { if (this.ammo <= 0) { return; } Vec2 vec2 = this.Offset(this.barrelOffset); if (this.isServerForObject) { QuadLaserBullet quadLaserBullet = new QuadLaserBullet(vec2.x, vec2.y, this.barrelVector); quadLaserBullet.killThingType = this.GetType(); Level.Add((Thing)quadLaserBullet); if (this.duck != null) { this.duck.hSpeed = (float)(-(double)this.barrelVector.x * 8.0); this.duck.vSpeed = (float)(-(double)this.barrelVector.y * 4.0 - 2.0); quadLaserBullet.responsibleProfile = this.duck.profile; } } --this.ammo; SFX.Play("laserBlast"); }
public override void Update() { base.Update(); if (_explodeFrames <= 0f && laserTimer <= 2f) { laserTimer = laserTimer - 0.01f; } if (laserTimer <= 1.5f) { if (laserTimer < 1.5f && laserTimer > 1.1f) { Vec2 barrel = this.Offset(base.barrelOffset); this.ApplyForce(new Vec2(1f, -4f)); this.hSpeed = 0.005f; this.vSpeed += 0.0003f; QuadLaserBullet b = new QuadLaserBullet(barrel.x, barrel.y, barrelVector); b.killThingType = base.GetType(); Level.Add(b); } else if (laserTimer < 1.1f && laserTimer > 0f) { Vec2 barrel = this.Offset(base.barrelOffset); //this.ApplyForce(new Vec2(1f, -4f)); this.hSpeed = -0.0025f; this.vSpeed = -0.02f; QuadLaserBullet b = new QuadLaserBullet(barrel.x, barrel.y, barrelVector); b.killThingType = base.GetType(); Level.Add(b); } } if (laserTimer <= 0f) { Level.Remove(this); } if (!this._pin) { this._timer -= 0.01f; } if (this._timer < 0.5f && this.owner == null && !this._didBonus) { this._didBonus = true; if (Recorder.currentRecording != null) { Recorder.currentRecording.LogBonus(); } } if (!this._localDidExplode && this._timer < 0f) { if (this._explodeFrames < 0) { this.CreateExplosion(this.position); this._explodeFrames = 4; } else { this._explodeFrames--; if (this._explodeFrames == 0 && finsihedExploding == false) { float cx = base.x; float cy = base.y - 2f; Graphics.flashAdd = 1.3f; Layer.Game.darken = 1.3f; if (base.isServerForObject) { for (int i = 0; i < 20; i++) { float dir = (float)i * 18f - 5f + Rando.Float(10f); ATShrapnel shrap = new ATShrapnel(); shrap.range = 60f + Rando.Float(18f); Bullet bullet = new Bullet(cx + (float)(System.Math.Cos((double)Maths.DegToRad(dir)) * 6.0), cy - (float)(System.Math.Sin((double)Maths.DegToRad(dir)) * 6.0), shrap, dir, null, false, -1f, false, true); bullet.firedFrom = this; this.firedBullets.Add(bullet); Level.Add(bullet); laserTimer = 2f; } System.Collections.Generic.IEnumerable <Window> windows = Level.CheckCircleAll <Window>(this.position, 40f); foreach (Window w in windows) { if (Level.CheckLine <Block>(this.position, w.position, w) == null) { w.Destroy(new DTImpact(this)); } } this.bulletFireIndex += 20; if (Network.isActive) { // public NMFireGun(Gun g, List<Bullet> varBullets, byte fIndex, bool rel, byte ownerIndex = 4, bool onlyFireActionVar = false); NMFireGun gunEvent = new NMFireGun(this, this.firedBullets, this.bulletFireIndex, false, 4, false); Send.Message(gunEvent, NetMessagePriority.ReliableOrdered, null); this.firedBullets.Clear(); } this.laserTimer = 2f; } // Level.Remove(this); finsihedExploding = true; base._destroyed = true; this._explodeFrames = -1; this.laserTimer = 2f; } } } if (base.prevOwner != null && this._cookThrower == null) { this._cookThrower = (base.prevOwner as Duck); this._cookTimeOnThrow = this._timer; } this._sprite.frame = (this._pin ? 0 : 1); }