public void CreateExplosion(WeaponInfo ExplosiveWeaponType, Point Target, NetworkMode Mode) { Sounds.explosion.ToSoundAsset().play(); if (Mode == NetworkMode.Local) { var Range = ExplosiveWeaponType.Range; foreach (var v in from i in AllMortals let p = i.ToPoint() - Target where p.length < Range select new { i, p }) { var Damage = (ExplosiveWeaponType.Damage * ((Range - v.p.length) / Range)).ToInt32(); if (NetworkAddDamageFromDirection != null) NetworkAddDamageFromDirection(v.i.NetworkId, Damage, v.p.GetRotation().RadiansToDegrees()); v.i.AddDamageFromDirection(Damage, v.p.GetRotation()); } } var a = new Animation(null, Images.Explosions.ani6); a.LastFrame += delegate { a.AnimationEnabled = false; a.Orphanize(); }; a.MoveTo(Target).AttachTo(GetWarzone()); a.AnimationEnabled = true; }
public void CreateExplosiveBarrel(Weapon weapon, Point Target, int BarrelId, NetworkMode Mode) { // fixme: Weapon Weapon - cannot have this. var barrel = new ExplosiveBarrel { ExplosiveMaterialType = weapon.Clone(), NetworkId = BarrelId }; barrel.ExplosiveMaterialType.Ammo = 1; var DamageTaken = false; #region HealthChangedToWorse barrel.HealthChangedToWorse += delegate { if (!barrel.IsAlive) return; if (DamageTaken) return; barrel.filters = new[] { new GlowFilter(ColorRed, 0.3) }; DamageTaken = true; if (Mode == NetworkMode.Local) 500.AtDelayDo( delegate { if (!barrel.IsAlive) return; var Damage = barrel.Health.ToInt32() + 1; if (this.NetworkAddDamage != null) this.NetworkAddDamage(barrel.NetworkId, Damage); barrel.AddDamage(Damage); // notify network? } ); }; #endregion barrel.Die += delegate { barrel.RemoveFrom(Barrels).Orphanize(); #region hole var hole = new Animation(Images.hole_1).MoveTo(barrel).AttachTo(GetWarzone()); (10000 + 10000.Random().ToInt32()).AtDelayDo( delegate { hole.Orphanize(); hole = new Animation(Images.hole_2).MoveTo(barrel).AttachTo(GetWarzone()); }, delegate { hole.Orphanize(); } ); #endregion // damage objects around the barrel var ExplosiveWeapon = barrel.ExplosiveMaterialType; CreateExplosion(ExplosiveWeapon.Type, barrel.ToPoint(), Mode); }; barrel.MoveTo(Target).AttachToBefore(Ego).AddTo(Barrels); }