76 lines
2.5 KiB
C#
76 lines
2.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Cruiser.Drawing;
|
|
using Cruiser.MovementStrategy;
|
|
|
|
|
|
namespace Cruiser.Generics
|
|
{
|
|
internal class CruisersGenericStorage
|
|
{
|
|
/// <summary>
|
|
/// Словарь (хранилище)
|
|
/// </summary>
|
|
readonly Dictionary<string, CarsGenericCollection<DrawingCruiser,DrawningObjectCar>> _cruiserStorages;
|
|
/// <summary>
|
|
/// Возвращение списка названий наборов
|
|
/// </summary>
|
|
public List<string> Keys => _cruiserStorages.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 CruisersGenericStorage(int pictureWidth, int pictureHeight)
|
|
{
|
|
_cruiserStorages = new Dictionary<string,CarsGenericCollection<DrawingCruiser, DrawningObjectCar>>();
|
|
_pictureWidth = pictureWidth;
|
|
_pictureHeight = pictureHeight;
|
|
}
|
|
/// <summary>
|
|
/// Добавление набора
|
|
/// </summary>
|
|
/// <param name="name">Название набора</param>
|
|
public void AddSet(string name)
|
|
{
|
|
if (_cruiserStorages.ContainsKey(name)) return;
|
|
_cruiserStorages[name] = new CarsGenericCollection<DrawingCruiser, DrawningObjectCar>(_pictureWidth, _pictureHeight);
|
|
}
|
|
/// <summary>
|
|
/// Удаление набора
|
|
/// </summary>
|
|
/// <param name="name">Название набора</param>
|
|
public void DelSet(string name)
|
|
{
|
|
if (!_cruiserStorages.ContainsKey(name)) return;
|
|
_cruiserStorages.Remove(name);
|
|
}
|
|
/// <summary>
|
|
/// Доступ к набору
|
|
/// </summary>
|
|
/// <param name="ind"></param>
|
|
/// <returns></returns>
|
|
public CarsGenericCollection<DrawingCruiser, DrawningObjectCar>?
|
|
this[string ind]
|
|
{
|
|
get
|
|
{
|
|
if (_cruiserStorages.ContainsKey(ind)) return _cruiserStorages[ind];
|
|
return null;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|