Закончил Лабу
This commit is contained in:
parent
a8847944db
commit
987cd86208
@ -26,7 +26,7 @@ public class EntityBasicSeaplane
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
Random random = new();
|
||||
|
||||
public EntityBasicSeaplane(int speed, double weight, Color bodyColor)
|
||||
{
|
||||
Speed = speed;
|
||||
|
@ -25,14 +25,13 @@ public class EntitySeaplane : EntityBasicSeaplane
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="landingGear">Тип "шасси"</param>
|
||||
/// <param name="radar">При</param>
|
||||
Random random = new();
|
||||
public EntitySeaplane(int speed, double weight, Color bodyColor, Color additionalColor, bool landingGear, bool radar) : base(0, 0, Color.Brown)
|
||||
|
||||
public EntitySeaplane(int speed, double weight, Color bodyColor, Color additionalColor, bool landingGear, bool radar) : base(speed, weight, bodyColor)
|
||||
{
|
||||
|
||||
AdditionalColor = additionalColor;
|
||||
LandingGear = landingGear;
|
||||
Radar = radar;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ namespace ProjectSeaplane
|
||||
/// <summary>
|
||||
/// Поле-объект для прорисовки объекта
|
||||
/// </summary>
|
||||
private DrawingBasicSeaplane? _drawingBasicSeaplane;
|
||||
private DrawingBasicSeaplane? _drawingSeaplane;
|
||||
/// <summary>
|
||||
/// Стратегия перемещения
|
||||
/// </summary>
|
||||
@ -29,14 +29,14 @@ namespace ProjectSeaplane
|
||||
/// </summary>
|
||||
private void Draw()
|
||||
{
|
||||
if (_drawingBasicSeaplane == null)
|
||||
if (_drawingSeaplane == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Bitmap bmp = new(pictureBoxSeaplane.Width, pictureBoxSeaplane.Height);
|
||||
Graphics gr = Graphics.FromImage(bmp);
|
||||
_drawingBasicSeaplane.DrawTransport(gr);
|
||||
_drawingSeaplane.DrawTransport(gr);
|
||||
pictureBoxSeaplane.Image = bmp;
|
||||
}
|
||||
/// <summary>
|
||||
@ -51,20 +51,20 @@ namespace ProjectSeaplane
|
||||
switch (type)
|
||||
{
|
||||
case nameof(DrawingBasicSeaplane):
|
||||
_drawingBasicSeaplane = new DrawingBasicSeaplane(random.Next(100, 300), random.Next(1000, 3000),
|
||||
_drawingSeaplane = new DrawingBasicSeaplane(random.Next(100, 300), random.Next(1000, 3000),
|
||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)));
|
||||
break;
|
||||
case nameof(DrawingSeaplane):
|
||||
_drawingBasicSeaplane = new DrawingSeaplane(random.Next(100, 300), random.Next(1000, 3000),
|
||||
_drawingSeaplane = new DrawingSeaplane(random.Next(100, 300), random.Next(1000, 3000),
|
||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
||||
Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)),
|
||||
Convert.ToBoolean(random.Next(1, 2)), Convert.ToBoolean(random.Next(1, 2)));
|
||||
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
_drawingBasicSeaplane.SetPictureSize(pictureBoxSeaplane.Width, pictureBoxSeaplane.Height);
|
||||
_drawingBasicSeaplane.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
_drawingSeaplane.SetPictureSize(pictureBoxSeaplane.Width, pictureBoxSeaplane.Height);
|
||||
_drawingSeaplane.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
_strategy = null;
|
||||
comboBoxStrategy.Enabled = true;
|
||||
Draw();
|
||||
@ -94,7 +94,7 @@ namespace ProjectSeaplane
|
||||
/// <param name="e"></param>
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawingBasicSeaplane == null)
|
||||
if (_drawingSeaplane == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -104,16 +104,16 @@ namespace ProjectSeaplane
|
||||
switch (name)
|
||||
{
|
||||
case "buttonUp":
|
||||
result = _drawingBasicSeaplane.MoveTransport(DirectionType.Up);
|
||||
result = _drawingSeaplane.MoveTransport(DirectionType.Up);
|
||||
break;
|
||||
case "buttonDown":
|
||||
result = _drawingBasicSeaplane.MoveTransport(DirectionType.Down);
|
||||
result = _drawingSeaplane.MoveTransport(DirectionType.Down);
|
||||
break;
|
||||
case "buttonLeft":
|
||||
result = _drawingBasicSeaplane.MoveTransport(DirectionType.Left);
|
||||
result = _drawingSeaplane.MoveTransport(DirectionType.Left);
|
||||
break;
|
||||
case "buttonRight":
|
||||
result = _drawingBasicSeaplane.MoveTransport(DirectionType.Right);
|
||||
result = _drawingSeaplane.MoveTransport(DirectionType.Right);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ namespace ProjectSeaplane
|
||||
/// <param name="e"></param>
|
||||
private void buttonStrategyStep_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (_drawingBasicSeaplane == null)
|
||||
if (_drawingSeaplane == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -146,7 +146,7 @@ namespace ProjectSeaplane
|
||||
{
|
||||
return;
|
||||
}
|
||||
_strategy.SetData(new MoveableSeaplane(_drawingBasicSeaplane), pictureBoxSeaplane.Width, pictureBoxSeaplane.Height);
|
||||
_strategy.SetData(new MoveableSeaplane(_drawingSeaplane), pictureBoxSeaplane.Width, pictureBoxSeaplane.Height);
|
||||
}
|
||||
|
||||
if (_strategy == null)
|
||||
|
@ -1,6 +1,4 @@
|
||||
|
||||
|
||||
namespace ProjectSeaplane.MovementStrategy;
|
||||
namespace ProjectSeaplane.MovementStrategy;
|
||||
|
||||
/// <summary>
|
||||
/// Интерфейс для работы с перемещаемым объектом
|
||||
|
@ -4,11 +4,49 @@ public class MoveToBorder : AbstractStrategy
|
||||
{
|
||||
protected override bool IsTargetDestinaion()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
ObjectParameters? objParams = GetObjectParameters;
|
||||
if (objParams == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return objParams.RightBorder <= FieldWidth &&
|
||||
objParams.RightBorder + GetStep() >= FieldWidth &&
|
||||
objParams.DownBorder <= FieldHeight &&
|
||||
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();
|
||||
}
|
||||
if (diffX < 0)
|
||||
{
|
||||
MoveRight();
|
||||
}
|
||||
}
|
||||
int diffY = objParams.DownBorder - FieldWidth;
|
||||
if (Math.Abs(diffY) > GetStep())
|
||||
{
|
||||
|
||||
if (diffX > 0)
|
||||
{
|
||||
MoveUp();
|
||||
}
|
||||
if (diffY < 0)
|
||||
{
|
||||
MoveDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,24 +12,17 @@ public class MoveableSeaplane : IMoveableObject
|
||||
/// <summary>
|
||||
/// Поле-объект класса Seaplane или его наследника
|
||||
/// </summary>
|
||||
private readonly DrawingSeaplane? _seaplane = null;
|
||||
private readonly DrawingBasicSeaplane? _seaplane = null;
|
||||
|
||||
/// <summary>
|
||||
/// Конструктор
|
||||
/// </summary>
|
||||
/// <param name="seaplane">Объект класса Seaplane</param>
|
||||
public MoveableSeaplane(DrawingSeaplane seaplane)
|
||||
public MoveableSeaplane(DrawingBasicSeaplane Seaplane)
|
||||
{
|
||||
_seaplane = seaplane;
|
||||
_seaplane = Seaplane;
|
||||
}
|
||||
/// <summary>
|
||||
/// АВТОКОРРЕКЦИЯ
|
||||
/// </summary>
|
||||
/// <param name="drawingBasicSeaplane"></param>
|
||||
public MoveableSeaplane(DrawingBasicSeaplane drawingBasicSeaplane)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public ObjectParameters? GetObjectPosition
|
||||
{
|
||||
get
|
||||
|
Loading…
Reference in New Issue
Block a user