if (Math.Round(enemyClone.position.y, 1) != Math.Round(player.position.y, 1) &&
Math.Round(enemyClone.position.x, 1) != Math.Round(player.position.x, 1))
{
if (Math.Abs(enemyClone.position.y - player.position.y) >
Math.Abs(enemyClone.position.x - player.position.x))
{
if (enemyClone.position.x < 0f)
{
Moved(270f); //Вправо
}
else if (enemyClone.position.x >= 0f)
{
Moved(90f); //Влево
}
}
else if (Math.Abs(enemyClone.position.y - player.position.y) <=
Math.Abs(enemyClone.position.x - player.position.x))
{
if (enemyClone.position.y < 0f)
{
Moved(0f); //Вверх
}
else if (enemyClone.position.y >= 0f)
{
Moved(180f); //Вниз
}
}
}
if (Math.Round(enemyClone.position.y, 1) == Math.Round(player.position.y, 1) &&
Math.Round(enemyClone.position.x, 1) != Math.Round(player.position.x, 1))
{
float dist = GetPos(player, enemyClone);
if (Math.Round(dist, 1) != 7f)
{
if (dist < 7f)
{
if (enemyClone.position.x < 0f)
{
Moved(90f); //Влево
}
else if (enemyClone.position.x >= 0f)
{
Moved(270f); //Вправо
}
}
else if (dist >= 7f)
{
if (enemyClone.position.x < 0f)
{
Moved(270f); //Вправо
}
else if (enemyClone.position.x >= 0f)
{
Moved(90f); //Влево
}
}
}
}
if (Math.Round(enemyClone.position.y, 1) != Math.Round(player.position.y, 1) &&
Math.Round(enemyClone.position.x, 1) != Math.Round(player.position.x, 1))
{
if (Math.Abs(enemyClone.position.y - player.position.y) >
Math.Abs(enemyClone.position.x - player.position.x))
{
if (enemyClone.position.x < 0f)
{
Moved(270f); //Вправо
}
else if (enemyClone.position.x >= 0f)
{
Moved(90f); //Влево
}
}
else if (Math.Abs(enemyClone.position.y - player.position.y) <=
Math.Abs(enemyClone.position.x - player.position.x))
{
if (enemyClone.position.y < 0f)
{
Moved(0f); //Вверх
}
else if (enemyClone.position.y >= 0f)
{
Moved(180f); //Вниз
}
}
}