namespace ProjectCruiser.MoveStrategy; public class MoveToBorder : AbstractStrategy { protected override bool IsTargetDestination() { ObjParameters? objP = GetObjectParameters; if (objP == null) { return false; } return FieldWidth - GetStep() < objP.RightBorder && FieldHeight - GetStep() < objP.DownBorder; } protected override void MoveToTarget() { ObjParameters? objP = GetObjectParameters; if (objP == null) { return; } int s = (int)GetStep(); int diffx = objP.RightBorder - FieldWidth; if (Math.Abs(diffx) > GetStep()) { if (diffx > 0) { MoveLeft(); } else { MoveRight(); } } int diffy = objP.DownBorder - FieldHeight; // (... - s) - step unnecessary if (Math.Abs(diffy) > GetStep()) { if (diffy > 0) { MoveUp(); } else { MoveDown(); } } } }