Пример #1
0
 public override bool OnClickUp(Point point, ScriptableTile tile, TileMap map)
 {
     map.UpdateTileMap();
     return(false);
 }
Пример #2
0
 public override Sprite GetSprite(TileMap tilemap = null, Point position = default(Point))
 {
     return(sprite);
 }
Пример #3
0
 public override bool OnClick(Point point, ScriptableTile tile, TileMap map)
 {
     return(false);
 }
Пример #4
0
 public override bool OnClickDown(Point point, ScriptableTile tile, TileMap map)
 {
     return(OnClick(point, tile, map));
 }
Пример #5
0
 //Called when the left mouse button is held down
 public override void OnClick(Point point, ScriptableTile tile, TileMap map)
 {
 }
Пример #6
0
 public override void OnClick(Point point, ScriptableTile tile, TileMap map)
 {
     base.OnClick(point, null, map);
 }
Пример #7
0
 //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;
 }
Пример #8
0
 public abstract Color [] GetColors(TileMap tilemap   = null, Point position = default(Point));
Пример #9
0
 /// <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);
Пример #10
0
 public override void OnClickUp(Point point, ScriptableTile tile, TileMap map)
 {
     map.primaryTile = map.GetTileAt(point);
 }
Пример #11
0
 //Called when LMB is released
 public virtual void OnClickUp(Point point, ScriptableTile tile, TileMap map)
 {
     map.FinishOperation();
 }
Пример #12
0
 //Called when LMB is clicked down
 public virtual void OnClickDown(Point point, ScriptableTile tile, TileMap map)
 {
     map.BeginOperation();
 }
Пример #13
0
 //Called when LMB is held down
 public abstract void OnClick(Point point, ScriptableTile tile, TileMap map);
Пример #14
0
 public override Texture2D GetTexture(TileMap tilemap = null, Point position = default(Point))
 {
     //	if (texture == null)
     //		RebuildTexture ();
     return(texture);
 }
Пример #15
0
        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);
        }
Пример #16
0
 public abstract Sprite GetSprite(TileMap tilemap = null, Point position = default(Point));
Пример #17
0
 public override bool OnClickDown(Point point, ScriptableTile tile, TileMap map)
 {
     map.BeginOperation();
     return(OnClick(point, tile, map));
 }
Пример #18
0
 public abstract Texture2D GetTexture(TileMap tilemap = null, Point position = default(Point));
Пример #19
0
 public override bool OnClickDown(Point point, ScriptableTile tile, TileMap map)
 {
     map.primaryTile = map.GetTileAt(point);
     return(true);
 }
Пример #20
0
        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);
        }
Пример #21
0
        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);
        }