protected void LoadFromStream(BinaryReader stream) { myWidth = stream.ReadInt16(); myHeight = stream.ReadInt16(); myTiles = new TileTemplate[Width, Height]; for (int x = 0; x < Width; ++x) { for (int y = 0; y < Height; ++y) { myTiles[x, y] = new TileTemplate(); myTiles[x, y].Load(stream); } } int types = stream.ReadInt16(); myMapTypes = new DungeonClass[types]; for (int i = 0; i < types; ++i) { myMapTypes[i] = DungeonClass.Get(stream.ReadString()); } int entCount = stream.ReadInt16(); myEntities = new Entity[entCount]; for (int i = 0; i < entCount; ++i) { myEntities[i] = Entity.Load(stream, false); myEntities[i].Probability = stream.ReadDouble(); } myConnectors = new ChunkConnector[4][]; for (int i = 0; i < 4; ++i) { int connectors = stream.ReadByte(); myConnectors[i] = new ChunkConnector[connectors]; for (int j = 0; j < connectors; ++j) { myConnectors[i][j] = new ChunkConnector(stream, this); } } FindOrganisedConnectors(); }
public OverworldMap(System.IO.BinaryReader reader, bool isServer) : base(false, 0xFFFF, isServer) { HorizontalChunks = reader.ReadInt16(); VerticalChunks = reader.ReadInt16(); ChunkWidth = reader.ReadInt16(); ChunkHeight = reader.ReadInt16(); Width = HorizontalChunks * ChunkWidth; Height = VerticalChunks * ChunkHeight; myTiles = new OverworldTile[HorizontalChunks, VerticalChunks]; for (int x = 0; x < HorizontalChunks; ++x) { for (int y = 0; y < VerticalChunks; ++y) { OverworldTile tile = myTiles[x, y] = new OverworldTile(x * ChunkWidth, y * ChunkHeight, this); tile.Load(reader); } } myDungeons = new List <Dungeon>(); UInt16 dungeonCount = reader.ReadUInt16(); for (int i = 0; i < dungeonCount; ++i) { UInt16 id = reader.ReadUInt16(); String dungClassName = reader.ReadString(); int x = reader.ReadInt32(); int y = reader.ReadInt32(); myDungeons.Add(new Dungeon(id, DungeonClass.Get(dungClassName), x, y, false)); } myVB = new VertexBuffer(); myTilesChanged = true; }