Exemplo n.º 1
0
        public static string MakeFrom(RoomParser roomParser,
                                      WillyStartParser willyStartParser,
                                      TravelatorParser travelatorParser,
                                      ExitParser exitParser,
                                      KeyParser keyParser,
                                      HorizontalBaddiesParser horizontal,
                                      AirParser airParser)
        {
            var file = new MMMapFile
            {
                rooms = new MMRoom[20]
            };

            for (int i = 0; i < 20; i++)
            {
                file.rooms[i] = new MMRoom
                {
                    blocks       = roomParser.RoomData[i],
                    name         = roomParser.RoomNames[i],
                    exitPosition = exitParser.Exits[i],
                    keys         = keyParser.Keys[i],
                    travelator   = travelatorParser.Travelators[i],
                    willyStart   = willyStartParser.WillyStart[i],
                    horizEnemies = horizontal.Baddies[i],
                    airCount     = airParser.AirCount[i]
                };
            }

            return(JsonConvert.SerializeObject(file));
        }
Exemplo n.º 2
0
        public string Parse()
        {
            // Read the contents of the file, but ignore lines that start
            // with a semi-colon (;) because those are comments in BlitzBASIC
            var lines = File.ReadLines(_map)
                        .Where((line) => !line.StartsWith(";"))
                        .ToArray();

            // Create the laundry list of parsers
            var roomParser       = new RoomParser();
            var willyStartParser = new WillyStartParser();
            var exitParser       = new ExitParser();
            var travelatorParser = new TravelatorParser();
            var keyParser        = new KeyParser();
            var horiz            = new HorizontalBaddiesParser();
            var airParser        = new AirParser();

            roomParser.Parse(lines);
            willyStartParser.Parse(lines);
            travelatorParser.Parse(lines);
            exitParser.Parse(lines);
            keyParser.Parse(lines);
            horiz.Parse(lines);
            airParser.Parse(lines);

            return(JsonUtil.MakeFrom(roomParser,
                                     willyStartParser,
                                     travelatorParser,
                                     exitParser,
                                     keyParser,
                                     horiz,
                                     airParser));

            /*
             * Each line:
             *  if it matches a marker; process the number of lines required for that section
             */
        }