Второй этап доделан
This commit is contained in:
parent
6a8da78193
commit
76c34b75ae
48
SelfPropelledArtilleryUnit/MapsCollection.cs
Normal file
48
SelfPropelledArtilleryUnit/MapsCollection.cs
Normal file
@ -0,0 +1,48 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Artilleries
|
||||
{
|
||||
internal class MapsCollection
|
||||
{
|
||||
readonly Dictionary<string, MapWithSetArtilleriesGeneric<DrawingObjectArtillery, AbstractMap>> _mapsStorage;
|
||||
public List<string> Keys => _mapsStorage.Keys.ToList();
|
||||
|
||||
private readonly int _pictureWidth;
|
||||
private readonly int _pictureHeight;
|
||||
|
||||
public MapsCollection(int pictureWidth, int pictureHeight)
|
||||
{
|
||||
_mapsStorage = new Dictionary<string, MapWithSetArtilleriesGeneric<DrawingObjectArtillery, AbstractMap>>();
|
||||
_pictureWidth = pictureWidth;
|
||||
_pictureHeight = pictureHeight;
|
||||
}
|
||||
|
||||
public void AddMap(string name, AbstractMap map)
|
||||
{
|
||||
if (!_mapsStorage.ContainsKey(name))
|
||||
{
|
||||
_mapsStorage.Add(name, new MapWithSetArtilleriesGeneric<DrawingObjectArtillery, AbstractMap>(_pictureWidth, _pictureHeight, map));
|
||||
}
|
||||
}
|
||||
|
||||
public void DelMap(string name)
|
||||
{
|
||||
if (_mapsStorage.ContainsKey(name))
|
||||
{
|
||||
_mapsStorage.Remove(name);
|
||||
}
|
||||
}
|
||||
|
||||
public MapWithSetArtilleriesGeneric<DrawingObjectArtillery, AbstractMap> this[string index]
|
||||
{
|
||||
get
|
||||
{
|
||||
return _mapsStorage.ContainsKey(index) ? _mapsStorage[index] : null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user