This commit is contained in:
marusya 2023-11-05 21:25:34 +04:00
parent a180995d19
commit 8dfd9434a9
4 changed files with 24 additions and 24 deletions

View File

@ -19,7 +19,7 @@ namespace SelfPropelledArtilleryUnit.DrawningObjects
/// <summary> /// <summary>
/// Класс-сущность /// Класс-сущность
/// </summary> /// </summary>
public EntityUsta? EntityUsta_ { get; set; } public EntityUsta? EntityUsta { get; set; }
/// <summary> /// <summary>
/// Ширина окна /// Ширина окна
/// </summary> /// </summary>
@ -58,7 +58,7 @@ namespace SelfPropelledArtilleryUnit.DrawningObjects
// TODO: Продумать проверки // TODO: Продумать проверки
_pictureWidth = width; _pictureWidth = width;
_pictureHeight = height; _pictureHeight = height;
EntityUsta_ = new EntityUsta(speed, weight, bodyColor); EntityUsta = new EntityUsta(speed, weight, bodyColor);
} }
/// <summary> /// <summary>
/// Конструктор /// Конструктор
@ -83,7 +83,7 @@ namespace SelfPropelledArtilleryUnit.DrawningObjects
_pictureHeight = height; _pictureHeight = height;
_ustaWidth = ustaWidth; _ustaWidth = ustaWidth;
_ustaHeight = ustaHeight; _ustaHeight = ustaHeight;
EntityUsta_ = new EntityUsta(speed, weight, bodyColor); EntityUsta = new EntityUsta(speed, weight, bodyColor);
} }
@ -143,20 +143,20 @@ namespace SelfPropelledArtilleryUnit.DrawningObjects
/// <returns>true - можно переместится по указанному направлению</returns> /// <returns>true - можно переместится по указанному направлению</returns>
public virtual bool CanMove(DirectionType direction) public virtual bool CanMove(DirectionType direction)
{ {
if (EntityUsta_ == null) if (EntityUsta == null)
{ {
return false; return false;
} }
return direction switch return direction switch
{ {
//влево //влево
DirectionType.Left => _startPosX - EntityUsta_.Step > 0, DirectionType.Left => _startPosX - EntityUsta.Step > 0,
//вверх //вверх
DirectionType.Up => _startPosY - EntityUsta_.Step > 7, DirectionType.Up => _startPosY - EntityUsta.Step > 7,
// вправо // вправо
DirectionType.Right => _startPosX + EntityUsta_.Step + _ustaWidth < _pictureWidth,// TODO: Продумать логику DirectionType.Right => _startPosX + EntityUsta.Step + _ustaWidth < _pictureWidth,// TODO: Продумать логику
//вниз //вниз
DirectionType.Down => _startPosY + EntityUsta_.Step + _ustaHeight < _pictureHeight,// TODO: Продумать логику DirectionType.Down => _startPosY + EntityUsta.Step + _ustaHeight < _pictureHeight,// TODO: Продумать логику
_ => false, _ => false,
}; };
} }
@ -167,37 +167,37 @@ namespace SelfPropelledArtilleryUnit.DrawningObjects
public virtual void MoveTransport(DirectionType direction) public virtual void MoveTransport(DirectionType direction)
{ {
if (!CanMove(direction) || EntityUsta_ == null) if (!CanMove(direction) || EntityUsta == null)
{ {
return; return;
} }
switch (direction) switch (direction)
{ {
case DirectionType.Left: case DirectionType.Left:
_startPosX -= (int)EntityUsta_.Step; _startPosX -= (int)EntityUsta.Step;
break; break;
case DirectionType.Up: case DirectionType.Up:
_startPosY -= (int)EntityUsta_.Step; _startPosY -= (int)EntityUsta.Step;
break; break;
case DirectionType.Right: case DirectionType.Right:
_startPosX += (int)EntityUsta_.Step; _startPosX += (int)EntityUsta.Step;
break; break;
case DirectionType.Down: case DirectionType.Down:
_startPosY += (int)EntityUsta_.Step; _startPosY += (int)EntityUsta.Step;
break; break;
} }
} }
public virtual void DrawTransport(Graphics g) public virtual void DrawTransport(Graphics g)
{ {
if (EntityUsta_ == null) if (EntityUsta == null)
{ {
return; return;
} }
Pen pen = new(Color.Black); Pen pen = new(Color.Black);
Brush BodyColor = new SolidBrush(EntityUsta_.BodyColor); Brush BodyColor = new SolidBrush(EntityUsta.BodyColor);
//зеленый темнее //зеленый темнее
int lineWidth = 10; int lineWidth = 10;

View File

@ -29,9 +29,9 @@ namespace SelfPropelledArtilleryUnit.DrawningObjects
additionalColor, bool bodyKit, bool pushka, int width, int height) : additionalColor, bool bodyKit, bool pushka, int width, int height) :
base(speed, weight, bodyColor, width, height, 140, 90) base(speed, weight, bodyColor, width, height, 140, 90)
{ {
if (EntityUsta_ != null) if (EntityUsta != null)
{ {
EntityUsta_ = new EntityUstaBat(speed, weight, bodyColor, EntityUsta = new EntityUstaBat(speed, weight, bodyColor,
additionalColor, bodyKit, pushka); additionalColor, bodyKit, pushka);
} }
} }
@ -39,14 +39,14 @@ namespace SelfPropelledArtilleryUnit.DrawningObjects
public override void DrawTransport(Graphics g) public override void DrawTransport(Graphics g)
{ {
if (EntityUsta_ is not EntityUstaBat ustaBat) if (EntityUsta is not EntityUstaBat ustaBat)
{ {
return; return;
} }
Pen pen = new(Color.Black); Pen pen = new(Color.Black);
Brush additionalBrush = new SolidBrush(ustaBat.AdditionalColor); Brush additionalBrush = new SolidBrush(ustaBat.AdditionalColor);
Brush BodyColor = new SolidBrush(EntityUsta_.BodyColor); Brush BodyColor = new SolidBrush(EntityUsta.BodyColor);
//зеленый темнее //зеленый темнее
Color color1 = Color.FromArgb(65, 72, 51); Color color1 = Color.FromArgb(65, 72, 51);

View File

@ -127,7 +127,7 @@ namespace SelfPropelledArtilleryUnit
{ {
if (e.Data.GetDataPresent(typeof(Color))) if (e.Data.GetDataPresent(typeof(Color)))
{ {
_usta.EntityUsta_.BodyColor = (Color)e.Data.GetData(typeof(Color)); _usta.EntityUsta.BodyColor = (Color)e.Data.GetData(typeof(Color));
} }
DrawUsta(); DrawUsta();
@ -136,7 +136,7 @@ namespace SelfPropelledArtilleryUnit
private void LabelColor_DragEnter(object sender, DragEventArgs e) private void LabelColor_DragEnter(object sender, DragEventArgs e)
{ {
if (_usta != null && _usta.EntityUsta_ is EntityUstaBat entityustabat) if (_usta != null && _usta.EntityUsta is EntityUstaBat entityustabat)
{ {
labelDopColor.AllowDrop = true; labelDopColor.AllowDrop = true;
} }
@ -155,7 +155,7 @@ namespace SelfPropelledArtilleryUnit
private void LabelDopColor_DragDrop(object sender, DragEventArgs e) private void LabelDopColor_DragDrop(object sender, DragEventArgs e)
{ {
if (_usta != null && _usta.EntityUsta_ is EntityUstaBat entityustabat) if (_usta != null && _usta.EntityUsta is EntityUstaBat entityustabat)
{ {
if (e.Data.GetDataPresent(typeof(Color))) if (e.Data.GetDataPresent(typeof(Color)))
{ {

View File

@ -23,7 +23,7 @@ namespace SelfPropelledArtilleryUnit.MovementStrategy
{ {
get get
{ {
if (_drawningUsta == null || _drawningUsta.EntityUsta_ == if (_drawningUsta == null || _drawningUsta.EntityUsta ==
null) null)
{ {
return null; return null;
@ -32,7 +32,7 @@ namespace SelfPropelledArtilleryUnit.MovementStrategy
_drawningUsta.GetPosY, _drawningUsta.GetWidth, _drawningUsta.GetHeight); _drawningUsta.GetPosY, _drawningUsta.GetWidth, _drawningUsta.GetHeight);
} }
} }
public int GetStep => (int)(_drawningUsta?.EntityUsta_?.Step ?? 0); public int GetStep => (int)(_drawningUsta?.EntityUsta?.Step ?? 0);
public bool CheckCanMove(DirectionType direction) => public bool CheckCanMove(DirectionType direction) =>
_drawningUsta?.CanMove(direction) ?? false; _drawningUsta?.CanMove(direction) ?? false;
public void MoveObject(DirectionType direction) => public void MoveObject(DirectionType direction) =>