Gruppe22.Backend.Map.WhichWayIs C# (CSharp) Метод

WhichWayIs() публичный статический Метод

Determine which way one square is from another
public static WhichWayIs ( Coords from, Backend to, bool DirectOnly = false ) : Direction
from Coords Source square
to Backend Target Square
DirectOnly bool false (default) if diagonals are allowed
Результат Direction
        public static Direction WhichWayIs(Coords from, Backend.Coords to, bool DirectOnly = false)
        {
            if (from.x < to.x)
            {
                if (from.y < to.y)
                {
                    if (!DirectOnly)
                        return Direction.UpLeft;
                    else
                        return Direction.Up;
                }
                else
                {
                    if (from.y > to.y)
                    {
                        if (!DirectOnly)
                            return Direction.DownLeft;
                        else
                            return Direction.Left;
                    }
                    else
                    {
                        return Direction.Left;
                    }
                }
            }
            else
            {
                if (from.x > to.x)
                {

                    if (from.y < to.y)
                    {
                        if (!DirectOnly)
                            return Direction.UpRight;
                        else
                            return Direction.Up;
                    }
                    else
                    {
                        if (from.y > to.y)
                        {
                            if (!DirectOnly)
                                return Direction.DownRight;
                            else
                                return Direction.Right;
                        }
                        else
                        {
                            return Direction.Right;
                        }
                    }
                }
                else
                {
                    if (from.y < to.y)
                    {
                        return Direction.Up;
                    }
                    else
                    {
                        if (from.y > to.y)
                        {
                            return Direction.Down;
                        }
                    }
                }
            }
            return Direction.None;
        }