public static Inventory CopyCompleteInventory(Oobject rootObject) { Oobject copyiedRootObject = Oobject.CopyObject(rootObject, null); Inventory copyiedInventory = new InsideInventory(copyiedRootObject); copyInventories(copyiedRootObject, rootObject); return(copyiedInventory); }
public VoidContainer(Inventory parentInventory, Location location) : base(parentInventory: parentInventory) { Location = location; //Synonyms = new string[] { "void" }; Noun = new GNoun("Void", Genre.masuclin); HasAboveContainer = false; HasInsideContainer = true; HasUnderContainer = false; insideInventory = new InsideInventory(this); }
public PlayerContainer(Inventory parentInventory, Player _player) : base(parentInventory: parentInventory) { Player = Player; //Synonyms = new string[] { "joueur" }; GenreSynonyms = new Genre[] { Genre.masuclin }; Noun = new GNoun("Moi", Genre.masuclin); Adjective = null; HasAboveContainer = false; HasInsideContainer = true; HasUnderContainer = false; insideInventory = new InsideInventory(this); }
public void CreateInventories() { if (HasAboveContainer && aboveInventory == null) { aboveInventory = new OnInventory(this); } if (HasInsideContainer && insideInventory == null) { insideInventory = new InsideInventory(this); } if (HasUnderContainer && underInventory == null) { underInventory = new UnderInventory(this); } }
private static Inventory copyThisInventory(bool hasInventory, Inventory inventoryToCopy, Oobject copyiedObjectParent, Oobject objReference) { if (hasInventory) { Inventory copyiedInventory = null; if (inventoryToCopy is OnInventory) { copyiedInventory = new OnInventory(copyiedObjectParent); } else if (inventoryToCopy is UnderInventory) { copyiedInventory = new UnderInventory(copyiedObjectParent); } else { copyiedInventory = new InsideInventory(copyiedObjectParent); } if (inventoryToCopy == null) { return(copyiedInventory); } foreach (var realObj in inventoryToCopy.objects) { Oobject childObjectCopy = Oobject.CopyObject(realObj, copyiedInventory); copyInventories(childObjectCopy, realObj); copyiedInventory.Add(childObjectCopy); } return(copyiedInventory); } else { return(null); } }
private Inventory loadInventory(string inventoryType, XElement inventory, Oobject parentObj, Inventory parentInventory) { Inventory inventoryToAdd = null; if (inventoryType == "On") { inventoryToAdd = new OnInventory(parentObj); } if (inventoryType == "Inside") { inventoryToAdd = new InsideInventory(parentObj); } if (inventoryType == "Under") { inventoryToAdd = new UnderInventory(parentObj); } //List<Oobject> objects = new List<Oobject>(); foreach (XElement obj in inventory.Elements("Object")) { Oobject objectToAdd; if (obj.Attribute("Type").Value == Oobject.AccessPointObjectType) { objectToAdd = new AccessPointObject(parentInventory); AccessPointObject apObj = (AccessPointObject)objectToAdd; apObj.Direction = obj.Element("Direction").Value; } else if (obj.Attribute("Type").Value == Oobject.FloorObjectType) { objectToAdd = new FloorContainer(parentInventory); } else if (obj.Attribute("Type").Value == Oobject.WallObjectType) { objectToAdd = new WallContainer(parentInventory); } else if (obj.Attribute("Type").Value == Oobject.CeilingObjectType) { objectToAdd = new CeilingContainer(parentInventory); } else { objectToAdd = new SolidObject(parentInventory); } objectToAdd.Id = Int32.Parse(obj.Attribute("Id").Value); objectToAdd.Noun.Singular = obj.Attribute("Name").Value; foreach (XElement elementInventory in obj.Elements("Inventory")) { if (elementInventory.Attribute("Type").Value == "On") { objectToAdd.aboveInventory = loadInventory("On", elementInventory, objectToAdd, inventoryToAdd); objectToAdd.HasAboveContainer = true; } else if (elementInventory.Attribute("Type").Value == "Under") { objectToAdd.underInventory = loadInventory("Under", elementInventory, objectToAdd, inventoryToAdd); objectToAdd.HasUnderContainer = true; } else { objectToAdd.insideInventory = loadInventory("Inside", elementInventory, objectToAdd, inventoryToAdd); objectToAdd.HasInsideContainer = true; } } inventoryToAdd.Add(objectToAdd); } return(inventoryToAdd); }