Example #1
0
 private static Map ParseMap(string zone, string[] lines) {
     Map tmpMap = new Map();
     tmpMap.zone = zone;
     if (tmpMap.zone != "") {
         List<MapLineSegment> segmentList = new List<MapLineSegment>();
         foreach (string l in lines) {
             if (l[0] == 'L') {
                 segmentList.Add(ParseSegment(l));
             }
             else if (l[0] == 'P') {
                 //parse place
             }
         }
         //group up line segments according to color(RGB) value, then create one pen for each color used
         //this should greatly lower the overhead for creating brush and pen objects 
         //*edit* aparently not.
         List<MapLineSegment> distinctSegments = segmentList.Distinct(new MapLineSegmentColorComparer()).ToList();
         foreach (MapLineSegment colorSource in distinctSegments) {
             List<MapLineSegment> tmpSegmentList = segmentList.FindAll(x => x.color == colorSource.color);
             SolidColorBrush colorBrush = new SolidColorBrush(colorSource.color);
             Pen tmpPen = new Pen(colorBrush, 1.0);
             tmpMap.lineList.Add(new MapLine(tmpSegmentList, tmpPen));
         }
         if (segmentList.Count > 0) {
             tmpMap.maxX = Math.Max(segmentList.Max(x => x.aX), segmentList.Max(x => x.bX));
             tmpMap.maxY = Math.Max(segmentList.Max(x => x.aY), segmentList.Max(x => x.bY));
             tmpMap.minX = Math.Min(segmentList.Min(x => x.aX), segmentList.Min(x => x.bX));
             tmpMap.minY = Math.Min(segmentList.Min(x => x.aY), segmentList.Min(x => x.bY));
             tmpMap.width = tmpMap.maxX - tmpMap.minX;
             tmpMap.height = tmpMap.maxY - tmpMap.minY;
             tmpMap.depth = tmpMap.maxZ - tmpMap.minZ;
         }
     }
     return tmpMap;
 }
Example #2
0
 public static Map ReadMap(string zone) {
     string[] zonefiles = Directory.GetFiles(@"maps\", zone + "_1.txt");
     Map tmpMap = new Map();
     List<String> allZoneFiles = new List<string>();
     foreach (string s in zonefiles) {
         allZoneFiles.AddRange(File.ReadAllLines(s));
     }
     tmpMap = ParseMap(zone, allZoneFiles.ToArray());
     return tmpMap;
 }
Example #3
0
 private void GameAnalyzer_OnZone(object sender, StringEventArgs e) {
     this.zoneMap = MapReader.ReadMap(e.value);
     mapVisuals.Clear();
     spawnVisuals.Clear();
     //ResizeCanvasToZone(e.value);
     this.rvh = GetResizeValHolder(e.value);
     DrawMap(this.rvh);
     if (followSelf) {
         centerView();
     }
     lblZone.Content = this.zoneMap.zone;
 }