Доработка лабораторной 3
This commit is contained in:
parent
c5fd61cb5a
commit
5b685650b5
@ -47,8 +47,13 @@ namespace AntiAircraftGun
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
_antiAircrafGun = new DrawingAntiAircraftGun(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)));
|
||||
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||
ColorDialog dialog = new();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
color = dialog.Color;
|
||||
}
|
||||
_antiAircrafGun = new DrawingAntiAircraftGun(rnd.Next(100, 300), rnd.Next(1000, 2000), color);
|
||||
SetData();
|
||||
Draw();
|
||||
}
|
||||
@ -96,9 +101,19 @@ namespace AntiAircraftGun
|
||||
private void ButtonCreareModif_Click(object sender, EventArgs e)
|
||||
{
|
||||
Random rnd = new();
|
||||
_antiAircrafGun = new DrawingUpdateAntiAircraftGun(rnd.Next(100, 300), rnd.Next(1000, 2000),
|
||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
||||
Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256)),
|
||||
Color color = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||
ColorDialog dialog = new();
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
color = dialog.Color;
|
||||
}
|
||||
Color dopColor = Color.FromArgb(rnd.Next(0, 256), rnd.Next(0, 256), rnd.Next(0, 256));
|
||||
ColorDialog dialogDop = new();
|
||||
if (dialogDop.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
dopColor = dialogDop.Color;
|
||||
}
|
||||
_antiAircrafGun = new DrawingUpdateAntiAircraftGun(rnd.Next(100, 300), rnd.Next(1000, 2000), color, dopColor,
|
||||
Convert.ToBoolean(rnd.Next(0, 2)), Convert.ToBoolean(rnd.Next(0, 2)));
|
||||
SetData();
|
||||
Draw();
|
||||
|
@ -149,14 +149,14 @@ namespace AntiAircraftGun
|
||||
/// <param name="g"></param>
|
||||
private void DrawBackground(Graphics g)
|
||||
{
|
||||
Brush brushGreen = new SolidBrush(Color.Green);
|
||||
Brush brushSandyBrown = new SolidBrush(Color.SandyBrown);
|
||||
Brush brushLightGray = new SolidBrush(Color.LightGray);
|
||||
for (int i = 0; i < _pictureWidth / _placeSizeWidth; i++)
|
||||
{
|
||||
for (int j = 0; j < _pictureHeight / _placeSizeHeight; ++j)
|
||||
{
|
||||
g.FillRectangle(brushGreen, i * _placeSizeWidth, j * _placeSizeHeight, _placeSizeWidth, _placeSizeHeight);
|
||||
g.FillRectangle(brushLightGray, i * _placeSizeWidth + _placeSizeWidth / 10, j * _placeSizeHeight + _placeSizeHeight / 10, _placeSizeWidth * 8 / 10, _placeSizeHeight * 8 / 10);
|
||||
g.FillRectangle(brushSandyBrown, i * _placeSizeWidth, j * _placeSizeHeight, _placeSizeWidth, _placeSizeHeight);
|
||||
g.FillRectangle(brushLightGray, i * _placeSizeWidth + _placeSizeWidth / 16, j * _placeSizeHeight + _placeSizeHeight / 14, _placeSizeWidth * 14 / 16, _placeSizeHeight * 12 / 14);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,11 +21,11 @@ namespace AntiAircraftGun
|
||||
private readonly Brush roadColor = new SolidBrush(Color.LightGray);
|
||||
protected override void DrawBarrierPart(Graphics g, int i, int j)
|
||||
{
|
||||
g.FillRectangle(barrierColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1));
|
||||
g.FillRectangle(barrierColor, i * _size_x, j * _size_y, _size_x, _size_y);
|
||||
}
|
||||
protected override void DrawRoadPart(Graphics g, int i, int j)
|
||||
{
|
||||
g.FillRectangle(roadColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1));
|
||||
g.FillRectangle(roadColor, i * _size_x, j * _size_y, _size_x, _size_y);
|
||||
}
|
||||
protected override void GenerateMap()
|
||||
{
|
||||
|
@ -18,11 +18,11 @@ namespace AntiAircraftGun
|
||||
private readonly Brush roadColor = new SolidBrush(Color.LightGreen);
|
||||
protected override void DrawBarrierPart(Graphics g, int i, int j)
|
||||
{
|
||||
g.FillRectangle(barrierColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1));
|
||||
g.FillRectangle(barrierColor, i * _size_x, j * _size_y,_size_x ,_size_y);
|
||||
}
|
||||
protected override void DrawRoadPart(Graphics g, int i, int j)
|
||||
{
|
||||
g.FillRectangle(roadColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1));
|
||||
g.FillRectangle(roadColor, i * _size_x, j * _size_y, _size_x, _size_y);
|
||||
}
|
||||
protected override void GenerateMap()
|
||||
{
|
||||
@ -39,11 +39,12 @@ namespace AntiAircraftGun
|
||||
}
|
||||
while (counter < 25)
|
||||
{
|
||||
int x = _random.Next(0, 100);
|
||||
int x = _random.Next(0, 99);
|
||||
int y = _random.Next(0, 100);
|
||||
if (_map[x, y] == _freeRoad)
|
||||
{
|
||||
_map[x, y] = _barrier;
|
||||
_map[x + 1, y] = _barrier;
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user