Ejemplo n.º 1
0
 /// <summary>
 /// Allows the game to perform any initialization it needs to before starting to run.
 /// This is where it can query for any required services and load any non-graphic
 /// related content.  Calling base.Initialize will enumerate through any components
 /// and initialize them as well.
 /// </summary>
 protected override void Initialize()
 {
     // TODO: Add your initialization logic here
     IsMouseVisible = true;
     currentGameState = GameState.MainMenu;
     mainMenu = new MainMenu(currentGameState);
     loadMenu = new LoadSaveMenu(currentGameState);
     map = new Map(currentGameState);
     readMap = new RaedMap();
     readMap.ReadMap(map);
     base.Initialize();
 }
Ejemplo n.º 2
0
        public static void ProcessDirectory(string targetDirectory,Map map)
        {
            // Process the list of files found in the directory.
            string[] fileEntries = Directory.GetFiles(targetDirectory);
            foreach (string fileName in fileEntries)
                ProcessFile(fileName, map);

            // Recurse into subdirectories of this directory.
            string[] subdirectoryEntries = Directory.GetDirectories(targetDirectory);
            foreach (string subdirectory in subdirectoryEntries)
                ProcessDirectory(subdirectory, map);
        }
Ejemplo n.º 3
0
 // Insert logic for processing found files here.
 public static void ProcessFile(string path, Map map)
 {
     if (!path.EndsWith(".csv"))
     {
         return;
     }
     var singleMap = new ReadSingleMap();
     var typeSplit = path.Split('-');
     var type = typeSplit[typeSplit.Length - 1];
     type = type.Substring(0, type.Length - 4);
     singleMap.ReadMap(path, type, map);
     System.Console.WriteLine("Processed file '{0}'.", path);
 }
Ejemplo n.º 4
0
        public void ReadMap(string path,string type,Map map)
        {
            try
            {
                using (StreamReader sr = new StreamReader(path))
                {
                    String line = sr.ReadToEnd();

                    string[] numberTextArr = line.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                    string[] singleLineForGetLength = numberTextArr[0].Split(',');
                    var len = singleLineForGetLength.Length;

                    int[,] matrix = new int[numberTextArr.Length, len];

                    for (int i = 0; i < numberTextArr.Length; i++)
                    {
                        string[] singleLine = numberTextArr[i].Split(',');
                        int[] numbersLine = new int[singleLine.Length];

                        for (int j = 0; j < singleLine.Length; j++)
                        {
                            numbersLine[j] = int.Parse(singleLine[j]);
                        }

                        for (int k = 0; k < len; k++)
                        {
                            matrix[i, k] = numbersLine[k];
                        }
                    }

                    map.LoadMap(type, matrix);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("The File could not be read:");
                Console.WriteLine(e.Message);

                Console.ReadLine();
            }
        }
Ejemplo n.º 5
0
        public void ReadMap(Map map)
        {
            string[] data = new string[2];
            data[0] = @"C:\Users\vutov\Documents\GitHub\Team-Helo-Prime-\Map-Files\StartLevel";
            foreach (string path in data)
            {
                if (File.Exists(path))
                {
                    // This path is a file
                    ProcessFile(path,map);

                }
                else if (Directory.Exists(path))
                {
                    // This path is a directory
                    ProcessDirectory(path,map);
                }
                else
                {
                    //Contain errors.
                }
            }
        }