public override bool OnClickUp(Point point, ScriptableTile tile, TileMap map) { map.UpdateTileMap(); return(false); }
public override Sprite GetSprite(TileMap tilemap = null, Point position = default(Point)) { return(sprite); }
public override bool OnClick(Point point, ScriptableTile tile, TileMap map) { return(false); }
public override bool OnClickDown(Point point, ScriptableTile tile, TileMap map) { return(OnClick(point, tile, map)); }
//Called when the left mouse button is held down public override void OnClick(Point point, ScriptableTile tile, TileMap map) { }
public override void OnClick(Point point, ScriptableTile tile, TileMap map) { base.OnClick(point, null, map); }
//Called when the left mouse button is initially held down public override void OnClickDown(Point point, ScriptableTile tile, TileMap map) { base.OnClickDown(point, tile, map); start = end = point; }
public abstract Color [] GetColors(TileMap tilemap = null, Point position = default(Point));
/// <summary> /// Called by the tilemap when the left click is let go of /// </summary> /// <param name="point">Where you want to use the tool</param> /// <param name="tile">The ScriptableTile you want to use</param> /// <param name="map">What you want to use the tool on</param> public abstract bool OnClickUp(Point point, ScriptableTile tile, TileMap map);
public override void OnClickUp(Point point, ScriptableTile tile, TileMap map) { map.primaryTile = map.GetTileAt(point); }
//Called when LMB is released public virtual void OnClickUp(Point point, ScriptableTile tile, TileMap map) { map.FinishOperation(); }
//Called when LMB is clicked down public virtual void OnClickDown(Point point, ScriptableTile tile, TileMap map) { map.BeginOperation(); }
//Called when LMB is held down public abstract void OnClick(Point point, ScriptableTile tile, TileMap map);
public override Texture2D GetTexture(TileMap tilemap = null, Point position = default(Point)) { // if (texture == null) // RebuildTexture (); return(texture); }
public override List <Point> GetRegion(Point point, ScriptableTile tile, TileMap map) { region = new List <Point>(); if (end == start) { return(base.GetRegion(point, tile, map)); } int x0 = Mathf.Min(start.x, end.x), x1 = Mathf.Max(start.x, end.x), y0 = Mathf.Min(start.y, end.y), y1 = Mathf.Max(start.y, end.y); int xc = Mathf.FloorToInt(x0 + (x1 - x0) / 2f); int yc = Mathf.FloorToInt(y0 + (y1 - y0) / 2f); int rx = x1 - xc; int ry = y1 - yc; int rxSq = rx * rx; int rySq = ry * ry; int x = 0, y = ry, p; int px = 0, py = 2 * rxSq * y; DrawQuadrants(xc, yc, x, y); //Region 1 p = (int)(rySq - (rxSq * ry) + (0.25f * rxSq)); while (px < py) { x++; px = px + 2 * rySq; if (p < 0) { p = p + rySq + px; } else { y--; py = py - 2 * rxSq; p = p + rySq + px - py; } DrawQuadrants(xc, yc, x, y); } //Region 2 p = (int)(rySq * (x + 0.5f) * (x + 0.5f) + rxSq * (y - 1) * (y - 1) - rxSq * rySq); while (y > 0) { y--; py = py - 2 * rxSq; if (p > 0) { p = p + rxSq - py; } else { x++; px = px + 2 * rySq; p = p + rxSq - py + px; } DrawQuadrants(xc, yc, x, y); } return(region); }
public abstract Sprite GetSprite(TileMap tilemap = null, Point position = default(Point));
public override bool OnClickDown(Point point, ScriptableTile tile, TileMap map) { map.BeginOperation(); return(OnClick(point, tile, map)); }
public abstract Texture2D GetTexture(TileMap tilemap = null, Point position = default(Point));
public override bool OnClickDown(Point point, ScriptableTile tile, TileMap map) { map.primaryTile = map.GetTileAt(point); return(true); }
public override List <Point> GetRegion(Point point, ScriptableTile tile, TileMap map) { if (region.Contains(point)) { return(region); } region = new List <Point>(); //Gets the tile where you clicked ScriptableTile start = map.GetTileAt(point); //Return if there tile specified is null if (tile == null) { return(region); } //The queue of points that need to be changed to the specified tile Queue <Point> open = new Queue <Point> (); //The list of points already changed to the specified tile List <Point> closed = new List <Point> (); //A number larger than the amount of tiles available int maxLoops = map.Width * map.Height * 10; //Add the specified point to the open queue open.Enqueue(point); //As long as there are items in the queue, keep this running while (open.Count > 0) { //Decrement the max loops value maxLoops--; //If we've executed this code more than the max loops then we've done something wrong :/ if (maxLoops <= 0) { Debug.LogError("Fill tool, max loops reached!"); return(region); } Point p = open.Dequeue(); if (closed.Contains(p)) { continue; } closed.Add(p); ScriptableTile t = map.GetTileAt(p); if (!map.IsInBounds(p) || t != start) { continue; } open.Enqueue(p.Up); open.Enqueue(p.Right); open.Enqueue(p.Down); open.Enqueue(p.Left); region.Add(p); } return(region); }
public override List <Point> GetRegion(Point point, ScriptableTile tile, TileMap map) { region = new List <Point>(); if (end == start) { return(base.GetRegion(point, tile, map)); } int x0 = start.x, x1 = end.x, y0 = start.y, y1 = end.y; int w = x1 - x0; int h = y1 - y0; int dx0 = 0, dy0 = 0, dx1 = 0, dy1 = 0; if (w < 0) { dx0 = -1; } else if (w > 0) { dx0 = 1; } if (h < 0) { dy0 = -1; } else if (h > 0) { dy0 = 1; } if (w < 0) { dx1 = -1; } else if (w > 0) { dx1 = 1; } int longest = Mathf.Abs(w); int shortest = Mathf.Abs(h); if (!(longest > shortest)) { longest = Mathf.Abs(h); shortest = Math.Abs(w); if (h < 0) { dy1 = -1; } else if (h > 0) { dy1 = 1; } dx1 = 0; } int numerator = longest >> 1; for (int i = 0; i <= longest; i++) { region.Add(new Point(x0, y0)); numerator += shortest; if (!(numerator < longest)) { numerator -= longest; x0 += dx0; y0 += dy0; } else { x0 += dx1; y0 += dy1; } } return(region); }