Переход на конструкторы.
This commit is contained in:
parent
21ea9f3d91
commit
79b4ee847c
@ -42,10 +42,9 @@ namespace AirBomber
|
|||||||
/// <param name="speed">Скорость</param>
|
/// <param name="speed">Скорость</param>
|
||||||
/// <param name="weight">Вес бомбардировщика</param>
|
/// <param name="weight">Вес бомбардировщика</param>
|
||||||
/// <param name="bodyColor">Цвет корпуса</param>
|
/// <param name="bodyColor">Цвет корпуса</param>
|
||||||
public void Init(int speed, float weight, Color bodyColor)
|
public DrawingAirBomber(int speed, float weight, Color bodyColor)
|
||||||
{
|
{
|
||||||
AirBomber = new EntityAirBomber();
|
AirBomber = new EntityAirBomber(speed, weight, bodyColor);
|
||||||
AirBomber.Init(speed, weight, bodyColor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -34,7 +34,7 @@ namespace AirBomber
|
|||||||
/// <param name="weight"></param>
|
/// <param name="weight"></param>
|
||||||
/// <param name="bodyColor"></param>
|
/// <param name="bodyColor"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public void Init(int speed, float weight, Color bodyColor)
|
public EntityAirBomber (int speed, float weight, Color bodyColor)
|
||||||
{
|
{
|
||||||
Random rnd = new();
|
Random rnd = new();
|
||||||
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
|
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
|
||||||
|
@ -24,8 +24,7 @@ namespace AirBomber
|
|||||||
private void buttonCreateAirBomber_Click(object sender, EventArgs e)
|
private void buttonCreateAirBomber_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random rnd = new();
|
Random rnd = new();
|
||||||
_airBomber = new DrawingAirBomber();
|
_airBomber = new DrawingAirBomber(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||||
_airBomber.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
|
||||||
_airBomber.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxAirBomber.Width, pictureBoxAirBomber.Height);
|
_airBomber.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxAirBomber.Width, pictureBoxAirBomber.Height);
|
||||||
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_airBomber.AirBomber.Speed}";
|
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_airBomber.AirBomber.Speed}";
|
||||||
toolStripStatusLabelWeight.Text = $"Âåñ: {_airBomber.AirBomber.Weight}";
|
toolStripStatusLabelWeight.Text = $"Âåñ: {_airBomber.AirBomber.Weight}";
|
||||||
|
Loading…
Reference in New Issue
Block a user