예제 #1
0
        void LoadShipImplementation(string path)
        {
            string filePath   = "./data/" + path;
            string fileFolder = Path.GetDirectoryName(filePath);

            if (File.Exists(filePath))
            {
                XDocument xmlDoc = XDocumentHelper.Load(filePath);
                shipImplementation = new ShipImplementation(xmlDoc, fileFolder, itemsList);
            }
        }
예제 #2
0
        void LoadLoadout(string path)
        {
            string filePath = "./data/" + path;
            string fileName = Path.GetFileNameWithoutExtension(filePath);

            if (File.Exists(filePath))
            {
                XDocument xmlDoc = XDocumentHelper.Load(filePath);
                shipLoadout = new Loadout(xmlDoc, fileName, filePath);
            }
        }
예제 #3
0
        public Loadout(string filePath)
        {
            string fileName = Path.GetFileNameWithoutExtension(filePath);

            if (File.Exists(filePath))
            {
                XDocument xmlDoc  = XDocumentHelper.Load(filePath);
                XElement  element = xmlDoc.Element("Loadout");
                Load(element, fileName, filePath);
            }
        }
예제 #4
0
        public void LoadItemIterfaces(string path)
        {
            if (Directory.Exists(path))
            {
                foreach (var file in Directory.GetFiles(path, "*.xml", SearchOption.AllDirectories))
                {
                    //Console.WriteLine(file);
                    XDocument xml = XDocumentHelper.Load(file);
                    IEnumerable <XElement> elements = xml.Elements();
                    foreach (var el in elements)
                    {
                        if (el.Name == "interface")
                        {
                            ItemInterface itemInterface = new ItemInterface();
                            itemInterface.name = el.Attribute("name").Value;
                            //Console.WriteLine(el.Name);
                            //Console.WriteLine(el.Element("geometry").Element("thirdperson"));
                            //Console.WriteLine(el.Descendants("geometry").Descendants("thirdperson"));
                            //foreach (XElement ell in el.Descendants("geometry").Descendants("thirdperson"))
                            //{
                            //    Console.WriteLine(ell);
                            //}
                            if (el.Element("geometry") != null)
                            {
                                if (el.Element("geometry").Element("thirdperson") != null)
                                {
                                    itemInterface.geometry = el.Element("geometry").Element("thirdperson").Attribute("name").Value;
                                    //Console.WriteLine(itemInterface.geometry);
                                    //Console.WriteLine(el.Element("geometry").Element("thirdperson").Attribute("name").Value);
                                }
                            }
                            //Console.WriteLine(itemInterface.name);

                            itemIterfaces.Add(itemInterface);
                        }
                    }
                }
            }
            else
            {
                Console.WriteLine("[ERROR] NOT FOUND: {0}", path);
                SuccessfullyLoaded = false;
            }
        }
예제 #5
0
        void Load(XElement el, string loadoutName, string loadoutPath)
        {
            XElement element = el;

            if (element != null)
            {
                name = loadoutName;
                path = loadoutPath;

                if (element.Element("Loadouts") != null)
                {
                    if (element.Element("Loadouts").Element("Loadout") != null)
                    {
                        XElement parentLoudoutEl   = element.Element("Loadouts").Element("Loadout");
                        string   parentLoudoutPath = "./data/" + parentLoudoutEl.Attribute("loadout").Value;

                        XDocument xml  = XDocumentHelper.Load(parentLoudoutPath);
                        string    name = Path.GetFileNameWithoutExtension(parentLoudoutPath);;

                        parentLoadout = new Loadout(xml, name, parentLoudoutPath);
                    }
                }
                if (element.Element("Items") != null)
                {
                    itemPorts.AddRange(LoadItemPorts(element.Element("Items")));
                }
                if (element.Element("Quality") != null)
                {
                    quality = new Quality();
                    XElement qualityEl = element.Element("Quality");
                    if (qualityEl.Attribute("wear") != null)
                    {
                        quality.wear = qualityEl.Attribute("wear").Value;
                    }
                    if (qualityEl.Attribute("dirt") != null)
                    {
                        quality.dirt = qualityEl.Attribute("dirt").Value;
                    }
                }
            }
        }
예제 #6
0
 public void LoadLoadouts(string path)
 {
     if (Directory.Exists(path))
     {
         foreach (var file in Directory.GetFiles(path, "*.xml", SearchOption.AllDirectories))
         {
             //Console.WriteLine(file);
             XDocument xml     = XDocumentHelper.Load(file);
             string    name    = Path.GetFileNameWithoutExtension(file);
             Loadout   loadout = new Loadout(xml, name, file);
             if (loadout.name != null)
             {
                 Loadouts.Add(loadout);
             }
         }
     }
     else
     {
         Console.WriteLine("[ERROR] NOT FOUND: {0}", path);
         SuccessfullyLoaded = false;
     }
 }
예제 #7
0
 public void LoadItems(string path)
 {
     if (Directory.Exists(path))
     {
         foreach (var file in Directory.GetFiles(path, "*.xml", SearchOption.AllDirectories))
         {
             //Console.WriteLine(file);
             XDocument xml = XDocumentHelper.Load(file);
             IEnumerable <XElement> elements = xml.Elements();
             foreach (var el in elements)
             {
                 if (el.Name == "item")
                 {
                     Item item = new Item();
                     item.name      = el.Attribute("name").Value;
                     item.itemclass = el.Attribute("class").Value;
                     //Console.WriteLine(el.Name);
                     //Console.WriteLine(el.Element("geometry").Element("thirdperson"));
                     //Console.WriteLine(el.Descendants("geometry").Descendants("thirdperson"));
                     //foreach (XElement ell in el.Descendants("geometry").Descendants("thirdperson"))
                     //{
                     //    Console.WriteLine(ell);
                     //}
                     if (el.Element("geometry") != null)
                     {
                         if (el.Element("geometry").Element("thirdperson") != null)
                         {
                             item.geometry = el.Element("geometry").Element("thirdperson").Attribute("name").Value;
                             //Console.WriteLine(item.geometry);
                             //Console.WriteLine(el.Element("geometry").Element("thirdperson").Attribute("name").Value);
                         }
                     }
                     if (el.Attribute("interface") != null)
                     {
                         item.intrface = el.Attribute("interface").Value;
                         ItemInterface iteminterface = FindItemInterface(item.intrface);
                         if (iteminterface.geometry != "")
                         {
                             item.geometry = iteminterface.geometry;
                         }
                         //Console.WriteLine(item.geometry);
                     }
                     if (el.Element("PrefabAttachments") != null)
                     {
                         foreach (XElement ell in el.Element("PrefabAttachments").Descendants("PrefabAttachment"))
                         {
                             PrefabAttachment prefabAtt = new PrefabAttachment();
                             prefabAtt.attachmentPoint = ell.Attribute("attachmentPoint").Value;
                             prefabAtt.prefabLibrary   = ell.Attribute("prefabLibrary").Value;
                             prefabAtt.prefabName      = ell.Attribute("prefabName").Value;
                             item.PrefabAttachments.Add(prefabAtt);
                             // Console.WriteLine("prefabatt {0} {1} {2}", prefabAtt.attachmentPoint, prefabAtt.prefabLibrary, prefabAtt.prefabName);
                         }
                         //Console.WriteLine(item.PrefabAttachments.Count);
                     }
                     //Console.WriteLine(item.name);
                     items.Add(item);
                 }
             }
         }
     }
     else
     {
         Console.WriteLine("[ERROR] NOT FOUND: {0}", path);
         SuccessfullyLoaded = false;
     }
 }