示例#1
0
        public RoomGrid(IRoomModel roomModel)
        {
            MapSizeX = roomModel.MapSizeX;
            MapSizeY = roomModel.MapSizeY;

            _roomTiles   = new Dictionary <int, RoomTile>();
            WalkableGrid = new bool[MapSizeX, MapSizeY];
            for (int y = 0; y < MapSizeY; y++)
            {
                for (int x = 0; x < MapSizeX; x++)
                {
                    WalkableGrid[x, y] = roomModel.GetTileState(x, y);
                    _roomTiles.Add(ConvertTo1D(x, y), new RoomTile());
                }
            }
        }
示例#2
0
        public HeightMapComposer(IRoomModel roomModel)
            : base(Headers.HeightMapMessageComposer)
        {
            WriteInt(roomModel.MapSizeX);
            WriteInt(roomModel.MapSizeX * roomModel.MapSizeY);

            for (int y = 0; y < roomModel.MapSizeY; y++)
            {
                for (int x = 0; x < roomModel.MapSizeX; x++)
                {
                    //Tile is valid.
                    if (roomModel.GetTileState(x, y))
                    {
                        WriteShort((short)(roomModel.GetHeight(x, y) * 256));
                    }
                    else
                    {
                        WriteShort(-1);
                    }
                }
            }
        }