rename base classes
This commit is contained in:
parent
336c2e7d1c
commit
19fd6bc82d
@ -6,13 +6,13 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace ProjectCatamaran.Drawnings;
|
namespace ProjectCatamaran.Drawnings;
|
||||||
public class DrawningCatamaranBase
|
public class DrawningBoat
|
||||||
{
|
{
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// класс-сущность
|
/// класс-сущность
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EntityCatamaranBase? EntityCatamaranBase { get; protected set; }
|
public EntityBoat? EntityBoat { get; protected set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ширина окна
|
/// ширина окна
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -57,7 +57,7 @@ public class DrawningCatamaranBase
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// пустой конструктор
|
/// пустой конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private DrawningCatamaranBase()
|
private DrawningBoat()
|
||||||
{
|
{
|
||||||
_pictureWidth = null;
|
_pictureWidth = null;
|
||||||
_pictureHeight = null;
|
_pictureHeight = null;
|
||||||
@ -70,9 +70,9 @@ public class DrawningCatamaranBase
|
|||||||
/// <param name="speed">Скорость</param>
|
/// <param name="speed">Скорость</param>
|
||||||
/// <param name="weight">Вес катера</param>
|
/// <param name="weight">Вес катера</param>
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
/// <param name="bodyColor">Основной цвет</param>
|
||||||
public DrawningCatamaranBase(int speed, double weight, Color bodyColor) : this()
|
public DrawningBoat(int speed, double weight, Color bodyColor) : this()
|
||||||
{
|
{
|
||||||
EntityCatamaranBase = new EntityCatamaranBase(speed, weight, bodyColor);
|
EntityBoat = new EntityBoat(speed, weight, bodyColor);
|
||||||
|
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -80,7 +80,7 @@ public class DrawningCatamaranBase
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="drawningCatamaranWidth">Ширина катера</param>
|
/// <param name="drawningCatamaranWidth">Ширина катера</param>
|
||||||
/// <param name="drawningCatamaranHeight">высота катера</param>
|
/// <param name="drawningCatamaranHeight">высота катера</param>
|
||||||
public DrawningCatamaranBase(int drawningCatamaranWidth, int drawningCatamaranHeight) : this()
|
public DrawningBoat(int drawningCatamaranWidth, int drawningCatamaranHeight) : this()
|
||||||
{
|
{
|
||||||
_drawningCatamaranWidth = drawningCatamaranWidth;
|
_drawningCatamaranWidth = drawningCatamaranWidth;
|
||||||
_drawningCatamaranHeight = drawningCatamaranHeight;
|
_drawningCatamaranHeight = drawningCatamaranHeight;
|
||||||
@ -129,34 +129,34 @@ public class DrawningCatamaranBase
|
|||||||
/// <returns>true - перемещение выполнено , false - перемещение невозможно</returns>
|
/// <returns>true - перемещение выполнено , false - перемещение невозможно</returns>
|
||||||
public bool MoveTransport(DirectionType direction)
|
public bool MoveTransport(DirectionType direction)
|
||||||
{
|
{
|
||||||
if (EntityCatamaranBase == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
if (EntityBoat == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
switch (direction)
|
switch (direction)
|
||||||
{
|
{
|
||||||
case DirectionType.Left:
|
case DirectionType.Left:
|
||||||
if (_startPosX.Value - EntityCatamaranBase.Step > 0)
|
if (_startPosX.Value - EntityBoat.Step > 0)
|
||||||
{
|
{
|
||||||
_startPosX -= (int)EntityCatamaranBase.Step;
|
_startPosX -= (int)EntityBoat.Step;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case DirectionType.Up:
|
case DirectionType.Up:
|
||||||
if (_startPosY.Value - EntityCatamaranBase.Step > 0)
|
if (_startPosY.Value - EntityBoat.Step > 0)
|
||||||
{
|
{
|
||||||
_startPosY -= (int)EntityCatamaranBase.Step;
|
_startPosY -= (int)EntityBoat.Step;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case DirectionType.Right:
|
case DirectionType.Right:
|
||||||
if (_startPosX.Value + (int)EntityCatamaranBase.Step + _drawningCatamaranWidth <= _pictureWidth)
|
if (_startPosX.Value + (int)EntityBoat.Step + _drawningCatamaranWidth <= _pictureWidth)
|
||||||
{
|
{
|
||||||
_startPosX += (int)EntityCatamaranBase.Step;
|
_startPosX += (int)EntityBoat.Step;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
case DirectionType.Down:
|
case DirectionType.Down:
|
||||||
if (_startPosY.Value + (int)EntityCatamaranBase.Step + _drawningCatamaranHeight <= _pictureHeight)
|
if (_startPosY.Value + (int)EntityBoat.Step + _drawningCatamaranHeight <= _pictureHeight)
|
||||||
{
|
{
|
||||||
_startPosY += (int)EntityCatamaranBase.Step;
|
_startPosY += (int)EntityBoat.Step;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
default:
|
default:
|
||||||
@ -169,11 +169,11 @@ public class DrawningCatamaranBase
|
|||||||
/// <param name="g"></param>
|
/// <param name="g"></param>
|
||||||
public virtual void DrawTransport(Graphics g)
|
public virtual void DrawTransport(Graphics g)
|
||||||
{
|
{
|
||||||
if (EntityCatamaranBase == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
if (EntityBoat == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Brush brBody = new SolidBrush(EntityCatamaranBase.BodyColor);
|
Brush brBody = new SolidBrush(EntityBoat.BodyColor);
|
||||||
|
|
||||||
g.FillRectangle(brBody, _startPosX.Value, _startPosY.Value, 40, 20);
|
g.FillRectangle(brBody, _startPosX.Value, _startPosY.Value, 40, 20);
|
||||||
Point[] triangle =
|
Point[] triangle =
|
@ -9,7 +9,7 @@ namespace ProjectCatamaran.Drawnings;
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// класс отвечающиай за перемещение и отрисовку
|
/// класс отвечающиай за перемещение и отрисовку
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class DrawningCatamaran : DrawningCatamaranBase
|
public class DrawningCatamaran : DrawningBoat
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
@ -23,12 +23,12 @@ public class DrawningCatamaran : DrawningCatamaranBase
|
|||||||
public DrawningCatamaran(int speed, double weight, Color bodyColor, Color additionalColor, bool floats, bool sail) :
|
public DrawningCatamaran(int speed, double weight, Color bodyColor, Color additionalColor, bool floats, bool sail) :
|
||||||
base(65,40)
|
base(65,40)
|
||||||
{
|
{
|
||||||
EntityCatamaranBase = new EntityCatamaran(speed, weight, bodyColor, additionalColor, floats, sail);
|
EntityBoat = new EntityCatamaran(speed, weight, bodyColor, additionalColor, floats, sail);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void DrawTransport(Graphics g)
|
public override void DrawTransport(Graphics g)
|
||||||
{
|
{
|
||||||
if (EntityCatamaranBase == null || EntityCatamaranBase is not EntityCatamaran catamaran || !_startPosX.HasValue || !_startPosY.HasValue)
|
if (EntityBoat == null || EntityBoat is not EntityCatamaran catamaran || !_startPosX.HasValue || !_startPosY.HasValue)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -7,9 +7,9 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ProjectCatamaran.Entities;
|
namespace ProjectCatamaran.Entities;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// класс-сущность "обычный катамаран"
|
/// класс-сущность "лодка"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class EntityCatamaranBase
|
public class EntityBoat
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Скорость
|
/// Скорость
|
||||||
@ -34,7 +34,7 @@ public class EntityCatamaranBase
|
|||||||
/// <param name="speed">Скорость</param>
|
/// <param name="speed">Скорость</param>
|
||||||
/// <param name="weight">Вес авто</param>
|
/// <param name="weight">Вес авто</param>
|
||||||
/// <param name="bodyColor">Основной цвет</param>
|
/// <param name="bodyColor">Основной цвет</param>
|
||||||
public EntityCatamaranBase(int speed, double weight, Color bodyColor)
|
public EntityBoat(int speed, double weight, Color bodyColor)
|
||||||
{
|
{
|
||||||
Speed = speed;
|
Speed = speed;
|
||||||
Weight = weight;
|
Weight = weight;
|
@ -2,7 +2,7 @@
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Класс-сущность "Катамарана"
|
/// Класс-сущность "Катамарана"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class EntityCatamaran : EntityCatamaranBase
|
public class EntityCatamaran : EntityBoat
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Дополнительный цвет(для опциональных элементов)
|
/// Дополнительный цвет(для опциональных элементов)
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
buttonRight = new Button();
|
buttonRight = new Button();
|
||||||
buttonLeft = new Button();
|
buttonLeft = new Button();
|
||||||
buttonDown = new Button();
|
buttonDown = new Button();
|
||||||
buttonCreateCatamaranBase = new Button();
|
buttonCreateBoat = new Button();
|
||||||
comboBoxStrategy = new ComboBox();
|
comboBoxStrategy = new ComboBox();
|
||||||
buttonStrategyStep = new Button();
|
buttonStrategyStep = new Button();
|
||||||
((System.ComponentModel.ISupportInitialize)pictureBoxCatamaran).BeginInit();
|
((System.ComponentModel.ISupportInitialize)pictureBoxCatamaran).BeginInit();
|
||||||
@ -45,7 +45,7 @@
|
|||||||
pictureBoxCatamaran.Dock = DockStyle.Fill;
|
pictureBoxCatamaran.Dock = DockStyle.Fill;
|
||||||
pictureBoxCatamaran.Location = new Point(0, 0);
|
pictureBoxCatamaran.Location = new Point(0, 0);
|
||||||
pictureBoxCatamaran.Name = "pictureBoxCatamaran";
|
pictureBoxCatamaran.Name = "pictureBoxCatamaran";
|
||||||
pictureBoxCatamaran.Size = new Size(800, 450);
|
pictureBoxCatamaran.Size = new Size(801, 450);
|
||||||
pictureBoxCatamaran.TabIndex = 0;
|
pictureBoxCatamaran.TabIndex = 0;
|
||||||
pictureBoxCatamaran.TabStop = false;
|
pictureBoxCatamaran.TabStop = false;
|
||||||
//
|
//
|
||||||
@ -108,16 +108,16 @@
|
|||||||
buttonDown.UseVisualStyleBackColor = true;
|
buttonDown.UseVisualStyleBackColor = true;
|
||||||
buttonDown.Click += ButtonMove_Click;
|
buttonDown.Click += ButtonMove_Click;
|
||||||
//
|
//
|
||||||
// buttonCreateCatamaranBase
|
// buttonCreateBoat
|
||||||
//
|
//
|
||||||
buttonCreateCatamaranBase.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
buttonCreateBoat.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
buttonCreateCatamaranBase.Location = new Point(184, 402);
|
buttonCreateBoat.Location = new Point(184, 402);
|
||||||
buttonCreateCatamaranBase.Name = "buttonCreateCatamaranBase";
|
buttonCreateBoat.Name = "buttonCreateBoat";
|
||||||
buttonCreateCatamaranBase.Size = new Size(166, 40);
|
buttonCreateBoat.Size = new Size(166, 40);
|
||||||
buttonCreateCatamaranBase.TabIndex = 6;
|
buttonCreateBoat.TabIndex = 6;
|
||||||
buttonCreateCatamaranBase.Text = "Создать базовый катамаран";
|
buttonCreateBoat.Text = "Создать лодку";
|
||||||
buttonCreateCatamaranBase.UseVisualStyleBackColor = true;
|
buttonCreateBoat.UseVisualStyleBackColor = true;
|
||||||
buttonCreateCatamaranBase.Click += ButtonCreateCatamaranBase_Click;
|
buttonCreateBoat.Click += ButtonCreateBoat_Click;
|
||||||
//
|
//
|
||||||
// comboBoxStrategy
|
// comboBoxStrategy
|
||||||
//
|
//
|
||||||
@ -147,7 +147,7 @@
|
|||||||
ClientSize = new Size(800, 450);
|
ClientSize = new Size(800, 450);
|
||||||
Controls.Add(buttonStrategyStep);
|
Controls.Add(buttonStrategyStep);
|
||||||
Controls.Add(comboBoxStrategy);
|
Controls.Add(comboBoxStrategy);
|
||||||
Controls.Add(buttonCreateCatamaranBase);
|
Controls.Add(buttonCreateBoat);
|
||||||
Controls.Add(buttonDown);
|
Controls.Add(buttonDown);
|
||||||
Controls.Add(buttonLeft);
|
Controls.Add(buttonLeft);
|
||||||
Controls.Add(buttonRight);
|
Controls.Add(buttonRight);
|
||||||
@ -168,7 +168,7 @@
|
|||||||
private Button buttonRight;
|
private Button buttonRight;
|
||||||
private Button buttonLeft;
|
private Button buttonLeft;
|
||||||
private Button buttonDown;
|
private Button buttonDown;
|
||||||
private Button buttonCreateCatamaranBase;
|
private Button buttonCreateBoat;
|
||||||
private ComboBox comboBoxStrategy;
|
private ComboBox comboBoxStrategy;
|
||||||
private Button buttonStrategyStep;
|
private Button buttonStrategyStep;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ namespace ProjectCatamaran
|
|||||||
{
|
{
|
||||||
public partial class FormCatamaran : Form
|
public partial class FormCatamaran : Form
|
||||||
{
|
{
|
||||||
private DrawningCatamaranBase? _drawningCatamaranBase;
|
private DrawningBoat? _drawningBoat;
|
||||||
private AbstractStrategy? _strategy;
|
private AbstractStrategy? _strategy;
|
||||||
public FormCatamaran()
|
public FormCatamaran()
|
||||||
{
|
{
|
||||||
@ -25,19 +25,19 @@ namespace ProjectCatamaran
|
|||||||
|
|
||||||
private void Draw()
|
private void Draw()
|
||||||
{
|
{
|
||||||
if (_drawningCatamaranBase == null)
|
if (_drawningBoat == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Bitmap bmp = new(pictureBoxCatamaran.Width, pictureBoxCatamaran.Height);
|
Bitmap bmp = new(pictureBoxCatamaran.Width, pictureBoxCatamaran.Height);
|
||||||
Graphics gr = Graphics.FromImage(bmp);
|
Graphics gr = Graphics.FromImage(bmp);
|
||||||
_drawningCatamaranBase.DrawTransport(gr);
|
_drawningBoat.DrawTransport(gr);
|
||||||
pictureBoxCatamaran.Image = bmp;
|
pictureBoxCatamaran.Image = bmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonMove_Click(object sender, EventArgs e)
|
private void ButtonMove_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_drawningCatamaranBase == null)
|
if (_drawningBoat == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -46,16 +46,16 @@ namespace ProjectCatamaran
|
|||||||
switch (name)
|
switch (name)
|
||||||
{
|
{
|
||||||
case "buttonUp":
|
case "buttonUp":
|
||||||
result = _drawningCatamaranBase.MoveTransport(DirectionType.Up);
|
result = _drawningBoat.MoveTransport(DirectionType.Up);
|
||||||
break;
|
break;
|
||||||
case "buttonDown":
|
case "buttonDown":
|
||||||
result = _drawningCatamaranBase.MoveTransport(DirectionType.Down);
|
result = _drawningBoat.MoveTransport(DirectionType.Down);
|
||||||
break;
|
break;
|
||||||
case "buttonLeft":
|
case "buttonLeft":
|
||||||
result = _drawningCatamaranBase.MoveTransport(DirectionType.Left);
|
result = _drawningBoat.MoveTransport(DirectionType.Left);
|
||||||
break;
|
break;
|
||||||
case "buttonRight":
|
case "buttonRight":
|
||||||
result = _drawningCatamaranBase.MoveTransport(DirectionType.Right);
|
result = _drawningBoat.MoveTransport(DirectionType.Right);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (result)
|
if (result)
|
||||||
@ -69,12 +69,12 @@ namespace ProjectCatamaran
|
|||||||
Random random = new();
|
Random random = new();
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case nameof(DrawningCatamaranBase):
|
case nameof(DrawningBoat):
|
||||||
_drawningCatamaranBase = new DrawningCatamaranBase(random.Next(100, 300), random.Next(1000, 3000),
|
_drawningBoat = new DrawningBoat(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)));
|
||||||
break;
|
break;
|
||||||
case nameof(DrawningCatamaran):
|
case nameof(DrawningCatamaran):
|
||||||
_drawningCatamaranBase = new DrawningCatamaran(random.Next(100, 300), random.Next(1000, 3000),
|
_drawningBoat = new DrawningCatamaran(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)),
|
||||||
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(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)));
|
||||||
@ -82,8 +82,8 @@ namespace ProjectCatamaran
|
|||||||
default:
|
default:
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_drawningCatamaranBase.SetPictureSize(pictureBoxCatamaran.Width, pictureBoxCatamaran.Height);
|
_drawningBoat.SetPictureSize(pictureBoxCatamaran.Width, pictureBoxCatamaran.Height);
|
||||||
_drawningCatamaranBase.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
_drawningBoat.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||||
_strategy = null;
|
_strategy = null;
|
||||||
comboBoxStrategy.Enabled = true;
|
comboBoxStrategy.Enabled = true;
|
||||||
Draw();
|
Draw();
|
||||||
@ -93,9 +93,9 @@ namespace ProjectCatamaran
|
|||||||
CreateObject(nameof(DrawningCatamaran));
|
CreateObject(nameof(DrawningCatamaran));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonCreateCatamaranBase_Click(object sender, EventArgs e)
|
private void ButtonCreateBoat_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
CreateObject(nameof(DrawningCatamaranBase));
|
CreateObject(nameof(DrawningBoat));
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Обработка нажатия кнопки "Шаг"
|
/// Обработка нажатия кнопки "Шаг"
|
||||||
@ -104,7 +104,7 @@ namespace ProjectCatamaran
|
|||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void ButtonStrategyStep_Click(object sender, EventArgs e)
|
private void ButtonStrategyStep_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_drawningCatamaranBase == null)
|
if (_drawningBoat == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ namespace ProjectCatamaran
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_strategy.SetData(new MoveableCatamaranBase(_drawningCatamaranBase),
|
_strategy.SetData(new MoveableBoat(_drawningBoat),
|
||||||
pictureBoxCatamaran.Width, pictureBoxCatamaran.Height);
|
pictureBoxCatamaran.Width, pictureBoxCatamaran.Height);
|
||||||
}
|
}
|
||||||
if (_strategy == null)
|
if (_strategy == null)
|
||||||
|
@ -7,45 +7,45 @@ using ProjectCatamaran.Drawnings;
|
|||||||
|
|
||||||
namespace ProjectCatamaran.MovementStrategy
|
namespace ProjectCatamaran.MovementStrategy
|
||||||
{
|
{
|
||||||
internal class MoveableCatamaranBase : IMoveableObject
|
internal class MoveableBoat : IMoveableObject
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Поле-объект класса DrawningCatamaranBase или его наследника
|
/// Поле-объект класса DrawningBoat или его наследника
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private DrawningCatamaranBase _catamaranBase = null;
|
private DrawningBoat _boat = null;
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конструктор
|
/// Конструктор
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="car">Объект класса DrawningCatamaranBase</param>
|
/// <param name="car">Объект класса DrawningBoat</param>
|
||||||
public MoveableCatamaranBase(DrawningCatamaranBase catamaranBase)
|
public MoveableBoat(DrawningBoat boat)
|
||||||
{
|
{
|
||||||
_catamaranBase = catamaranBase;
|
_boat = boat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ObjectParameters? GetObjectPosition
|
public ObjectParameters? GetObjectPosition
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_catamaranBase == null || _catamaranBase.EntityCatamaranBase == null || !_catamaranBase.GetPosX.HasValue
|
if (_boat == null || _boat.EntityBoat == null || !_boat.GetPosX.HasValue
|
||||||
|| !_catamaranBase.GetPosY.HasValue)
|
|| !_boat.GetPosY.HasValue)
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ObjectParameters(_catamaranBase.GetPosX.Value, _catamaranBase.GetPosY.Value,
|
return new ObjectParameters(_boat.GetPosX.Value, _boat.GetPosY.Value,
|
||||||
_catamaranBase.GetWidth, _catamaranBase.GetHeight);
|
_boat.GetWidth, _boat.GetHeight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int GetStep => (int)(_catamaranBase?.EntityCatamaranBase?.Step ?? 0);
|
public int GetStep => (int)(_boat?.EntityBoat?.Step ?? 0);
|
||||||
public bool TryMoveObject(MovementDirection direction)
|
public bool TryMoveObject(MovementDirection direction)
|
||||||
{
|
{
|
||||||
if (_catamaranBase == null || _catamaranBase.EntityCatamaranBase == null)
|
if (_boat == null || _boat.EntityBoat == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return _catamaranBase.MoveTransport(GetDirectionType(direction));
|
return _boat.MoveTransport(GetDirectionType(direction));
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Конвертация из MovementDirection в DirectionType
|
/// Конвертация из MovementDirection в DirectionType
|
Loading…
x
Reference in New Issue
Block a user