예제 #1
0
        /// <summary>
        /// Cleans the map and removes isolated groups of 1-2
        /// tiles to make the map look much cleaner
        /// </summary>
        void CleanMap()
        {
            for (int x = 0; x < Width; x++)
            {
                for (int y = 0; y < Height; y++)
                {
                    if (GetNeighbours(x, y) <= 2)
                    {
                        Map [x, y].Type = TileType.Air;
                    }
                }
            }
            Location l = Escapade.GetPlayer().Location;

            if (l != null)
            {
                Map [l.X, l.Y].Type = TileType.Air;
            }
        }
예제 #2
0
        /// <summary>
        /// Modifies a tile at a specific location
        /// </summary>
        /// <param name="loc">The location of the tile being modified</param>
        public void ModifyTile(Location loc)
        {
            if (SwinGame.PointPointDistance(new Point2D {
                X = loc.X, Y = loc.Y
            }, new Point2D {
                X = Escapade.GetPlayer().Location.X, Y = Escapade.GetPlayer().Location.Y
            }) > 2)
            {
                return;
            }
            if (loc.X < 1 || loc.X >= Width - 1 || loc.Y < 1 || loc.Y >= Height - 1)
            {
                return;
            }
            Tile tile = Map [loc.X, loc.Y];

            if (tile.Type == TileType.Rock)
            {
                Map[loc.X, loc.Y] = new Tile(TileType.Air);
                if (tile.Mineral != null)
                {
                    Escapade.GetPlayer().Inventory.AddItem(tile.Mineral);
                }
            }
            if (tile.Type == TileType.Air && SwinGame.KeyDown(KeyCode.ShiftKey))
            {
                Map [loc.X, loc.Y] = new Tile(TileType.Rock);
            }
            for (int x = -1; x <= 1; x++)
            {
                for (int y = -1; y <= 1; y++)
                {
                    if (loc.X + x < 0 || loc.Y + y < 0 || loc.X + x > Width - 1 || loc.Y + y > Height - 1)
                    {
                        continue;
                    }
                    Map [loc.X + x, loc.Y + y].Mask = GetTileMask(loc.X + x, loc.Y + y);
                }
            }
        }