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