public L2Spawn(int NpcId, long Respawn, L2Territory zone, string pos) { this.NpcId = NpcId; this.Respawn = Respawn; this.zone = zone; if (pos != null) { this.x = Convert.ToInt32(pos[0]); this.y = Convert.ToInt32(pos[1]); this.z = Convert.ToInt32(pos[2]); this.h = Convert.ToInt32(pos[3]); } }
public void read(string path) { XElement xml = XElement.Parse(File.ReadAllText(path)); XElement ex = xml.Element("list"); foreach (var m in ex.Elements()) { if (m.Name == "territory") { L2Territory zone = new L2Territory(); zone.name = m.Attribute("name").Value; zone.controller = m.Attribute("controller").Value; zone.start_active = bool.Parse(m.Attribute("start_active").Value); foreach (var stp in m.Elements()) { switch (stp.Name.LocalName) { case "npc": int cnt = Convert.ToInt32(stp.Attribute("count").Value); string pos = null; if (stp.Attribute("pos") != null) { pos = stp.Attribute("pos").Value; } zone.AddNpc(Convert.ToInt32(stp.Attribute("id").Value), cnt, stp.Attribute("respawn").Value, pos); npcs += cnt; break; case "zone": zone.AddPoint(stp.Attribute("loc").Value.Split(' ')); break; } } zone.InitZone(); //создаем зону if (territorries.ContainsKey(zone.name)) { Console.WriteLine("dublicate zone name " + zone.name); } else { territorries.Add(zone.name, zone); } } else if (m.Name == "spawn") { foreach (var stp in m.Elements()) { switch (stp.Name.LocalName) { case "npc": { string respawn = stp.Attribute("respawn").Value; long value = Convert.ToInt32(respawn.Remove(respawn.Length - 1)); if (respawn.Contains("s")) { value *= 1000; } else if (respawn.Contains("m")) { value *= 60000; } else if (respawn.Contains("h")) { value *= 3600000; } else if (respawn.Contains("d")) { value *= 86400000; } spawns.Add(new L2Spawn(Convert.ToInt32(stp.Attribute("id").Value), value, stp.Attribute("pos").Value.Split(' '))); } npcs++; break; } } } } }