public PingMine(Player owner, float angle, World world, MainGameScreen game, Color color) { this.owner = owner; this.world = world; this.game = game; this.color = color; body = BodyFactory.CreateRectangle(world, ConvertUnits.ToSimUnits(10f), ConvertUnits.ToSimUnits(3f), 1f, owner.Body.Position); body.BodyType = BodyType.Dynamic; body.UserData = "invisible"; body.IsBullet = true; body.Rotation = angle + MathHelper.PiOver2; Vector2 impulse = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * 0.01f; body.ApplyLinearImpulse(impulse); body.OnCollision += body_OnCollision; traveling = true; sonarRotation = 0; sonarDistance = 150f; sonarPoints = new List<TempPingInstance>(); sonarPings = new List<TempPingInstance>(); sonarResolution = 1000f; reverseRotation = false; }
public override void Initialize() { screenCursorPos = Vector2.Zero; worldCursorPos = Vector2.Zero; world = new World(Vector2.Zero); map = LoadMapFromFile("map1"); mapBodies = new List<Body>(); for (int i = 0; i < map.Count - 1; i++) { Vector2 difference = map[i] - map[(i + 1) % map.Count]; float distance = Vector2.Distance(map[i], map[(i + 1) % map.Count]); Vector2 centre = (map[i] + map[(i + 1) % map.Count]) / 2f; float angle = (float)Math.Atan2(difference.Y, difference.X) + MathHelper.PiOver2; Body temp = BodyFactory.CreateRectangle(world, ConvertUnits.ToSimUnits(3f), distance, 1f, centre); temp.CollisionCategories = Category.Cat2; temp.CollidesWith = Category.Cat1; temp.Rotation = angle; temp.BodyType = BodyType.Static; mapBodies.Add(temp); } player1 = new Player(this, ConvertUnits.ToSimUnits(0, 0), world, Color.Yellow); player2 = new Player(this, ConvertUnits.ToSimUnits(500, 500), world, Color.Aquamarine); camera = new Camera(owner.Graphics.GraphicsDevice); camera.TrackBody(player1.Body); }