diff --git a/AntiAirCraftGun/AntiAirCraftGun/Generics/AntiAirCraftGunGenericCollection.cs b/AntiAirCraftGun/AntiAirCraftGun/Generics/AntiAirCraftGunGenericCollection.cs index cc54afd..583b694 100644 --- a/AntiAirCraftGun/AntiAirCraftGun/Generics/AntiAirCraftGunGenericCollection.cs +++ b/AntiAirCraftGun/AntiAirCraftGun/Generics/AntiAirCraftGunGenericCollection.cs @@ -51,31 +51,26 @@ namespace AntiAircraftGun.Generics /// /// /// - public static bool operator +(AntiAirCraftGunGenericCollection collect, T? obj) + public static int operator +(AntiAirCraftGunGenericCollection collect, T? obj) { if (obj == null) - { - MessageBox.Show("Объект пустой. Невозможно добавить."); - return false; - } - return collect?._collection.Insert(obj) ?? false; + return -1; + return collect?._collection.Insert(obj) ?? -1; } - /// /// Перегрузка оператора вычитания /// /// /// /// - public static T? operator -(AntiAirCraftGunGenericCollection collect, int pos) + public static bool operator -(AntiAirCraftGunGenericCollection collect, int pos) { - T? obj = collect._collection[pos]; - if (obj != null) - { - collect._collection.Remove(pos); - } - return obj; + T? obj = collect._collection.Get(pos); + if (obj != null) + return collect._collection.Remove(pos); + return false; } + /// /// Получение объекта IMoveableObject /// @@ -156,9 +151,21 @@ namespace AntiAircraftGun.Generics if (y + distance_between_objects >= maxY) { y = 0; - x += obj.GetWidth + 10 + _placeSizeWidth; + x += _placeSizeWidth; } } + if (obj == null) + { + // Увеличиваем координату Y для следующего объекта + y += distance_between_objects; + + // Проверяем, если Y достигло максимума, изменяем X и сбрасываем Y + if (y+distance_between_objects >= maxY) + { + y = 0; + x += _placeSizeWidth; + } + }; } } } diff --git a/AntiAirCraftGun/AntiAirCraftGun/Generics/SetGeneric.cs b/AntiAirCraftGun/AntiAirCraftGun/Generics/SetGeneric.cs index ee2a8b2..a9e6890 100644 --- a/AntiAirCraftGun/AntiAirCraftGun/Generics/SetGeneric.cs +++ b/AntiAirCraftGun/AntiAirCraftGun/Generics/SetGeneric.cs @@ -35,7 +35,7 @@ namespace AntiAircraftGun.Generics /// /// Добавляемый автомобиль /// - public bool Insert(T car) + public int Insert(T car) { if (_places.Count == _maxCount) return false;