예제 #1
0
        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);
        }
예제 #2
0
        public Zone Populate()
        {
            Zone startingZone = null;
            Zone papa         = CreateNewZone("Maison de Papa");

            papa.AddLocation(new Location("Chambre de papa", ""));
            papa.AddLocation(new Location("Ancienne chambre de mike", ""));
            papa.AddLocation(new Location("Salon papa", ""));

            Zone fred = CreateNewZone("Maison de Fred");

            fred.AddLocation(new Location("Chambre mike et nastia", ""));
            fred.AddLocation(new Location("Chambre manon", ""));
            fred.AddLocation(new Location("Kot de Fred", ""));

            Zone maman = CreateNewZone("Maison de Maman");

            maman.AddLocation(new Location("Chambre maman et éric", ""));
            maman.AddLocation(new Location("Jardin pourri", ""));
            maman.AddLocation(new Location("Salle de bain", ""));
            startingZone = papa;
            return(papa);
        }