Переход на конструкторы
This commit is contained in:
parent
e10074bebf
commit
d4ebff9421
@ -45,10 +45,9 @@ namespace Stormtrooper
|
|||||||
/// <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 Drawning(int speed, float weight, Color bodyColor)
|
||||||
{
|
{
|
||||||
Storm = new EntityStormtrooper();
|
Storm = new EntityStormtrooper(speed, weight, bodyColor);
|
||||||
Storm.Init(speed, weight, bodyColor);
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Установка позиции самолёта
|
/// Установка позиции самолёта
|
||||||
|
@ -34,7 +34,7 @@ namespace Stormtrooper
|
|||||||
/// <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 EntityStormtrooper(int speed, float weight, Color bodyColor)
|
||||||
{
|
{
|
||||||
Random rnd = new Random();
|
Random rnd = new Random();
|
||||||
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
|
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
|
||||||
|
@ -27,8 +27,7 @@ namespace Stormtrooper
|
|||||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random rnd = new();
|
Random rnd = new();
|
||||||
_storm = new Drawning();
|
_storm = new Drawning(rnd.Next(100,300), rnd.Next(1000,2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||||
_storm.Init(rnd.Next(100,300), rnd.Next(1000,2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
|
||||||
_storm.SetPosition(rnd.Next(0, 150), rnd.Next(0, 300), pictureBoxStormtrooper.Width, pictureBoxStormtrooper.Height);
|
_storm.SetPosition(rnd.Next(0, 150), rnd.Next(0, 300), pictureBoxStormtrooper.Width, pictureBoxStormtrooper.Height);
|
||||||
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_storm.Storm.Speed}";
|
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_storm.Storm.Speed}";
|
||||||
toolStripStatusLabelWeight.Text = $"Âåñ: {_storm.Storm.Weight}";
|
toolStripStatusLabelWeight.Text = $"Âåñ: {_storm.Storm.Weight}";
|
||||||
|
Loading…
Reference in New Issue
Block a user