Исправление неточностей

This commit is contained in:
ker73rus 2022-11-15 11:03:23 +04:00
parent 468f859fe0
commit 61de90a13a
6 changed files with 27 additions and 19 deletions

View File

@ -37,9 +37,9 @@ namespace Stormtrooper
/// Высота отрисовки самолёта
/// </summary>
protected readonly int _airplaneHeight;
public DrawningMilitaryAirplane(int speed, int weight, int wight = 80, int height = 100)
public DrawningMilitaryAirplane(int speed, int weight,Color color, int wight = 80, int height = 100)
{
Airplane = new EntityMilitaryAirplane(speed, weight);
Airplane = new EntityMilitaryAirplane(speed, weight, color);
_airplaneWidth = wight;
_airplaneHeight = height;
}
@ -110,7 +110,7 @@ namespace Stormtrooper
Pen pen = new Pen(Color.Black);
Brush brush = new SolidBrush(Color.DarkGreen);
Brush brush = new SolidBrush(Airplane.Color);
g.FillPolygon(brush, new PointF[3] {new PointF(_startPosX, _startPosY + _airplaneHeight / 2),
new PointF(_startPosX + _airplaneWidth * 0.1f, _startPosY + _airplaneHeight * 0.45f),
new PointF(_startPosX + _airplaneWidth * 0.1f, _startPosY + _airplaneHeight * 0.55f)});

View File

@ -8,9 +8,9 @@ namespace Stormtrooper
{
internal class DrawningStormtrooper : DrawningMilitaryAirplane
{
public DrawningStormtrooper(int speed, int weight, int crew, Color advColor, bool rockets, bool boosters, bool radar) : base(speed, weight)
public DrawningStormtrooper(int speed, int weight, Color color, Color advColor, bool rockets, bool boosters, bool radar) : base(speed, weight, color)
{
Airplane = new EntityStormtrooper(speed, weight,crew, advColor, rockets, boosters, radar);
Airplane = new EntityStormtrooper(speed, weight,color, advColor, rockets, boosters, radar);
}
public override void DrawAirplane(Graphics g)
{

View File

@ -10,16 +10,16 @@ namespace Stormtrooper
{
public int Speed { get; private set; }
public int Weight { get; private set; }
public int Crew { get; private set; }
public Color Color { get; private set; }
public float Step => Speed * 25 / Weight;
public EntityMilitaryAirplane(int speed, int weight, int crew = 10)
public EntityMilitaryAirplane(int speed, int weight, Color color)
{
Random random = new Random();
Speed = speed <= 0 ? random.Next(10, 100) : speed;
Weight = weight <= 0 ? random.Next(50, 150) : weight;
Crew = crew;
Color = color;
}

View File

@ -25,8 +25,8 @@ namespace Stormtrooper
/// </summary>
public bool Radar { get; private set; }
public EntityStormtrooper(int speed, int weight, int crew, Color advColor, bool rockets, bool boosters, bool radar)
: base(speed, weight, crew)
public EntityStormtrooper(int speed, int weight, Color color, Color advColor, bool rockets, bool boosters, bool radar)
: base(speed, weight, color)
{
Rockets = rockets;
Booster = boosters;

View File

@ -22,7 +22,7 @@ namespace Stormtrooper
private void buttonCreate_Click(object sender, EventArgs e)
{
Random random = new Random();
_airplane = new DrawningMilitaryAirplane(10, 50);
_airplane = new DrawningMilitaryAirplane(10, 50, Color.DarkGreen);
_airplane.SetPosition(random.Next(100,150), random.Next(100,150), pictureBoxAirplane.Width, pictureBoxAirplane.Height);
SetData();
}
@ -53,7 +53,6 @@ namespace Stormtrooper
{
toolStripLabelSpeed.Text = $"Скорость: {_airplane.Airplane.Speed}";
toolStripLabelWeight.Text = $"Вес: {_airplane.Airplane.Weight}";
toolStripLabelCrew.Text = $"Экипаж: {_airplane.Airplane.Crew}";
pictureBoxAirplane.Image = _abstractMap.CreateMap(pictureBoxAirplane.Width, pictureBoxAirplane.Height,
new DrawningObject(_airplane));
}
@ -62,7 +61,7 @@ namespace Stormtrooper
{
Random random = new Random();
_airplane = new DrawningStormtrooper(random.Next(10,100),random.Next(50,250),random.Next(1,100),
_airplane = new DrawningStormtrooper(random.Next(10,100),random.Next(50,250), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
Color.FromArgb(random.Next(0,256), random.Next(0, 256), random.Next(0, 256)),
Convert.ToBoolean(random.Next(0,2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
_airplane.SetPosition(random.Next(100, 150), random.Next(100, 150), pictureBoxAirplane.Width, pictureBoxAirplane.Height);

View File

@ -29,10 +29,15 @@ namespace Stormtrooper
}
private void buttonCreate_Click(object sender, EventArgs e)
{
Random rnd = new Random();
_airplane = new DrawningMilitaryAirplane(10, 50);
_airplane.SetPosition(rnd.Next(100,150), rnd.Next(100,150), pictureBoxAirplane.Width, pictureBoxAirplane.Height);
Random random = new Random();
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
ColorDialog dialog = new();
if (dialog.ShowDialog() == DialogResult.OK)
{
color = dialog.Color;
}
_airplane = new DrawningMilitaryAirplane(10, 50, color);
_airplane.SetPosition(random.Next(100,150), random.Next(100,150), pictureBoxAirplane.Width, pictureBoxAirplane.Height);
SetData();
Draw();
}
@ -68,7 +73,6 @@ namespace Stormtrooper
{
toolStripLabelSpeed.Text = $"Скорость: {_airplane.Airplane.Speed}";
toolStripLabelWeight.Text = $"Вес: {_airplane.Airplane.Weight}";
toolStripLabelCrew.Text = $"Экипаж: {_airplane.Airplane.Crew}";
}
private void buttonCreateMod_Click(object sender, EventArgs e)
@ -76,12 +80,17 @@ namespace Stormtrooper
Random random = new Random();
Color color = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
Color advColor = Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256));
ColorDialog dialog = new();
if (dialog.ShowDialog() == DialogResult.OK)
{
color = dialog.Color;
}
_airplane = new DrawningStormtrooper(random.Next(10,100),random.Next(50,250),random.Next(1,100),
if (dialog.ShowDialog() == DialogResult.OK)
{
advColor = dialog.Color;
}
_airplane = new DrawningStormtrooper(random.Next(10,100),random.Next(50,250),advColor,
color,
Convert.ToBoolean(random.Next(0,2)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
_airplane.SetPosition(random.Next(100, 150), random.Next(100, 150), pictureBoxAirplane.Width, pictureBoxAirplane.Height);