Пример #1
0
 public void AddNode(MapNode node)
 {
     node.Map.AddNode(node);
     if (node is TeleportNode)
     {
         node = ((TeleportNode)node).Target;
         node.Map.AddNode(node);
     }
 }
Пример #2
0
 public UseTeleportNode(ClusteredMap map, Vertex2D location, MapNode target, short useObject, short useWithObject)
     : base(map, location, target)
 {
     this.useObject = useObject;
     this.useWithObject = useWithObject;
 }
Пример #3
0
 public TeleportPadNode(ClusteredMap map, Vertex2D location, MapNode target, Vertex2D padLocation)
     : base(map, location, target)
 {
     this.padLocation = padLocation;
 }
Пример #4
0
 public TeleportNode(ClusteredMap map, short x, short y, ClusteredMap destMap, short destX, short destY)
     : base(map, x, y)
 {
     this.target = new MapNode(destMap, destX, destY);
 }
Пример #5
0
 public TeleportNode(ClusteredMap map, Vertex2D location, MapNode target)
     : base(map, location)
 {
     this.target = target;
 }
Пример #6
0
 public BeamMeNode(ClusteredMap map, Vertex2D location, MapNode target)
     : base(map, location, target)
 {
 }
Пример #7
0
 public void AddNode(MapNode node)
 {
     if (!mapNodes.ContainsKey(node))
         mapNodes.Add(node, node);
 }
Пример #8
0
        public Path FindPath(MapNode start, List<MapNode> targets, int limit)
        {
            Path path = null;

            List<MapNode> list = new ShortestPath(mapManager, beamTarget).FindPath(start, targets);
            if (list == null || list.Count == 0)
                return null;

            foreach (MapNode node in list)
            {
                TheLogger.Debug(node.ToString() + "\n");
            }

            list.Reverse();
            path = new Path();
            path.mapnodes = new Stack<MapNode>(list);
            return path;
        }
Пример #9
0
        public void LoadMapDef()
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(new FileStream("maps.xml", FileMode.Open, FileAccess.Read));
            XmlNodeList maps = doc.SelectNodes("/maps/map");
            foreach (XmlNode node in maps)
            {
                string mapName = node.SelectSingleNode("@name").Value;
                ClusteredMap map = GetMapByName(mapName + ".elm");
                if (map == null)
                    continue;

                if (map.Name != mapName)
                    AddAlias(mapName, map.Name);

                XmlNodeList mapAliasNodes = node.SelectNodes("alias");
                foreach (XmlNode aliasNode in mapAliasNodes)
                {
                    string alias = aliasNode.InnerText;
                    AddAlias(alias, map.Name);
                }

                XmlNode mapBeamOutNode = node.SelectSingleNode("beam");
                if (mapBeamOutNode != null)
                    map.BeamOut = Boolean.Parse(mapBeamOutNode.InnerText);
            }

            foreach (XmlNode node in maps)
            {
                string mapName = node.SelectSingleNode("@name").Value;
                ClusteredMap map = GetMapByName(mapName);

                XmlNodeList mapNodes = node.SelectNodes("node");
                foreach (XmlNode xmlNode in mapNodes)
                {
                    MapNode mapNode = LoadMapNode(xmlNode, map);
                    AddNode(mapNode);
                }
            }

            XmlNode beamNode = doc.SelectSingleNode("/maps/beam");
            if (beamNode != null)
            {
                short destx = Int16.Parse(beamNode.SelectSingleNode("target/@x").Value);
                short desty = Int16.Parse(beamNode.SelectSingleNode("target/@y").Value);
                ClusteredMap destmap = GetMapByName(beamNode.SelectSingleNode("target/@map").Value);
                beamTarget = new MapNode(destmap, new MapNode.Vertex2D(destx, desty));
            }
            else
            {
                beamTarget = null;
            }

            if (File.Exists("maplist.lst"))
            {
                StreamReader reader = new StreamReader("maplist.lst");
                try
                {

                    Regex re = new Regex(@"^(\S*)\s+(\S*).*?$");
                    while (!reader.EndOfStream)
                    {
                        String line = reader.ReadLine();
                        Match match = re.Match(line);
                        String mapname = match.Groups[1].Value;
                        String alias = match.Groups[2].Value.Replace('_', ' ');
                            if (mapManager.GetMapByName(mapname) != null)
                                AddAlias(alias, mapname);
                    }

                }
                finally
                {
                    reader.Close();
                }
            }
        }