Добавлены конструкторы
This commit is contained in:
parent
13a011a189
commit
d9e184ca89
@ -15,10 +15,9 @@ namespace Artilleries
|
|||||||
private int? _pictureHeight = null;
|
private int? _pictureHeight = null;
|
||||||
private readonly int _artilleryWidth = 80;
|
private readonly int _artilleryWidth = 80;
|
||||||
private readonly int _artilleryHeight = 50;
|
private readonly int _artilleryHeight = 50;
|
||||||
public void Init(int speed, float weight, Color bodyColor)
|
public DrawingArtillery(int speed, float weight, Color bodyColor)
|
||||||
{
|
{
|
||||||
Artillery = new EntityArtillery();
|
Artillery = new EntityArtillery(speed, weight, bodyColor);
|
||||||
Artillery.Init(speed, weight, bodyColor);
|
|
||||||
}
|
}
|
||||||
public void SetPosition(int x, int y, int width, int height)
|
public void SetPosition(int x, int y, int width, int height)
|
||||||
{
|
{
|
||||||
|
@ -12,7 +12,7 @@ namespace Artilleries
|
|||||||
public float Weight { get; private set; }
|
public float Weight { get; private set; }
|
||||||
public Color BodyColor { get; private set; }
|
public Color BodyColor { get; private set; }
|
||||||
public float Step => Speed * 100 / Weight;
|
public float Step => Speed * 100 / Weight;
|
||||||
public void Init(int speed, float weight, Color bodyColor)
|
public EntityArtillery(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;
|
||||||
|
@ -20,9 +20,8 @@ namespace Artilleries
|
|||||||
private void buttonCreate_Click(object sender, EventArgs e)
|
private void buttonCreate_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Random rnd = new();
|
Random rnd = new();
|
||||||
_artillery = new DrawingArtillery();
|
_artillery = new DrawingArtillery(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||||
_artillery.Init(rnd.Next(100, 300), rnd.Next(1000, 2000), Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
_artillery.SetPosition(rnd.Next(10, 100), rnd.Next(10, 100), pictureBoxArtilleries.Width, pictureBoxArtilleries.Height);
|
||||||
_artillery.SetPosition(rnd.Next(pictureBoxArtilleries.Width - 161, pictureBoxArtilleries.Width - 81), rnd.Next(10, 100), pictureBoxArtilleries.Width, pictureBoxArtilleries.Height);
|
|
||||||
SpeedStatusLabel.Text = $"Скорость: {_artillery.Artillery.Speed}";
|
SpeedStatusLabel.Text = $"Скорость: {_artillery.Artillery.Speed}";
|
||||||
WeightStatusLabel.Text = $"Вес: {_artillery.Artillery.Weight}";
|
WeightStatusLabel.Text = $"Вес: {_artillery.Artillery.Weight}";
|
||||||
ColorStatusLabel.Text = $"Цвет: {_artillery.Artillery.BodyColor.Name}";
|
ColorStatusLabel.Text = $"Цвет: {_artillery.Artillery.BodyColor.Name}";
|
||||||
|
Loading…
Reference in New Issue
Block a user