235 lines
7.9 KiB
C#
235 lines
7.9 KiB
C#
|
using ProjectCruiser;
|
|||
|
using System.Drawing.Drawing2D;
|
|||
|
|
|||
|
namespace ProjectCruiser;
|
|||
|
/// <summary>
|
|||
|
/// <20><><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// </summary>
|
|||
|
public class DrawningCruiser
|
|||
|
{
|
|||
|
/// <summary>
|
|||
|
/// <20><><EFBFBD><EFBFBD><EFBFBD>-<2D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// </summary>
|
|||
|
public EntityCruiser? EntityCruiser { get; private set; }
|
|||
|
/// <summary>
|
|||
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|||
|
/// </summary>
|
|||
|
private int? _pictureWidth;
|
|||
|
/// <summary>
|
|||
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|||
|
/// </summary>
|
|||
|
private int? _pictureHeight;
|
|||
|
/// <summary>
|
|||
|
/// <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// </summary>
|
|||
|
private int? _startPosX;
|
|||
|
/// <summary>
|
|||
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// </summary>
|
|||
|
private int? _startPosY;
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// </summary>
|
|||
|
private readonly int _drawningCruiserWidth = 110;
|
|||
|
/// <summary>
|
|||
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// </summary>
|
|||
|
private readonly int _drawningCruiserHeight = 60;
|
|||
|
/// <summary>
|
|||
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// </summary>
|
|||
|
/// <param name="speed"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|||
|
/// <param name="weight"><3E><><EFBFBD></param>
|
|||
|
/// <param name="bodyColor"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD></param>
|
|||
|
/// <param name="additionalColor"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD></param>
|
|||
|
/// <param name="helicopterArea"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|||
|
/// <param name="boat"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|||
|
/// <param name="wepon"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|||
|
public void Init(int speed, double weight, Color bodyColor, Color
|
|||
|
additionalColor, bool helicopterArea, bool boat, bool wepon)
|
|||
|
{
|
|||
|
EntityCruiser = new EntityCruiser();
|
|||
|
EntityCruiser.Init(speed, weight, bodyColor, additionalColor,
|
|||
|
helicopterArea, boat, wepon);
|
|||
|
_pictureWidth = null;
|
|||
|
_pictureHeight = null;
|
|||
|
_startPosX = null;
|
|||
|
_startPosY = null;
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|||
|
/// </summary>
|
|||
|
/// <param name="width"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD></param>
|
|||
|
/// <param name="height"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD></param>
|
|||
|
/// <returns>true - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, false - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></returns>
|
|||
|
public bool SetPictureSize(int width, int height)
|
|||
|
{
|
|||
|
// TODO <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>
|
|||
|
// <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
if (_startPosX + 150 > width)
|
|||
|
{
|
|||
|
_startPosX -= (_startPosX + 150) - width;
|
|||
|
}
|
|||
|
if (_startPosY + 80 > height)
|
|||
|
{
|
|||
|
_startPosY -= (_startPosY + 80) - height;
|
|||
|
}
|
|||
|
|
|||
|
_pictureWidth = width;
|
|||
|
_pictureHeight = height;
|
|||
|
return true;
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// </summary>
|
|||
|
/// <param name="x"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> X</param>
|
|||
|
/// <param name="y"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Y</param>
|
|||
|
public void SetPosition(int x, int y)
|
|||
|
{
|
|||
|
if (!_pictureHeight.HasValue || !_pictureWidth.HasValue)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
if(x + 150 > _pictureWidth)
|
|||
|
{
|
|||
|
x -= (x+150) - _pictureWidth.Value;
|
|||
|
}
|
|||
|
|
|||
|
if (y + 50 > _pictureHeight)
|
|||
|
{
|
|||
|
y -= (y+50) - _pictureHeight.Value;
|
|||
|
}
|
|||
|
// TODO <20><><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><> <20><><EFBFBD><EFBFBD><EFBFBD> "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>" <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
// <20><> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
_startPosX = x;
|
|||
|
_startPosY = y;
|
|||
|
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// </summary>
|
|||
|
/// <param name="direction"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|||
|
/// <returns>true - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, false - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></returns>
|
|||
|
public bool MoveTransport(DirectionType direction)
|
|||
|
{
|
|||
|
if (EntityCruiser == null || !_startPosX.HasValue || !_startPosY.HasValue)
|
|||
|
{
|
|||
|
return false;
|
|||
|
}
|
|||
|
switch (direction)
|
|||
|
{
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
case DirectionType.Left:
|
|||
|
if (_startPosX.Value - EntityCruiser.Step > 0)
|
|||
|
{
|
|||
|
_startPosX -= (int)EntityCruiser.Step;
|
|||
|
}
|
|||
|
|
|||
|
return true;
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
case DirectionType.Up:
|
|||
|
if (_startPosY.Value - EntityCruiser.Step > 0)
|
|||
|
{
|
|||
|
_startPosY -= (int)EntityCruiser.Step;
|
|||
|
}
|
|||
|
return true;
|
|||
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
case DirectionType.Right:
|
|||
|
if (_startPosX.Value >= 640)
|
|||
|
{
|
|||
|
return true;
|
|||
|
}
|
|||
|
//TODO <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
if (_startPosX.Value + EntityCruiser.Step > 0)
|
|||
|
{
|
|||
|
_startPosX += (int)EntityCruiser.Step;
|
|||
|
}
|
|||
|
return true;
|
|||
|
//<2F><><EFBFBD><EFBFBD>
|
|||
|
case DirectionType.Down:
|
|||
|
//TODO <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD>
|
|||
|
if(_startPosY.Value >= 390)
|
|||
|
{
|
|||
|
return true;
|
|||
|
}
|
|||
|
if (_startPosY.Value + EntityCruiser.Step > 0)
|
|||
|
{
|
|||
|
_startPosY += (int)EntityCruiser.Step;
|
|||
|
}
|
|||
|
return true;
|
|||
|
default:
|
|||
|
return false;
|
|||
|
}
|
|||
|
}
|
|||
|
/// <summary>
|
|||
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
/// </summary>
|
|||
|
/// <param name="g"></param>
|
|||
|
public void DrawTransport(Graphics g)
|
|||
|
{
|
|||
|
if (EntityCruiser == null || !_startPosX.HasValue ||
|
|||
|
!_startPosY.HasValue)
|
|||
|
{
|
|||
|
return;
|
|||
|
}
|
|||
|
Pen pen = new(Color.Black, 2);
|
|||
|
Brush additionalBrush = new SolidBrush(Color.Black);
|
|||
|
Brush weaponBrush = new SolidBrush(Color.Black);
|
|||
|
Brush weaponBrush2 = new SolidBrush(EntityCruiser.AdditionalColor);
|
|||
|
Brush helicopterAreaBrush = new HatchBrush(HatchStyle.ZigZag, EntityCruiser.AdditionalColor, Color.FromArgb(163, 163, 163));
|
|||
|
Brush boatBrush = new SolidBrush(EntityCruiser.AdditionalColor);
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
|||
|
g.DrawLine(pen, _startPosX.Value, _startPosY.Value, _startPosX.Value + 105, _startPosY.Value);
|
|||
|
g.DrawLine(pen, _startPosX.Value + 105, _startPosY.Value, _startPosX.Value + 147, _startPosY.Value + 24);
|
|||
|
|
|||
|
g.DrawLine(pen, _startPosX.Value, _startPosY.Value + 49, _startPosX.Value + 105, _startPosY.Value + 49);
|
|||
|
g.DrawLine(pen, _startPosX.Value + 105, _startPosY.Value + 49, _startPosX.Value + 147, _startPosY.Value + 24);
|
|||
|
|
|||
|
g.DrawLine(pen, _startPosX.Value, _startPosY.Value, _startPosX.Value, _startPosY.Value + 49);
|
|||
|
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
g.DrawEllipse(pen, _startPosX.Value + 94, _startPosY.Value + 14, 19, 19);
|
|||
|
|
|||
|
g.DrawRectangle(pen, _startPosX.Value + 63, _startPosY.Value + 11, 21, 28);
|
|||
|
g.DrawRectangle(pen, _startPosX.Value + 35, _startPosY.Value + 17, 28, 14);
|
|||
|
|
|||
|
//<2F><><EFBFBD>
|
|||
|
g.FillRectangle(additionalBrush, _startPosX.Value - 3, _startPosY.Value + 7, 3, 14);
|
|||
|
g.FillRectangle(additionalBrush, _startPosX.Value - 3, _startPosY.Value + 26, 3, 14);
|
|||
|
|
|||
|
if (EntityCruiser.HelicopterArea)
|
|||
|
{
|
|||
|
g.FillEllipse(helicopterAreaBrush, _startPosX.Value + 5, _startPosY.Value + 9, 25, 30);
|
|||
|
g.DrawEllipse(pen, _startPosX.Value + 5, _startPosY.Value + 9, 25, 30);
|
|||
|
}
|
|||
|
|
|||
|
if (EntityCruiser.Boat)
|
|||
|
{
|
|||
|
g.DrawEllipse(pen, _startPosX.Value + 34, _startPosY.Value + 2, 30, 7);
|
|||
|
g.FillEllipse(boatBrush, _startPosX.Value + 34, _startPosY.Value + 2, 30, 7);
|
|||
|
|
|||
|
g.DrawEllipse(pen, _startPosX.Value + 34, _startPosY.Value + 39, 30, 7);
|
|||
|
g.FillEllipse(boatBrush, _startPosX.Value + 34, _startPosY.Value + 39, 30, 7);
|
|||
|
}
|
|||
|
|
|||
|
if (EntityCruiser.Weapon)
|
|||
|
{
|
|||
|
g.DrawEllipse(pen, _startPosX.Value + 97, _startPosY.Value + 36, 10, 10);
|
|||
|
g.FillEllipse(weaponBrush2, _startPosX.Value + 97, _startPosY.Value + 36, 10, 10);
|
|||
|
|
|||
|
|
|||
|
g.FillRectangle(weaponBrush, _startPosX.Value + 107, _startPosY.Value + 40, 15, 5);
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|