PIbd-23_Dolgova_D.N._Warmly.../WarmlyShip/DrawningObjects/DrawningWarmlyShip.cs
2023-12-10 23:51:40 +04:00

89 lines
4.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WarmlyShip.Entities;
namespace WarmlyShip.DrawningObjects
{
/// <summary>
/// Класс, отвечающий за прорисовку и перемещение объекта-сущности
/// </summary>
public class DrawningWarmlyShip : DrawningShip
{
/// <summary>
/// Инициализация свойств
/// </summary>
/// <param name="speed">Скорость</param>
/// <param name="weight">Вес</param>
/// <param name="bodyColor">Цвет корпуса</param>
/// <param name="additionalColor">Дополнительный цвет</param>
/// <param name="pipe">Признак наличия труб</param>
/// <param name="fuelCompartment">Признак наличия отсека для топлива</param>
/// <param name="width">Ширина картинки</param>
/// <param name="height">Высота картинки</param>
/// <returns>true - объект создан, false - проверка не пройдена, нельзя создать объект в этих размерах</returns>
public DrawningWarmlyShip(int speed, double weight, Color bodyColor, Color
additionalColor, bool pipe, bool fuelCompartment, int width, int height) :
base(speed, weight, bodyColor, width, height, 140, 60)
{
if (EntityShip != null)
{
EntityShip = new EntityWarmlyShip(speed, weight, bodyColor,
additionalColor, pipe, fuelCompartment);
}
}
/// <summary>
/// Прорисовка объекта
/// </summary>
/// <param name="g"></param>
public override void DrawTransport(Graphics g)
{
if (EntityShip is not EntityWarmlyShip warmlyShip)
{
return;
}
Pen pen = new(Color.Black);
Brush additionalBrush = new SolidBrush(warmlyShip.AdditionalColor);
if (warmlyShip.Pipe)
{
//трубы
g.FillRectangle(additionalBrush, _startPosX + 20, _startPosY + 5, 10, 15);
g.DrawRectangle(pen, _startPosX + 20, _startPosY + 5, 10, 15);
g.FillRectangle(additionalBrush, _startPosX + 60, _startPosY + 5, 10, 15);
g.DrawRectangle(pen, _startPosX + 60, _startPosY + 5, 10, 15);
g.FillRectangle(additionalBrush, _startPosX + 100, _startPosY + 5, 10, 15);
g.DrawRectangle(pen, _startPosX + 100, _startPosY + 5, 10, 15);
Brush brBlack = new SolidBrush(Color.Black);
g.FillRectangle(brBlack, _startPosX + 20, _startPosY, 10, 5);
g.DrawRectangle(pen, _startPosX + 20, _startPosY, 10, 5);
g.FillRectangle(brBlack, _startPosX + 60, _startPosY, 10, 5);
g.DrawRectangle(pen, _startPosX + 60, _startPosY, 10, 5);
g.FillRectangle(brBlack, _startPosX + 100, _startPosY, 10, 5);
g.DrawRectangle(pen, _startPosX + 100, _startPosY, 10, 5);
}
base.DrawTransport(g);
if (warmlyShip.FuelCompartment)
{
// отсек под топливо
g.FillRectangle(additionalBrush, _startPosX + 30, _startPosY + 45, 20, 15);
g.DrawRectangle(pen, _startPosX + 30, _startPosY + 45, 20, 15);
g.FillRectangle(additionalBrush, _startPosX + 50, _startPosY + 45, 20, 15);
g.DrawRectangle(pen, _startPosX + 50, _startPosY + 45, 20, 15);
g.FillRectangle(additionalBrush, _startPosX + 70, _startPosY + 45, 20, 15);
g.DrawRectangle(pen, _startPosX + 70, _startPosY + 45, 20, 15);
}
}
public void SetAddColor(Color color)
{
((EntityWarmlyShip)EntityShip).AdditionalColor = color;
}
}
}