Beispiel #1
0
        public static Vector2 GetAdjacent(this Vector2 vector, BorderSide side)
        {
            switch (side)
            {
            case BorderSide.Top: return(vector.Translate(0, -1));

            case BorderSide.Left: return(vector.Translate(-1, 0));

            case BorderSide.Right: return(vector.Translate(1, 0));

            case BorderSide.Bottom: return(vector.Translate(0, 1));

            case BorderSide.TopLeftCorner: return(vector.Translate(-1, -1));

            case BorderSide.TopRightCorner: return(vector.Translate(1, -1));

            case BorderSide.BottomLeftCorner: return(vector.Translate(-1, 1));

            case BorderSide.BottomRightCorner: return(vector.Translate(1, 1));

            case BorderSide.None: return(vector.Translate(0, 0));

            default: throw new NotImplementedException();
            }
        }
Beispiel #2
0
 public static Vector2 GetAdjacent(this Vector2 vector, Direction dir)
 {
     return(vector.Translate(dir.ToXY()));
 }