Окончательные изменения
This commit is contained in:
parent
d60f81c6f7
commit
3290b58955
@ -40,7 +40,13 @@ namespace AirFighter
|
|||||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random rnd = new Random();
|
Random rnd = new Random();
|
||||||
_airFighter = new DrawningAirFighter(rnd.Next(200, 500), rnd.Next(2000, 5000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||||
|
ColorDialog dialog = new();
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
color = dialog.Color;
|
||||||
|
}
|
||||||
|
_airFighter = new DrawningAirFighter(rnd.Next(200, 500), rnd.Next(2000, 5000), color);
|
||||||
SetData();
|
SetData();
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
@ -87,8 +93,20 @@ namespace AirFighter
|
|||||||
private void ButtonUpgrade_Click(object sender, EventArgs e)
|
private void ButtonUpgrade_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random rnd = new();
|
Random rnd = new();
|
||||||
_airFighter = new DrawningUpgradeAirFighter(rnd.Next(300, 600), rnd.Next(2000, 5000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)), Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
ColorDialog dialog = new();
|
||||||
|
if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
color = dialog.Color;
|
||||||
|
}
|
||||||
|
Color dopColor = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||||
|
ColorDialog dialogDop = new();
|
||||||
|
if (dialogDop.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
dopColor = dialogDop.Color;
|
||||||
|
}
|
||||||
|
_airFighter = new DrawningUpgradeAirFighter(rnd.Next(300, 600), rnd.Next(2000, 5000), color,
|
||||||
|
dopColor, Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
||||||
SetData();
|
SetData();
|
||||||
Draw();
|
Draw();
|
||||||
}
|
}
|
||||||
|
@ -129,10 +129,10 @@ namespace AirFighter
|
|||||||
{
|
{
|
||||||
for (; j > i; j--)
|
for (; j > i; j--)
|
||||||
{
|
{
|
||||||
var car = _setAirFighters.Get(j);
|
var airFighter = _setAirFighters.Get(j);
|
||||||
if (car != null)
|
if (airFighter != null)
|
||||||
{
|
{
|
||||||
_setAirFighters.Insert(car, i);
|
_setAirFighters.Insert(airFighter, i);
|
||||||
_setAirFighters.Remove(j);
|
_setAirFighters.Remove(j);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -57,29 +57,7 @@ namespace AirFighter
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int Insert(T airFighter)
|
public int Insert(T airFighter)
|
||||||
{
|
{
|
||||||
if (!CheckNullPosition(0))
|
return Insert(airFighter, 0);
|
||||||
{
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
T temp = airFighter;
|
|
||||||
for(int i = 0; i < _places.Length; i++)
|
|
||||||
{
|
|
||||||
if (_places[i] == null)
|
|
||||||
{
|
|
||||||
_places[i] = temp;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
T temp2 = _places[i];
|
|
||||||
_places[i] = temp;
|
|
||||||
temp = temp2;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Добавление объекта в набор на конкретную позицию
|
/// Добавление объекта в набор на конкретную позицию
|
||||||
@ -89,6 +67,10 @@ namespace AirFighter
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public int Insert(T airFighter, int position)
|
public int Insert(T airFighter, int position)
|
||||||
{
|
{
|
||||||
|
if(airFighter == null)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
if (_places[position] == null)
|
if (_places[position] == null)
|
||||||
{
|
{
|
||||||
_places[position] = airFighter;
|
_places[position] = airFighter;
|
||||||
@ -97,19 +79,19 @@ namespace AirFighter
|
|||||||
{
|
{
|
||||||
if(CheckNullPosition(position + 1))
|
if(CheckNullPosition(position + 1))
|
||||||
{
|
{
|
||||||
T temp = airFighter;
|
T tempMain = airFighter;
|
||||||
for (int i = position; i < _places.Length; i++)
|
for (int i = position; i < _places.Length; i++)
|
||||||
{
|
{
|
||||||
if (_places[i] == null)
|
if (_places[i] == null)
|
||||||
{
|
{
|
||||||
_places[i] = temp;
|
_places[i] = tempMain;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
T temp2 = _places[i];
|
T temp2 = _places[i];
|
||||||
_places[i] = temp;
|
_places[i] = tempMain;
|
||||||
temp = temp2;
|
tempMain = temp2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user