Exemplo n.º 1
0
        public override R2NonCircularDirection ReflectAboutEqualAxis(int[] axisIndeces, int numberOfTimes)
        {
            R2Direction <R2NonCircularDirection, DoubleLinkedList <R2Point>, NonCircularDirection <R2NonCircularDirection, R2Point> > .ReflectAroundEqualAxis(new List <int>(axisIndeces), numberOfTimes, ref direction);

            return(new R2NonCircularDirection(new R2Point(StartingPoint.GetAxisAt(0), StartingPoint.GetAxisAt(1), StartingPoint.CanShoot),
                                              Direction, SharedDirection.DirectionLength, SharedDirection.Divisor, CanShoot, Duration));
        }
Exemplo n.º 2
0
        // Reflect about the  x-axis or y-axis, and return the result.
        // 0 means x-axis, 1 means y-axis.
        public override R2NonCircularDirection ReflectAboutAxis(int axisIndex)
        {
            R2Direction <R2NonCircularDirection, DoubleLinkedList <R2Point>, NonCircularDirection <R2NonCircularDirection, R2Point> > .ReflectAboutAxis(axisIndex, ref direction);


            return(new R2NonCircularDirection(new R2Point(StartingPoint), Direction, SharedDirection.DirectionLength, SharedDirection.Divisor, canShootList, Duration));
        }
        public R2NCDirection()
            : base()
        {
            nonCircularDirection = new NonCircularDirection <R2NCDirection, R2Point>();
            directionHelper      = new R2Direction <R2NCDirection>();

            InitializeAttributes();
        }
        public R2CDirection(R2Direction <R2CDirection> directionHelper)
        {
            this.directionHelper = directionHelper;

            circularDirection = new CircularDirection <R2CDirection, R2Point>(
                CreateCanSwitchList(), true, 1);

            InitializeAttributes();
        }
Exemplo n.º 5
0
        public int CompareTo(R2Direction <IDirection> other)
        {
            int             result = 0;
            SharedDirection shared = (SharedDirection)direction.SharedDirection;

            if (shared.XLength < ((SharedDirection)other.Direction.SharedDirection).XLength)
            {
                result = -1;
            }

            else if (shared.XLength > ((SharedDirection)other.Direction.SharedDirection).XLength)
            {
                result = 1;
            }

            else
            {
                if (shared.YLength < ((SharedDirection)other.Direction.SharedDirection).YLength)
                {
                    result = -1;
                }

                else if (shared.YLength > ((SharedDirection)other.Direction.SharedDirection).YLength)
                {
                    result = 1;
                }

                else
                {
                    if (shared.Divisor > ((SharedDirection)other.Direction.SharedDirection).Divisor)
                    {
                        result = -1;
                    }

                    else if (shared.Divisor < ((SharedDirection)other.Direction.SharedDirection).Divisor)
                    {
                        result = 1;
                    }

                    else
                    {
                        if (direction.MyDirection < other.Direction.MyDirection)
                        {
                            result = -1;
                        }

                        else if (direction.MyDirection > other.Direction.MyDirection)
                        {
                            result = 1;
                        }
                    }
                }
            }

            return(result);
        }
        // Rotate about the  x-axis or y-axis a certatin number of times, and return the result.
        // Rotate around the x-axis or the y-axis.
        public override R2CircularDirection RotateAroundAxis(int indexOfAxis, int numberOfTimes)
        {
            R2CircularDirection direction = this;


            R2Direction <R2CircularDirection, CircularLinkedList <R2Point>, CircularDirection <R2CircularDirection, R2Point> > .RotateAroundAxis(indexOfAxis, numberOfTimes, this);

            return(new R2CircularDirection(new R2Point(StartingPoint.GetAxisAt(0), StartingPoint.GetAxisAt(1), StartingPoint.CanShoot),
                                           Direction, SharedDirection.DirectionLength, SharedDirection.Divisor, CanShoot, Duration));
        }
        // Move direction.
        // Change the starting position on a direction.
        public override R2CircularDirection translate(int coordinateSystemDirection, float amount)
        {
            R2CircularDirection initialDirection = new R2CircularDirection(new R2Point(StartingPoint), Direction, SharedDirection.DirectionLength, SharedDirection.Divisor, canShootList, Duration);

            float finalX = initialDirection.StartingPoint.GetAxisAt(0);
            float finalY = initialDirection.StartingPoint.GetAxisAt(1);


            R2Direction <R2CircularDirection, CircularLinkedList <R2Point>, CircularDirection <R2CircularDirection, R2Point> > .Translate(coordinateSystemDirection, amount, finalX, finalY);

            return(new R2CircularDirection(new R2Point(finalX, finalY, initialDirection.StartingPoint.CanShoot),
                                           Direction, SharedDirection.DirectionLength, SharedDirection.Divisor, CanShoot, Duration));
        }
        public R2CDirection(R2Point startingPoint, int direction, float xLength,
                            float yLength, float directionDivisor, List <float> speedList, List <bool>
                            canSwitchList, int numberOfRepeatations, bool canSwitch, float speed)
        {
            circularDirection = new CircularDirection <R2CDirection, R2Point>(
                canSwitchList, canSwitch, numberOfRepeatations);

            directionHelper = new R2Direction <R2CDirection>(startingPoint, direction,
                                                             xLength, yLength, directionDivisor, speedList, speed);


            InitializeAttributes();
        }
 // Checkes whether or not points making up a direction have a correct dimension.
 public override bool IsPointDimensionCorrect()
 {
     return(R2Direction <R2CircularDirection, CircularLinkedList <R2Point>,
                         CircularDirection <R2CircularDirection, R2Point> > .IsPointDimensionCorrect(StartingPoint));
 }
 // Determines whether or not a direction is within the boundaries..
 public override bool IsDirectionValid(int direction)
 {
     return(R2Direction <R2CircularDirection, CircularLinkedList <R2Point>,
                         CircularDirection <R2CircularDirection, R2Point> > .IsDirectionValid(direction));
 }
 // Will always return true for a two dimensional direction.
 public override bool IsDirectionDimensionCorrect()
 {
     return(R2Direction <R2CircularDirection, CircularLinkedList <R2Point>,
                         CircularDirection <R2CircularDirection, R2Point> > .IsDirectionDimensionCorrect(Dimension));
 }
