Esempio n. 1
0
        public void Read(string path)
        {
            ProgressMax?.Invoke(File.ReadAllLines(path).Length);
            ProgressText("Загружаем coord_data.txt");
            StreamReader sr = new StreamReader(path);

            Header = sr.ReadLine();
            while (!sr.EndOfStream)
            {
                ProgressNext?.Invoke();
                string[] data = Regex.Replace(sr.ReadLine().Replace('"', ' ').Replace(",", " "), @"\s+", " ").Split(' ');
                if (data.Length > 3)
                {
                    if (!Entrys.ContainsKey(data[0]))
                    {
                        Entrys.Add(data[0], new List <CoordDataEntry>());
                    }
                    Entrys[data[0]].Add(new CoordDataEntry()
                    {
                        MapNumber = data[1],
                        X         = float.Parse(data[2].Replace('.', ',')),
                        Y         = float.Parse(data[3].Replace('.', ',')),
                        Z         = float.Parse(data[4].Replace('.', ','))
                    });
                }
            }
            ProgressValue?.Invoke(0);
            ProgressText?.Invoke($"coord_data.txt загружен, {Entrys.Keys.Count} объектов");
            sr.Close();
        }
Esempio n. 2
0
 public void ReadNpcgen(BinaryReader br)
 {
     ProgressText?.Invoke("Загружаем npcgen.data");
     File_version    = br.ReadInt32();
     NpcMobsAmount   = br.ReadInt32();
     ResourcesAmount = br.ReadInt32();
     DynobjectAmount = br.ReadInt32();
     if (File_version > 6)
     {
         TriggersAmount = br.ReadInt32();
     }
     ProgressMax.Invoke(NpcMobsAmount + ResourcesAmount);
     for (int i = 0; i < NpcMobsAmount; i++)
     {
         NpcMobList.Add(ReadExistence(br, File_version));
         ProgressNext?.Invoke();
     }
     for (int i = 0; i < ResourcesAmount; i++)
     {
         ResourcesList.Add(ReadResource(br, File_version));
         ProgressNext?.Invoke();
     }
     ProgressText?.Invoke($"npcgen.data загружен, {NpcMobsAmount + ResourcesAmount} объектов");
     ProgressValue(0);
     br.Close();
 }
Esempio n. 3
0
        public void Save(string path)
        {
            ProgressMax?.Invoke(Entrys.Keys.Count);
            StreamWriter sw = new StreamWriter(path);

            sw.WriteLine(Header);
            ProgressValue?.Invoke(0);
            foreach (KeyValuePair <string, List <CoordDataEntry> > entry in Entrys)
            {
                ProgressNext?.Invoke();
                entry.Value.ForEach(x =>
                {
                    sw.WriteLine($"{entry.Key}\t{x.MapNumber}\t{string.Format("{0:F2}", x.X).Replace(",", ".")}\t{string.Format("{0:F2}", x.Y).Replace(",", ".")}\t{string.Format("{0:F2}", x.Z).Replace(",", ".")}");
                });
            }
            ProgressValue?.Invoke(0);
            ProgressText?.Invoke($"coord_data.txt успешно сохранен");
            sw.Close();
        }