示例#1
0
        private static void BuildTeleporters(string elementName, XmlElement root, ref int unique)
        {
            var name = root.GetElementsByTagName(elementName);

            for (var index = 0; index < name.Count; index++)
            {
                var region = (XmlElement)name[index];
                var list   = new Dictionary <WorldLocation, WorldLocation>();

                Map locMap  = null;
                Map teleMap = null;

                var tiles = region.GetElementsByTagName("tiles");

                for (var i = 0; i < tiles.Count; i++)
                {
                    var     tile    = (XmlElement)tiles[i];
                    Point3D from    = Point3D.Parse(Utility.GetAttribute(tile, "from", "(0, 0, 0)"));
                    Map     fromMap = Map.Parse(Utility.GetAttribute(tile, "frommap", null));

                    Point3D to    = Point3D.Parse(Utility.GetAttribute(tile, "to", "(0, 0, 0)"));
                    Map     toMap = Map.Parse(Utility.GetAttribute(tile, "tomap", null));

                    int id  = Utility.ToInt32(Utility.GetAttribute(tile, "ItemID", "-1"));
                    int hue = Utility.ToInt32(Utility.GetAttribute(tile, "Hue", "-1"));

                    if (fromMap == null)
                    {
                        throw new ArgumentException($"Map parsed as null: {from}");
                    }

                    if (toMap == null)
                    {
                        throw new ArgumentException($"Map parsed as null: {to}");
                    }

                    if (Siege.SiegeShard && (fromMap == Map.Trammel || toMap == Map.Trammel))
                    {
                        continue;
                    }

                    list.Add(new WorldLocation(from, fromMap), new WorldLocation(to, toMap));

                    if (list.Count == 1)
                    {
                        locMap  = fromMap;
                        teleMap = toMap;
                    }

                    if (id > -1)
                    {
                        bool any = false;

                        foreach (var s in fromMap.FindItems <Static>(from, 0))
                        {
                            if (s.ItemID == id)
                            {
                                any = true;
                                break;
                            }
                        }

                        if (!any)
                        {
                            var st = new Static(id);

                            if (hue > -1)
                            {
                                st.Hue = hue;
                            }

                            st.MoveToWorld(from, fromMap);
                        }
                    }
                }

                if (list.Count > 0)
                {
                    Rectangle3D[] recs = new Rectangle3D[list.Count];
                    var           i    = 0;

                    foreach (var kvp in list)
                    {
                        recs[i++] = new Rectangle3D(kvp.Key.Location.X, kvp.Key.Location.Y, kvp.Key.Location.Z - 5, 1, 1, 10);
                    }

                    TeleportRegion teleRegion;

                    if (!Siege.SiegeShard && locMap != null && locMap.Rules != MapRules.FeluccaRules && teleMap.Rules == MapRules.FeluccaRules)
                    {
                        teleRegion = new TeleportRegionPVPWarning($"Teleport Region {unique.ToString()}", locMap, recs, list);
                    }
                    else
                    {
                        teleRegion = new TeleportRegion($"Teleport Region {unique.ToString()}", locMap, recs, list);
                    }

                    teleRegion.Register();

                    unique++;
                }
            }
        }
示例#2
0
        private static void BuildTeleporters(string elementName, XmlElement root, ref int unique)
        {
            foreach (XmlElement region in root.GetElementsByTagName(elementName))
            {
                var list = new Dictionary <WorldLocation, WorldLocation>();

                Map locMap  = null;
                Map teleMap = null;

                foreach (XmlElement tile in region.GetElementsByTagName("tiles"))
                {
                    Point3D from    = Point3D.Parse(Utility.GetAttribute(tile, "from", "(0, 0, 0)"));
                    Map     fromMap = Map.Parse(Utility.GetAttribute(tile, "frommap", null));

                    Point3D to    = Point3D.Parse(Utility.GetAttribute(tile, "to", "(0, 0, 0)"));
                    Map     toMap = Map.Parse(Utility.GetAttribute(tile, "tomap", null));

                    int id  = Utility.ToInt32(Utility.GetAttribute(tile, "ItemID", "-1"));
                    int hue = Utility.ToInt32(Utility.GetAttribute(tile, "Hue", "-1"));

                    if (fromMap == null)
                    {
                        throw new ArgumentException(string.Format("Map parsed as null: {0}", from));
                    }

                    if (toMap == null)
                    {
                        throw new ArgumentException(string.Format("Map parsed as null: {0}", to));
                    }

                    if (Siege.SiegeShard && (fromMap == Map.Trammel || toMap == Map.Trammel))
                    {
                        continue;
                    }

                    list.Add(new WorldLocation(from, fromMap), new WorldLocation(to, toMap));

                    if (list.Count == 1)
                    {
                        locMap  = fromMap;
                        teleMap = toMap;
                    }

                    if (id > -1)
                    {
                        if (!fromMap.FindItems <Static>(from, 0).Any(s => s.ItemID == id))
                        {
                            var st = new Static(id);

                            if (hue > -1)
                            {
                                st.Hue = hue;
                            }

                            st.MoveToWorld(from, fromMap);
                        }
                    }
                }

                if (list.Count > 0)
                {
                    Rectangle3D[] recs = new Rectangle3D[list.Count];
                    var           i    = 0;

                    foreach (var kvp in list)
                    {
                        recs[i++] = new Rectangle3D(kvp.Key.Location.X, kvp.Key.Location.Y, kvp.Key.Location.Z - 5, 1, 1, 10);
                    }

                    TeleportRegion teleRegion;

                    if (!Siege.SiegeShard && locMap != null && locMap.Rules != MapRules.FeluccaRules && teleMap.Rules == MapRules.FeluccaRules)
                    {
                        teleRegion = new TeleportRegionPVPWarning(string.Format("Teleport Region {0}", unique.ToString()), locMap, recs, list);
                    }
                    else
                    {
                        teleRegion = new TeleportRegion(string.Format("Teleport Region {0}", unique.ToString()), locMap, recs, list);
                    }

                    teleRegion.Register();

                    unique++;
                }
            }
        }