Промежуточный коммит
This commit is contained in:
parent
60ab887cca
commit
cbf4305be0
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectBulldozer;
|
||||
namespace ProjectBulldozer.Drawnings;
|
||||
|
||||
public enum DirectionType
|
||||
{
|
@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ProjectBulldozer.Entities;
|
||||
|
||||
namespace ProjectBulldozer.Drawnings;
|
||||
|
||||
/// <summary>
|
||||
/// Класс отвечающий за прорисовку и перемещение объекта-сущности
|
||||
/// </summary>
|
||||
public class DrawningBulldozer : DrawningDozer
|
||||
{
|
||||
///<summary>
|
||||
///Конструктор
|
||||
/// </summary>
|
||||
/// ///<param name="speed">Скорость</param>
|
||||
///<param name="weight">Вес</param>
|
||||
///<param name="bodyColor">Основной цвет</param>
|
||||
///<param name="additionalColor">Дополнительный цвет</param>
|
||||
///<param name="blade">Признак наличия отвала</param>
|
||||
///<param name="caterpillar">Признак наличия гусеницы</param>
|
||||
public DrawningBulldozer(int speed, double weight, Color bodyColor, Color additionalColor, bool blade, bool caterpillar) : base(150, 90)
|
||||
{
|
||||
EntityDozer = new EntityBulldozer(speed, weight, bodyColor, additionalColor, blade, caterpillar);
|
||||
}
|
||||
|
||||
public override void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityDozer == null || !_startPosX.HasValue || !_startPosY.HasValue || EntityDozer is not EntityBulldozer bulldozer)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Pen pen = new(Color.Black);
|
||||
Brush bodyBrush = new SolidBrush(EntityDozer.BodyColor);
|
||||
Brush additionalBrush = new SolidBrush(EntityDozer.AdditionalColor);
|
||||
//BULDOZER
|
||||
//caterpillar
|
||||
if (bulldozer.Caterpillar)
|
||||
{
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value, _startPosY.Value, 150, 15);
|
||||
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value, 150, 15);
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value, _startPosY.Value + 75, 150, 15);
|
||||
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + 75, 150, 15);
|
||||
}
|
||||
|
||||
//blade
|
||||
if (bulldozer.Blade)
|
||||
{ //smth like hands?
|
||||
g.FillRectangle(bodyBrush, _startPosX.Value + 75, _startPosY.Value + 3, 75, 15);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 75, _startPosY.Value + 3, 75, 15);
|
||||
g.FillRectangle(bodyBrush, _startPosX.Value + 75, _startPosY.Value + 72, 75, 15);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 75, _startPosY.Value + 72, 75, 15);
|
||||
//blade itself
|
||||
g.FillRectangle(bodyBrush, _startPosX.Value + 125, _startPosY.Value, 25, 90);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 125, _startPosY.Value, 25, 90);
|
||||
g.DrawLine(pen, _startPosX.Value + 140, _startPosY.Value, _startPosX.Value + 140, _startPosY.Value + 90);
|
||||
}
|
||||
_startPosX += 0;
|
||||
_startPosY += 0;
|
||||
base.DrawTransport(g);
|
||||
_startPosX -= 0;
|
||||
_startPosY -= 0;
|
||||
}
|
||||
}
|
@ -1,20 +1,21 @@
|
||||
using System;
|
||||
using ProjectBulldozer.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectBulldozer;
|
||||
namespace ProjectBulldozer.Drawnings;
|
||||
|
||||
/// <summary>
|
||||
/// Классб отвечающий за прорисовку и перемещение объекта-сущности
|
||||
/// Класс отвечающий за прорисовку и перемещение объекта-сущности
|
||||
/// </summary>
|
||||
internal class DrawningBulldozer
|
||||
public class DrawningDozer
|
||||
{
|
||||
///<summary>
|
||||
/// Класс-сущность
|
||||
/// </summary>
|
||||
public EntityBulldozer? EntityBulldozer { get; private set; }
|
||||
public EntityDozer? EntityDozer { get; protected set; }
|
||||
|
||||
///<summary>
|
||||
///Ширина окна
|
||||
@ -29,12 +30,12 @@ internal class DrawningBulldozer
|
||||
///<summary>
|
||||
/// Левая координата прорисовки бульдозера
|
||||
/// </summary>
|
||||
private int? _startPosX;
|
||||
protected int? _startPosX;
|
||||
|
||||
///<summary>
|
||||
/// Верхнаяя координата прорисовки бульдозера
|
||||
/// </summary>
|
||||
private int? _startPosY;
|
||||
protected int? _startPosY;
|
||||
|
||||
///<summary>
|
||||
///Ширина прорисовки бульдозера
|
||||
@ -46,26 +47,42 @@ internal class DrawningBulldozer
|
||||
/// </summary>
|
||||
private readonly int _drawningBulldozerHeight = 90;
|
||||
|
||||
///<summary>
|
||||
///Инициализация свойств
|
||||
/// <summary>
|
||||
/// Пустой конструктор.
|
||||
/// </summary>
|
||||
/// ///<param name="speed">Скорость</param>
|
||||
///<param name="weight">Вес</param>
|
||||
///<param name="bodyColor">Основной цвет</param>
|
||||
///<param name="additionalColor">Дополнительный цвет</param>
|
||||
///<param name="blade">Признак наличия отвала</param>
|
||||
///<param name="caterpillar">Признак наличия гусеницы</param>
|
||||
public void Init(int speed, double weight, Color bodyColor, Color additionalColor, bool blade, bool caterpillar)
|
||||
//public void Init(EntityBulldozer entityBulldozer)
|
||||
private DrawningDozer()
|
||||
{
|
||||
EntityBulldozer = new EntityBulldozer();
|
||||
EntityBulldozer.Init(speed, weight, bodyColor, additionalColor, blade, caterpillar);
|
||||
_pictureWidth = null;
|
||||
_pictureHeight = null;
|
||||
_startPosX = null;
|
||||
_startPosY = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет(цвет колёс)</param>
|
||||
public DrawningDozer(int speed, double weight, Color bodyColor, Color additionalColor) : this()
|
||||
{
|
||||
EntityDozer = new EntityDozer(speed, weight, bodyColor, additionalColor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор для наследников
|
||||
/// </summary>
|
||||
/// <param name="drawningBulldozerWidth">Ширина прорисовки бульдозера</param>
|
||||
/// <param name="drawningBulldozerHeigh">Высота прорисовки бульдозера</param>
|
||||
protected DrawningDozer (int drawningBulldozerWidth, int drawningBulldozerHeigh)
|
||||
{
|
||||
_drawningBulldozerWidth = drawningBulldozerWidth;
|
||||
//????????
|
||||
_pictureHeight = drawningBulldozerHeigh;
|
||||
//????????
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Установка границ поля
|
||||
/// </summary>
|
||||
@ -104,7 +121,6 @@ internal class DrawningBulldozer
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -147,6 +163,7 @@ internal class DrawningBulldozer
|
||||
_startPosY = y;
|
||||
}
|
||||
}
|
||||
|
||||
///<summary>
|
||||
///Изменение направления перемещения
|
||||
/// </summary>
|
||||
@ -154,7 +171,7 @@ internal class DrawningBulldozer
|
||||
/// <returns>true - перемещениие выполнено, false - перемещение невозможно</returns>
|
||||
public bool MoveTransport(DirectionType direction)
|
||||
{
|
||||
if (EntityBulldozer == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
if (EntityDozer == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@ -163,51 +180,51 @@ internal class DrawningBulldozer
|
||||
{
|
||||
// влево
|
||||
case DirectionType.Left:
|
||||
if (_startPosX.Value - EntityBulldozer.Step > 0)
|
||||
if (_startPosX.Value - EntityDozer.Step > 0)
|
||||
{
|
||||
_startPosX -= (int)EntityBulldozer.Step;
|
||||
_startPosX -= (int)EntityDozer.Step;
|
||||
}
|
||||
return true;
|
||||
// вверх
|
||||
case DirectionType.Up:
|
||||
if (_startPosY.Value - EntityBulldozer.Step > 0)
|
||||
if (_startPosY.Value - EntityDozer.Step > 0)
|
||||
{
|
||||
_startPosY -= (int)EntityBulldozer.Step;
|
||||
_startPosY -= (int)EntityDozer.Step;
|
||||
}
|
||||
return true;
|
||||
// вправо
|
||||
case DirectionType.Right:
|
||||
if (_startPosX.Value + EntityBulldozer.Step + _drawningBulldozerWidth < _pictureWidth)
|
||||
if (_startPosX.Value + EntityDozer.Step + _drawningBulldozerWidth < _pictureWidth)
|
||||
{
|
||||
_startPosX += (int)EntityBulldozer.Step;
|
||||
_startPosX += (int)EntityDozer.Step;
|
||||
}
|
||||
return true;
|
||||
// вниз
|
||||
case DirectionType.Down:
|
||||
if (_startPosY.Value + EntityBulldozer.Step + _drawningBulldozerHeight < _pictureHeight)
|
||||
if (_startPosY.Value + EntityDozer.Step + _drawningBulldozerHeight < _pictureHeight)
|
||||
{
|
||||
_startPosY += (int)EntityBulldozer.Step;
|
||||
_startPosY += (int)EntityDozer.Step;
|
||||
}
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
///<summary>
|
||||
/// Прорисовка объекта
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
public void DrawTransport(Graphics g)
|
||||
public virtual void DrawTransport(Graphics g)
|
||||
{
|
||||
if (EntityBulldozer == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
if (EntityDozer == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Pen pen = new(Color.Black);
|
||||
Brush bodyBrush = new SolidBrush(EntityBulldozer.BodyColor);
|
||||
Brush additionalBrush = new SolidBrush(EntityBulldozer.AdditionalColor);
|
||||
Brush bodyBrush = new SolidBrush(EntityDozer.BodyColor);
|
||||
Brush additionalBrush = new SolidBrush(EntityDozer.AdditionalColor);
|
||||
//BULDOZER
|
||||
//body
|
||||
g.FillRectangle(bodyBrush, _startPosX.Value + 10, _startPosY.Value + 15, _drawningBulldozerWidth - 20, _drawningBulldozerHeight - 30);
|
||||
@ -234,27 +251,5 @@ internal class DrawningBulldozer
|
||||
Brush windowBrush = new SolidBrush(Color.FromArgb(170, 170, 215));
|
||||
g.FillRectangle(windowBrush, _startPosX.Value + 55, _startPosY.Value + 20, _drawningBulldozerWidth - 90, _drawningBulldozerHeight - 40);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 55, _startPosY.Value + 20, _drawningBulldozerWidth - 90, _drawningBulldozerHeight - 40);
|
||||
|
||||
//caterpillar
|
||||
if (EntityBulldozer.Caterpillar)
|
||||
{
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value, _startPosY.Value, _drawningBulldozerWidth, 15);
|
||||
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value, _drawningBulldozerWidth, 15);
|
||||
g.FillRectangle(additionalBrush, _startPosX.Value, _startPosY.Value + _drawningBulldozerHeight - 15, _drawningBulldozerWidth, 15);
|
||||
g.DrawRectangle(pen, _startPosX.Value, _startPosY.Value + _drawningBulldozerHeight - 15, _drawningBulldozerWidth, 15);
|
||||
}
|
||||
|
||||
//blade
|
||||
if (EntityBulldozer.Blade)
|
||||
{ //smth like hands?
|
||||
g.FillRectangle(bodyBrush, _startPosX.Value + 75, _startPosY.Value + 3, 75, 15);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 75, _startPosY.Value + 3, 75, 15);
|
||||
g.FillRectangle(bodyBrush, _startPosX.Value + 75, _startPosY.Value + _drawningBulldozerHeight - 18, 75, 15);
|
||||
g.DrawRectangle(pen, _startPosX.Value + 75, _startPosY.Value + _drawningBulldozerHeight - 18, 75, 15);
|
||||
//blade itself
|
||||
g.FillRectangle(bodyBrush, _startPosX.Value + _drawningBulldozerWidth - 25, _startPosY.Value, 25, _drawningBulldozerHeight);
|
||||
g.DrawRectangle(pen, _startPosX.Value + _drawningBulldozerWidth - 25, _startPosY.Value, 25, _drawningBulldozerHeight);
|
||||
g.DrawLine(pen, _startPosX.Value + _drawningBulldozerWidth - 10, _startPosY.Value, _startPosX.Value + _drawningBulldozerWidth - 10, _startPosY.Value + _drawningBulldozerHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectBulldozer;
|
||||
namespace ProjectBulldozer.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Класс-сущность "Бульдозер"
|
54
ProjectBulldozer/ProjectBulldozer/Entities/EntityDozer.cs
Normal file
54
ProjectBulldozer/ProjectBulldozer/Entities/EntityDozer.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectBulldozer.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Класс-сущность "Бульдозер"
|
||||
/// </summary>
|
||||
public class EntityDozer
|
||||
{
|
||||
///<summary>
|
||||
/// Скорость
|
||||
/// </summary>
|
||||
public int Speed { get; private set; }
|
||||
|
||||
///<summary>
|
||||
/// Вес
|
||||
/// </summary>
|
||||
public double Weight { get; private set; }
|
||||
|
||||
///<summary>
|
||||
/// Основной цвет
|
||||
/// </summary>
|
||||
public Color BodyColor { get; private set; }
|
||||
|
||||
///<summary>
|
||||
/// Дополнительный цвет
|
||||
/// </summary>
|
||||
public Color AdditionalColor { get; private set; }
|
||||
|
||||
///<summary>
|
||||
/// Шаг перемещения бульдозера
|
||||
/// </summary>
|
||||
public double Step => Speed * 100 / Weight;
|
||||
|
||||
///<summary>
|
||||
/// Конструктор сущности
|
||||
/// </summary>
|
||||
///<param name="speed">Скорость</param>
|
||||
///<param name="weight">Вес</param>
|
||||
///<param name="bodyColor">Основной цвет</param>
|
||||
///<param name="additionalColor">Дополнительный цвет</param>
|
||||
public EntityDozer(int speed, double weight, Color bodyColor, Color additionalColor)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
AdditionalColor = additionalColor;
|
||||
}
|
||||
|
||||
}
|
@ -7,6 +7,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using ProjectBulldozer.Drawnings;
|
||||
|
||||
namespace ProjectBulldozer
|
||||
{
|
||||
|
18
ProjectBulldozer/ProjectBulldozer/NewClass.cs
Normal file
18
ProjectBulldozer/ProjectBulldozer/NewClass.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectBulldozer
|
||||
{
|
||||
internal class NewClass
|
||||
{
|
||||
private int closedField;
|
||||
public double Property { private get; set; }
|
||||
public void NewMethod()
|
||||
{
|
||||
//Новый метод.
|
||||
}
|
||||
}
|
||||
}
|
@ -23,4 +23,8 @@
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="MovementStrategy\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user