using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ProjectAirbus.MovementStrategy { internal class MoveToBorder : AbstractStrategy { // достигнута ли цель protected override bool IsTargetDestination() { var objParams = GetObjectParameters; if (objParams == null) { return false; } return objParams.RightBorder <= FieldWidth && objParams.RightBorder + GetStep() >= FieldWidth && objParams.DownBorder <= FieldHeight && objParams.DownBorder + GetStep() >= FieldHeight; } // движение к цели protected override void MoveToTarget() { var objParams = GetObjectParameters; if (objParams == null) { return; } var diffX = FieldWidth; if (Math.Abs(diffX) > GetStep()) { if (diffX < 0) { MoveLeft(); } else { MoveRight(); } } var diffY = FieldHeight; if (Math.Abs(diffY) > GetStep()) { if (diffY < 0) { MoveUp(); } else { MoveDown(); } } } } }