public Texture2D TextureFromWorldElement(PhysicsWorldElementEntity elementEntity) { Vertices vertices; switch (elementEntity.ElementType) { case ElementType.Circle: throw new NotImplementedException(); case ElementType.Elipsis: throw new NotImplementedException(); case ElementType.Polygon: PolygonElementEntity polygon = elementEntity as PolygonElementEntity; vertices = new Vertices(polygon.Vertices.Count); foreach (var vertex in polygon.Vertices) { vertices.Add(ConvertUnits.ToDisplayUnits(vertex)); } polygon.Origin = polygon.Vertices.GetCentroid(); break; case ElementType.Rectangle: RectangleElementEntity rectangle = elementEntity as RectangleElementEntity; vertices = new Vertices(4); vertices.Add(Vector2.Zero); vertices.Add(new Vector2(ConvertUnits.ToDisplayUnits(rectangle.Width), 0)); vertices.Add(new Vector2(ConvertUnits.ToDisplayUnits(rectangle.Width), ConvertUnits.ToDisplayUnits(rectangle.Height))); vertices.Add(new Vector2(0, ConvertUnits.ToDisplayUnits(rectangle.Height))); rectangle.Origin = new Vector2(ConvertUnits.ToDisplayUnits(rectangle.Width / 2f), ConvertUnits.ToDisplayUnits(rectangle.Height / 2f)); break; default: throw new NotSupportedException(String.Format("ElementType '{0}' is not supported", elementEntity.ElementType)); } return(TextureFromVertices(vertices, elementEntity.Material, elementEntity.FillColor, elementEntity.OutlineColor.A != 0, elementEntity.OutlineColor, elementEntity.MaterialScale)); }
private WorldEntity createTestWorld() { WorldEntity world = new WorldEntity(); world.WorldInfo = new WorldInfoEntity(); world.WorldInfo.Language = "en"; world.WorldInfo.Name = "UnitTestLevel"; world.WorldInfo.Description = "Test \n \"Description"; world.PhysicsSettings = new PhysicsSettingsEntity(); world.PhysicsSettings.Gravity = Vector2.Zero; RectangleElementEntity rectangle = new RectangleElementEntity(); rectangle.FillColor = Color.Wheat; rectangle.OutlineColor = Color.Black; rectangle.Position = new Vector2(5, 5); rectangle.Width = 5; rectangle.Height = 5; world.WorldElements.Add(rectangle); return(world); }
public override void LoadContent() { base.LoadContent(); TheCoolOne = WorldElements["The Cool One"] as RectangleElementEntity; }
public static void GenerateTexture(GraphicsDevice graphicsDevice, RectangleElementEntity entity) { //Texture2D texture = new Texture2D(graphicsDevice, entity.Size.X, entity.Size.Y, false, SurfaceFormat.Color); }