Придумала проверки
This commit is contained in:
parent
5a20381dea
commit
289e6b6192
@ -24,43 +24,44 @@ namespace WarmlyShip
|
||||
/// </summary>
|
||||
private int _pictureHeight;
|
||||
/// <summary>
|
||||
/// Левая координата прорисовки автомобиля
|
||||
/// Левая координата прорисовки теплохода
|
||||
/// </summary>
|
||||
private int _startPosX;
|
||||
/// <summary>
|
||||
/// Верхняя кооридната прорисовки автомобиля
|
||||
/// Верхняя кооридната прорисовки теплохода
|
||||
/// </summary>
|
||||
private int _startPosY;
|
||||
/// <summary>
|
||||
/// Ширина прорисовки теплохода
|
||||
/// </summary>
|
||||
private readonly int _WarmlyShipWidth = 170;
|
||||
private readonly int _WarmlyShipWidth = 180;
|
||||
/// <summary>
|
||||
/// Высота прорисовки теплохода
|
||||
/// </summary>
|
||||
private readonly int _WarmlyShipHeight = 180;
|
||||
private readonly int _WarmlyShipHeight = 185;
|
||||
/// <summary>
|
||||
/// Инициализация свойств
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес</param>
|
||||
/// <param name="bodyColor">Цвет кузова</param>
|
||||
/// <param name="bodyColor">Цвет корпуса</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="bodyKit">Признак наличия обвеса</param>
|
||||
/// <param name="wing">Признак наличия антикрыла</param>
|
||||
/// <param name="sportLine">Признак наличия гоночной полосы</param>
|
||||
/// <param name="pipes">Признак наличия труб</param>
|
||||
/// <param name="section">Признак наличия отсека для топлива</param>
|
||||
/// <param name="width">Ширина картинки</param>
|
||||
/// <param name="height">Высота картинки</param>
|
||||
/// <returns>true - объект создан, false - проверка не пройдена,нельзя создать объект в этих размерах</returns>
|
||||
public bool Init(int speed, double weight, Color bodyColor, Color
|
||||
additionalColor, bool bodyKit, bool wing, bool sportLine, int width, int height)
|
||||
public bool Init(int speed, double weight, Color bodyColor, Color additionalColor, bool pipes, bool section,
|
||||
int width, int height)
|
||||
{
|
||||
// TODO: Продумать проверки
|
||||
if (width <_WarmlyShipWidth || height <_WarmlyShipHeight)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_pictureWidth = width;
|
||||
_pictureHeight = height;
|
||||
EntityWarmlyShip = new EntityWarmlyShip();
|
||||
EntityWarmlyShip.Init(speed, weight, bodyColor, additionalColor,
|
||||
bodyKit, wing, sportLine);
|
||||
EntityWarmlyShip.Init(speed, weight, bodyColor, additionalColor, pipes, section);
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
@ -70,10 +71,12 @@ additionalColor, bool bodyKit, bool wing, bool sportLine, int width, int height)
|
||||
/// <param name="y">Координата Y</param>
|
||||
public void SetPosition(int x, int y)
|
||||
{
|
||||
// TODO: Изменение x, y
|
||||
if (x >= 0 && x + _WarmlyShipWidth <= _pictureWidth && y >= 0 && y + _WarmlyShipHeight <= _pictureHeight)
|
||||
{
|
||||
_startPosX = x;
|
||||
_startPosY = y;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Изменение направления перемещения
|
||||
/// </summary>
|
||||
@ -132,26 +135,32 @@ additionalColor, bool bodyKit, bool wing, bool sportLine, int width, int height)
|
||||
//корпус теплохода
|
||||
Point[] hull = new Point[]
|
||||
{
|
||||
new Point(_startPosX + 10, _startPosY + 115),
|
||||
new Point(_startPosX + 190, _startPosY + 115),
|
||||
new Point(_startPosX + 150, _startPosY + 190),
|
||||
new Point(_startPosX + 50, _startPosY + 190),
|
||||
new Point(_startPosX, _startPosY + 110),
|
||||
new Point(_startPosX + 180, _startPosY + 110),
|
||||
new Point(_startPosX + 140, _startPosY + 185),
|
||||
new Point(_startPosX + 40, _startPosY + 185),
|
||||
};
|
||||
g.FillPolygon(additionalBrush, hull);
|
||||
g.DrawPolygon(pen, hull);
|
||||
Brush bra = new SolidBrush(EntityWarmlyShip.AdditionalColor);
|
||||
//палуба
|
||||
g.FillRectangle(bra, _startPosX + 35, _startPosY + 85, 130, 30);
|
||||
g.DrawRectangle(pen, _startPosX + 35, _startPosY + 85, 130, 30);
|
||||
g.FillRectangle(bra, _startPosX + 25, _startPosY + 80, 130, 30);
|
||||
g.DrawRectangle(pen, _startPosX + 25, _startPosY + 80, 130, 30);
|
||||
//отсек для топлива
|
||||
Brush brGray = new SolidBrush(Color.Gray);
|
||||
g.FillEllipse(brGray, _startPosX + 140, _startPosY + 130, 20, 20);
|
||||
g.DrawEllipse(pen, _startPosX + 140, _startPosY + 130, 20, 20);
|
||||
if (EntityWarmlyShip.Section)
|
||||
{
|
||||
g.FillEllipse(brGray, _startPosX + 130, _startPosY + 130, 20, 20);
|
||||
g.DrawEllipse(pen, _startPosX + 130, _startPosY + 130, 20, 20);
|
||||
}
|
||||
//трубы
|
||||
g.FillRectangle(additionalBrush, _startPosX + 65, _startPosY + 5, 25, 80);
|
||||
g.DrawRectangle(pen, _startPosX + 65, _startPosY + 5, 25, 80);
|
||||
g.FillRectangle(additionalBrush, _startPosX + 100, _startPosY + 25, 25, 60);
|
||||
g.DrawRectangle(pen, _startPosX + 100, _startPosY + 25, 25, 60);
|
||||
if (EntityWarmlyShip.Pipes)
|
||||
{
|
||||
g.FillRectangle(brGray, _startPosX + 55, _startPosY, 25, 80);
|
||||
g.DrawRectangle(pen, _startPosX + 55, _startPosY, 25, 80);
|
||||
g.FillRectangle(brGray, _startPosX + 90, _startPosY + 20, 25, 60);
|
||||
g.DrawRectangle(pen, _startPosX + 90, _startPosY + 20, 25, 60);
|
||||
}
|
||||
//якорь
|
||||
g.DrawLine(anchor, new Point(_startPosX + 50, _startPosY + 130), new Point(_startPosX + 50,_startPosY + 150));
|
||||
g.DrawLine(anchor, new Point(_startPosX + 40, _startPosY + 140), new Point(_startPosX + 60, _startPosY + 140));
|
||||
|
@ -25,41 +25,35 @@ namespace WarmlyShip
|
||||
/// </summary>
|
||||
public Color AdditionalColor { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак (опция) наличия обвеса
|
||||
/// Признак (опция) наличия труб
|
||||
/// </summary>
|
||||
public bool BodyKit { get; private set; }
|
||||
public bool Pipes { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак (опция) наличия антикрыла
|
||||
/// Признак (опция) наличия отсека для топлива
|
||||
/// </summary>
|
||||
public bool Wing { get; private set; }
|
||||
public bool Section { get; private set; }
|
||||
/// <summary>
|
||||
/// Признак (опция) наличия гоночной полосы
|
||||
/// </summary>
|
||||
public bool SportLine { get; private set; }
|
||||
/// <summary>
|
||||
/// Шаг перемещения автомобиля
|
||||
/// Шаг перемещения теплохода
|
||||
/// </summary>
|
||||
public double Step => (double)Speed * 100 / Weight;
|
||||
/// <summary>
|
||||
/// Инициализация полей объекта-класса спортивного автомобиля
|
||||
/// Инициализация полей объекта-класса теплохода
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес автомобиля</param>
|
||||
/// <param name="weight">Вес теплохода</param>
|
||||
/// <param name="bodyColor">Основной цвет</param>
|
||||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||||
/// <param name="bodyKit">Признак наличия обвеса</param>
|
||||
/// <param name="wing">Признак наличия антикрыла</param>
|
||||
/// <param name="sportLine">Признак наличия гоночной полосы</param>
|
||||
/// <param name="pipes">Признак наличия труб</param>
|
||||
/// <param name="section">Признак наличия отсека для топлива</param>
|
||||
public void Init(int speed, double weight, Color bodyColor, Color
|
||||
additionalColor, bool bodyKit, bool wing, bool sportLine)
|
||||
additionalColor, bool pipes, bool section)
|
||||
{
|
||||
Speed = speed;
|
||||
Weight = weight;
|
||||
BodyColor = bodyColor;
|
||||
AdditionalColor = additionalColor;
|
||||
BodyKit = bodyKit;
|
||||
Wing = wing;
|
||||
SportLine = sportLine;
|
||||
Pipes = pipes;
|
||||
Section = section;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -44,10 +44,9 @@ namespace WarmlyShip
|
||||
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)),
|
||||
pictureBoxWarmlyShip.Width, pictureBoxWarmlyShip.Height);
|
||||
_drawingWarmlyShip.SetPosition(random.Next(10, 100),
|
||||
random.Next(10, 100));
|
||||
_drawingWarmlyShip.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
Draw();
|
||||
}
|
||||
/// <summary>
|
||||
@ -92,12 +91,10 @@ namespace WarmlyShip
|
||||
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)),
|
||||
pictureBoxWarmlyShip.Width, pictureBoxWarmlyShip.Height);
|
||||
_drawingWarmlyShip.SetPosition(random.Next(10, 100),
|
||||
random.Next(10, 100));
|
||||
_drawingWarmlyShip.SetPosition(random.Next(10, 100), random.Next(10, 100));
|
||||
Draw();
|
||||
|
||||
}
|
||||
|
||||
private void ButtonMove_Click(object sender, EventArgs e)
|
||||
|
Loading…
Reference in New Issue
Block a user