Ejemplo n.º 1
0
        public MapInfo(ushort index)
        {
            Index = index;
            if (File.Exists(@"Maps\" + index + ".ini"))
            {
                IniParser parser = new IniParser(@"Maps\" + index + ".ini");

                try
                {
                    Name = parser.GetSetting("map", "name");
                    XScale = float.Parse(parser.GetSetting("map", "x_scale"));
                    YScale = float.Parse(parser.GetSetting("map", "y_scale"));
                    XOffset = float.Parse(parser.GetSetting("map", "x_offset"));
                    YOffset = float.Parse(parser.GetSetting("map", "y_offset"));
                    bool result = int.TryParse(parser.GetSetting("map", "resolution"),out Resolution);

                    if (result == false)
                        Resolution = 4;

                    if (File.Exists(@"Maps\" + index + ".nav"))
                    {
                        LoadNav();

                        HasNavCoordinates = true;
                    }
                    Valid = true;
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Debug.Print("Problem reading map ini file. " + ex.Message);
                    Valid = false;
                }
            }
        }
Ejemplo n.º 2
0
        private void GetMarkers(string filePath)
        {
            IniParser reader = new IniParser(filePath);
            short markerCount;

            try
            {
                markerCount = short.Parse(reader.GetSetting("map", "markers"));
            } catch (Exception ex)
            {
                markerCount = 0;
            }

            _markers.Clear();

            for(short i = 0; i < markerCount; i++)
            {
                Coordinate coordinate = new Coordinate(float.Parse(reader.GetSetting("Marker " + (i + 1), "x")), float.Parse(reader.GetSetting("Marker " + (i + 1), "y")), 0);
                MapMarker marker = new MapMarker(coordinate, reader.GetSetting("Marker " + (i + 1), "icon"));
                _markers.Add(marker);
            }
        }