рабочие TODO

This commit is contained in:
AnnZhimol 2022-10-04 14:49:13 +04:00
parent c9d1b9f133
commit 7fb61aaaf1
4 changed files with 70 additions and 44 deletions

View File

@ -161,7 +161,9 @@
//
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxSelectorMap.FormattingEnabled = true;
this.comboBoxSelectorMap.Items.AddRange(new object[] {"Простая карта"});
this.comboBoxSelectorMap.Items.AddRange(new object[] {
"Первая карта",
"Вторая карта"});
this.comboBoxSelectorMap.Location = new System.Drawing.Point(17, 32);
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
this.comboBoxSelectorMap.Size = new System.Drawing.Size(175, 23);
@ -190,6 +192,7 @@
this.groupBoxTools.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
this.ResumeLayout(false);
}
#endregion

View File

@ -22,11 +22,15 @@ namespace Warship
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
{
AbstractMap map = null;
switch (comboBoxSelectorMap.Text)
{
case ростая карта":
case ервая карта":
map = new SimpleMap();
break;
case "Вторая карта":
map = new SecondMap();
break;
}
if (map != null)
{

View File

@ -96,30 +96,31 @@ namespace Warship
private void DrawBackground(Graphics gr)
{
Pen pen = new(Color.Black, 3);
Pen pen = new(Color.Black, 5);
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
{
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j)
{
gr.DrawLine(pen, i * _placeSizeWidth, j * _placeSizeHeight, i * _placeSizeWidth + _placeSizeWidth / 2, j * _placeSizeHeight);
gr.DrawLine(pen, i * _placeSizeWidth+10, j * _placeSizeHeight+2, i * _placeSizeWidth + (int)(_placeSizeWidth*0.8), j * _placeSizeHeight+2);
gr.DrawLine(pen, i * _placeSizeWidth + (int)(_placeSizeWidth * 0.8), j * _placeSizeHeight + 2, i * _placeSizeWidth + (int)(_placeSizeWidth * 0.9)+10, j * _placeSizeHeight + 2+20);
gr.DrawLine(pen, i * _placeSizeWidth + (int)(_placeSizeWidth * 0.9) + 10, j * _placeSizeHeight + 2 + 20, i * _placeSizeWidth + (int)(_placeSizeWidth * 0.9) + 10, j * _placeSizeHeight + 2 + 20);
}
gr.DrawLine(pen, i * _placeSizeWidth, 0, i * _placeSizeWidth, (_pictureHeight/_placeSizeHeight) * _placeSizeHeight);
}
}
private void DrawWarship(Graphics gr)
{
int width = _pictureWidth / _placeSizeWidth;
int height = _pictureHeight / _placeSizeHeight;
for (int i = 0; i < _setWarship.Count; i++)
{
for (int i1 = 0; i1 < _pictureWidth / _placeSizeWidth; i1++)
if (_setWarship.Get(i) != null)
{
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j)
{
_setWarship.Get(i)?.SetObject(i1 * _placeSizeWidth, j * _placeSizeHeight, _pictureWidth, _pictureHeight);
}
}
_setWarship.Get(i).SetObject(i % width * _placeSizeWidth + 10, (height - 1 - i / width) * _placeSizeHeight + 10, _pictureWidth, _pictureHeight);
_setWarship.Get(i)?.DrawingObject(gr);
}
}
}
}
}

View File

@ -20,24 +20,36 @@ namespace Warship
public bool Insert(T warship)
{
_places[0] = warship;
return true;
return Insert(warship,0);
}
public bool Insert(T warship, int position)
{
int EmptyEl=position;
int EmptyEl=-1;
if (_places[position]!=null)
if (position>=Count || position < 0)
return false;
if (_places[position] == null)
{
for (int i = position; i < Count; i++)
_places[position] = warship;
return true;
}
else if (_places[position] != null)
{
for (int i = position + 1; i < Count; i++)
if (_places[i] == null)
{
EmptyEl = i;
break;
}
for (int j = EmptyEl; j > position; j--)
_places[j] = _places[j - 1];
if (EmptyEl == -1)
return false;
for (int i = EmptyEl; i > position; i--)
_places[i] = _places[i - 1];
}
_places[position] = warship;
@ -46,12 +58,18 @@ namespace Warship
public bool Remove(int position)
{
if (position >= Count || position < 0 || _places[position]==null)
return false;
_places[position] = null;
return true;
}
public T Get(int position)
{
if (position >= Count || position < 0)
return null;
return _places[position];
}
}