Небольшие изменения.

This commit is contained in:
Павел Сорокин 2022-11-07 22:37:13 +04:00
parent dd9105c2e4
commit 401fa5cbd7

View File

@ -74,43 +74,32 @@ namespace Liner
string bufferTextFromFile = "";
using (StreamReader sr = new(filename))
{
bool isFirst = true;
string str;
string str = sr.ReadLine();
if (!str.Contains("MapsCollection"))
{
return false;
}
_mapStorages.Clear();
while ((str = sr.ReadLine()) != null)
{
if (isFirst)
var tempElem = str.Split(separatorDict);
AbstractMap map = null;
switch (tempElem[1])
{
if (!str.Contains("MapsCollection"))
{
return false;
}
else
{
_mapStorages.Clear();
}
isFirst = false;
}
else
{
var tempElem = str.Split(separatorDict);
AbstractMap map = null;
switch (tempElem[1])
{
case "SimpleMap":
map = new SimpleMap();
break;
case "SeaMap":
map = new SeaMap();
break;
case "SwampMap":
map = new SwampMap();
break;
case "SimpleMap":
map = new SimpleMap();
break;
case "SeaMap":
map = new SeaMap();
break;
case "SwampMap":
map = new SwampMap();
break;
}
_mapStorages.Add(tempElem[0], new MapWithSetShipsGeneric<IDrawingObject, AbstractMap>(_pictureWidth, _pictureHeight, map));
_mapStorages[tempElem[0]].LoadData(tempElem[2].Split(separatorData, StringSplitOptions.RemoveEmptyEntries));
}
}
_mapStorages.Add(tempElem[0], new MapWithSetShipsGeneric<IDrawingObject, AbstractMap>(_pictureWidth, _pictureHeight, map));
_mapStorages[tempElem[0]].LoadData(tempElem[2].Split(separatorData, StringSplitOptions.RemoveEmptyEntries));
}
}
return true;
}