ПИбд-21 Лобашов Иван 5 лаб простая #5

Closed
goldfest228 wants to merge 4 commits from lab5 into lab4
4 changed files with 24 additions and 24 deletions
Showing only changes of commit 8dfd9434a9 - Show all commits

View File

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

View File

@ -29,9 +29,9 @@ namespace SelfPropelledArtilleryUnit.DrawningObjects
additionalColor, bool bodyKit, bool pushka, int width, int height) :
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);
}
}
@ -39,14 +39,14 @@ namespace SelfPropelledArtilleryUnit.DrawningObjects
public override void DrawTransport(Graphics g)
{
if (EntityUsta_ is not EntityUstaBat ustaBat)
if (EntityUsta is not EntityUstaBat ustaBat)
{
return;
}
Pen pen = new(Color.Black);
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);

View File

@ -127,7 +127,7 @@ namespace SelfPropelledArtilleryUnit
{
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();
@ -136,7 +136,7 @@ namespace SelfPropelledArtilleryUnit
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;
}
@ -155,7 +155,7 @@ namespace SelfPropelledArtilleryUnit
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)))
{

View File

@ -23,7 +23,7 @@ namespace SelfPropelledArtilleryUnit.MovementStrategy
{
get
{
if (_drawningUsta == null || _drawningUsta.EntityUsta_ ==
if (_drawningUsta == null || _drawningUsta.EntityUsta ==
null)
{
return null;
@ -32,7 +32,7 @@ namespace SelfPropelledArtilleryUnit.MovementStrategy
_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) =>
_drawningUsta?.CanMove(direction) ?? false;
public void MoveObject(DirectionType direction) =>