private void ConnectRoomUp(IZone zone, int roomNumber, int otherRoomNumber) { ZoneHelper.ConnectRoom(zone.Rooms[roomNumber], Direction.North, zone.Rooms[otherRoomNumber]); }
private void ConnectRoomLeft(IZone zone, int roomNumber, int otherRoomNumber) { ZoneHelper.ConnectRoom(zone.Rooms[roomNumber], Direction.West, zone.Rooms[otherRoomNumber]); }
public IZone AddRoad(IZone zone, ZoneConnection northZoneId, ZoneConnection eastZoneId, ZoneConnection southZoneId, ZoneConnection westZoneId) { RoomPos northPos = null; RoomPos eastPos = null; RoomPos southPos = null; RoomPos westPos = null; bool northContinue = false; bool eastContinue = false; bool southContinue = false; bool westContinue = false; List <RoomPos> northRoad = new List <RoomPos>(); List <RoomPos> eastRoad = new List <RoomPos>(); List <RoomPos> southRoad = new List <RoomPos>(); List <RoomPos> westRoad = new List <RoomPos>(); List <List <RoomPos> > allRoads = new List <List <RoomPos> >() { northRoad, eastRoad, southRoad, westRoad }; #region Setup if (northZoneId != null) { northPos = new RoomPos(_exits[0], 0); northContinue = true; northRoad.Add(northPos); IRoom room = GetRoom(northPos, zone); ZoneHelper.ConnectZone(room, Direction.North, northZoneId.ZoneId, northZoneId.RoomId); } if (eastZoneId != null) { eastPos = new RoomPos(Width - 1, _exits[1]); eastContinue = true; eastRoad.Add(eastPos); IRoom room = GetRoom(eastPos, zone); ZoneHelper.ConnectZone(room, Direction.East, eastZoneId.ZoneId, eastZoneId.RoomId); } if (southZoneId != null) { southPos = new RoomPos(_exits[2], Height - 1); southContinue = true; southRoad.Add(southPos); IRoom room = GetRoom(southPos, zone); ZoneHelper.ConnectZone(room, Direction.South, southZoneId.ZoneId, southZoneId.RoomId); } if (westZoneId != null) { westPos = new RoomPos(0, _exits[3]); westContinue = true; westRoad.Add(westPos); IRoom room = GetRoom(westPos, zone); ZoneHelper.ConnectZone(room, Direction.West, westZoneId.ZoneId, westZoneId.RoomId); } #endregion Setup while (MultipleRoadsContinue(northContinue, eastContinue, southContinue, westContinue)) { if (northContinue) { bool matchPos = SearchForRoadMatch(northPos, northRoad, allRoads); if (matchPos) { northContinue = false; } else { RoomPos newPos = new RoomPos(northPos.X, northPos.Y - 1); northRoad.Add(newPos); northPos = newPos; } } if (eastContinue) { bool matchPos = SearchForRoadMatch(eastPos, eastRoad, allRoads); if (matchPos) { eastContinue = false; } else { RoomPos newPos = new RoomPos(eastPos.X - 1, eastPos.Y); eastRoad.Add(newPos); eastPos = newPos; } } if (southContinue) { bool matchPos = SearchForRoadMatch(southPos, southRoad, allRoads); if (matchPos) { southContinue = false; } else { RoomPos newPos = new RoomPos(southPos.X, southPos.Y - 1); southRoad.Add(newPos); southPos = newPos; } } if (westContinue) { bool matchPos = SearchForRoadMatch(westPos, westRoad, allRoads); if (matchPos) { westContinue = false; } else { RoomPos newPos = new RoomPos(westPos.X + 1, westPos.Y); westRoad.Add(newPos); westPos = newPos; } } } foreach (List <RoomPos> road in allRoads) { foreach (RoomPos roomPos in road) { IRoom room = GetRoom(roomPos, zone); room.LongDescription = RoadDescription.LongDescription; room.ShortDescription = RoadDescription.ShortDescription; room.ExamineDescription = RoadDescription.ExamineDescription; } } return(zone); }