public override void FireInternal(bool alt) { var matterList = new List <NetMatter>(); StructuralIntegrity <NetMatter> matterIntegrity = null; for (var y = 0; y < 3; y++) { for (var x = 0; x < 7; x++) { var matter = new NetMatter(this); var force = new Force(matter.Speed, 45f.NormalizeQuantity(Holder.CalculateAngleToTarget()), Holder.CalculateAngleToTarget()); var matterX = this.Holder.Left + 1 + x; var matterY = this.Holder.Top - 1 + y; matter.MoveTo(matterX, matterY, 1); matterList.Add(matter); // wraps the character in the net if it hits them matter.Speed.ImpactOccurred.SubscribeForLifetime((i) => { if (i.ObstacleHit != Holder && i.ObstacleHit is Character) { OnWrappedCharacter.Fire(new NetWrappedEventArgs() { Net = this, Wrapped = i.ObstacleHit as Character }); matterList.ForEach(m => m.Lifetime.Dispose()); matterList.Clear(); matterIntegrity.Lifetime.Dispose(); for (var newX = i.ObstacleHit.Left - 2; newX <= i.ObstacleHit.Left + 2; newX++) { for (var newY = i.ObstacleHit.Top - 1; newY <= i.ObstacleHit.Top + 1; newY++) { var newMatter = new NetMatter(this); newMatter.MoveTo(newX, newY); matterList.Add(newMatter); } } matterList.ForEach(m => { m.Composite = matterList; SpaceTime.CurrentSpaceTime.Add(m); OnWeaponElementEmitted.Fire(m); }); } }, matter.Lifetime); } } matterList.ForEach(m => { m.Composite = matterList; SpaceTime.CurrentSpaceTime.Add(m); }); matterIntegrity = new StructuralIntegrity <NetMatter>(matterList); SpaceTime.CurrentSpaceTime.Add(matterIntegrity); }
public override void FireInternal(bool alt) { var mine = new TimedMine(this, Delay); ProximityMineDropper.PlaceMineSafe(mine, Holder, !alt); SpaceTime.CurrentSpaceTime.Add(mine); mine.Exploded.SubscribeOnce(this.Exploded.Fire); OnWeaponElementEmitted.Fire(mine); }
public override void FireInternal(bool alt) { var ex = new Explosive(this); ex.SetProperty <Character>(nameof(Holder), this.Holder); ProximityMineDropper.PlaceMineSafe(ex, Holder, !alt); SpaceTime.CurrentSpaceTime.Add(ex); OnWeaponElementEmitted.Fire(ex); }
public override void FireInternal(bool alt) { var mine = new ProximityMine(this) { TargetTag = TargetTag }; PlaceMineSafe(mine, Holder, !alt); SpaceTime.CurrentSpaceTime.Add(mine); OnWeaponElementEmitted.Fire(mine); }
public override void FireInternal(bool alt) { var mine = new ProximityMine(this) { TargetTag = TargetTag, Range = Range, AngleIncrement = AngleIncrement }; mine.SetProperty(nameof(Holder), this.Holder); ProximityMineDropper.PlaceMineSafe(mine, Holder, !alt, Speed); SpaceTime.CurrentSpaceTime.Add(mine); OnWeaponElementEmitted.Fire(mine); }
public override void FireInternal(bool alt) { var targetAngle = Holder.CalculateAngleToTarget(); var sprayAngle = 30.0f; var sprayIncrement = 5; var startAngle = targetAngle.AddToAngle(-sprayAngle / 2); var sprayedSoFar = 0; var bullets = new List <Projectile>(); while (sprayedSoFar <= sprayAngle) { var angle = startAngle.AddToAngle(sprayedSoFar); var bullet = new Projectile(this, Speed, angle) { Range = Range.NormalizeQuantity(angle), PlaySoundOnImpact = true }; bullet.Velocity.HitDetectionExclusions.Add(Holder); Holder.Velocity.HitDetectionExclusions.Add(bullet); bullet.Lifetime.OnDisposed(() => { Holder.Velocity.HitDetectionExclusions.Remove(bullet); }); bullet.MoveTo(bullet.Left, bullet.Top, Holder.ZIndex); if (ProjectilePen != null) { bullet.Pen = ProjectilePen; } bullets.Add(bullet); OnWeaponElementEmitted.Fire(bullet); sprayedSoFar += sprayIncrement; } // n squared so keep n small or else pay the price!!! foreach (var bullet in bullets) { foreach (var innerBullet in bullets) { if (innerBullet != bullet) { bullet.Velocity.HitDetectionExclusions.Add(innerBullet); } } } foreach (var bullet in bullets) { SpaceTime.CurrentSpaceTime.Add(bullet); } }
public override void FireInternal(bool alt) { var bullet = new Projectile(this, Speed, Holder.CalculateAngleToTarget()) { PlaySoundOnImpact = true }; bullet.Velocity.HitDetectionExclusions.Add(Holder); bullet.Velocity.HitDetectionExclusions.AddRange(Holder.Velocity.HitDetectionExclusions); bullet.Velocity.HitDetectionExclusionTypes.AddRange(Holder.Velocity.HitDetectionExclusionTypes); Holder.Velocity.HitDetectionExclusions.Add(bullet); bullet.Lifetime.OnDisposed(() => Holder.Velocity.HitDetectionExclusions.Remove(bullet)); bullet.MoveTo(bullet.Left, bullet.Top, Holder.ZIndex); if (ProjectilePen != null) { bullet.Pen = ProjectilePen; } SpaceTime.CurrentSpaceTime.Add(bullet); OnWeaponElementEmitted.Fire(bullet); }
private void FireDoubleInternal(float x, float y, float angle) // :) { var rpg = new TimedMine(this, TimeSpan.FromSeconds(2)) { Silent = true, ProjectilePen = ProjectilePen }; rpg.MoveTo(x, y, Holder.ZIndex); var rpgSpeed = new Velocity(rpg); rpgSpeed.HitDetectionExclusions.Add(Holder); Holder.Velocity.HitDetectionExclusions.Add(rpg); rpgSpeed.ImpactOccurred.SubscribeForLifetime((impact) => { DamageBroker.Instance.ReportImpact(impact); rpg.Explode(); }, rpg.Lifetime); new Force(rpgSpeed, 45.NormalizeQuantity(angle), angle); SpaceTime.CurrentSpaceTime.Add(rpg); OnWeaponElementEmitted.Fire(rpg); }
public override void FireInternal(bool alt) { activeBlades.ForEach(b => { if (b.Lifetime.IsExpired == false) { b.Lifetime.Dispose(); } }); activeBlades.Clear(); for (var i = 1; i < 1 + Range.NormalizeQuantity(Holder.CalculateAngleToTarget()); i++) { var location = Holder.Center().MoveTowards(Holder.CalculateAngleToTarget(), i); var newBounds = Cli.Physics.RectangularF.Create(location.Left - .5f, location.Top - .5f, 1, 1); if (SpaceTime.CurrentSpaceTime.Bounds.Contains(newBounds)) { var blade = new Blade(this); var holderLocation = Holder.TopLeft(); blade.MoveTo(newBounds.Left, newBounds.Top); SpaceTime.CurrentSpaceTime.Add(blade); activeBlades.Add(blade); OnWeaponElementEmitted.Fire(blade); } } }