65 lines
2.8 KiB
C#
65 lines
2.8 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Text;
|
||
using System.Threading.Tasks;
|
||
using static ProjectContainerShip.Direction;
|
||
using ProjectContainerShip.Entities;
|
||
using System.Net.NetworkInformation;
|
||
|
||
namespace ProjectContainerShip.DrawningObjects
|
||
{
|
||
public class DrawningContainerShip : DrawningShip
|
||
{
|
||
/// <summary>
|
||
/// Инициализация свойств
|
||
/// </summary>
|
||
/// <param name="speed">Скорость</param>
|
||
/// <param name="weight">Вес</param>
|
||
/// <param name="bodyColor">Цвет палубы</param>
|
||
/// <param name="additionalColor">Дополнительный цвет</param>
|
||
/// <param name="crane">Признак наличия крана</param>
|
||
/// <param name="container">Признак наличия контейнеров</param>
|
||
/// <param name="width">Ширина картинки</param>
|
||
/// <param name="height">Высота картинки</param>
|
||
/// <returns>true - объект создан, false - проверка не пройдена, нельзя создать объект в этих размерах</returns>
|
||
public DrawningContainerShip(int speed, double weight, Color bodyColor, Color additionalColor, bool crane, bool container, int width, int height) :
|
||
base(speed, weight, bodyColor, width, height, 200, 30)
|
||
{
|
||
if (EntityShip != null)
|
||
{
|
||
EntityShip = new EntityContainerShip(speed, weight, bodyColor, additionalColor, crane, container);
|
||
}
|
||
}
|
||
public override void DrawTransport(Graphics g)
|
||
{
|
||
if (EntityShip is not EntityContainerShip containerShip)
|
||
{
|
||
return;
|
||
}
|
||
Brush additionalBrush = new SolidBrush(containerShip.AdditionalColor);
|
||
// Контейнер
|
||
if (containerShip.Container)
|
||
{
|
||
g.FillRectangle(additionalBrush, _startPosX + 55, _startPosY + 7, 35, 5);
|
||
}
|
||
//кран
|
||
if (containerShip.Crane)
|
||
{
|
||
Brush brBl = new SolidBrush(Color.Black);
|
||
g.FillRectangle(brBl, _startPosX + 110, _startPosY + 0, 3, 12);
|
||
g.FillRectangle(brBl, _startPosX + 105, _startPosY + 1, 20, 2);
|
||
}
|
||
// несколько контенеров
|
||
if (containerShip.Container)
|
||
{
|
||
g.FillRectangle(additionalBrush, _startPosX + 55, _startPosY + 2, 35, 5);
|
||
g.FillRectangle(additionalBrush, _startPosX + 135, _startPosY + 7, 35, 5);
|
||
g.FillRectangle(additionalBrush, _startPosX + 135, _startPosY + 2, 35, 5);
|
||
}
|
||
base.DrawTransport(g);
|
||
}
|
||
}
|
||
}
|
||
|