Переход на конструкторы
This commit is contained in:
parent
1f16cad283
commit
746f60a4b1
@ -16,10 +16,9 @@ namespace AirBomber
|
||||
private readonly int _airBomberWidth = 100;
|
||||
private readonly int _airBomberHeight = 100;
|
||||
|
||||
public void Init(int speed, float weight, Color bodyColor)
|
||||
public DrawningBomber(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
AirBomber = new EntityAirBomber();
|
||||
AirBomber.Init(speed, weight, bodyColor);
|
||||
AirBomber = new EntityAirBomber(speed, weight, bodyColor);
|
||||
}
|
||||
|
||||
public void SetPosition(int x, int y, int width, int height)
|
||||
|
@ -13,9 +13,9 @@ namespace AirBomber
|
||||
public Color BodyColor { get; private set; }
|
||||
public float Step => Speed * 100 / Weight;
|
||||
|
||||
public void Init(int speed, float weight, Color bodyColor)
|
||||
public EntityAirBomber(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Random rnd = new();
|
||||
Random rnd = new Random();
|
||||
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
|
||||
Weight = weight <= 0 ? rnd.Next(40, 70) : weight;
|
||||
BodyColor = bodyColor;
|
||||
|
@ -19,8 +19,7 @@ namespace AirBomber
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
_airBomber = new DrawningBomber();
|
||||
_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 = new DrawningBomber(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);
|
||||
toolStripStatusLabelSpeed.Text = $"Ñêîðîñòü: {_airBomber.AirBomber.Speed}";
|
||||
toolStripStatusLabelWeight.Text = $"Âåñ: {_airBomber.AirBomber.Weight}";
|
||||
|
Loading…
Reference in New Issue
Block a user