35 lines
1022 B
C#
35 lines
1022 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace ProjectFighterJet.MovementStrategy;
|
|
|
|
public class MoveToBorder : AbstractStrategy
|
|
{
|
|
protected override bool IsTargetDestinaion()
|
|
{
|
|
ObjectParameters? objParams = GetObjectParameters;
|
|
if (objParams == null)
|
|
{
|
|
return false;
|
|
}
|
|
return objParams.LeftBorder - GetStep() <= 0 ||
|
|
objParams.RightBorder + GetStep() >= FieldWidth ||
|
|
objParams.TopBorder - GetStep() <= 0
|
|
|| objParams.ObjectMiddleVertical + GetStep() >= FieldHeight;
|
|
}
|
|
protected override void MoveToTarget()
|
|
{
|
|
ObjectParameters? objParams = GetObjectParameters;
|
|
if (objParams == null)
|
|
{
|
|
return;
|
|
}
|
|
int x = objParams.RightBorder;
|
|
if (x + GetStep() < FieldWidth) MoveRight();
|
|
int y = objParams.DownBorder;
|
|
if (y + GetStep() < FieldHeight) MoveDown();
|
|
}
|
|
} |