From 93d704a1b8446b5cdbcfea479b57dec0f096ef67 Mon Sep 17 00:00:00 2001 From: "d.agil" Date: Wed, 2 Nov 2022 11:52:30 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=BA=D0=B0=D1=80=D1=82=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBomber/AirBomber/MapsCollection.cs | 49 ++++++++++++--------------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/AirBomber/AirBomber/MapsCollection.cs b/AirBomber/AirBomber/MapsCollection.cs index 7ba6aa9..c9aaea7 100644 --- a/AirBomber/AirBomber/MapsCollection.cs +++ b/AirBomber/AirBomber/MapsCollection.cs @@ -110,39 +110,34 @@ namespace AirBomber { throw new FileNotFoundException("Файл не найден"); } - List strs = new List(); using (StreamReader fs = new(filename)) { + if (!fs.ReadLine().Contains("MapsCollection")) + { + //если нет такой записи, то это не те данные + throw new FileFormatException("Формат данных в файле не правильный"); + } + //очищаем записи + _mapStorages.Clear(); while (!fs.EndOfStream) { - strs.Add(fs.ReadLine()); + var elem = fs.ReadLine().Split(separatorDict); + AbstractMap map = null; + switch (elem[1]) + { + case "SimpleMap": + map = new SimpleMap(); + break; + case "WallMap": + map = new WallMap(); + break; + } + _mapStorages.Add(elem[0], new + MapWithSetAirplanesGeneric(_pictureWidth, _pictureHeight, map)); + _mapStorages[elem[0]].LoadData(elem[2].Split(separatorData, + StringSplitOptions.RemoveEmptyEntries)); } } - if (!strs[0].Contains("MapsCollection")) - { - //если нет такой записи, то это не те данные - throw new FileFormatException("Формат данных в файле не правильный"); - } - //очищаем записи - _mapStorages.Clear(); - for (int i = 1; i < strs.Count; ++i) - { - var elem = strs[i].Split(separatorDict); - AbstractMap map = null; - switch (elem[1]) - { - case "SimpleMap": - map = new SimpleMap(); - break; - case "WallMap": - map = new WallMap(); - break; - } - _mapStorages.Add(elem[0], new - MapWithSetAirplanesGeneric(_pictureWidth, _pictureHeight, map)); - _mapStorages[elem[0]].LoadData(elem[2].Split(separatorData, - StringSplitOptions.RemoveEmptyEntries)); - } } } }