Sorokin_P.V. Lab Work 6 #6
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user