// Gets the spawn point of the UFO in a position that is not near any other UFO. private static Vector2 SpawnPoint() { Point BATTLEFIELD = (Point)Settings.BATTLEFIELD_DIMENSION.VALUE; Vector2 position; bool distant; do { distant = true; position = new Vector2(Mathematics.Random.Next(50, BATTLEFIELD.X - 50 + 1), Mathematics.Random.Next(50, BATTLEFIELD.Y - 50 + 1)); foreach (Ufo u in EntityManager.ufos) { if (Mathematics.Pythagoras(position, u.Position, Enums.ENEMY_DISTANCE)) { distant = false; break; } } } while (!distant); return(position); }
// All hitboxes are circles private static bool OnCollision(Entity e1, Entity e2) { if (e1.Remove || e2.Remove) { return(false); } return(Mathematics.Pythagoras(e1.Position, e2.Position, (e1.Radius + e2.Radius))); }