Создание двух дополнительных реализаций абстрактного класса.
This commit is contained in:
parent
0e640ab2cb
commit
88b6b488ba
@ -19,7 +19,7 @@ namespace Airbus
|
|||||||
|
|
||||||
void IDrawningObject.DrawningObject(Graphics g)
|
void IDrawningObject.DrawningObject(Graphics g)
|
||||||
{
|
{
|
||||||
//ДОДУМАТЬ ЛОГИКУ ЭТОГО МЕТОДА
|
_airbus.DrawTransport(g);
|
||||||
}
|
}
|
||||||
|
|
||||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||||
|
4
Airbus/Airbus/FormMap.Designer.cs
generated
4
Airbus/Airbus/FormMap.Designer.cs
generated
@ -168,7 +168,9 @@
|
|||||||
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
this.comboBoxSelectorMap.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
this.comboBoxSelectorMap.FormattingEnabled = true;
|
this.comboBoxSelectorMap.FormattingEnabled = true;
|
||||||
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
this.comboBoxSelectorMap.Items.AddRange(new object[] {
|
||||||
"Простая карта"});
|
"Простая карта",
|
||||||
|
"Пустыня",
|
||||||
|
"Космос"});
|
||||||
this.comboBoxSelectorMap.Location = new System.Drawing.Point(10, 9);
|
this.comboBoxSelectorMap.Location = new System.Drawing.Point(10, 9);
|
||||||
this.comboBoxSelectorMap.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
this.comboBoxSelectorMap.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||||
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
this.comboBoxSelectorMap.Name = "comboBoxSelectorMap";
|
||||||
|
@ -78,6 +78,13 @@ namespace Airbus
|
|||||||
case "Простая карта":
|
case "Простая карта":
|
||||||
_abstractMap = new SimpleMap();
|
_abstractMap = new SimpleMap();
|
||||||
break;
|
break;
|
||||||
|
case "Пустыня":
|
||||||
|
_abstractMap = new SecondSimpleMap();
|
||||||
|
break;
|
||||||
|
case "Космос":
|
||||||
|
|
||||||
|
_abstractMap = new ThirdSimpleMap();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
55
Airbus/Airbus/SecondSimpleMap.cs
Normal file
55
Airbus/Airbus/SecondSimpleMap.cs
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Airbus
|
||||||
|
{
|
||||||
|
internal class SecondSimpleMap: AbstractMap
|
||||||
|
{
|
||||||
|
//цвет закрытого участка
|
||||||
|
Brush barriedColor = new SolidBrush(Color.DarkRed);
|
||||||
|
|
||||||
|
//цвет открытого участка
|
||||||
|
Brush roadColor = new SolidBrush(Color.DarkOrange);
|
||||||
|
|
||||||
|
protected override void DrawBarrierPart(Graphics g, int i, int j)
|
||||||
|
{
|
||||||
|
g.FillEllipse(barriedColor, i * _size_x, j * _size_y, _size_x, _size_x);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void DrawRoadPart(Graphics g, int i, int j)
|
||||||
|
{
|
||||||
|
g.FillRectangle(roadColor, i * _size_x, j * _size_y, _size_x, _size_y);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void GenerateMap()
|
||||||
|
{
|
||||||
|
_map = new int[100, 100];
|
||||||
|
_size_x = (float)_width / _map.GetLength(0);
|
||||||
|
_size_y = (float)_height / _map.GetLength(1);
|
||||||
|
int counter = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < _map.GetLength(0); ++i)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < _map.GetLength(1); ++j)
|
||||||
|
{
|
||||||
|
_map[i, j] = _freeRoad;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (counter < 50)
|
||||||
|
{
|
||||||
|
int x = _random.Next(0, 100);
|
||||||
|
int y = _random.Next(0, 100);
|
||||||
|
|
||||||
|
if (_map[x, y] == _freeRoad)
|
||||||
|
{
|
||||||
|
_map[x, y] = _barrier;
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,7 @@ namespace Airbus
|
|||||||
{
|
{
|
||||||
internal class SimpleMap: AbstractMap
|
internal class SimpleMap: AbstractMap
|
||||||
{
|
{
|
||||||
//цвет закрытого уастка
|
//цвет закрытого участка
|
||||||
Brush barriedColor = new SolidBrush(Color.Black);
|
Brush barriedColor = new SolidBrush(Color.Black);
|
||||||
|
|
||||||
//цвет открытого участка
|
//цвет открытого участка
|
||||||
@ -16,12 +16,12 @@ namespace Airbus
|
|||||||
|
|
||||||
protected override void DrawBarrierPart(Graphics g, int i, int j)
|
protected override void DrawBarrierPart(Graphics g, int i, int j)
|
||||||
{
|
{
|
||||||
g.FillRectangle(barriedColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1));
|
g.FillRectangle(barriedColor, i * _size_x, j * _size_y, _size_x, _size_y);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void DrawRoadPart(Graphics g, int i, int j)
|
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()
|
protected override void GenerateMap()
|
||||||
|
62
Airbus/Airbus/ThirdSimpleMap.cs
Normal file
62
Airbus/Airbus/ThirdSimpleMap.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Airbus
|
||||||
|
{
|
||||||
|
internal class ThirdSimpleMap: AbstractMap
|
||||||
|
{
|
||||||
|
Random rnd = new Random();
|
||||||
|
|
||||||
|
//цвет выстрела из лазера
|
||||||
|
Color randomColor = new Color();
|
||||||
|
|
||||||
|
//цвет закрытого участка
|
||||||
|
Brush barriedColor;
|
||||||
|
|
||||||
|
//цвет открытого участка
|
||||||
|
Brush roadColor = new SolidBrush(Color.DarkBlue);
|
||||||
|
|
||||||
|
protected override void DrawBarrierPart(Graphics g, int i, int j)
|
||||||
|
{
|
||||||
|
randomColor = Color.FromArgb(rnd.Next(256), rnd.Next(256), rnd.Next(256));
|
||||||
|
barriedColor = new SolidBrush(randomColor);
|
||||||
|
g.FillRectangle(barriedColor, 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, _size_x, _size_y);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void GenerateMap()
|
||||||
|
{
|
||||||
|
_map = new int[100, 100];
|
||||||
|
_size_x = (float)_width / _map.GetLength(0);
|
||||||
|
_size_y = (float)_height / _map.GetLength(1);
|
||||||
|
int counter = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < _map.GetLength(0); ++i)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < _map.GetLength(1); ++j)
|
||||||
|
{
|
||||||
|
_map[i, j] = _freeRoad;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (counter < 50)
|
||||||
|
{
|
||||||
|
int x = _random.Next(0, 100);
|
||||||
|
int y = _random.Next(0, 100);
|
||||||
|
|
||||||
|
if (_map[x, y] == _freeRoad)
|
||||||
|
{
|
||||||
|
_map[x, y] = _barrier;
|
||||||
|
counter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user