Этап 2. Добавлен класс MapsCollection
This commit is contained in:
parent
40da0fe01d
commit
a9d7e440cc
52
Locomotive/Locomotive/MapsCollection.cs
Normal file
52
Locomotive/Locomotive/MapsCollection.cs
Normal file
@ -0,0 +1,52 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Locomotive
|
||||
{
|
||||
internal class MapsCollection
|
||||
{
|
||||
/// Словарь (хранилище) с картами
|
||||
readonly Dictionary<string, MapWithSetLocomotivesGeneric<DrawningObjectLocomotive,
|
||||
AbstractMap>> _mapStorages;
|
||||
/// Возвращение списка названий карт
|
||||
public List<string> Keys => _mapStorages.Keys.ToList();
|
||||
/// Ширина окна отрисовки
|
||||
private readonly int _pictureWidth;
|
||||
/// Высота окна отрисовки
|
||||
private readonly int _pictureHeight;
|
||||
/// Конструктор
|
||||
public MapsCollection(int pictureWidth, int pictureHeight)
|
||||
{
|
||||
_mapStorages = new Dictionary<string,
|
||||
MapWithSetLocomotivesGeneric<DrawningObjectLocomotive, AbstractMap>>();
|
||||
_pictureWidth = pictureWidth;
|
||||
_pictureHeight = pictureHeight;
|
||||
}
|
||||
/// Добавление карты
|
||||
public void AddMap(string name, AbstractMap map)
|
||||
{
|
||||
// Логика для добавления
|
||||
if (!_mapStorages.ContainsKey(name)) _mapStorages.Add(name, new MapWithSetLocomotivesGeneric<DrawningObjectLocomotive, AbstractMap>(_pictureWidth, _pictureHeight, map));
|
||||
}
|
||||
/// Удаление карты
|
||||
public void DelMap(string name)
|
||||
{
|
||||
// Логика для удаления
|
||||
if (_mapStorages.ContainsKey(name)) _mapStorages.Remove(name);
|
||||
}
|
||||
/// Доступ к парковке
|
||||
public MapWithSetLocomotivesGeneric<DrawningObjectLocomotive, AbstractMap> this[string ind]
|
||||
{
|
||||
get
|
||||
{
|
||||
// Логика получения объекта
|
||||
if (_mapStorages.ContainsKey(ind)) return _mapStorages[ind];
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user