Example #1
0
        static public Oobject CopyObject(Oobject obj, Inventory copyiedParentInventory)
        {
            Oobject copyiedObject;

            if (obj is AccessPointObject)
            {
                copyiedObject = new AccessPointObject(copyiedParentInventory);
                AccessPointObject apRealObjet  = (AccessPointObject)obj;
                AccessPointObject apCopyiedObj = (AccessPointObject)copyiedObject;
                apCopyiedObj.Direction = apRealObjet.Direction;
            }
            else if (obj is FloorContainer)
            {
                copyiedObject = new FloorContainer(copyiedParentInventory);
            }
            else if (obj is WallContainer)
            {
                copyiedObject = new WallContainer(copyiedParentInventory);
            }
            else if (obj is CeilingContainer)
            {
                copyiedObject = new CeilingContainer(copyiedParentInventory);
            }
            else
            {
                copyiedObject = new SolidObject(copyiedParentInventory);
            }

            copyiedObject.Id   = obj.Id;
            copyiedObject.Noun = obj.Noun;

            List <String> synonyms = new List <string>();

            synonyms.AddRange(synonyms);
            obj.Synonyms = synonyms.ToArray();

            List <Genre> GenreSynonyms = new List <Genre>();

            GenreSynonyms.AddRange(GenreSynonyms);
            obj.GenreSynonyms = GenreSynonyms.ToArray();

            copyiedObject.HasAboveContainer  = obj.HasAboveContainer;
            copyiedObject.HasInsideContainer = obj.HasInsideContainer;
            copyiedObject.HasUnderContainer  = obj.HasUnderContainer;

            copyiedObject.sayOnTryToGo = obj.sayOnTryToGo;



            return(copyiedObject);
        }
Example #2
0
        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);
        }