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