/// <summary> /// Removes the old terrain physics bodies and replaces them with new ones, /// generated from the given terrain. /// </summary> public void UpdateTerrainBody(Terrain terrain) { Terrain = terrain; foreach (var body in TerrainBodies) { var fixtures = body.FixtureList.ToArray(); foreach (var fixture in fixtures) { fixture.Dispose(); } body.Dispose(); } TerrainBodies.Clear(); // Update the terrain explicitly terrain.Update(); var outlines = terrain.GetOutline(); foreach (var outline in outlines) { var vertices = new Vector2[outline.Count]; for (int i = 0; i < outline.Count; i++) { vertices[i] = outline[i] * terrain.Scale; } var shape = new ChainShape(new Vertices(vertices)); var body = new Body(PhysicsWorld); body.BodyType = BodyType.Static; body.Friction = 1.0f; body.CreateFixture(shape); TerrainBodies.Add(body); } }
public World(Terrain newTerrain) { StaticGeometry = newTerrain; Water = new Water(50,25); }
public World(List<Entity> newEntitites, Terrain newTerrain) { Entities = newEntitites; StaticGeometry = newTerrain; }
public override void OnTerrainCollision(Terrain terrain, Vector2 position) { if (Ballz.The().Match.IsRemoteControlled) return; float impact = 0.04f * Velocity.Length() * BulletHoleRadius; if (impact > 0.2) { // Destroy terrain and die terrain.SubtractCircle(position.X, position.Y, impact); } onAnyCollision(); }