public static void Explode(Vector2 pos, short damage) { CircleF circle = new CircleF(pos, 128); foreach (IParticle prtcl in Game1.mapLive.mapParticles) { if (prtcl.Boundary != null) { LineSegmentF Temp = new LineSegmentF(pos, prtcl.Boundary.Origin); Vector2?_thru = CompareF.IntersectionLineWithOthers(Temp, Game1.mapLive.TileMapLines, null); if (_thru == null) { prtcl.Push(Vector2.Normalize(Temp.NormalizedWithZeroSolution() * (float)(Globals.GlobalRandom.NextDouble()) * 2)); } } } int j = 0; foreach (Inpc npc in Game1.mapLive.MapNpcs) { if (j < 8) { LineSegmentF Temp = new LineSegmentF(pos, npc.Boundary.Origin); Vector2?_thru = CompareF.IntersectionLineWithOthers(Temp, Game1.mapLive.TileMapLines, null); if (_thru == null && LineSegmentF.Lenght(pos, npc.Boundary.Origin) < 256) { if (npc.Friendly == false) { npc.KineticDamage(damage); } npc.Push(Vector2.Normalize(Temp.NormalizedWithZeroSolution() * (float)(Globals.GlobalRandom.NextDouble()) * 2)); j++; } } } int x = 4; for (int i = 0; i < x; i++) { Game1.mapLive.mapParticles.Add(new ParticleSmokeBig(circle.GenerateRandomPoint())); } for (int i = 0; i < x; i++) { Game1.mapLive.mapParticles.Add(new ParticleFireBig(circle.GenerateRandomPoint())); } for (int i = 0; i < x; i++) { Game1.mapLive.mapParticles.Add(new ParticleFireSmall(circle.GenerateRandomPoint())); } Camera2DGame.Shake(10, pos); Sound.PlaySoundPosition(pos, Game1.soundExplosion, CustomMath.RandomAroundZero(Globals.GlobalRandom) / 2f); }
public PlayerTurret(Vector2 position) : base() { Boundary = new RectangleF(new Vector2(36, 64), position); _resolver = new CollisionResolver(Globals.TileSize); _weight = 1f; _time = new Timer(100, true); _target = null; _rotation = (float)Math.PI / 2f; _ammo = 0; _bubbleTime = new Timer(300, true); _kick = 0; if (_target == null || LineSegmentF.Lenght(HeadPos, _target.Boundary.Origin) > 512 || CompareF.IntersectionLineWithOthers(new LineObject(Game1.PlayerInstance, new LineSegmentF(HeadPos, _target.Boundary.Origin)), Game1.mapLive.TileMapLines, Game1.mapLive) != null) { foreach (Inpc npc in Game1.mapLive.MapNpcs) { if (npc.Friendly == false && !(npc is IUnkillable) && LineSegmentF.Lenght(HeadPos, npc.Boundary.Origin) <= 512 && CompareF.IntersectionLineWithOthers(new LineObject(Game1.PlayerInstance, new LineSegmentF(HeadPos, npc.Boundary.Origin)), Game1.mapLive.TileMapLines, Game1.mapLive) == null) { _target = npc; break; } } } }