ready product
This commit is contained in:
parent
d3a855e23c
commit
f70635aed5
@ -22,7 +22,6 @@ public class DrawningDiselLoko : DrawningLoko
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Прорисовка объекта
|
||||
/// </summary>
|
||||
@ -36,6 +35,9 @@ public class DrawningDiselLoko : DrawningLoko
|
||||
|
||||
Pen pen = new(Color.Black);
|
||||
Brush additionalBrush = new SolidBrush(diselLoko.ColorComportament);
|
||||
Brush blackBrush = new SolidBrush(Color.Black);
|
||||
|
||||
|
||||
|
||||
// труба
|
||||
if (diselLoko.IsTube)
|
||||
@ -45,28 +47,26 @@ public class DrawningDiselLoko : DrawningLoko
|
||||
Point[] chimney = {
|
||||
new Point(_startPosX.Value + 20, _startPosY.Value - 20),
|
||||
new Point(_startPosX.Value + 35, _startPosY.Value - 20),
|
||||
new Point(_startPosX.Value + 35, _startPosY.Value),
|
||||
new Point(_startPosX.Value + 20, _startPosY.Value)
|
||||
new Point(_startPosX.Value + 35, _startPosY.Value+5),
|
||||
new Point(_startPosX.Value + 20, _startPosY.Value+5)
|
||||
};
|
||||
g.FillPolygon(blackBrush, chimney);
|
||||
g.DrawPolygon(pen, chimney);
|
||||
}
|
||||
|
||||
_startPosX += 10;//change
|
||||
_startPosY += 5;
|
||||
base.DrawTransport(g);
|
||||
_startPosX -= 10;
|
||||
_startPosY -= 5;
|
||||
|
||||
// отсек
|
||||
if (diselLoko.IsComportament)
|
||||
{
|
||||
//Топливный отсек(полигон)
|
||||
Point[] fuelTank = {
|
||||
new Point(_startPosX.Value + 110, _startPosY.Value ), // Верхний левый угол
|
||||
new Point(_startPosX.Value + 130, _startPosY.Value ), // Верхний правый угол
|
||||
new Point(_startPosX.Value +130 , _startPosY.Value ), // Нижний правый угол
|
||||
new Point(_startPosX.Value + 110, _startPosY.Value ) // Нижний левый угол
|
||||
new Point(_startPosX.Value + 110, _startPosY.Value + GetHeight - 20 ), // Верхний левый угол
|
||||
new Point(_startPosX.Value + 130, _startPosY.Value + GetHeight - 20 ), // Верхний правый угол
|
||||
new Point(_startPosX.Value + 130, _startPosY.Value + GetHeight - 5 ), // Нижний правый угол
|
||||
new Point(_startPosX.Value + 110, _startPosY.Value + GetHeight - 5 ) // Нижний левый угол
|
||||
};
|
||||
g.FillPolygon(additionalBrush, fuelTank);
|
||||
g.DrawPolygon(pen, fuelTank);
|
||||
}
|
||||
|
||||
|
@ -15,12 +15,12 @@ public class DrawningLoko
|
||||
///<summary>
|
||||
///Ширина окна
|
||||
///</summary>
|
||||
private int? _pictureWidth;
|
||||
protected int? _pictureWidth;
|
||||
|
||||
///<summary>
|
||||
///Высота окна
|
||||
///</summary>
|
||||
private int? _pictureHeight;
|
||||
protected int? _pictureHeight;
|
||||
|
||||
///<summary>
|
||||
///Левая координата прорисовки тепловоза
|
||||
@ -35,27 +35,27 @@ public class DrawningLoko
|
||||
///<summary>
|
||||
///Ширина прорисовки тепловоза
|
||||
///</summary>
|
||||
private readonly int _drawingCarWidth = 140;//поменять
|
||||
private readonly int _drawingCarWidth = 140;
|
||||
|
||||
///<summary>
|
||||
///Высота прорисовки тепловоза
|
||||
///</summary>
|
||||
private readonly int _drawingCarHeight = 60;//поменять
|
||||
private readonly int _drawingCarHeight = 60;
|
||||
|
||||
///<summary>
|
||||
///Высота прорисовки тепловоза с трубой
|
||||
///</summary>
|
||||
private int _drawingCarHeightWithKit = 0;
|
||||
|
||||
///<summary>
|
||||
///Высота прорисовки тепловоза с трубой
|
||||
///</summary>
|
||||
private int _WheelHeight = 25;
|
||||
protected int _TubeHeight = 20;
|
||||
|
||||
///<summary>
|
||||
///ширина вставки сбоку
|
||||
///</summary>
|
||||
private int _InsertWidth = 10;
|
||||
protected int _InsertWidth = 10;
|
||||
|
||||
///<summary>
|
||||
///ширина вставки сбоку
|
||||
///</summary>
|
||||
protected int _WheelHeight = 18;
|
||||
|
||||
/// <summary>
|
||||
/// Координата X объекта
|
||||
@ -77,16 +77,26 @@ public class DrawningLoko
|
||||
/// </summary>
|
||||
public int GetHeight => _drawingCarHeight;
|
||||
|
||||
///<summary>
|
||||
///Высота прорисовки тепловоза с трубой
|
||||
///</summary>
|
||||
public int GetWheelHeight => _TubeHeight;
|
||||
|
||||
///<summary>
|
||||
///ширина вставки сбоку
|
||||
///</summary>
|
||||
public int GetInsertWidth => _InsertWidth;
|
||||
|
||||
/// <summary>
|
||||
/// Пустой конструктор
|
||||
/// </summary>
|
||||
private DrawningLoko()
|
||||
public DrawningLoko()
|
||||
{
|
||||
_pictureWidth = null;
|
||||
_pictureHeight = null;
|
||||
_startPosX = null;
|
||||
_startPosY = null;
|
||||
_InsertWidth = 10;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -179,7 +189,7 @@ public class DrawningLoko
|
||||
{
|
||||
//влево
|
||||
case Direction.Left:
|
||||
if (_startPosX.Value - EntityLoko.Step > 0)
|
||||
if (_startPosX.Value - EntityLoko.Step - _InsertWidth > 0)
|
||||
{
|
||||
_startPosX -= (int)EntityLoko.Step;
|
||||
}
|
||||
@ -187,7 +197,7 @@ public class DrawningLoko
|
||||
//вверх
|
||||
case Direction.Up:
|
||||
|
||||
if (_startPosY.Value - _drawingCarHeightWithKit >= 0)
|
||||
if (_startPosY.Value - EntityLoko.Step >= 0)
|
||||
{
|
||||
_startPosY = _startPosY - (int)EntityLoko.Step;
|
||||
}
|
||||
@ -201,7 +211,7 @@ public class DrawningLoko
|
||||
return true;
|
||||
//вниз
|
||||
case Direction.Down:
|
||||
if (_startPosY.Value + _WheelHeight + _drawingCarHeight < _pictureHeight.Value)
|
||||
if (_startPosY.Value + _WheelHeight + _drawingCarHeight < _pictureHeight.Value)
|
||||
{
|
||||
_startPosY += (int)EntityLoko.Step;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ public class DiselLoko : EntityLoko
|
||||
/// <param name="Comportament">цвет отсека</param>
|
||||
/// <param name="isTube">признак наличия трубы</param>
|
||||
/// <param name="isComportament">признак наличия отсека</param>
|
||||
public DiselLoko(int speed, double weight, Color bodyColor, Color Comportament, bool isTube, bool isComportament) : base(0, 0, Color.Black)
|
||||
public DiselLoko(int speed, double weight, Color bodyColor, Color Comportament, bool isTube, bool isComportament) : base(speed, weight, bodyColor)
|
||||
{
|
||||
ColorComportament = Comportament;
|
||||
IsTube = isTube;
|
||||
|
@ -4,11 +4,49 @@ public class MoveToBoarder : AbstractStrategy
|
||||
{
|
||||
protected override bool IsTargetDestinaion()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
ObjectParameters? objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return objParams.RightBorder + GetStep() >= FieldWidth &&
|
||||
objParams.DownBorder + GetStep() >= FieldHeight ;
|
||||
}
|
||||
|
||||
protected override void MoveToTarget()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
ObjectParameters? objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int diffX = objParams.RightBorder - FieldWidth;
|
||||
if (Math.Abs(diffX) > GetStep())
|
||||
{
|
||||
if (diffX > 0)
|
||||
{
|
||||
MoveLeft();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveRight();
|
||||
}
|
||||
}
|
||||
|
||||
int diffY = objParams.DownBorder - FieldHeight;
|
||||
if (Math.Abs(diffY) > GetStep())
|
||||
{
|
||||
if (diffY > 0)
|
||||
{
|
||||
MoveUp();
|
||||
}
|
||||
else
|
||||
{
|
||||
MoveDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -14,12 +14,13 @@ public class MoveableLoko : IMoveableObject
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="loko">Объект класса DrawningCar</param>
|
||||
/// <param name="loko">Объект класса DrawningLoko</param>
|
||||
public MoveableLoko(DrawningLoko loko)
|
||||
{
|
||||
_loko = loko;
|
||||
}
|
||||
|
||||
|
||||
public ObjectParameters? GetObjectPosition
|
||||
{
|
||||
get
|
||||
|
@ -5,6 +5,17 @@
|
||||
/// </summary>
|
||||
public class ObjectParameters
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Длина колеса
|
||||
/// </summary>
|
||||
private readonly int _wheelHeight = 18;
|
||||
|
||||
/// <summary>
|
||||
/// Ширина вставки сзади
|
||||
/// </summary>
|
||||
private readonly int _insertWidth = 10;
|
||||
|
||||
/// <summary>
|
||||
/// Координата X
|
||||
/// </summary>
|
||||
@ -38,12 +49,12 @@ public class ObjectParameters
|
||||
/// <summary>
|
||||
/// Правая граница
|
||||
/// </summary>
|
||||
public int RightBorder => _x + _width;
|
||||
public int RightBorder => _x + _width + _insertWidth;
|
||||
|
||||
/// <summary>
|
||||
/// Нижняя граница
|
||||
/// </summary>
|
||||
public int DownBorder => _y + _height;
|
||||
public int DownBorder => _y + _height + _wheelHeight;
|
||||
|
||||
/// <summary>
|
||||
/// Середина объекта
|
||||
|
Loading…
x
Reference in New Issue
Block a user