Upload files to 'lainer/Lainer1'
This commit is contained in:
parent
f631fce11e
commit
7d41cfe353
10
lainer/Lainer1/DirectionTypeEnum.cs
Normal file
10
lainer/Lainer1/DirectionTypeEnum.cs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
namespace ProjectLainer
|
||||||
|
{
|
||||||
|
public enum DirectionType
|
||||||
|
{
|
||||||
|
Up = 1,
|
||||||
|
Down = 2,
|
||||||
|
Left = 3,
|
||||||
|
Right = 4
|
||||||
|
}
|
||||||
|
}
|
144
lainer/Lainer1/DrawningLainer.cs
Normal file
144
lainer/Lainer1/DrawningLainer.cs
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
namespace ProjectLainer
|
||||||
|
{
|
||||||
|
public class DrawningLainer
|
||||||
|
{
|
||||||
|
public EntityLainer? EntityLainer { get; private set; }
|
||||||
|
private int _pictureWidth;
|
||||||
|
private int _pictureHeight;
|
||||||
|
private int _startPosX;
|
||||||
|
private int _startPosY;
|
||||||
|
private readonly int _LainerWidth = 150;
|
||||||
|
private readonly int _LainerHeight = 80;
|
||||||
|
public bool Init(int speed, double weight, Color bodyColor, Color additionalColor, bool ispool, bool addDecks, int width, int height)
|
||||||
|
{
|
||||||
|
if(width <= _LainerWidth || height <= _LainerHeight)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_pictureWidth = width;
|
||||||
|
_pictureHeight = height;
|
||||||
|
EntityLainer = new EntityLainer();
|
||||||
|
EntityLainer.Init(speed, weight, bodyColor, additionalColor, ispool, addDecks);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public void SetPosition(int x, int y)
|
||||||
|
{
|
||||||
|
if(x + _LainerWidth < _pictureWidth && x + _LainerWidth > 0)
|
||||||
|
{
|
||||||
|
_startPosX = x;
|
||||||
|
}
|
||||||
|
if (y + _LainerHeight < _pictureHeight && y + _LainerHeight > 0)
|
||||||
|
{
|
||||||
|
_startPosY = y;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void MoveTransport(DirectionType direction)
|
||||||
|
{
|
||||||
|
if (EntityLainer == null)
|
||||||
|
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch (direction)
|
||||||
|
{
|
||||||
|
//âëåâî
|
||||||
|
case DirectionType.Left:
|
||||||
|
if (_startPosX - EntityLainer.Step > 0)
|
||||||
|
{
|
||||||
|
_startPosX -= (int)EntityLainer.Step;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_startPosX = 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
//ââåðõ
|
||||||
|
case DirectionType.Up:
|
||||||
|
if (_startPosY - EntityLainer.Step > 0)
|
||||||
|
{
|
||||||
|
_startPosY -= (int)EntityLainer.Step;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_startPosY = 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
// âïðàâî
|
||||||
|
case DirectionType.Right:
|
||||||
|
if (_startPosX + EntityLainer.Step <= _pictureWidth - _LainerWidth)
|
||||||
|
{
|
||||||
|
_startPosX += (int)EntityLainer.Step;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_startPosX = _pictureWidth - _LainerWidth;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
//âíèç
|
||||||
|
case DirectionType.Down:
|
||||||
|
if (_startPosY + EntityLainer.Step <= _pictureHeight - _LainerHeight)
|
||||||
|
{
|
||||||
|
_startPosY += (int)EntityLainer.Step;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_startPosY = _pictureHeight - _LainerHeight;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void DrawTransport(Graphics g)
|
||||||
|
{
|
||||||
|
if (EntityLainer == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Brush brBlue = new SolidBrush(Color.LightBlue);
|
||||||
|
Pen pen = new(Color.Black);
|
||||||
|
Brush additionalBrush = new
|
||||||
|
SolidBrush(EntityLainer.AdditionalColor);
|
||||||
|
var brush = new SolidBrush(Color.Black);
|
||||||
|
// äîï ïàëóáû è îòðèñîâêà òðóá
|
||||||
|
Rectangle smokestack1 = new Rectangle(_startPosX + 20, _startPosY, 20, 50);
|
||||||
|
Rectangle smokestack2 = new Rectangle(_startPosX + 60, _startPosY, 20, 50);
|
||||||
|
g.FillRectangle(brush, smokestack1);
|
||||||
|
g.FillRectangle(brush, smokestack2);
|
||||||
|
if (EntityLainer.Decks)
|
||||||
|
{
|
||||||
|
Rectangle deck2 = new Rectangle(_startPosX + 10, _startPosY + 10, _LainerWidth - 18, 20);
|
||||||
|
g.FillRectangle(additionalBrush, deck2);
|
||||||
|
for (int i = 2; i < 6; i++)
|
||||||
|
{
|
||||||
|
g.FillEllipse(brBlue, _startPosX + i * 16, _startPosY + 15, 12, 12);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//ãðàíèöû ëàéíåðà
|
||||||
|
pen = new(Color.Red);
|
||||||
|
brush = new SolidBrush(Color.Red);
|
||||||
|
Point point1 = new Point(_startPosX, _startPosY + 50);
|
||||||
|
Point point2 = new Point(_startPosX + _LainerWidth, _startPosY+50);
|
||||||
|
Point point3 = new Point(_startPosX + 20, _startPosY+80);
|
||||||
|
Point point4 = new Point(_startPosX + 80, _startPosY + 80);
|
||||||
|
Point[] points = { point1, point2, point4, point3};
|
||||||
|
g.DrawPolygon(pen, points);
|
||||||
|
g.FillPolygon(brush, points);
|
||||||
|
//1 ïàëóáà
|
||||||
|
brush = new SolidBrush(Color.Green);
|
||||||
|
Rectangle deck = new Rectangle(_startPosX + 5, _startPosY + 30, _LainerWidth - 10, 20);
|
||||||
|
g.FillRectangle(brush,deck);
|
||||||
|
//ñòåêëà
|
||||||
|
for (int i = 1; i < 7; i++)
|
||||||
|
{
|
||||||
|
g.FillEllipse(brBlue, _startPosX + i*16, _startPosY + 33, 14, 14);
|
||||||
|
}
|
||||||
|
// áàññåéí
|
||||||
|
if (EntityLainer.Pool)
|
||||||
|
{
|
||||||
|
g.FillEllipse(brBlue, _startPosX + _LainerWidth - 35, _startPosY + _LainerHeight - 55, 35, 12);
|
||||||
|
brush = new SolidBrush(Color.DarkGray);
|
||||||
|
Rectangle rect2 = new Rectangle(_startPosX + _LainerWidth - 35, _startPosY + _LainerHeight - 50, 35, 20);
|
||||||
|
g.FillRectangle(brush, rect2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
23
lainer/Lainer1/EntityLainer.cs
Normal file
23
lainer/Lainer1/EntityLainer.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
namespace ProjectLainer
|
||||||
|
{
|
||||||
|
public class EntityLainer
|
||||||
|
{
|
||||||
|
public int Speed { get; private set; }
|
||||||
|
public double Weight { get; private set; }
|
||||||
|
public Color BodyColor { get; private set; }
|
||||||
|
public Color AdditionalColor { get; private set; }
|
||||||
|
public bool Pool { get; private set; }
|
||||||
|
public bool Decks { get; private set; }
|
||||||
|
public double Step => (double)Speed * 100 / Weight;
|
||||||
|
public void Init(int speed, double weight, Color bodyColor, Color
|
||||||
|
additionalColor, bool ispool, bool addDecks)
|
||||||
|
{
|
||||||
|
Speed = speed;
|
||||||
|
Weight = weight;
|
||||||
|
BodyColor = bodyColor;
|
||||||
|
AdditionalColor = additionalColor;
|
||||||
|
Pool = ispool;
|
||||||
|
Decks = addDecks;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
26
lainer/Lainer1/Lainer1.csproj
Normal file
26
lainer/Lainer1/Lainer1.csproj
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>WinExe</OutputType>
|
||||||
|
<TargetFramework>net6.0-windows</TargetFramework>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Update="Properties\Resources.Designer.cs">
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Update="Properties\Resources.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
</EmbeddedResource>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
Loading…
Reference in New Issue
Block a user