Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     Sub ParseXML_PlanetInfo()
  2.         Dim xmlDoc As New XmlDocument
  3.         Dim ParseNodes As XmlNodeList
  4.         Dim ParseNode As XmlNode
  5.         Dim rawData As String
  6.  
  7.         rawData = XMLData
  8.  
  9.         xmlDoc.LoadXml(rawData)
  10.  
  11.         ParseNodes = xmlDoc.GetElementsByTagName("header")
  12.  
  13.         For Each ParseNode In ParseNodes
  14.             ParseType.Uni = ParseNode.Attributes("universe").Value
  15.         Next
  16.  
  17.         If Not ParseType.Uni = ogProfile.Uni.UniName Then
  18.             ' An dieser Stelle sollte zusätzlich geprüft werden, ob ein Profil für die Daten vorhanden ist.
  19.            '
  20.            '
  21.            '
  22.            MsgBox(getLngTxt("XMLParse", "WrongUni"), MsgBoxStyle.Critical)
  23.             Exit Sub
  24.         End If
  25.  
  26.         ParseNodes = Nothing
  27.  
  28.         ParseNodes = xmlDoc.GetElementsByTagName("planetinfo")
  29.  
  30.         For Each ParseNode In ParseNodes
  31.  
  32.             'Spielername auslesen
  33.            ParseType.OwnerName = ParseNode.Attributes("playername").Value
  34.             'Planetenname auslesen
  35.            ParseType.Planet.Planet.Name = ParseNode.Attributes("planetname").Value
  36.             'Koordinaten des Planeten auslesen
  37.            ParseType.Planet.Koords.Galaxie = ParseNode.Attributes("galaxy").Value
  38.             ParseType.Planet.Koords.System = ParseNode.Attributes("system").Value
  39.             ParseType.Planet.Koords.Number = ParseNode.Attributes("planet").Value
  40.             'Hier wird geprüft ob es sich hierbei um einen Planeten oder Mond handelt
  41.            If CBool(ParseNode.Attributes("moon").Value) = False Then
  42.                 ParseType.Planet.Planet.Name = ParseNode.Attributes("planetname").Value
  43.             Else
  44.                 ParseType.Planet.Moon.Name = ParseNode.Attributes("planetname").Value
  45.             End If
  46.         Next
  47.  
  48.         ParseNodes = Nothing
  49.         ParseNodes = xmlDoc.GetElementsByTagName("entry")
  50.         sPlanetInfoPage = ""
  51.  
  52.         For Each ParseNode In ParseNodes
  53.             '#####################################################
  54.            'Ermitteln der Ressourcen
  55.            'Energie wäre zwar auch möglich macht aber keinen Sinn, da wir das lieber mit hilfe der
  56.            'Gebäude und Forschungen errechnen =D
  57.            If ParseNode.Attributes("name").Value = "Metal" Then
  58.                 ParseType.Planet.Planet.Supplies.Metal = ParseNode.Attributes("amount").Value
  59.             End If
  60.             If ParseNode.Attributes("name").Value = "Crystal" Then
  61.                 ParseType.Planet.Planet.Supplies.Crystal = ParseNode.Attributes("amount").Value
  62.             End If
  63.             If ParseNode.Attributes("name").Value = "Deuterium" Then
  64.                 ParseType.Planet.Planet.Supplies.Deuterium = ParseNode.Attributes("amount").Value
  65.             End If
  66.  
  67.             '#####################################################
  68.            'Ermitteln der Gebäude (Ressourcen)
  69.            If ParseNode.Attributes("name").Value = "Metal Mine" Then
  70.                 ParseType.Planet.Planet.Resources.MetalMine = ParseNode.Attributes("amount").Value
  71.                 sPlanetInfoPage = "ress"
  72.             End If
  73.             If ParseNode.Attributes("name").Value = "Crystal Mine" Then
  74.                 ParseType.Planet.Planet.Resources.CrystalMine = ParseNode.Attributes("amount").Value
  75.                 sPlanetInfoPage = "ress"
  76.             End If
  77.             If ParseNode.Attributes("name").Value = "Deuterium Synthesizer" Then
  78.                 ParseType.Planet.Planet.Resources.DeuteriumSynthesizer = ParseNode.Attributes("amount").Value
  79.                 sPlanetInfoPage = "ress"
  80.             End If
  81.             If ParseNode.Attributes("name").Value = "Solar Plant" Then
  82.                 ParseType.Planet.Planet.Resources.SolarPlant = ParseNode.Attributes("amount").Value
  83.                 sPlanetInfoPage = "ress"
  84.             End If
  85.             If ParseNode.Attributes("name").Value = "Fusion Reactor" Then
  86.                 ParseType.Planet.Planet.Resources.FusionReactor = ParseNode.Attributes("amount").Value
  87.                 sPlanetInfoPage = "ress"
  88.             End If
  89.             If ParseNode.Attributes("name").Value = "Solar Satellite" Then
  90.                 ParseType.Planet.Planet.Resources.SolarSatellite = ParseNode.Attributes("amount").Value
  91.                 ' An dieser Stelle wird der Seitenname NICHT übergeben! Könnte ja auch die Flottenseite sein.
  92.            End If
  93.             If ParseNode.Attributes("name").Value = "Metal Storage" Then
  94.                 ParseType.Planet.Planet.Resources.MetalStorage = ParseNode.Attributes("amount").Value
  95.                 sPlanetInfoPage = "ress"
  96.             End If
  97.             If ParseNode.Attributes("name").Value = "Crystal Storage" Then
  98.                 ParseType.Planet.Planet.Resources.CrystalStorage = ParseNode.Attributes("amount").Value
  99.                 sPlanetInfoPage = "ress"
  100.             End If
  101.             If ParseNode.Attributes("name").Value = "Deuterium Tank" Then
  102.                 ParseType.Planet.Planet.Resources.DeuteriumTank = ParseNode.Attributes("amount").Value
  103.                 sPlanetInfoPage = "ress"
  104.             End If
  105.  
  106.             '#####################################################
  107.            'Ermitteln der Gebäude (Facilities)
  108.            If ParseNode.Attributes("name").Value = "Robotics Factory" Then
  109.                 ParseType.Planet.Planet.Facilities.RoboticFactory = ParseNode.Attributes("amount").Value
  110.                 sPlanetInfoPage = "faci"
  111.             End If
  112.             If ParseNode.Attributes("name").Value = "Nanite Factory" Then
  113.                 ParseType.Planet.Planet.Facilities.RoboticFactory = ParseNode.Attributes("amount").Value
  114.                 sPlanetInfoPage = "faci"
  115.             End If
  116.             If ParseNode.Attributes("name").Value = "Shipyard" Then
  117.                 ParseType.Planet.Planet.Facilities.RoboticFactory = ParseNode.Attributes("amount").Value
  118.                 sPlanetInfoPage = "faci"
  119.             End If
  120.             If ParseNode.Attributes("name").Value = "Research Lab" Then
  121.                 ParseType.Planet.Planet.Facilities.RoboticFactory = ParseNode.Attributes("amount").Value
  122.                 sPlanetInfoPage = "faci"
  123.             End If
  124.             If ParseNode.Attributes("name").Value = "Terraformer" Then
  125.                 ParseType.Planet.Planet.Facilities.RoboticFactory = ParseNode.Attributes("amount").Value
  126.                 sPlanetInfoPage = "faci"
  127.             End If
  128.             If ParseNode.Attributes("name").Value = "Alliance Depot" Then
  129.                 ParseType.Planet.Planet.Facilities.RoboticFactory = ParseNode.Attributes("amount").Value
  130.                 sPlanetInfoPage = "faci"
  131.             End If
  132.             If ParseNode.Attributes("name").Value = "Missile Silo" Then
  133.                 ParseType.Planet.Planet.Facilities.RoboticFactory = ParseNode.Attributes("amount").Value
  134.                 sPlanetInfoPage = "faci"
  135.             End If
  136.  
  137.             '#####################################################
  138.            'Ermitteln der Forschungen (Research)
  139.            If ParseNode.Attributes("name").Value = "Espionage Technology" Then
  140.                 ParseType.Research.EspionageTechnology = ParseNode.Attributes("amount").Value
  141.                 sPlanetInfoPage = "rese"
  142.             End If
  143.             If ParseNode.Attributes("name").Value = "Computer Technology" Then
  144.                 ParseType.Research.ComputerTechnology = ParseNode.Attributes("amount").Value
  145.                 sPlanetInfoPage = "rese"
  146.             End If
  147.             If ParseNode.Attributes("name").Value = "Weapons Technology" Then
  148.                 ParseType.Research.WeaponsTechnology = ParseNode.Attributes("amount").Value
  149.                 sPlanetInfoPage = "rese"
  150.             End If
  151.             If ParseNode.Attributes("name").Value = "Shielding Technology" Then
  152.                 ParseType.Research.ShieldingTechnology = ParseNode.Attributes("amount").Value
  153.                 sPlanetInfoPage = "rese"
  154.             End If
  155.             If ParseNode.Attributes("name").Value = "Armour Technology" Then
  156.                 ParseType.Research.ArmorTechnology = ParseNode.Attributes("amount").Value
  157.                 sPlanetInfoPage = "rese"
  158.             End If
  159.             If ParseNode.Attributes("name").Value = "Energy Technology" Then
  160.                 ParseType.Research.EnergyTechnology = ParseNode.Attributes("amount").Value
  161.                 sPlanetInfoPage = "rese"
  162.             End If
  163.             If ParseNode.Attributes("name").Value = "Hyperspace Technology" Then
  164.                 ParseType.Research.HyperspaceTechnology = ParseNode.Attributes("amount").Value
  165.                 sPlanetInfoPage = "rese"
  166.             End If
  167.             If ParseNode.Attributes("name").Value = "Combustion Drive" Then
  168.                 ParseType.Research.CombustionDrive = ParseNode.Attributes("amount").Value
  169.                 sPlanetInfoPage = "rese"
  170.             End If
  171.             If ParseNode.Attributes("name").Value = "Impulse Drive" Then
  172.                 ParseType.Research.ImpulseDrive = ParseNode.Attributes("amount").Value
  173.                 sPlanetInfoPage = "rese"
  174.             End If
  175.             If ParseNode.Attributes("name").Value = "Hyperspace Drive" Then
  176.                 ParseType.Research.HyperspaceDrive = ParseNode.Attributes("amount").Value
  177.                 sPlanetInfoPage = "rese"
  178.             End If
  179.             If ParseNode.Attributes("name").Value = "Laser Technology" Then
  180.                 ParseType.Research.LaserTechnology = ParseNode.Attributes("amount").Value
  181.                 sPlanetInfoPage = "rese"
  182.             End If
  183.             If ParseNode.Attributes("name").Value = "Ion Technology" Then
  184.                 ParseType.Research.IonTechnology = ParseNode.Attributes("amount").Value
  185.                 sPlanetInfoPage = "rese"
  186.             End If
  187.             If ParseNode.Attributes("name").Value = "Plasma Technology" Then
  188.                 ParseType.Research.PlasmaTechnology = ParseNode.Attributes("amount").Value
  189.                 sPlanetInfoPage = "rese"
  190.             End If
  191.             If ParseNode.Attributes("name").Value = "Intergalactic Research Network" Then
  192.                 ParseType.Research.IntergalacticResearch = ParseNode.Attributes("amount").Value
  193.                 sPlanetInfoPage = "rese"
  194.             End If
  195.             If ParseNode.Attributes("name").Value = "Astrophysics" Then
  196.                 ParseType.Research.Astrophysics = ParseNode.Attributes("amount").Value
  197.                 sPlanetInfoPage = "rese"
  198.             End If
  199.             If ParseNode.Attributes("name").Value = "Graviton Technology" Then
  200.                 ParseType.Research.GravitonTechnology = ParseNode.Attributes("amount").Value
  201.                 sPlanetInfoPage = "rese"
  202.             End If
  203.  
  204.         Next
  205.  
  206.  
  207.         ParseNodes = Nothing
  208.         ParseNodes = xmlDoc.GetElementsByTagName("officers")
  209.         sPlanetInfoPage = ""
  210.  
  211.         For Each ParseNode In ParseNodes
  212.             If ParseNode.Attributes("officer name").Value = "commander" Then
  213.                 ParseType.Officers.Commander = ParseNode.Attributes("enabled").Value
  214.                 MsgBox(ParseType.Officers.Commander)
  215.                 sPlanetInfoPage = "over"
  216.             End If
  217.  
  218.             If ParseNode.Attributes("officer name").Value = "admiral" Then
  219.                 ParseType.Officers.Admiral = ParseNode.Attributes("enabled").Value
  220.                 sPlanetInfoPage = "over"
  221.             End If
  222.  
  223.             If ParseNode.Attributes("officer name").Value = "engineer" Then
  224.                 ParseType.Officers.Engineer = ParseNode.Attributes("enabled").Value
  225.                 sPlanetInfoPage = "over"
  226.             End If
  227.  
  228.             If ParseNode.Attributes("officer name").Value = "geologist" Then
  229.                 ParseType.Officers.Geologist = ParseNode.Attributes("enabled").Value
  230.                 sPlanetInfoPage = "over"
  231.             End If
  232.  
  233.             If ParseNode.Attributes("officer name").Value = "technocrat" Then
  234.                 ParseType.Officers.Technocrat = ParseNode.Attributes("enabled").Value
  235.                 sPlanetInfoPage = "over"
  236.             End If
  237.  
  238.         Next
  239.     End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement