Edited from first lab
This commit is contained in:
parent
7e28d26868
commit
66f19085b9
@ -1,28 +1,28 @@
|
|||||||
using System;
|
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 ProjectTank
|
namespace ProjectTank
|
||||||
{
|
{
|
||||||
public enum DirectionType
|
public enum DirectionType
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Вверх
|
/// Вверх
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Up = 1,
|
Up = 1,
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Вниз
|
/// Вниз
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Down = 2,
|
Down = 2,
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Влево
|
/// Влево
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Left = 3,
|
Left = 3,
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Вправо
|
/// Вправо
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Right = 4
|
Right = 4
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,19 +25,19 @@ namespace ProjectTank.DrawningObjects
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private int _pictureHeight;
|
private int _pictureHeight;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Левая координата прорисовки автомобиля
|
/// Левая координата прорисовки транспорта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected int _startPosX;
|
protected int _startPosX;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Верхняя кооридната прорисовки автомобиля
|
/// Верхняя кооридната прорисовки транспорта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected int _startPosY;
|
protected int _startPosY;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Ширина прорисовки автомобиля
|
/// Ширина прорисовки транспорта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected readonly int _transportWidth = 200;
|
protected readonly int _transportWidth = 200;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Высота прорисовки автомобиля
|
/// Высота прорисовки транспорта
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected readonly int _transportHeight = 80;
|
protected readonly int _transportHeight = 80;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -65,14 +65,14 @@ namespace ProjectTank.DrawningObjects
|
|||||||
/// <param name="width">Ширина картинки</param>
|
/// <param name="width">Ширина картинки</param>
|
||||||
/// <param name="height">Высота картинки</param>
|
/// <param name="height">Высота картинки</param>
|
||||||
public DrawningArmoredTransport(int speed, double weight, Color bodyColor, int
|
public DrawningArmoredTransport(int speed, double weight, Color bodyColor, int
|
||||||
width, int height)
|
width, int height)
|
||||||
{
|
{
|
||||||
_pictureWidth = width;
|
if ((height > _transportHeight) && (width > _transportWidth))
|
||||||
_pictureHeight = height;
|
|
||||||
if ((_pictureHeight > _transportHeight) && (_pictureWidth > _transportWidth))
|
|
||||||
{
|
{
|
||||||
EntityArmoredTransport = new EntityArmoredTransport(speed, weight, bodyColor);
|
EntityArmoredTransport = new EntityArmoredTransport(speed, weight, bodyColor);
|
||||||
}
|
}
|
||||||
|
_pictureWidth = width;
|
||||||
|
_pictureHeight = height;
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
@ -82,19 +82,19 @@ namespace ProjectTank.DrawningObjects
|
|||||||
/// <param name="bodyColor">Основной цвет</param>
|
/// <param name="bodyColor">Основной цвет</param>
|
||||||
/// <param name="width">Ширина картинки</param>
|
/// <param name="width">Ширина картинки</param>
|
||||||
/// <param name="height">Высота картинки</param>
|
/// <param name="height">Высота картинки</param>
|
||||||
/// <param name="transportWidth">Ширина прорисовки автомобиля</param>
|
/// <param name="transportWidth">Ширина прорисовки транспорта</param>
|
||||||
/// <param name="transportHeight">Высота прорисовки автомобиля</param>
|
/// <param name="transportHeight">Высота прорисовки транспорта</param>
|
||||||
protected DrawningArmoredTransport(int speed, double weight, Color bodyColor, int
|
protected DrawningArmoredTransport(int speed, double weight, Color bodyColor, int
|
||||||
width, int height, int transportWidth, int transportHeight)
|
width, int height, int transportWidth, int transportHeight)
|
||||||
{
|
{
|
||||||
|
if ((height > transportHeight) && (width > transportWidth))
|
||||||
|
{
|
||||||
|
EntityArmoredTransport = new EntityArmoredTransport(speed, weight, bodyColor);
|
||||||
|
}
|
||||||
_pictureWidth = width;
|
_pictureWidth = width;
|
||||||
_pictureHeight = height;
|
_pictureHeight = height;
|
||||||
_transportWidth = transportWidth;
|
_transportWidth = transportWidth;
|
||||||
_transportHeight = transportHeight;
|
_transportHeight = transportHeight;
|
||||||
if ((_pictureHeight > _transportHeight) && (_pictureWidth > _transportWidth))
|
|
||||||
{
|
|
||||||
EntityArmoredTransport = new EntityArmoredTransport(speed, weight, bodyColor);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Установка позиции
|
/// Установка позиции
|
||||||
@ -130,7 +130,7 @@ namespace ProjectTank.DrawningObjects
|
|||||||
Brush blackColorBrush = new SolidBrush(Color.Black);
|
Brush blackColorBrush = new SolidBrush(Color.Black);
|
||||||
Brush bodyBrush = new SolidBrush(EntityArmoredTransport.BodyColor);
|
Brush bodyBrush = new SolidBrush(EntityArmoredTransport.BodyColor);
|
||||||
|
|
||||||
// Границы автомобиля
|
// Границы транспорта
|
||||||
// гусеницы
|
// гусеницы
|
||||||
g.DrawEllipse(pen, _startPosX + 14, _startPosY + 44, 151, 31);
|
g.DrawEllipse(pen, _startPosX + 14, _startPosY + 44, 151, 31);
|
||||||
g.FillEllipse(blackColorBrush, _startPosX + 15, _startPosY + 45, 150, 30);
|
g.FillEllipse(blackColorBrush, _startPosX + 15, _startPosY + 45, 150, 30);
|
||||||
|
@ -21,13 +21,12 @@ namespace ProjectTank.MovementStrategy
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_drawningArmoredTransport == null || _drawningArmoredTransport.EntityArmoredTransport ==
|
if (_drawningArmoredTransport == null || _drawningArmoredTransport.EntityArmoredTransport == null)
|
||||||
null)
|
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new ObjectParameters(_drawningArmoredTransport.GetPosX,
|
return new ObjectParameters(_drawningArmoredTransport.GetPosX, _drawningArmoredTransport.GetPosY,
|
||||||
_drawningArmoredTransport.GetPosY, _drawningArmoredTransport.GetWidth, _drawningArmoredTransport.GetHeight);
|
_drawningArmoredTransport.GetWidth, _drawningArmoredTransport.GetHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public int GetStep => (int)(_drawningArmoredTransport?.EntityArmoredTransport?.Step ?? 0);
|
public int GetStep => (int)(_drawningArmoredTransport?.EntityArmoredTransport?.Step ?? 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user