Ejemplo n.º 1
0
        public override bool OnClick(Point point, ScriptableTile tile, TileMap map)
        {
            if (tile == null && map == null)
            {
                return(false);
            }

            //If we haven't already started an operation, start one now
            //This is for undo/ redo support
            if (!map.OperationInProgress())
            {
                map.BeginOperation();
            }

            int correctedRadius = radius - 1;

            bool result = false;

            for (int x = -correctedRadius; x <= correctedRadius; x++)
            {
                for (int y = -correctedRadius; y <= correctedRadius; y++)
                {
                    Point offsetPoint = point + new Point(x, y);

                    if (map.SetTileAt(offsetPoint, null))
                    {
                        result = true;
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        //Called when the left mouse button is held down
        public override bool OnClick(Point point, ScriptableTile tile, TileMap map)
        {
            //Return if the tilemap is null/empty
            if (map == null)
            {
                return(false);
            }

            //If we haven't already started an operation, start one now
            //This is for undo/ redo support
            if (!map.OperationInProgress())
            {
                map.BeginOperation();
            }

            //Set the tile at the specified point to the specified tile
            return(map.SetTileAt(point, tile));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Called by the tilemap editor to paint tiles
        /// </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 override bool OnClick(Point point, ScriptableTile tile, TileMap map)
        {
            if (tile == null || map == null)
            {
                return(false);
            }

            //If we haven't already started an operation, start one now
            //This is for undo/ redo support
            if (!map.OperationInProgress())
            {
                map.BeginOperation();
            }

            int correctedRadius = radius - 1;

            bool result = false;

            for (int x = -correctedRadius; x <= correctedRadius; x++)
            {
                for (int y = -correctedRadius; y <= correctedRadius; y++)
                {
                    Point offsetPoint = point + new Point(x, y);

                    if (shape == BrushShape.Circle)
                    {
                        Vector2 delta = (Vector2)(offsetPoint - point);
                        if (delta.sqrMagnitude > radius * radius)
                        {
                            continue;
                        }
                    }

                    if (map.SetTileAt(offsetPoint, tile))
                    {
                        result = true;
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 4
0
        // Called by the tilemap editor to paint tiles
        public override void OnClick(Point point, ScriptableTile tile, TileMap map)
        {
            if (map == null)
            {
                return;
            }

            //If we haven't already started an operation, start one now
            //This is for undo/ redo support
            if (!map.OperationInProgress())
            {
                map.BeginOperation();
            }

            for (int i = 0; i < region.Count; i++)
            {
                Point offsetPoint = region[i];

                map.SetTileAt(offsetPoint, tile);
            }
        }