Exemple #1
0
        public static void Draw(Bounds bounds, Direction4 direction, float length = 1f)
        {
            if (direction.IsHorizontal())
            {
                Vector2 originTop = (Vector2)bounds.center + new Vector2(bounds.extents.x * direction.Sign(), bounds.extents.y);
                Debug.DrawLine(originTop, originTop + direction.ToVector2(length), Color.magenta);

                Vector2 originCenter = (Vector2)bounds.center + new Vector2(bounds.extents.x * direction.Sign(), 0);
                Debug.DrawLine(originCenter, originCenter + direction.ToVector2(length), Color.magenta);

                Vector2 originBottom = (Vector2)bounds.center + new Vector2(bounds.extents.x * direction.Sign(), -bounds.extents.y);
                Debug.DrawLine(originBottom, originBottom + direction.ToVector2(length), Color.magenta);
            }
            else
            {
                Vector2 originLeft = (Vector2)bounds.center + new Vector2(-bounds.extents.x, bounds.extents.y * direction.Sign());
                Debug.DrawLine(originLeft, originLeft + direction.ToVector2(length), Color.magenta);

                Vector2 originCenter = (Vector2)bounds.center + new Vector2(0, bounds.extents.y * direction.Sign());
                Debug.DrawLine(originCenter, originCenter + direction.ToVector2(length), Color.magenta);

                Vector2 originRight = (Vector2)bounds.center + new Vector2(bounds.extents.x, bounds.extents.y * direction.Sign());
                Debug.DrawLine(originRight, originRight + direction.ToVector2(length), Color.magenta);
            }
        }
Exemple #2
0
 public static Direction2V ToDirection2V(this Direction4 direction)
 {
     if (direction.IsHorizontal())
     {
         throw new Exception("Passed horizontal direction4 in place of vertical");
     }
     return(direction == Direction4.Up ? Direction2V.Up : Direction2V.Down);
 }
 public bool IsHorizontal() => dir4.IsHorizontal();
Exemple #4
0
 public static Orientation ToOrientation(this Direction4 direction) =>
 direction.IsHorizontal() ? Orientation.Horizontal : Orientation.Vertical;