Промежуточный коммит

This commit is contained in:
MariaBelkina 2024-03-13 10:29:32 +04:00
parent 60ab887cca
commit cbf4305be0
8 changed files with 198 additions and 59 deletions

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace ProjectBulldozer; namespace ProjectBulldozer.Drawnings;
public enum DirectionType public enum DirectionType
{ {

View File

@ -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;
}
}

View File

@ -1,20 +1,21 @@
using System; using ProjectBulldozer.Entities;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace ProjectBulldozer; namespace ProjectBulldozer.Drawnings;
/// <summary> /// <summary>
/// Классб отвечающий за прорисовку и перемещение объекта-сущности /// Класс отвечающий за прорисовку и перемещение объекта-сущности
/// </summary> /// </summary>
internal class DrawningBulldozer public class DrawningDozer
{ {
///<summary> ///<summary>
/// Класс-сущность /// Класс-сущность
/// </summary> /// </summary>
public EntityBulldozer? EntityBulldozer { get; private set; } public EntityDozer? EntityDozer { get; protected set; }
///<summary> ///<summary>
///Ширина окна ///Ширина окна
@ -29,12 +30,12 @@ internal class DrawningBulldozer
///<summary> ///<summary>
/// Левая координата прорисовки бульдозера /// Левая координата прорисовки бульдозера
/// </summary> /// </summary>
private int? _startPosX; protected int? _startPosX;
///<summary> ///<summary>
/// Верхнаяя координата прорисовки бульдозера /// Верхнаяя координата прорисовки бульдозера
/// </summary> /// </summary>
private int? _startPosY; protected int? _startPosY;
///<summary> ///<summary>
///Ширина прорисовки бульдозера ///Ширина прорисовки бульдозера
@ -46,26 +47,42 @@ internal class DrawningBulldozer
/// </summary> /// </summary>
private readonly int _drawningBulldozerHeight = 90; private readonly int _drawningBulldozerHeight = 90;
///<summary> /// <summary>
///Инициализация свойств /// Пустой конструктор.
/// </summary> /// </summary>
/// ///<param name="speed">Скорость</param> private DrawningDozer()
///<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)
{ {
EntityBulldozer = new EntityBulldozer();
EntityBulldozer.Init(speed, weight, bodyColor, additionalColor, blade, caterpillar);
_pictureWidth = null; _pictureWidth = null;
_pictureHeight = null; _pictureHeight = null;
_startPosX = null; _startPosX = null;
_startPosY = 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>
///Установка границ поля ///Установка границ поля
/// </summary> /// </summary>
@ -104,7 +121,6 @@ internal class DrawningBulldozer
} }
} }
return true; return true;
} }
@ -147,6 +163,7 @@ internal class DrawningBulldozer
_startPosY = y; _startPosY = y;
} }
} }
///<summary> ///<summary>
///Изменение направления перемещения ///Изменение направления перемещения
/// </summary> /// </summary>
@ -154,7 +171,7 @@ internal class DrawningBulldozer
/// <returns>true - перемещениие выполнено, false - перемещение невозможно</returns> /// <returns>true - перемещениие выполнено, false - перемещение невозможно</returns>
public bool MoveTransport(DirectionType direction) public bool MoveTransport(DirectionType direction)
{ {
if (EntityBulldozer == null || !_startPosX.HasValue || !_startPosY.HasValue) if (EntityDozer == null || !_startPosX.HasValue || !_startPosY.HasValue)
{ {
return false; return false;
} }
@ -163,51 +180,51 @@ internal class DrawningBulldozer
{ {
// влево // влево
case DirectionType.Left: 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; return true;
// вверх // вверх
case DirectionType.Up: 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; return true;
// вправо // вправо
case DirectionType.Right: 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; return true;
// вниз // вниз
case DirectionType.Down: 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; return true;
default: default:
return false; return false;
} }
} }
///<summary> ///<summary>
/// Прорисовка объекта /// Прорисовка объекта
/// </summary> /// </summary>
/// <param name="g"></param> /// <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; return;
} }
Pen pen = new(Color.Black); Pen pen = new(Color.Black);
Brush bodyBrush = new SolidBrush(EntityBulldozer.BodyColor); Brush bodyBrush = new SolidBrush(EntityDozer.BodyColor);
Brush additionalBrush = new SolidBrush(EntityBulldozer.AdditionalColor); Brush additionalBrush = new SolidBrush(EntityDozer.AdditionalColor);
//BULDOZER //BULDOZER
//body //body
g.FillRectangle(bodyBrush, _startPosX.Value + 10, _startPosY.Value + 15, _drawningBulldozerWidth - 20, _drawningBulldozerHeight - 30); 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)); Brush windowBrush = new SolidBrush(Color.FromArgb(170, 170, 215));
g.FillRectangle(windowBrush, _startPosX.Value + 55, _startPosY.Value + 20, _drawningBulldozerWidth - 90, _drawningBulldozerHeight - 40); 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); 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);
}
} }
} }

View File

@ -4,7 +4,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace ProjectBulldozer; namespace ProjectBulldozer.Entities;
/// <summary> /// <summary>
/// Класс-сущность "Бульдозер" /// Класс-сущность "Бульдозер"

View 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;
}
}

View File

@ -7,6 +7,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using ProjectBulldozer.Drawnings;
namespace ProjectBulldozer namespace ProjectBulldozer
{ {

View 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()
{
//Новый метод.
}
}
}

View File

@ -23,4 +23,8 @@
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup>
<Folder Include="MovementStrategy\" />
</ItemGroup>
</Project> </Project>