PIbd-22_Shabunov_O.A._AirBo.../AirBomber/Generics/EntitiesGenericStorage.cs

54 lines
1.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using AirBomber.MovementStrategy;
using AirBomber.Rendering;
namespace AirBomber.Generics
{
internal class EntitiesGenericStorage
{
readonly Dictionary<string, EntitiesGenericCollection<BomberRendererBase, ObjectEntityRenderer>> _entityStorages;
public List<string> Keys => _entityStorages.Keys.ToList();
private readonly int _pictureWidth;
private readonly int _pictureHeight;
public EntitiesGenericStorage(int PictureWidth, int PictureHeight)
{
_entityStorages = new Dictionary<string, EntitiesGenericCollection<BomberRendererBase, ObjectEntityRenderer>>();
_pictureWidth = PictureWidth;
_pictureHeight = PictureHeight;
}
public void AddSet(string Name)
{
var NewCollection =
new EntitiesGenericCollection<BomberRendererBase, ObjectEntityRenderer>(_pictureWidth, _pictureHeight);
if (Keys.Contains(Name))
{
MessageBox.Show("Набор с таким именем уже существует", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_entityStorages.Add(Name, NewCollection);
}
public void RemoveSet(string Name)
{
_entityStorages.Remove(Name);
}
public EntitiesGenericCollection<BomberRendererBase, ObjectEntityRenderer>? this[string Index]
{
get
{
if (!_entityStorages.ContainsKey(Index))
return null;
return _entityStorages[Index];
}
}
}
}