Exemplo n.º 12
0
 // Will always return true for a two dimensional direction.
 public override bool IsDirectionDimensionCorrect()
 {
     return(R2Direction <R2NonCircularDirection, DoubleLinkedList <R2Point>,
                         NonCircularDirection <R2NonCircularDirection, R2Point> > .IsDirectionDimensionCorrect(dimension));
 }
Exemplo n.º 13
0
        // Reflect a point about a direction that has both axis coordinate changing.
        // Reflect about the  line y = x or y = -x a certain number of times, and return the result.
        // A negetive element means on the negetive side of the axis.
        // Reflect about y = x and y = -x. However y = x correspond to two axis indeces,
        // likewise for y = -x.
        public R2Direction <IDirection> ReflectAboutEqualAxis(List <int> axisIndeces, int numberOfTimes)
        {
            R2Direction <IDirection> r2Direction = (R2Direction <IDirection>)Clone();

            for (int i = 0; i < numberOfTimes; i++)
            {
                if ((axisIndeces[0] == 1 && axisIndeces[1] == 1) || (axisIndeces[0] == -1 && axisIndeces[1] == -1))
                {
                    switch (direction.MyDirection)
                    {
                    case 1:
                        direction.MyDirection = 3;
                        break;

                    case 2:
                        direction.MyDirection = 8;
                        break;

                    case 3:
                        direction.MyDirection = 1;
                        break;

                    case 4:
                        direction.MyDirection = 5;
                        break;

                    case 5:
                        direction.MyDirection = 4;
                        break;

                    case 6:
                        direction.MyDirection = 6;
                        break;

                    case 7:
                        direction.MyDirection = 7;
                        break;

                    case 8:
                        direction.MyDirection = 2;
                        break;
                    }
                }

                else if ((axisIndeces[0] == -1 && axisIndeces[1] == 1) || (axisIndeces[0] == 1 && axisIndeces[1] == -1))
                {
                    switch (direction.MyDirection)
                    {
                    case 1:
                        direction.MyDirection = 2;
                        break;

                    case 2:
                        direction.MyDirection = 1;
                        break;

                    case 3:
                        direction.MyDirection = 8;
                        break;

                    case 4:
                        direction.MyDirection = 4;
                        break;

                    case 5:
                        direction.MyDirection = 5;
                        break;

                    case 6:
                        direction.MyDirection = 7;
                        break;

                    case 7:
                        direction.MyDirection = 6;
                        break;

                    case 8:
                        direction.MyDirection = 3;
                        break;
                    }
                }

                SharedDirection shared = (SharedDirection)direction.SharedDirection;
                r2Direction = new R2Direction <IDirection>(new R2Point(direction.StartingPoint),
                                                           direction.MyDirection, shared.XLength, shared.YLength, shared.Divisor,
                                                           direction.SpeedList, direction.Speed);
            }
            return(r2Direction);
        }