public FillTool(Tile baseTile) { BaseTile = baseTile; PreviousTiles = new Dictionary<Point, Tile>(); CurrentTiles = new Dictionary<Point, Tile>(); Index = 1; Used = false; }
public BrushTool(Tile baseTile, int brushSize) { BaseTile = baseTile; BrushSize = brushSize; PreviousTiles = new Dictionary<Point, Tile>(); CurrentTiles = new Dictionary<Point, Tile>(); Index = 0; Used = false; tiles = UtilityFramework.Util.GetInitialized2DArray<Tile>(BrushSize, BrushSize, BaseTile); }
public CurrentBrush(Tile tile) { Tool = new BrushTool(tile, 1); boundsColor = new Color[] { new Color(255, 255, 255, 100) }; SetTile(); }
public static void SetTileAt(int x, int y, Tile tile) { ActiveLayer.Tiles[x][y] = tile; }
public static void ResetLayer(Tile clearTile, int layerIndex) { Layers[layerIndex].Generate(clearTile); SetActiveLayer(layerIndex); }
public static void ResetActiveLayer(Tile clearTile) { ActiveLayer.Generate(clearTile); }
public static void GenerateNewLayer(int XCount, int YCount, int SingleWidth, int SingleHeight, Tile clearTile, string layerName, LayerTraits options = 0) { Settings.Dimensions = new Dimensions(XCount, YCount, SingleWidth, SingleHeight); Layers.Add(new TileLayer(layerName, options, Game1.UPS * 1)); Layers.Last().Generate(clearTile); SetActiveLayer(Layers.Count - 1); }
public static void GenerateNewLayer(Dimensions dim, Tile clearTile, string layerName, LayerTraits options = 0) { Settings.Dimensions = dim; Layers.Add(new TileLayer(layerName, options, Game1.UPS * 1)); Layers.Last().Generate(clearTile); SetActiveLayer(Layers.Count - 1); }
public override void Use() { if (Used) return; Used = true; OverwriteTile = Map.GetTileAt(Origin.X, Origin.Y); if (BaseTile == OverwriteTile) return; List<Vector2> queue = new List<Vector2>(); List<Vector2> processed = new List<Vector2>(); queue.Add(Origin.ToVector2()); while (queue.Count > 0) { Vector2 n = queue[0]; queue.RemoveAt(0); if (Map.GetTileAt((int)n.X, (int)n.Y) == OverwriteTile) { PreviousTiles.Add(n.ToPoint(), Map.GetTileAt((int)n.X, (int)n.Y)); Map.SetTileAt((int)n.X, (int)n.Y, BaseTile); CurrentTiles.Add(n.ToPoint(), BaseTile); processed.Add(n); if (!processed.Contains(n + new Vector2(-1, 0)) && n.X - 1 >= 0) queue.Add(n + new Vector2(-1, 0)); if (!processed.Contains(n + new Vector2(1, 0)) && n.X + 1 < Map.Settings.Dimensions.XCount) queue.Add(n + new Vector2(1, 0)); if (!processed.Contains(n + new Vector2(0, -1)) && n.Y - 1 >= 0) queue.Add(n + new Vector2(0, -1)); if (!processed.Contains(n + new Vector2(0, 1)) && n.Y + 1 < Map.Settings.Dimensions.YCount) queue.Add(n + new Vector2(0, 1)); } } }
public UseCurrentTool() { tool = Map.CurrentBrush.Tool; origin = tool.Origin; baseTile = tool.BaseTile; overwriteTile = Map.GetTileAt(origin.X, origin.Y); currentLayer = Map.ActiveLayer; brushSize = tool.BrushSize; }
public void LoadFromFile(string filePath) { //index index index ... Stains = Util.GetInitialized2DArray<Color>(Map.Settings.Dimensions.XCount, Map.Settings.Dimensions.YCount, Color.White); StreamReader sr = new StreamReader(filePath); List<int> data = new List<int>(); int count = Map.Settings.Dimensions.XCount * Map.Settings.Dimensions.YCount; int counter = 0; double loadCounter = 0; string options = sr.ReadLine(); Options = (LayerTraits)Convert.ToInt32(options); while (counter < count) { data.Add(Convert.ToInt32(sr.ReadLine())); counter++; Util.LoadCounter(count * 2, '-', ref loadCounter); } sr.Dispose(); Tiles = new Tile[Map.Settings.Dimensions.XCount][]; for (int x = 0; x < Map.Settings.Dimensions.XCount; x++) { Tiles[x] = new Tile[Map.Settings.Dimensions.YCount]; for (int y = 0; y < Map.Settings.Dimensions.YCount; y++) { Tiles[x][y] = Map.Settings.AccessibleTiles.TilesByIndex[data[y * Map.Settings.Dimensions.XCount + x]]; Util.LoadCounter(count * 2, '-', ref loadCounter); } } data = null; GC.Collect(); }
public void Generate(Tile fillTile) { Tiles = new Tile[Map.Settings.Dimensions.XCount][]; Stains = Util.GetInitialized2DArray<Color>(Map.Settings.Dimensions.XCount, Map.Settings.Dimensions.YCount, Color.White); for (int x = 0; x < Map.Settings.Dimensions.XCount; x++) { Tiles[x] = new Tile[Map.Settings.Dimensions.YCount]; for (int y = 0; y < Map.Settings.Dimensions.YCount; y++) { Tiles[x][y] = fillTile; } } }