public static void BeginGoldExplosion( ExplodeFX fx, Point3D center, Map map, int range, int minGold, int maxGold, int[] explodeSounds = null, int[] dropSounds = null) { BaseExplodeEffect efx = fx.CreateInstance(center, map, 2, 3); if (efx == null) { return; } minGold = Math.Max(10, Math.Min(60000, minGold)); maxGold = Math.Max(minGold, Math.Min(60000, maxGold)); explodeSounds = explodeSounds ?? new[] {284, 285, 286, 776, 1231}; efx.AverageZ = false; efx.EffectHandler = e => { if (Utility.RandomDouble() < 0.25) { Effects.PlaySound(e.Source, e.Map, explodeSounds.GetRandom()); } }; efx.Callback = () => { efx.Start = efx.Start.Clone3D(0, 0, 10); if (efx.CurProcess >= efx.Repeat) { EndGoldExplosion(fx, center.Clone3D(0, 0, 10 * efx.Repeat), map, range, minGold, maxGold, dropSounds); } }; efx.Send(); }
public static void BeginGoldExplosion( ExplodeFX fx, Point3D center, Map map, int range, int minGold, int maxGold, int[] explodeSounds = null, int[] dropSounds = null) { BaseExplodeEffect efx = fx.CreateInstance(center, map, 2, 3); if (efx == null) { return; } minGold = Math.Max(10, Math.Min(60000, minGold)); maxGold = Math.Max(minGold, Math.Min(60000, maxGold)); explodeSounds = explodeSounds ?? new[] { 284, 285, 286, 776, 1231 }; efx.AverageZ = false; efx.EffectHandler = e => { if (Utility.RandomDouble() < 0.25) { Effects.PlaySound(e.Source, e.Map, explodeSounds.GetRandom()); } }; efx.Callback = () => { efx.Start = efx.Start.Clone3D(0, 0, 10); if (efx.CurProcess >= efx.Repeat) { EndGoldExplosion(fx, center.Clone3D(0, 0, 10 * efx.Repeat), map, range, minGold, maxGold, dropSounds); } }; efx.Send(); }
public static void EndGoldExplosion( ExplodeFX fx, Point3D center, Map map, int range, int minGold, int maxGold, int[] dropSounds = null) { BaseExplodeEffect efx = fx.CreateInstance(center, map, range); if (efx == null) { return; } efx.AverageZ = false; efx.Callback = () => { var points = new List<Point3D>(); center.ScanRange( map, range, r => { if (!r.Excluded) { if (r.QueryMap.CanFit(r.Current, 1, false, false) || r.QueryMap.HasWater(r.Current)) { points.Add(r.Current); } else { r.Exclude(); } } return false; }); if (points.Count == 0) { return; } dropSounds = dropSounds ?? new[] {553, 554}; Timer goldTimer = null; goldTimer = Timer.DelayCall( TimeSpan.FromSeconds(1), TimeSpan.FromMilliseconds(100), points.Count, () => { if (points.Count == 0) { if (goldTimer != null) { goldTimer.Running = false; goldTimer = null; } return; } Point3D p = points.GetRandom(); points.Remove(p); Effects.PlaySound(p, map, dropSounds.GetRandom()); new MovingEffectInfo(p.Clone3D(0, 0, Utility.RandomMinMax(30, 50)), p, map, 3823, 0, 10, EffectRender.Lighten) .MovingImpact( e => { int amount = Utility.RandomMinMax(minGold, maxGold); if (amount <= 0) { return; } var g = new Gold(amount); g.MoveToWorld(e.Target.Location, e.Map); new EffectInfo(e.Target, e.Map, 14202, 51, 10, 40, EffectRender.Lighten).Send(); Effects.PlaySound(e.Target, e.Map, g.GetDropSound()); }); }); }; efx.Send(); }
public static void EndGoldExplosion( ExplodeFX fx, Point3D center, Map map, int range, int minGold, int maxGold, int[] dropSounds = null) { BaseExplodeEffect efx = fx.CreateInstance(center, map, range); if (efx == null) { return; } efx.AverageZ = false; efx.Callback = () => { var points = new List <Point3D>(); center.ScanRange( map, range, r => { if (!r.Excluded) { if (r.QueryMap.CanFit(r.Current, 1, false, false) || r.QueryMap.HasWater(r.Current)) { points.Add(r.Current); } else { r.Exclude(); } } return(false); }); if (points.Count == 0) { return; } dropSounds = dropSounds ?? new[] { 553, 554 }; Timer goldTimer = null; goldTimer = Timer.DelayCall( TimeSpan.FromSeconds(1), TimeSpan.FromMilliseconds(100), points.Count, () => { if (points.Count == 0) { if (goldTimer != null) { goldTimer.Running = false; goldTimer = null; } return; } Point3D p = points.GetRandom(); points.Remove(p); Effects.PlaySound(p, map, dropSounds.GetRandom()); new MovingEffectInfo(p.Clone3D(0, 0, Utility.RandomMinMax(30, 50)), p, map, 3823, 0, 10, EffectRender.Lighten) .MovingImpact( e => { int amount = Utility.RandomMinMax(minGold, maxGold); if (amount <= 0) { return; } var g = new Gold(amount); g.MoveToWorld(e.Target.Location, e.Map); new EffectInfo(e.Target, e.Map, 14202, 51, 10, 40, EffectRender.Lighten).Send(); Effects.PlaySound(e.Target, e.Map, g.GetDropSound()); }); }); }; efx.Send(); }