Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
552b55aeca | |||
8721d19621 | |||
9671af356a | |||
6eb7548f3e | |||
614a721e04 |
@ -58,27 +58,13 @@ namespace AircraftCarrier
|
|||||||
/// <param name="width"></param>
|
/// <param name="width"></param>
|
||||||
/// <param name="height"></param>
|
/// <param name="height"></param>
|
||||||
public void SetPosition(int x, int y, int width, int height)
|
public void SetPosition(int x, int y, int width, int height)
|
||||||
|
{
|
||||||
|
if (width >= x + _warshipWidth && height >= y + _warshipHeight && x >= 0 && y >= 0)
|
||||||
{
|
{
|
||||||
_startPosX = x;
|
_startPosX = x;
|
||||||
_startPosY = y;
|
_startPosY = y;
|
||||||
_pictureWidth = width;
|
_pictureWidth = width;
|
||||||
_pictureHeight = height;
|
_pictureHeight = height;
|
||||||
|
|
||||||
if (width < _warshipWidth)
|
|
||||||
{
|
|
||||||
width = _warshipWidth;
|
|
||||||
}
|
|
||||||
if (height < _warshipHeight)
|
|
||||||
{
|
|
||||||
height = _warshipHeight;
|
|
||||||
}
|
|
||||||
if(x + _warshipWidth > width)
|
|
||||||
{
|
|
||||||
_startPosX -= x + _warshipWidth - width;
|
|
||||||
}
|
|
||||||
if (y + _warshipHeight > height)
|
|
||||||
{
|
|
||||||
_pictureHeight -= y + _warshipHeight - height;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -40,7 +40,5 @@ namespace AircraftCarrier
|
|||||||
Weight = weight <= 0 ? rnd.Next(40, 70) : weight;
|
Weight = weight <= 0 ? rnd.Next(40, 70) : weight;
|
||||||
BodyColor = bodyColor;
|
BodyColor = bodyColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user