LabWork02 #3
@ -12,16 +12,16 @@ namespace AircraftCarrier
|
||||
/// Инициализация свойств
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес автомобиля</param>
|
||||
/// <param name="bodyColor">Цвет кузова</param>
|
||||
/// <param name="weight">Вес военного корабля</param>
|
||||
/// <param name="bodyColor">Цвет основной палубы</param>
|
||||
/// <param name="dopColor">Дополнительный цвет</param>
|
||||
/// <param name="bodyKit">Признак наличия обвеса</param>
|
||||
/// <param name="wing">Признак наличия антикрыла</param>
|
||||
/// <param name="sportLine">Признак наличия гоночной полосы</param>
|
||||
public DrawingAircraftCarrier(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool wing, bool sportLine) :
|
||||
base(speed, weight, bodyColor, 110, 60)
|
||||
/// <param name="bodyKit">Признак наличия боковой площадки</param>
|
||||
/// <param name="сabin">Признак наличия рубки</param>
|
||||
/// <param name="superEngine">Признак наличия усиленного двигателя</param>
|
||||
public DrawingAircraftCarrier(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool сabin, bool superEngine) :
|
||||
base(speed, weight, bodyColor, 114, 40)
|
||||
{
|
||||
Warship = new EntityAircraftCarrier(speed, weight, bodyColor, dopColor, bodyKit, wing, sportLine);
|
||||
Warship = new EntityAircraftCarrier(speed, weight, bodyColor, dopColor, bodyKit, сabin, superEngine);
|
||||
}
|
||||
|
||||
public override void DrawTransport(Graphics g)
|
||||
|
39
AircraftCarrier/AircraftCarrier/DrawingObjectWarship.cs
Normal file
39
AircraftCarrier/AircraftCarrier/DrawingObjectWarship.cs
Normal file
@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AircraftCarrier
|
||||
{
|
||||
internal class DrawingObjectWarship : IDrawingObject
|
||||
{
|
||||
private DrawingWarship _warship = null;
|
||||
|
||||
public DrawingObjectWarship(DrawingWarship warship)
|
||||
{
|
||||
_warship = warship;
|
||||
}
|
||||
public float Step => _warship?.Warship?.Step ?? 0;
|
||||
|
||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||
{
|
||||
return _warship?.GetCurrentPosition() ?? default;
|
||||
}
|
||||
|
||||
public void MoveObject(Direction direction)
|
||||
{
|
||||
_warship?.MoveTransport(direction);
|
||||
}
|
||||
|
||||
public void SetObject(int x, int y, int width, int height)
|
||||
{
|
||||
_warship.SetPosition(x, y, width, height);
|
||||
}
|
||||
|
||||
void IDrawingObject.DrawningObject(Graphics g)
|
||||
{
|
||||
_warship.DrawTransport(g);
|
||||
}
|
||||
}
|
||||
}
|
@ -199,6 +199,14 @@ namespace AircraftCarrier
|
||||
_startPosY = _pictureHeight.Value - _warshipHeight;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Получение текущей позиции объекта
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public (float Left, float Right, float Top, float Bottom) GetCurrentPosition()
|
||||
{
|
||||
return (_startPosX, _startPosY, _startPosX + _warshipWidth, _startPosY + _warshipHeight);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -28,19 +28,19 @@ namespace AircraftCarrier
|
||||
/// Инициализация свойств
|
||||
/// </summary>
|
||||
/// <param name="speed">Скорость</param>
|
||||
/// <param name="weight">Вес автомобиля</param>
|
||||
/// <param name="bodyColor">Цвет кузова</param>
|
||||
/// <param name="weight">Вес военного корабля</param>
|
||||
/// <param name="bodyColor">Цвет основной палубы</param>
|
||||
/// <param name="dopColor">Дополнительный цвет</param>
|
||||
/// <param name="bodyKit">Признак наличия обвеса</param>
|
||||
/// <param name="wing">Признак наличия антикрыла</param>
|
||||
/// <param name="sportLine">Признак наличия гоночной полосы</param>
|
||||
public EntityAircraftCarrier(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool wing, bool sportLine) :
|
||||
/// <param name="bodyKit">Признак наличия боковой площадки</param>
|
||||
/// <param name="сabin">Признак наличия рубки</param>
|
||||
/// <param name="superEngine">Признак наличия усиленного двигателя</param>
|
||||
public EntityAircraftCarrier(int speed, float weight, Color bodyColor, Color dopColor, bool bodyKit, bool сabin, bool superEngine) :
|
||||
base(speed, weight, bodyColor)
|
||||
{
|
||||
DopColor = dopColor;
|
||||
BodyKit = bodyKit;
|
||||
Сabin = wing;
|
||||
SuperEngine = sportLine;
|
||||
Сabin = сabin;
|
||||
SuperEngine = superEngine;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
43
AircraftCarrier/AircraftCarrier/IDrawingObject.cs
Normal file
43
AircraftCarrier/AircraftCarrier/IDrawingObject.cs
Normal file
@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AircraftCarrier
|
||||
{
|
||||
/// <summary>
|
||||
/// Интерфейс для работы с объектом, прорисовываемым на форме
|
||||
/// </summary>
|
||||
internal interface IDrawingObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Шаг перемещения объекта
|
||||
/// </summary>
|
||||
public float Step { get; }
|
||||
/// <summary>
|
||||
/// Установка позиции объекта
|
||||
/// </summary>
|
||||
/// <param name="x">Координата X</param>
|
||||
/// <param name="y">Координата Y</param>
|
||||
/// <param name="width">Ширина полотна</param>
|
||||
/// <param name="height">Высота полотна</param>
|
||||
void SetObject(int x, int y, int width, int height);
|
||||
/// <summary>
|
||||
/// Изменение направления пермещения объекта
|
||||
/// </summary>
|
||||
/// <param name="direction">Направление</param>
|
||||
/// <returns></returns>
|
||||
void MoveObject(Direction direction);
|
||||
/// <summary>
|
||||
/// Отрисовка объекта
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
void DrawningObject(Graphics g);
|
||||
/// <summary>
|
||||
/// Получение текущей позиции объекта
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
(float Left, float Right, float Top, float Bottom) GetCurrentPosition();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user