// Invoked from World.Settings internal static void LoadSettings(IEnumerable <XElement> xmlToolSettings) { foreach (var xElement in xmlToolSettings.Elements("Tool")) { string toolName = (string)xElement.Attribute("Name"); switch (toolName) { case "Paint": _paintMode = (PaintMode)ToEnum(typeof(PaintMode), (string)xElement.Attribute("Mode") ?? PaintMode.Tile.ToString()); break; case "Brush": _brushWidth = (int?)xElement.Attribute("Width") ?? 20; _brushHeight = (int?)xElement.Attribute("Height") ?? 20; _brushOutline = (int?)xElement.Attribute("Outline") ?? 1; _brushShape = (BrushShape)ToEnum(typeof(BrushShape), (string)xElement.Attribute("Shape") ?? BrushShape.Square.ToString()); break; case "Tile": _paintTile = (int?)xElement.Attribute("Tile") ?? 0; _paintTileMask = (int?)xElement.Attribute("Mask") ?? 0; _paintTileMaskMode = (MaskMode)ToEnum(typeof(MaskMode), (string)xElement.Attribute("Mode") ?? MaskMode.Off.ToString()); break; case "Wall": _paintWall = (int?)xElement.Attribute("Wall") ?? 0; _paintWallMask = (int?)xElement.Attribute("Mask") ?? 0; _paintWallMaskMode = (MaskMode)ToEnum(typeof(MaskMode), (string)xElement.Attribute("Mode") ?? MaskMode.Off.ToString()); break; } } }
public virtual void SetData(string key, string value, Bot bot, Player player) { switch (key) { case "size": case "radius": { if (int.TryParse(value, out size)) { bot.connection.Send("say", player.name + ": Size: " + size); } else { bot.connection.Send("say", player.name + ": That is not a size."); } } break; case "shape": { BrushShape brushShape = BrushShape.FromName(value); if (brushShape != null) { shape = brushShape; bot.connection.Send("say", player.name + ": Shape: " + brushShape.Name); } else { bot.connection.Send("say", player.name + ": Shape doesn't exist."); } } break; } }
void DrawCursor(BrushShape S) { Gizmos.color = Color.green; List <Vector3> Positions = new List <Vector3>(); foreach (Vector3 V in S.vertices) { Positions.Add((new Vector3(V.x, 0f, V.y) * brushSize) + mousePosition); } for (int i = 0; i < Positions.Count; i++) { Positions[i] += new Vector3(0f, .1f, 0f); } for (int i = 0; i < Positions.Count - 1; i++) { Gizmos.DrawLine(Positions[i], Positions[i + 1]); } Gizmos.DrawLine(Positions[Positions.Count - 1], Positions[0]); /*foreach(Vector3 V in Positions) * { * * Gizmos.DrawCube(V, new Vector3(.25f,.25f,.25f)); * * }*/ //Gizmos.DrawLine(mousePosition + (Vector3) S.vertices[0], mousePosition + (Vector3) S.vertices[1]); //Gizmos.DrawWireSphere(this.transform.position, 5f); }
public void SetBrushShape(BrushShape s) { _brushShape = s; goc_cylinder.SetActive(s == BrushShape.Cylinder); goc_sphere.SetActive(s == BrushShape.Sphere); goc_cube.SetActive(s == BrushShape.Cube); _currentShapeGo = s == BrushShape.Cube ? goc_cube : s == BrushShape.Sphere ? goc_sphere : goc_cylinder; }
public void SetShape(int newShape) { if (newShape == 0) { shape = BrushShape.Sphere; sphereMesh.gameObject.SetActive(true); cubeMesh.gameObject.SetActive(false); } else if (newShape == 1) { shape = BrushShape.Cuboid; cubeMesh.gameObject.SetActive(true); sphereMesh.gameObject.SetActive(false); } }
void OnGUI() { GUILayout.Label("Base Settings", EditorStyles.boldLabel); GUILayout.Label(currentDisplayMode.ToString()); //SetToolMode((DisplayMode)EditorGUILayout.EnumPopup("View Mode", currentDisplayMode)); if (currentDisplayMode == DisplayMode.GameView) { canvasSize = EditorGUILayout.Vector2IntField("Canvas Scale", canvasSize); if (GUILayout.Button("Spawn Canvas")) { SpawnWorldCanvas(); } } if (currentDisplayMode == DisplayMode.DrawView) { color = EditorGUILayout.ColorField("Pencil Color", color); currentBrushShape = (BrushShape)EditorGUILayout.EnumPopup("Brush Shape", currentBrushShape); brushSize = EditorGUILayout.Slider(brushSize, 1f, 100f); if (GUILayout.Button("Finish Drawing")) { SetToolMode(DisplayMode.GameView); Sprite drawSprite = currentCanvas.GetComponent <SpriteRenderer>().sprite; for (int y = 0; y < currentCanvas.GetComponent <WorldEditorCanvas>().size.y; y++) { for (int x = 0; x < currentCanvas.GetComponent <WorldEditorCanvas>().size.x; x++) { if (drawSprite.texture.GetPixel(x, y) == new Color(1, 1, 1, 1)) { drawSprite.texture.SetPixel(x, y, new Color(0, 0, 0, 0)); } } } drawSprite.texture.Apply(); currentCanvas.GetComponent <SpriteRenderer>().sprite = drawSprite; currentCanvas.GetComponent <WorldEditorCanvas>().SetColliderType(typeof(PolygonCollider2D)); } } }
// Invoked from World.Settings internal static void LoadSettings(IEnumerable<XElement> xmlToolSettings) { foreach (var xElement in xmlToolSettings.Elements("Tool")) { string toolName = (string)xElement.Attribute("Name"); switch (toolName) { case "Paint": _paintMode = (PaintMode)ToEnum(typeof(PaintMode), (string)xElement.Attribute("Mode") ?? PaintMode.TileAndWall.ToString()); break; case "Brush": _brushWidth = (int?)xElement.Attribute("Width") ?? 20; _brushHeight = (int?)xElement.Attribute("Height") ?? 20; _brushOutline = (int?)xElement.Attribute("Outline") ?? 1; _brushShape = (BrushShape)ToEnum(typeof(BrushShape), (string)xElement.Attribute("Shape") ?? BrushShape.Square.ToString()); break; case "Tile": _paintTile = (int?)xElement.Attribute("Tile") ?? 0; _paintTileMask = (int?)xElement.Attribute("Mask") ?? 0; _paintTileActive = (bool)xElement.Attribute("Active"); _paintTileMaskMode = (MaskMode)ToEnum(typeof(MaskMode), (string)xElement.Attribute("Mode") ?? MaskMode.Off.ToString()); break; case "Wall": _paintWall = (int?)xElement.Attribute("Wall") ?? 0; _paintWallMask = (int?)xElement.Attribute("Mask") ?? 0; _paintWallActive = (bool)xElement.Attribute("Active"); _paintWallMaskMode = (MaskMode)ToEnum(typeof(MaskMode), (string)xElement.Attribute("Mode") ?? MaskMode.Off.ToString()); break; case "Wire": _redWire = (bool)xElement.Attribute("Red"); _blueWire = (bool)xElement.Attribute("Blue"); _greenWire = (bool)xElement.Attribute("Green"); break; } } }
/// <summary> /// The default constructor where you can set up default variable values /// </summary> public Brush() : base() { radius = 1; shape = BrushShape.Square; }
public Brush(Color color, BrushSize size, BrushShape shape) { this.Color = color; this.Size = size; this.Shape = shape; }