You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.1 KiB

namespace WebApplication1
{
public static class FigureMover
{
public static readonly int FieldYMin = 0;
public static readonly int FieldYMax = 7;
public static readonly int FieldXMin = 0;
public static readonly int FieldXMax = 7;
public static bool Move(Figure figure)
{
if (figure.FigureType == 1)
{
return h_MoveSimple(figure);
}
return false;
}
private static bool h_MoveSimple(Figure figure)
{
bool bDirectionUp = false;
if (figure.FigureColor == 1)
{
bDirectionUp = true;
}
int iInc = bDirectionUp ? 1 : -1;
figure.PosY += iInc;
if (figure.PosY < FieldYMin)
{
figure.PosY = FieldYMin;
return false;
}
if (figure.PosY > FieldYMax)
{
figure.PosY = FieldYMax;
return false;
}
return true;
}
}
}