From 4dab796efa738cb22b4ae3641e35a9902196c951 Mon Sep 17 00:00:00 2001 From: 1yuee Date: Mon, 3 Oct 2022 16:14:34 +0400 Subject: [PATCH] Changing return type of Insert and Remove --- AirFighter/MapWithSetAircraftsGeneric.cs | 40 ++++++++++-------------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/AirFighter/MapWithSetAircraftsGeneric.cs b/AirFighter/MapWithSetAircraftsGeneric.cs index 2bb627d..c37b1bd 100644 --- a/AirFighter/MapWithSetAircraftsGeneric.cs +++ b/AirFighter/MapWithSetAircraftsGeneric.cs @@ -32,13 +32,13 @@ namespace AirFighter _map = map; } - public static bool operator +(MapWithSetAircraftsGeneric map, T aircraft) + public static int operator +(MapWithSetAircraftsGeneric map, T aircraft) { return map._setAircrafts.Insert(aircraft); } - public static bool operator -(MapWithSetAircraftsGeneric map, int position) + public static T operator -(MapWithSetAircraftsGeneric map, int position) { return map._setAircrafts.Remove(position); } @@ -75,8 +75,6 @@ namespace AirFighter return new(_pictureWidth, _pictureHeight); } - - private void Shaking() { int j = _setAircrafts.Count - 1; @@ -111,22 +109,12 @@ namespace AirFighter for (int j = 0; j < _pictureHeight / _placeSizeHeight; j++) { - g.DrawLine(pen, i * _placeSizeWidth + 20, j * _placeSizeHeight + 135, - _pictureWidth - 80, j * _placeSizeHeight + 135); - + g.DrawLine(pen, i * _placeSizeWidth + 20, j * _placeSizeHeight + 135, _pictureWidth - 80, j * _placeSizeHeight + 135); g.DrawLine(pen, i * _placeSizeWidth + 20, j * _placeSizeHeight + 60, i * _placeSizeWidth + _placeSizeWidth /2 + 20, j * _placeSizeHeight + 45); g.DrawLine(pen, i * _placeSizeWidth + _placeSizeWidth / 2 + 20, j * _placeSizeHeight + 45, i * _placeSizeWidth + _placeSizeWidth + 20 , j * _placeSizeHeight + 60); - g.DrawLine(pen, i * _placeSizeWidth + 20, j * _placeSizeHeight + 135, i * _placeSizeWidth + 20, j * _placeSizeHeight + 60); - - - } - - - - } } @@ -134,21 +122,25 @@ namespace AirFighter private void DrawAircrafts(Graphics g) { - - //int curX = _pictureWidth / _placeSizeWidth; - //int curY = _pictureHeight / _placeSizeHeight; + int curX = _pictureWidth / _placeSizeWidth - 1; + int curY = _pictureHeight / _placeSizeHeight - 1; for (int i = 0; i < _setAircrafts.Count; i++) { - //_setAircrafts.Get(i)?.SetObject(curX , curY , 100, 100); + _setAircrafts.Get(i)?.SetObject(curX * _placeSizeWidth + 30, curY * _placeSizeHeight + 40, _pictureWidth, _pictureHeight); _setAircrafts.Get(i)?.DrawingObject(g); - //if (curX < 0) - //{ - // curX = _pictureWidth / _placeSizeWidth; - // curY--; - //} + if (curX <= 0) + { + curX = _pictureWidth / _placeSizeWidth - 1; + curY--; + } + else + { + curX--; + + } } }