From cc6f49f85d7ce94f749006cc64d3427f51be6187 Mon Sep 17 00:00:00 2001 From: Danil Malin Date: Mon, 7 Nov 2022 22:22:28 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5=D0=BD?= =?UTF-8?q?=D0=B8=D0=B5=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D0=B0=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WarmlyLocomotive/MapsCollection.cs | 56 ++++++++----------- 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/WarmlyLocomotive/WarmlyLocomotive/MapsCollection.cs b/WarmlyLocomotive/WarmlyLocomotive/MapsCollection.cs index 9788743..54991f0 100644 --- a/WarmlyLocomotive/WarmlyLocomotive/MapsCollection.cs +++ b/WarmlyLocomotive/WarmlyLocomotive/MapsCollection.cs @@ -123,43 +123,31 @@ namespace WarmlyLocomotive } using (StreamReader sr = new(filename)) { - bool isFirst = true; - string str; - while((str = sr.ReadLine()) != null) + string str = sr.ReadLine(); + if (!str.Contains("MapsCollection")) { - if (isFirst) + //если нет такой записи, то это не те данные + return false; + } + _mapStorages.Clear(); + while ((str = sr.ReadLine()) != null) + { + var elem = str.Split(separatorDict); + AbstractMap map = null; + switch (elem[1]) { - if (!str.Contains("MapsCollection")) - { - //если нет такой записи, то это не те данные - return false; - } - else - { - //очищаем записи - _mapStorages.Clear(); - } - isFirst = false; - } - else - { - var elem = str.Split(separatorDict); - AbstractMap map = null; - switch (elem[1]) - { - case "SimpleMap": - map = new SimpleMap(); - break; - case "BigBarriersMap": - map = new BigBarriersMap(); - break; - case "CirclesMap": - map = new CirclesMap(); - break; - } - _mapStorages.Add(elem[0], new MapWithSetLocomotivesGeneric(_pictureWidth, _pictureHeight, map)); - _mapStorages[elem[0]].LoadData(elem[2].Split(separatorData, StringSplitOptions.RemoveEmptyEntries)); + case "SimpleMap": + map = new SimpleMap(); + break; + case "BigBarriersMap": + map = new BigBarriersMap(); + break; + case "CirclesMap": + map = new CirclesMap(); + break; } + _mapStorages.Add(elem[0], new MapWithSetLocomotivesGeneric(_pictureWidth, _pictureHeight, map)); + _mapStorages[elem[0]].LoadData(elem[2].Split(separatorData, StringSplitOptions.RemoveEmptyEntries)); } } return true;