예제 #1
0
        // not currently in use, may be used to determine where to to place secrets/collectables
        //static List<Pair> DeadEnds;

        public static Level[,] GenerateMap()
        {
            // load levels to internal list
            LevelPool pool = LevelPool.LoadPoolMapTest();

            Levels = pool.Levels;

            // initialize map
            Map = new Level[MAP_HEIGHT, MAP_WIDTH];

            // place first screen to start from
            var startLevel = Utility.FindLevelInListByName(HubLevels, "start");

            PlaceLevel(MAP_HEIGHT / 2, MAP_WIDTH / 2, startLevel);
            AddEnds(MAP_HEIGHT / 2, MAP_WIDTH / 2, startLevel);
            Levels.Remove(startLevel);

            // start subroutine of placing screens
            while (OpenEnds.Count != 0)
            {
                /*if (OpenEnds.Count != 0)
                 *  break;*/
                PlaceNext();
                PrintDebugCSV();
            }

            // convert the map to a 2d array
            //string[][] arr = MapToArray();

            PrintCSV();

            return(Map);
        }
예제 #2
0
 static void LoadLevelPoolCategories()
 {
     LevelPoolCategories = new ObservableCollection <LevelPoolCategory>();
     foreach (var dir in Directory.GetDirectories(LevelPoolPath, "*", SearchOption.TopDirectoryOnly))
     {
         var folder = Path.GetFileNameWithoutExtension(dir);
         var cat    = new LevelPoolCategory()
         {
             Name = folder, Pools = new ObservableCollection <LevelPool>()
             {
             }
         };
         var tempList = new List <LevelPool>()
         {
         };
         string author  = null;
         bool   enabled = false;
         foreach (var file in Directory.GetFiles($"{LevelPoolPath}/{folder}", "*.xml", SearchOption.TopDirectoryOnly))
         {
             var pool = LevelPool.LoadPool(file);    // pool creation done in Pool constructor
             if (pool != null)
             {
                 if (pool.Author != null)        // set category author
                 {
                     if (author == null)         // if author not already set, set it
                     {
                         author = pool.Author;
                     }
                     else if (author != pool.Author)  // if there is more than one pool author in the category, set to V.A.
                     {
                         author = "V.A.";
                     }
                 }
                 if (pool.Active == true)
                 {
                     enabled = true;
                 }
                 tempList.Add(pool);
             }
         }
         cat.Enabled = enabled;
         cat.Author  = author;
         cat.Pools   = tempList.OrderBy(p => p.Order);
         LevelPoolCategories.Add(cat);
     }
 }