diff --git a/MotorBoat/MotorBoat/AbstractMap.cs b/MotorBoat/MotorBoat/AbstractMap.cs index 413d614..e6cd207 100644 --- a/MotorBoat/MotorBoat/AbstractMap.cs +++ b/MotorBoat/MotorBoat/AbstractMap.cs @@ -34,13 +34,13 @@ namespace MotorBoat // TODO проверка, что объект может переместится в требуемом направлении (float leftX, float topY, float rightX, float bottomY) = _drawningObject.GetCurrentPosition(); bool can = true; - + //координаты в системе массива int topYinS = Convert.ToInt32((topY) / _size_y); int rightXinS = Convert.ToInt32((rightX) / _size_x); int leftXinS = Convert.ToInt32((leftX) / _size_x); int bottomYinS = Convert.ToInt32(bottomY / _size_y); - int stepinS = 0; + int stepinS = 0; switch (direction) { diff --git a/MotorBoat/MotorBoat/DrawningObjectBoat.cs b/MotorBoat/MotorBoat/DrawningObjectBoat.cs index 09a0531..f551b37 100644 --- a/MotorBoat/MotorBoat/DrawningObjectBoat.cs +++ b/MotorBoat/MotorBoat/DrawningObjectBoat.cs @@ -9,29 +9,23 @@ namespace MotorBoat internal class DrawningObjectBoat : IDrawningObject { private DrawningBoat _boat = null; - public DrawningObjectBoat(DrawningBoat boat) { _boat = boat; } - public float Step => _boat?.Boat?.Step ?? 0; - public (float Left, float Right, float Top, float Bottom) GetCurrentPosition() { return _boat?.GetCurrentPosition() ?? default; } - public void MoveObject(Direction direction) { _boat?.MoveTransport(direction); } - public void SetObject(int x, int y, int width, int height) { _boat.SetPosition(x, y, width, height); } - void IDrawningObject.DrawningObject(Graphics g) { _boat.DrawTransport(g); diff --git a/MotorBoat/MotorBoat/FormMapWithSetBoats.cs b/MotorBoat/MotorBoat/FormMapWithSetBoats.cs index 8876f6f..f9155e4 100644 --- a/MotorBoat/MotorBoat/FormMapWithSetBoats.cs +++ b/MotorBoat/MotorBoat/FormMapWithSetBoats.cs @@ -12,22 +12,11 @@ namespace MotorBoat { public partial class FormMapWithSetBoats : Form { - /// - /// Объект от класса карты с набором объектов - /// private MapWithSetBoatsGeneric _mapBoatsCollectionGeneric; - /// - /// Конструктор - /// public FormMapWithSetBoats() { InitializeComponent(); } - /// - /// Выбор карты - /// - /// - /// private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e) { AbstractMap map = null; @@ -53,11 +42,6 @@ namespace MotorBoat _mapBoatsCollectionGeneric = null; } } - /// - /// Добавление объекта - /// - /// - /// private void ButtonAddBoat_Click(object sender, EventArgs e) { if (_mapBoatsCollectionGeneric == null) @@ -79,11 +63,6 @@ namespace MotorBoat } } } - /// - /// Удаление объекта - /// - /// - /// private void ButtonRemoveBoat_Click(object sender, EventArgs e) { if (string.IsNullOrEmpty(maskedTextBoxPosition.Text)) @@ -105,11 +84,6 @@ namespace MotorBoat MessageBox.Show("Не удалось удалить объект"); } } - /// - /// Вывод набора - /// - /// - /// private void ButtonShowStorage_Click(object sender, EventArgs e) { if (_mapBoatsCollectionGeneric == null) @@ -118,11 +92,6 @@ namespace MotorBoat } pictureBox.Image = _mapBoatsCollectionGeneric.ShowSet(); } - /// - /// Вывод карты - /// - /// - /// private void ButtonShowOnMap_Click(object sender, EventArgs e) { if (_mapBoatsCollectionGeneric == null) @@ -131,18 +100,12 @@ namespace MotorBoat } pictureBox.Image = _mapBoatsCollectionGeneric.ShowOnMap(); } - /// - /// Перемещение - /// - /// - /// private void ButtonMove_Click(object sender, EventArgs e) { if (_mapBoatsCollectionGeneric == null) { return; } - //получаем имя кнопки string name = ((Button)sender)?.Name ?? string.Empty; Direction dir = Direction.None; switch (name) diff --git a/MotorBoat/MotorBoat/SetBoatsGeneric.cs b/MotorBoat/MotorBoat/SetBoatsGeneric.cs index 3b4a951..0c788f4 100644 --- a/MotorBoat/MotorBoat/SetBoatsGeneric.cs +++ b/MotorBoat/MotorBoat/SetBoatsGeneric.cs @@ -9,7 +9,6 @@ namespace MotorBoat internal class SetBoatsGeneric where T : class { - private readonly T[] _places; public int Count => _places.Length; public SetBoatsGeneric(int count) @@ -18,8 +17,6 @@ namespace MotorBoat } public int Insert(T boat) { - // TODO вставка в начало набора - //return true; return Insert(boat, 0); } public int Insert(T boat, int position) @@ -34,28 +31,25 @@ namespace MotorBoat return position; } // проверка, что после вставляемого элемента в массиве есть пустой элемент - int findEmptyPos = -1; + int EmptyPos = -1; for (int i = position + 1; i < Count; i++) { if (_places[i] == null) { - findEmptyPos = i; + EmptyPos = i; break; } } - if (findEmptyPos < 0) return -1; + if (EmptyPos < 0) return -1; // сдвиг всех объектов, находящихся справа от позиции до первого пустого элемента - for (int i = findEmptyPos; i > position; i--) + for (int i = EmptyPos; i > position; i--) { _places[i] = _places[i - 1]; } // вставка по позиции _places[position] = boat; return position; - // TODO вставка по позиции - _places[position] = boat; - //return true; } public T Remove(int position) {