Доделан return в функции движения к краю

This commit is contained in:
Cat-pranks 2024-03-06 12:08:33 +04:00
parent 8cbceb87b7
commit ee25905cc2

View File

@ -15,10 +15,8 @@ public class MoveToBorder : AbstractStategy
{ {
return false; return false;
} }
return objParams.ObjectMiddleHorizontal - GetStep() <= FieldWidth return objParams.RightBorder <= FieldWidth && objParams.RightBorder + GetStep() >= FieldWidth &&
&& objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth && objParams.DownBorder <= FieldHeight && objParams.DownBorder + GetStep() >= FieldHeight;
objParams.ObjectMiddleVertical - GetStep() <= FieldHeight
&& objParams.ObjectMiddleVertical + GetStep() >= FieldHeight;
} }
protected override void MoveToTarget() protected override void MoveToTarget()
{ {
@ -30,7 +28,7 @@ public class MoveToBorder : AbstractStategy
int diffX = objParams.ObjectMiddleHorizontal - FieldWidth; int diffX = objParams.ObjectMiddleHorizontal - FieldWidth;
if (Math.Abs(diffX) > GetStep()) if (Math.Abs(diffX) > GetStep())
{ {
if (diffX < 0) if (diffX > 0)
{ {
MoveLeft(); MoveLeft();
} }
@ -42,7 +40,7 @@ public class MoveToBorder : AbstractStategy
int diffY = objParams.ObjectMiddleVertical - FieldHeight; int diffY = objParams.ObjectMiddleVertical - FieldHeight;
if (Math.Abs(diffY) > GetStep()) if (Math.Abs(diffY) > GetStep())
{ {
if (diffY < 0) if (diffY > 0)
{ {
MoveUp(); MoveUp();
} }