public static void PartyWarp(EliteAPI api, MatchCollection senderMatch, MatchCollection coordMatch) { string sender = senderMatch[0] + ""; Structs.Position p = new Structs.Position(); p.X = float.Parse(coordMatch[0] + ""); p.Y = float.Parse(coordMatch[1] + ""); p.Z = float.Parse(coordMatch[2] + ""); p.Zone = int.Parse(coordMatch[3] + ""); int endZoneID = p.Zone; string endZone = Structs.Zones.NameFromID(endZoneID); int startZoneID = api.Player.ZoneId; string startZone = Structs.Zones.NameFromID(startZoneID); if (endZoneID == startZoneID) { string s = "You have been requested by " + sender + " in " + endZone + ". You have until you zone to accept."; Chat.SendEcho(api, s); Player.reqPos = p; Player.hasDialogue = true; } else { //endZoneID != startZoneID api.ThirdParty.SendString("/echo Cannot warp to " + endZone + " from " + startZone + "."); } }
public static void LoadWarps() { try { settingsDoc = XDocument.Load(SETTINGS); IEnumerable <XElement> allElements = from xEle in settingsDoc.Descendants("Zones") select xEle; foreach (XElement result in allElements) { result.Descendants("WarpPoint").Select(t => new { zone = t.Parent.Attribute("id").Value, title = t.Attribute("title").Value, x = t.Element("X").Value, y = t.Element("Y").Value, z = t.Element("Z").Value, }).ToList().ForEach(t => { Structs.Position pos = new Structs.Position(); pos.X = float.Parse(t.x); pos.Y = float.Parse(t.y); pos.Z = float.Parse(t.z); Structs.WarpPoint wp = new Structs.WarpPoint(); wp.title = t.title; wp.zone = int.Parse(t.zone); wp.pos = pos; Structs.warpPoints.Add(wp); }); } } catch (FileNotFoundException) { XML.Create(); } }
public static void SaveWarp(EliteAPI api) { try { settingsDoc = XDocument.Load(SETTINGS); //http://www.c-sharpcorner.com/UploadFile/de41d6/learning-linq-made-easy-linq-to-xml-tutorial-3/ Structs.Position pos = new Structs.Position(); pos.X = api.Player.X; pos.Y = api.Player.Z; pos.Z = api.Player.Y; Structs.WarpPoint wp = new Structs.WarpPoint(); string warpText = NailClipr.GUI_WARP.Text; if (warpText == "") { NailClipr.GUI_WARP.Text = "Untitled Location"; wp.title = "Untitled Location"; } else { wp.title = warpText; } wp.zone = api.Player.ZoneId; wp.pos = pos; string zoneName = Structs.Zones.NameFromID(wp.zone); //Updating - delete old and save new. int index = Structs.zonePoints.FindIndex(p => p.title == wp.title); if (index >= 0) { Chat.SendEcho(api, " Updating warp point: " + zoneName + " - " + NailClipr.GUI_WARP.Text + "."); DeleteWarp(api, true); } else { Chat.SendEcho(api, " Saving new warp point: " + zoneName + " - " + NailClipr.GUI_WARP.Text + "."); } Structs.warpPoints.Add(wp); Functions.AddZonePoint(wp); try { string s = settingsDoc.Element("NailClipr").Element("Zones").Elements("Zone").Single(z => z.Attribute("id").Value == wp.zone + "").Value; } catch (InvalidOperationException) { settingsDoc.Element("NailClipr").Element("Zones").Add(new XElement("Zone", new XAttribute("id", wp.zone), new XAttribute("title", zoneName))); settingsDoc.Save(SETTINGS); } settingsDoc.Element("NailClipr").Elements("Zones").Elements("Zone").Single(z => z.Attribute("id").Value == wp.zone + "") .Add( new XElement("WarpPoint", new XAttribute("title", wp.title), new XElement("X", wp.pos.X), new XElement("Y", wp.pos.Y), new XElement("Z", wp.pos.Z) )); settingsDoc.Save(SETTINGS); } catch (FileNotFoundException) { Create(); SaveWarp(api); } }