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