public void GoToNextLocation(AccessPoint accessPoint) { Location lastLoc = CurrentLocation; CurrentLocation = world.GetLocation(accessPoint.DestZone, accessPoint.DestLoc); while (CurrentLocation.TransitionLocation) { Location nextRoom = null; bool found = false; foreach (var ap in CurrentLocation.AccessPoints) { Location tempRoom = world.GetLocation(ap.DestZone, ap.DestLoc); if (tempRoom != lastLoc) { nextRoom = tempRoom; found = true; } if (found) { lastLoc = CurrentLocation; CurrentLocation = nextRoom; break; } } } }
public World LoadWorld(string CompletePath) { World loadedWorld = new World(); XDocument doc; doc = XDocument.Load(CompletePath); loadedWorld.GameTitle = doc.Element("Root").Element("World").Attribute("Name").Value; loadedWorld.zones = new Dictionary <string, Zone>(); foreach (XElement element in doc.Root.Descendants("Zone")) { Zone zoneToAdd = new Zone(element.Attribute("Name").Value); loadedWorld.zones.Add(element.Attribute("Name").Value, zoneToAdd); foreach (XElement elementLoc in element.Descendants("Location")) { bool transitionLocation = false; if (elementLoc.Attribute("TransitionLocation").Value == "true") { transitionLocation = true; } bool startingRoom = false; if (elementLoc.Attribute("SartingLocation").Value == "true") { startingRoom = true; } Location locToAdd = new Location(elementLoc.Attribute("Name").Value, elementLoc.Element("Description").Value, transitionLocation, startingRoom); locToAdd.Id = Int32.Parse(elementLoc.Attribute("Id").Value); locToAdd.Zone = zoneToAdd; zoneToAdd.AddLocation(locToAdd); List <AccessPoint> accessPointsToAdd = new List <AccessPoint>(); foreach (XElement elementAp in elementLoc.Descendants("AccessPoint")) { AccessPoint apToAdd = new AccessPoint(elementAp.Attribute("Dir").Value, elementAp.Attribute("ZoneDest").Value, elementAp.Attribute("LocationDest").Value); accessPointsToAdd.Add(apToAdd); } locToAdd.AccessPoints = accessPointsToAdd; XElement inventory = elementLoc.Element("Inventory"); locToAdd.Void.insideInventory = loadInventory("Inside", inventory, locToAdd.Void, null); } } string lastLocationId = doc.Element("Root").Element("World").Attribute("LastLocationEditedId").Value; if (lastLocationId != "") { loadedWorld.LastLocationEdited = loadedWorld.GetLocation(Int32.Parse(lastLocationId)); } return(loadedWorld); }
public bool IsEqualTo(AccessPoint other) { if (Direction == other.Direction && DestZone == other.DestZone && DestLoc == other.DestLoc) { return(true); } return(false); }
public bool IsOppositeAccessPointExisting(Location currentLocation, Zone currentZone, World world) { foreach (AccessPoint apOpposite in GetAllAccessPointFromWorld(world)) { if (apOpposite.Direction == AccessPoint.ReturnOppositeDirection(Direction) && apOpposite.DestZone == currentZone.Name && apOpposite.DestLoc == currentLocation.Title) { return(true); } } return(false); }
public void CreateOppositeAccessPoint(Location currentLocation, Zone currentZone, Location locReceivingNewAccessPoint) { AccessPoint apToAdd = new AccessPoint(AccessPoint.ReturnOppositeDirection(Direction), currentZone.Name, currentLocation.Title); locReceivingNewAccessPoint.AccessPoints.Add(apToAdd); }
public DirectionObject(Inventory parentInventory, AccessPoint accessPoint) : base(parentInventory: parentInventory) { this.accessPoint = accessPoint; Noun.Singular = accessPoint.Direction.ToLower(); SetDirectionSynonyms(Noun.Singular); }