Exemple #1
0
        public Map(World world, string name, int width, int height, Random random)
        {
            Height = height;
            Name = name;
            Width = width;

            _random = random;
            _connections = new List<MapConnection>(256);
            _items = new List<Item>();
            _mobiles = new List<Mobile>();
            _tiles = new Tile[width * height];
            _world = world;

            for (var i = 0; i < TileCount; ++i)
            {
                _tiles[i] = new Tile();
                _tiles[i].Position = IndexToPoint(i);
            }
        }
Exemple #2
0
 public void AddSubtile(Tile tile)
 {
     _subTiles.Add(tile);
 }
Exemple #3
0
 public static Tile GetRandomTile(string stem)
 {
     var tileNamesMatchingStem = AllTiles.Keys.Where(tileName => tileName.Contains(stem)).ToArray();
     var tile = new Tile
     {
         Color = Color.White,
         Size = Constants.Graphics.Tiles.DefaultTileSize,
         Texture = AllTiles[tileNamesMatchingStem[_random.Next(0, tileNamesMatchingStem.Length)]],
         //TODO(philipp): idk which retard came up with that. make it nice and get rid of that utter shit here
         IsSolid = "TreeRockMountainDungeonWall".Contains(stem),
         IsTeleporter = "Arrows_DownArrows_UpArrows_LeftArrows_RightVortex_01Vortex_02Vortex_03Stairs_01Stairs_02".Contains(stem),
     };
     return tile;
 }
Exemple #4
0
        public void AddTile(Tile tile, Point position)
        {
            if (tile == null)
            {
                throw new ArgumentNullException("tile");
            }

            var tileIndex = PointToIndex(position);
            tile.Position = position;
            _tiles[tileIndex] = tile;
        }
Exemple #5
0
        //TODO(philipp): remove that return shit
        public Tile AddSubTile(Tile subTile, Point position, bool forceReplaceSolid = false)
        {
            if (subTile == null)
            {
                throw new ArgumentNullException("subTile");
            }

            var tileIndex = PointToIndex(position);
            var tile = _tiles[tileIndex];
            if (tile != null)
            {
                if (tile.IsSolid && forceReplaceSolid)
                {
                    tile.ClearSubtiles();
                }
                else
                {
                    subTile.Position = position;
                    tile.AddSubtile(subTile);
                }
                return tile;
            }
            return null;
        }