рабочие TODO
This commit is contained in:
parent
c9d1b9f133
commit
7fb61aaaf1
@ -161,7 +161,9 @@
|
|||||||
//
|
//
|
||||||
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
this.comboBoxSelectorMap.FormattingEnabled = true;
|
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.Location = new System.Drawing.Point(17, 32);
|
||||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||||
this.comboBoxSelectorMap.Size = new System.Drawing.Size(175, 23);
|
this.comboBoxSelectorMap.Size = new System.Drawing.Size(175, 23);
|
||||||
@ -190,6 +192,7 @@
|
|||||||
this.groupBoxTools.PerformLayout();
|
this.groupBoxTools.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.pictureBox)).EndInit();
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -22,11 +22,15 @@ namespace Warship
|
|||||||
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
private void ComboBoxSelectorMap_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
AbstractMap map = null;
|
AbstractMap map = null;
|
||||||
|
|
||||||
switch (comboBoxSelectorMap.Text)
|
switch (comboBoxSelectorMap.Text)
|
||||||
{
|
{
|
||||||
case "Простая карта":
|
case "Первая карта":
|
||||||
map = new SimpleMap();
|
map = new SimpleMap();
|
||||||
break;
|
break;
|
||||||
|
case "Вторая карта":
|
||||||
|
map = new SecondMap();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (map != null)
|
if (map != null)
|
||||||
{
|
{
|
||||||
|
@ -96,30 +96,31 @@ namespace Warship
|
|||||||
|
|
||||||
private void DrawBackground(Graphics gr)
|
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 i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight + 1; ++j)
|
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)
|
private void DrawWarship(Graphics gr)
|
||||||
{
|
{
|
||||||
|
int width = _pictureWidth / _placeSizeWidth;
|
||||||
|
int height = _pictureHeight / _placeSizeHeight;
|
||||||
|
|
||||||
for (int i = 0; i < _setWarship.Count; i++)
|
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(i % width * _placeSizeWidth + 10, (height - 1 - i / width) * _placeSizeHeight + 10, _pictureWidth, _pictureHeight);
|
||||||
{
|
|
||||||
_setWarship.Get(i)?.SetObject(i1 * _placeSizeWidth, j * _placeSizeHeight, _pictureWidth, _pictureHeight);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_setWarship.Get(i)?.DrawingObject(gr);
|
_setWarship.Get(i)?.DrawingObject(gr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,24 +20,36 @@ namespace Warship
|
|||||||
|
|
||||||
public bool Insert(T warship)
|
public bool Insert(T warship)
|
||||||
{
|
{
|
||||||
_places[0] = warship;
|
return Insert(warship,0);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Insert(T warship, int position)
|
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)
|
if (_places[i] == null)
|
||||||
{
|
{
|
||||||
EmptyEl = i;
|
EmptyEl = i;
|
||||||
break;
|
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;
|
_places[position] = warship;
|
||||||
@ -46,12 +58,18 @@ namespace Warship
|
|||||||
|
|
||||||
public bool Remove(int position)
|
public bool Remove(int position)
|
||||||
{
|
{
|
||||||
|
if (position >= Count || position < 0 || _places[position]==null)
|
||||||
|
return false;
|
||||||
|
|
||||||
_places[position] = null;
|
_places[position] = null;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T Get(int position)
|
public T Get(int position)
|
||||||
{
|
{
|
||||||
|
if (position >= Count || position < 0)
|
||||||
|
return null;
|
||||||
|
|
||||||
return _places[position];
|
return _places[position];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user