public UserMessage CommandOpen(Command command, Point position, Room currentRoom) { // Run the Open command UserMessage returnMessage = new UserMessage(); CastleItem key = FindItemInInventory("Key"); if(key == null) { returnMessage.AddLine(" You don't"); returnMessage.AddLine(" have a key!"); return returnMessage; } if(command.Subject.StartsWith("Door", StringComparison.CurrentCultureIgnoreCase) == false) { returnMessage.AddLine("Impossible!!"); return returnMessage; } // Is door in room if (currentRoom.Door == null) { returnMessage.AddLine(" I don't"); returnMessage.AddLine(" see a door."); return returnMessage; } if (currentRoom.Door.Locked) { foreach (Point point in currentRoom.Door.UnlockPoints) { if (position.X == point.X && position.Y == point.Y) { currentRoom.Door.Locked = false; returnMessage.AddLine("Done"); return returnMessage; } } } returnMessage.AddLine(" I can't"); returnMessage.AddLine(" reach it!."); return returnMessage; }
private void DrawRoom() { if (currentRoom != null) { currentRoom.ClearReplacePoints(); } currentRoom = mapReader.FindRoom(currentRoomIndex); ItemManager.LoadRoomItems(currentRoomIndex, player.Position); DrawMap(); DrawDescription(); ResetPrompt(); ClearMessages(true); ClearItemList(); DrawItems(); }
private void ParseMap() { using(FileStream fileStream = File.Open("Map/Castle.RAN", FileMode.Open, FileAccess.Read, FileShare.None)) { using(BinaryReader reader = new BinaryReader(fileStream)) { for(int roomIndex = 1; roomIndex < Room.MaxRooms + 1; roomIndex++) { Room newRoom = new Room(); newRoom.RoomBytes = reader.ReadBytes(Room.RoomSize); newRoom.DescriptionBytes = reader.ReadBytes(Room.DescriptionSize); newRoom.ExitBytes = reader.ReadBytes(Room.ExitSize); newRoom.ParseData(); roomList.Add(roomIndex, newRoom); } } } }