Ejemplo n.º 1
0
        static public CardinalOrdinalDirection GetNext(this CardinalOrdinalDirection item, RotationDirection direction)
        {
            switch (direction)
            {
            case RotationDirection.Clockwise: return(item.GetClockwiseNext());

            case RotationDirection.CounterClockwise: return(item.GetCounterClockwiseNext());
            }

            throw new UnaccountedBranchException("direction", direction);
        }
Ejemplo n.º 2
0
        static public Vector2 GetVector2(this CardinalOrdinalDirection item)
        {
            switch (item)
            {
            case CardinalOrdinalDirection.Right: return(new Vector2(1.0f, 0.0f));

            case CardinalOrdinalDirection.RightUp: return(new Vector2(Mathq.DIAGONAL, Mathq.DIAGONAL));

            case CardinalOrdinalDirection.Up: return(new Vector2(0.0f, 1.0f));

            case CardinalOrdinalDirection.LeftUp: return(new Vector2(-Mathq.DIAGONAL, Mathq.DIAGONAL));

            case CardinalOrdinalDirection.Left: return(new Vector2(-1.0f, 0.0f));

            case CardinalOrdinalDirection.LeftDown: return(new Vector2(-Mathq.DIAGONAL, -Mathq.DIAGONAL));

            case CardinalOrdinalDirection.Down: return(new Vector2(0.0f, -1.0f));

            case CardinalOrdinalDirection.RightDown: return(new Vector2(Mathq.DIAGONAL, -Mathq.DIAGONAL));
            }

            throw new UnaccountedBranchException("item", item);
        }
Ejemplo n.º 3
0
        static public float GetAngleInPercent(this CardinalOrdinalDirection item)
        {
            switch (item)
            {
            case CardinalOrdinalDirection.Right: return(0.0f / 8.0f);

            case CardinalOrdinalDirection.RightUp: return(1.0f / 8.0f);

            case CardinalOrdinalDirection.Up: return(2.0f / 8.0f);

            case CardinalOrdinalDirection.LeftUp: return(3.0f / 8.0f);

            case CardinalOrdinalDirection.Left: return(4.0f / 8.0f);

            case CardinalOrdinalDirection.LeftDown: return(5.0f / 8.0f);

            case CardinalOrdinalDirection.Down: return(6.0f / 8.0f);

            case CardinalOrdinalDirection.RightDown: return(7.0f / 8.0f);
            }

            throw new UnaccountedBranchException("item", item);
        }
Ejemplo n.º 4
0
        static public CardinalOrdinalDirection GetClockwiseNext(this CardinalOrdinalDirection item)
        {
            switch (item)
            {
            case CardinalOrdinalDirection.Right: return(CardinalOrdinalDirection.RightDown);

            case CardinalOrdinalDirection.RightDown: return(CardinalOrdinalDirection.Down);

            case CardinalOrdinalDirection.Down: return(CardinalOrdinalDirection.LeftDown);

            case CardinalOrdinalDirection.LeftDown: return(CardinalOrdinalDirection.Left);

            case CardinalOrdinalDirection.Left: return(CardinalOrdinalDirection.LeftUp);

            case CardinalOrdinalDirection.LeftUp: return(CardinalOrdinalDirection.Up);

            case CardinalOrdinalDirection.Up: return(CardinalOrdinalDirection.RightUp);

            case CardinalOrdinalDirection.RightUp: return(CardinalOrdinalDirection.Right);
            }

            throw new UnaccountedBranchException("item", item);
        }
Ejemplo n.º 5
0
        static public VectorF2 GetVectorF2(this CardinalOrdinalDirection item)
        {
            switch (item)
            {
            case CardinalOrdinalDirection.Right: return(VectorF2.RIGHT);

            case CardinalOrdinalDirection.RightUp: return(VectorF2.RIGHT_UP);

            case CardinalOrdinalDirection.Up: return(VectorF2.UP);

            case CardinalOrdinalDirection.LeftUp: return(VectorF2.LEFT_UP);

            case CardinalOrdinalDirection.Left: return(VectorF2.LEFT);

            case CardinalOrdinalDirection.LeftDown: return(VectorF2.LEFT_DOWN);

            case CardinalOrdinalDirection.Down: return(VectorF2.DOWN);

            case CardinalOrdinalDirection.RightDown: return(VectorF2.RIGHT_DOWN);
            }

            throw new UnaccountedBranchException("item", item);
        }
        static public GamepadStickZone GetGamepadStickZone(this CardinalOrdinalDirection item)
        {
            switch (item)
            {
            case CardinalOrdinalDirection.Right: return(GamepadStickZone.Right);

            case CardinalOrdinalDirection.RightUp: return(GamepadStickZone.RightUp);

            case CardinalOrdinalDirection.Up: return(GamepadStickZone.Up);

            case CardinalOrdinalDirection.LeftUp: return(GamepadStickZone.LeftUp);

            case CardinalOrdinalDirection.Left: return(GamepadStickZone.Left);

            case CardinalOrdinalDirection.LeftDown: return(GamepadStickZone.LeftDown);

            case CardinalOrdinalDirection.Down: return(GamepadStickZone.Down);

            case CardinalOrdinalDirection.RightDown: return(GamepadStickZone.RightDown);
            }

            throw new UnaccountedBranchException("item", item);
        }
Ejemplo n.º 7
0
 static public float GetAngleInRadians(this CardinalOrdinalDirection item)
 {
     return(item.GetAngleInPercent() * Mathq.FULL_REVOLUTION_RADIANS);
 }
Ejemplo n.º 8
0
 static public float GetAngleInDegrees(this CardinalOrdinalDirection item)
 {
     return(item.GetAngleInPercent() * Mathq.FULL_REVOLUTION_DEGREES);
 }
Ejemplo n.º 9
0
 static public CardinalOrdinalDirection GetCounterClockwisePrevious(this CardinalOrdinalDirection item)
 {
     return(item.GetClockwiseNext());
 }
Ejemplo n.º 10
0
 static public IEnumerable <CardinalOrdinalDirection> GetSequenceTo(this CardinalOrdinalDirection item, CardinalOrdinalDirection target, RotationDirection direction)
 {
     return(item.TraverseLoop(z => z.GetNext(direction))
            .EndAt(target)
            .Prepend(item));
 }
Ejemplo n.º 11
0
 static public IEnumerable <CardinalOrdinalDirection> GetFullRotationSequence(this CardinalOrdinalDirection item, RotationDirection direction)
 {
     return(item.GetSequenceTo(item, direction));
 }