public void SetInitialRoomIndex(InitialRooms.ID roomIndex) { Debug.Assert(InitialRooms.IsValidInitialRoomIndex(roomIndex)); mInitialRoomIndex = roomIndex; mDescription = InitialRooms.initialRooms[roomIndex].mDescription; }
public void GenerateFreshGame(InitialRooms.ID initialRoomID = defaultInitialRoom) { mLastCommandResponse = newGameCommand; mInventory = new Inventory(); mRoom = new Room(); mGameTime = new GameTime(); mNPCIdentities = InitialRooms.identityData; InitialRooms.Initialize(); mRoom.CreateFrom(initialRoomID, this); }
// Returns true if the game was successfully parsed public bool ParsePreviousText(string inputText) { string[] lines = inputText.Split('\n'); if (lines.Length != numTotalRows) { return(false); } string saveDataLine = lines[saveDataRowIndex]; mRoom = new Room(); mInventory = new Inventory(); mGameTime = new GameTime(); mNPCIdentities = new Dictionary <int, NPCIdentityData>(); InitialRooms.Initialize(); Load(saveDataLine); return(true); }
public void Stream(SaveStream stream) { if (stream.IsWriting()) { Debug.Assert(InitialRooms.IsValidInitialRoomIndex(mInitialRoomIndex)); stream.Stream(ref mInitialRoomIndex); } else { InitialRooms.ID roomIndex = InitialRooms.ID.Unknown; stream.Stream(ref roomIndex); SetInitialRoomIndex(roomIndex); LoadStaticGridFromInitialRoom(); } int dynamicObjectCount = mDynamicObjects.Count; stream.Stream(ref dynamicObjectCount, SaveUtils.GetNumBitsToStoreValue(maxNumDynamicObjects)); if (stream.IsWriting()) { foreach (DynamicObject dynamicObject in mDynamicObjects) { dynamicObject.Stream(stream); } } else { mDynamicObjects.Clear(); for (int dynamicObjectIndex = 0; dynamicObjectIndex < dynamicObjectCount; dynamicObjectIndex++) { DynamicObject dynamicObject = (DynamicObject)Emoji.CreateObject(stream as ReadStream); dynamicObject.Stream(stream); mDynamicObjects.Add(dynamicObject); } } }
void LoadDynamicObjectsFromInitialRoom() { Debug.Assert(InitialRooms.IsValidInitialRoomIndex(mInitialRoomIndex)); mDynamicObjects = InitialRooms.initialRooms[mInitialRoomIndex].mDynamicObjects; }
void LoadStaticGridFromInitialRoom() { Debug.Assert(InitialRooms.IsValidInitialRoomIndex(mInitialRoomIndex)); mStaticRoomGrid = InitialRooms.initialRooms[mInitialRoomIndex].mStaticRoomGrid; }