Добавление нового класса - коллекции карт

This commit is contained in:
prodigygirl 2022-10-09 18:53:58 +04:00
parent 20616550bc
commit 3664eed949

View File

@ -0,0 +1,70 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ArmoredCar
{
internal class MapsCollection
{
/// Словарь (хранилище) с картами
/// </summary>
readonly Dictionary<string, MapWithSetArmoredCarsGeneric<DrawningObjectArmCar, AbstractMap>> _mapStorages;
/// <summary>
/// Возвращение списка названий карт
/// </summary>
public List<string> Keys => _mapStorages.Keys.ToList();
/// <summary>
/// Ширина окна отрисовки
/// </summary>
private readonly int _pictureWidth;
/// <summary>
/// Высота окна отрисовки
/// </summary>
private readonly int _pictureHeight;
/// <summary>
/// Конструктор
/// </summary>
/// <param name="pictureWidth"></param>
/// <param name="pictureHeight"></param>
public MapsCollection(int pictureWidth, int pictureHeight)
{
_mapStorages = new Dictionary<string, MapWithSetArmoredCarsGeneric<DrawningObjectArmCar, AbstractMap>>();
_pictureWidth = pictureWidth;
_pictureHeight = pictureHeight;
}
/// <summary>
/// Добавление карты
/// </summary>
/// <param name="name">Название карты</param>
/// <param name="map">Карта</param>
public void AddMap(string name, AbstractMap map)
{
_mapStorages.Add(name, new MapWithSetArmoredCarsGeneric<DrawningObjectArmCar, AbstractMap>(_pictureWidth, _pictureHeight, map));
}
/// <summary>
/// Удаление карты
/// </summary>
/// <param name="name">Название карты</param>
public void DelMap(string name)
{
_mapStorages.Remove(name);
}
/// <summary>
/// Доступ к парковке
/// </summary>
/// <param name="ind"></param>
/// <returns></returns>
public MapWithSetArmoredCarsGeneric<DrawningObjectArmCar, AbstractMap> this[string
ind]
{
get
{
if (Keys.Contains(ind))
return _mapStorages[ind];
return null;
}
}
}
}