Конец..?

This commit is contained in:
Katerina881 2022-10-03 15:58:09 +04:00
parent 5795b9c88a
commit 06987670c4
5 changed files with 86 additions and 25 deletions

View File

@ -21,7 +21,7 @@ namespace ProjectPlane
public DrawingWarPlane(int speed, float weight, Color bodyColor, Color dopColor, bool isBomber, bool isFighter, bool superTurbine) :
base(speed, weight, bodyColor, 110, 60)
{
Plane = new EntityWarPlane(speed, weight, bodyColor, dopColor, isBomber, isFighter, superTurbine);
Plane = new EntityWarPlane(speed, weight, bodyColor, dopColor, isFighter, superTurbine);
}
public override void DrawTransport(Graphics g)
{
@ -52,16 +52,7 @@ namespace ProjectPlane
_startPosX -= 10;
_startPosY -= 5;
if (warplane.IsBomber)
{
g.FillEllipse(brBlack, _startPosX + 88, _startPosY + 20, 4, 4);
g.FillRectangle(Brush, _startPosX + 60, _startPosY + 20, 30, 12);
}
if (warplane.IsFighter)
if (warplane.extraCell)
{
Point[] Nose = new Point[4];
Nose[0].X = Convert.ToInt32(_startPosX + 118); Nose[0].Y = Convert.ToInt32(_startPosY + 22);

View File

@ -15,14 +15,11 @@ namespace ProjectPlane
/// Дополнительный цвет
/// </summary>
public Color DopColor { get; private set; }
/// <summary>
/// Бомбандировщик ли
/// доп отсек
/// </summary>
public bool IsBomber { get; private set; }
/// <summary>
/// Истребитель ли
/// </summary>
public bool IsFighter { get; private set; }
public bool extraCell { get; private set; }
/// <summary>
/// наличие супертурбины
/// </summary>
@ -32,18 +29,16 @@ namespace ProjectPlane
/// Инициализация свойств
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес автомобиля</param>
/// <param name="bodyColor">Цвет кузова</param>
/// <param name="weight">Вес самолета</param>
/// <param name="bodyColor">Цвет корпуса</param>
/// <param name="dopColor">Дополнительный цвет</param>
/// <param name="bodyKit">Признак наличия обвеса</param>
/// <param name="wing">Признак наличия антикрыла</param>
/// <param name="cell">Признак наличия доп остсека>
///
public EntityWarPlane(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool wing, bool superturbine) :
public EntityWarPlane(int speed, float weight, Color bodyColor, Color dopColor, bool cell, bool superturbine) :
base(speed, weight, bodyColor)
{
DopColor = dopColor;
IsBomber = bodyKit;
IsFighter = wing;
extraCell = cell;
SuperTurbine = superturbine;
}
}

View File

@ -108,6 +108,7 @@
this.pictureBoxPlane.Size = new System.Drawing.Size(800, 450);
this.pictureBoxPlane.TabIndex = 5;
this.pictureBoxPlane.TabStop = false;
//
// statusStrip1
//
@ -155,10 +156,14 @@
//
this.comboMapSelector.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboMapSelector.FormattingEnabled = true;
this.comboMapSelector.Items.AddRange(new object[] {
"Simple Map",
"Sky Map"});
this.comboMapSelector.Location = new System.Drawing.Point(12, 12);
this.comboMapSelector.Name = "comboMapSelector";
this.comboMapSelector.Size = new System.Drawing.Size(121, 23);
this.comboMapSelector.TabIndex = 11;
this.comboMapSelector.SelectedIndexChanged += new System.EventHandler(this.comboMapSelector_SelectedIndexChanged);
//
// FormMap
//

View File

@ -18,6 +18,19 @@ namespace ProjectPlane
InitializeComponent();
_abstractMap = new SimpleMap();
}
private void comboMapSelector_SelectedIndexChanged(object sender, EventArgs e)
{
switch (comboMapSelector.SelectedIndex)
{
case 0:
_abstractMap = new SimpleMap();
break;
case 1:
_abstractMap = new SkyMap();
break;
}
}
/// <param name="plane"></param>
private void SetData(DrawingPlane plane)
{
@ -78,7 +91,7 @@ namespace ProjectPlane
SetData(_plane);
}
}
}

View File

@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectPlane
{
internal class SkyMap : AbstractMap
{
/// <summary>
/// Цвет участка закрытого
/// </summary>
private readonly Brush barrierColor = new SolidBrush(Color.Black);
/// <summary>
/// Цвет участка открытого
/// </summary>
private readonly Brush skyColor = new SolidBrush(Color.AliceBlue);
protected override void DrawBarrierPart(Graphics g, int i, int j)
{
Point[] Triangle = new Point[3];
Triangle[0].X = i * (int)_size_x; Triangle[0].Y = j * (int)_size_y;
Triangle[1].X = i * (int)_size_x + 8; Triangle[1].Y = j * (int)_size_y - 5;
Triangle[2].X = i * (int)_size_x + 8; Triangle[2].Y = j * (int)_size_y + 5;
g.FillPolygon(barrierColor, Triangle);
}
protected override void DrawRoadPart(Graphics g, int i, int j)
{
g.FillRectangle(skyColor, i * _size_x, j * _size_y, i * (_size_x + 1), j * (_size_y + 1));
}
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 < 30)
{
int x = _random.Next(0, 100);
int y = _random.Next(0, 100);
if (_map[x, y] == _freeRoad)
{
_map[x, y] = _barrier;
counter++;
}
}
}
}
}