Пример #1
0
        static public void LoadMapSet(MapSets map_set, ref AreaMapType map_template)
        {
            line = string.Empty;
            try
            {
                System.IO.Stream       stream           = TitleContainer.OpenStream(mapSetNames[(int)map_set]); // <------ this is where the MapSets enum is used
                System.IO.StreamReader map_set_txt_file = new System.IO.StreamReader(stream);

                if ((line = map_set_txt_file.ReadLine()) == "START")
                {
                    GetName(ref map_template, "MAP_SET_NAME", ref map_set_txt_file);
                    GetMapType(ref map_template, "MAP_TYPE", ref map_set_txt_file);
                    GetRoomTypes(ref map_template, "ROOM_TYPES", ref map_set_txt_file);
                    GetRoomTypeProbabilities(ref map_template, "ROOM_PROBABILITIES", ref map_set_txt_file);
                    GetRoomSizesRange(ref map_template, "ROOM_SIZES_RANGE", ref map_set_txt_file);
                    GetRoomBarriers(ref map_template, "ROOM_BARRIER_SIZES", ref map_set_txt_file);
                    GetTileSets(ref map_template, "TILE_SETS", ref map_set_txt_file);
                }

                map_set_txt_file.Close();
            }
            catch (System.IO.FileNotFoundException)
            {
                //temp_game.Exit();
            }
        }
Пример #2
0
        /// <summary>
        /// Deserialize the XML file into the game
        /// </summary>
        /// <param name="loadSettings">True to load the settings and high scores, or false for just the high scores</param>
        private void Deserialize(bool loadSettings)
        {
            try
            {
                // Load the document
                XDocument doc  = XDocument.Load("CoinCollector.xml");
                XElement  root = doc.Root;

                // Load the settings
                if (loadSettings)
                {
                    Controller.Player.Character = root.Element("Settings").Element("Player").Parse("Character", PlayerCharacter.Suit);
                }

                // Load the maps' high scores
                foreach (XElement mapset in root.Element("Mapsets").Elements("Mapset"))
                {
                    MapSet set = MapSets.FirstOrDefault(m => m.Filename == mapset.Parse <string>("Filename"));
                    if (set != null)
                    {
                        foreach (XElement map in mapset.Elements("Map"))
                        {
                            BaseMap baseMap = set.Maps.FirstOrDefault(m => m.MapNumber == map.Parse <int>("MapNumber"));
                            if (baseMap != null)
                            {
                                baseMap.HighScore = map.Parse <ulong>("HighScore");
                            }
                        }
                    }
                }
            }
            catch { }
        }
Пример #3
0
        /// <summary>
        /// Load all the mapsets for the game
        /// </summary>
        /// <param name="isReload">True if the mapstes are being reloaded, or false otherwise</param>
        private void LoadMapsets(bool isReload)
        {
            // Clear the existing mapsets
            MapSets.Clear();

            // Load all the default mapsets
            string[] maps = new string[] { "Beginner.mps", "Intermediate.mps" };
            foreach (string map in maps)
            {
                MapSets.Add(new MapSet(map, true));
            }

            // Load all the directory mapsets
            if (Directory.Exists("Mapsets"))
            {
                foreach (string filepath in Directory.GetFiles("Mapsets"))
                {
                    string filename = filepath.Split('\\').Last();
                    if (filename.EndsWith(".mps"))
                    {
                        MapSets.Add(new MapSet(filename, false));
                    }
                }
            }

            // Load the high scores
            Deserialize(!isReload);
        }
Пример #4
0
        static public void GenerateMap(ref ContentManager cm, ref int disc_rooms, ref int room_count)
        {
            AreaMap         current_map;
            AreaMapTemplate map_template = new AreaMapTemplate();

            discRooms = new List <int>();
            MapSets map_set   = MapSets.TEST_MAP_SET;           // change this
            Sizes   map_size  = Sizes.LARGE;                    // change this
            string  file_name = "test.xml";                     // change/remove this

            LoadMapSet(map_set, ref map_template);
            MapGenHelper.MakeMap(out current_map, ref map_template, map_size);
            MapGenHelper.GetMapData(ref disc_rooms, ref room_count);
            MapGenHelper.ResetMapGenHelper();
            //MapGenHelper.GetMapData(ref discRooms);
            MapLoader.MapToSavedMap(ref current_map, ref file_name);
        }
Пример #5
0
 static public void GenerateMap(ref AreaMap current_map, ref List <string> currMapTexNames, MapSets map_set, Sizes map_size,
                                ref List <int> dcRoomList)
 {
     areaMapType = new AreaMapType();
     LoadMapSet(map_set, ref areaMapType);
     MapGenHelper.MakeMap(ref current_map, ref areaMapType, ref currMapTexNames, map_size);
     MapGenHelper.GetMapData(ref dcRoomList);
 }