// ---------------------------------------------------------------------------------------------------- #endregion #region Loading & Writing Methods public static BoardFile LoadDefault() { BoardFile boardFile = new BoardFile(); boardFile.BoardInfo = new BoardInfo(); boardFile.BoardData = new BoardData(); SquareData bankSquare = SquareData.LoadDefault((byte)0); bankSquare.SquareTypeId = 1; boardFile.BoardData.Squares.Add(bankSquare); return(boardFile); }
// ---------------------------------------------------------------------------------------------------- #endregion #region Loading & Writing Methods // ---------------------------------------------------------------------------------------------------- /// <summary> /// Loads a board from a stream. /// </summary> /// <param name="stream">The stream to read from.</param> /// <returns>A new BoardData object representing the contents of a FortuneStreet board.</returns> public static BoardData LoadFromStream(EndianBinaryReader stream) { BoardData board = new BoardData(); UInt16 squareCount; // Verify Header & Read FileSize board.ReadMagicNumberAndHeaderSize(stream); stream.ReadUInt32(); // Padding squareCount = stream.ReadUInt16(); stream.ReadUInt16(); // Padding // Loading Square Data for (Byte i = 0; i < squareCount; i++) { board.Squares.Add(SquareData.LoadFromStream(stream, i)); } return(board); }
// ---------------------------------------------------------------------------------------------------- /// <summary> /// Loads a new SquareData from a stream. /// </summary> /// <param name="stream">The stream to load from.</param> /// <returns>A new SquareData representing a square.</returns> public static SquareData LoadFromStream(EndianBinaryReader stream, Byte squareId) { SquareData data = new SquareData(); data.Id = squareId; // Read SquareType ID data.SquareTypeId = stream.ReadUInt16(); // Read Position data.Position = new Position(stream.ReadInt16(), stream.ReadInt16()); // Read Waypoints data.Unknown1 = stream.ReadUInt16(); data.Waypoint1 = WaypointData.LoadFromStream(stream); data.Waypoint2 = WaypointData.LoadFromStream(stream); data.Waypoint3 = WaypointData.LoadFromStream(stream); data.Waypoint4 = WaypointData.LoadFromStream(stream); data.Waypoints = new WaypointData[] { data.Waypoint1, data.Waypoint2, data.Waypoint3, data.Waypoint4, }; // Read District ID / Destination ID data.DistrictDestinationId = stream.ReadByte(); data.OneWayLift = stream.ReadByte(); // Read Property Value data.Value = stream.ReadUInt16(); // Read Shop Price data.Price = stream.ReadUInt16(); // Read Unknown Value data.Unknown2 = stream.ReadByte(); // Read Shop Model ID data.ShopModelId = stream.ReadByte(); data.initialized = true; return(data); }
// ---------------------------------------------------------------------------------------------------- #endregion #region Loading & Writing Methods public static SquareData LoadDefault(Byte squareId) { var newSquare = new SquareData() { Id = squareId, Position = new Position(0, 0), Waypoint1 = new WaypointData() { EntryId = 255, Destination1 = 255, Destination2 = 255, Destination3 = 255, }, Waypoint2 = new WaypointData() { EntryId = 255, Destination1 = 255, Destination2 = 255, Destination3 = 255, }, Waypoint3 = new WaypointData() { EntryId = 255, Destination1 = 255, Destination2 = 255, Destination3 = 255, }, Waypoint4 = new WaypointData() { EntryId = 255, Destination1 = 255, Destination2 = 255, Destination3 = 255, }, }; newSquare.Waypoints = new WaypointData[] { newSquare.Waypoint1, newSquare.Waypoint2, newSquare.Waypoint3, newSquare.Waypoint4, }; newSquare.initialized = true; return(newSquare); }