Novopolltsev.A.A. TwoStep #1
@ -7,20 +7,20 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Warship
|
||||
{
|
||||
internal class DrawningShip
|
||||
public class DrawningShip
|
||||
{
|
||||
/// <summary>
|
||||
/// Класс-сущность
|
||||
/// </summary>
|
||||
public EntityShip Ship { private set; get; }
|
||||
public EntityShip Ship { protected set; get; }
|
||||
/// <summary>
|
||||
/// Левая координата отрисовки лодки
|
||||
/// </summary>
|
||||
private float _startPosX;
|
||||
protected float _startPosX;
|
||||
/// <summary>
|
||||
/// Верхняя кооридната отрисовки лодки
|
||||
/// </summary>
|
||||
private float _startPosY;
|
||||
protected float _startPosY;
|
||||
/// <summary>
|
||||
/// Ширина окна отрисовки
|
||||
/// </summary>
|
||||
@ -32,7 +32,7 @@ namespace Warship
|
||||
/// <summary>
|
||||
/// Ширина отрисовки лодки
|
||||
/// </summary>
|
||||
private readonly int _shipWidth = 120;
|
||||
private readonly int _shipWidth = 125;
|
||||
/// <summary>
|
||||
/// Высота отрисовки лодки
|
||||
/// </summary>
|
||||
@ -43,10 +43,14 @@ namespace Warship
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес лодки</param>
|
||||
/// <param name="bodyColor">Цвет кузова</param>
|
||||
public void Init(int speed, float weight, Color bodyColor)
|
||||
public DrawningShip(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Ship = new EntityShip();
|
||||
Ship.Init(speed, weight, bodyColor);
|
||||
Ship = new EntityShip(speed, weight, bodyColor);
|
||||
}
|
||||
protected DrawningShip(int speed, float weight, Color bodyColor, int shipWight, int shipHeight) : this(speed, weight, bodyColor)
|
||||
{
|
||||
_shipWidth = shipWight;
|
||||
_shipHeight = shipHeight;
|
||||
}
|
||||
/// <summary>
|
||||
/// Установка позиции корабля
|
||||
@ -111,8 +115,17 @@ namespace Warship
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public bool DrawCheck()
|
||||
{
|
||||
if (_startPosX < 0 || _startPosY < 0 || !_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// <param name="g"></param>
|
||||
public void DrawTransport(Graphics g)
|
||||
public virtual void DrawTransport(Graphics g)
|
||||
{
|
||||
if (_startPosX < 0 || _startPosY < 0
|
||||
|| !_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
||||
@ -165,5 +178,10 @@ namespace Warship
|
||||
_startPosY = _pictureHeight.Value - _shipHeight;
|
||||
}
|
||||
}
|
||||
|
||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||
{
|
||||
return (_startPosX, _startPosY, _startPosX + _shipWidth, _startPosY + _shipHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Warship
|
||||
{
|
||||
internal class EntityShip
|
||||
public class EntityShip
|
||||
|
||||
{
|
||||
/// <summary>
|
||||
@ -32,7 +32,7 @@ namespace Warship
|
||||
/// <param name="weight"></param>
|
||||
/// <param name="bodyColor"></param>
|
||||
/// <returns></returns>
|
||||
public void Init(int speed, float weight, Color bodyColor)
|
||||
public EntityShip(int speed, float weight, Color bodyColor)
|
||||
{
|
||||
Random rnd = new();
|
||||
Speed = speed <= 0 ? rnd.Next(50, 150) : speed;
|
||||
|
Loading…
Reference in New Issue
Block a user