Example #1
0
        // Makes a copy of the current object.
        public object Clone()
        {
            SharedDirection shared = (SharedDirection)direction.SharedDirection;

            return(new R2Direction <IDirection>(new R2Point(direction.StartingPoint),
                                                direction.MyDirection, shared.XLength, shared.YLength, direction.
                                                SharedDirection.Divisor, direction.SpeedList, direction.Speed));
        }
 protected R2NCLetter(Point _startingPoint, char letter, bool smaller, int letterDirection,
                      List <bool> CanSwitchList, Dictionary <int, int> duration, int numberOfRotations,
                      SharedDirection shareDirection)
     : base(_startingPoint, letter, R2Plane.GetR2Plane(), smaller, letterDirection,
            CanSwitchList, duration, numberOfRotations)
 {
     Fill();
 }
Example #3
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);
        }
        // Make a copy of this direction.
        public object Clone()
        {
            SharedDirection shared = (SharedDirection)directionHelper.Direction.SharedDirection;

            return(new R2CDirection(new R2Point(directionHelper.Direction.StartingPoint),
                                    directionHelper.Direction.MyDirection, shared.XLength, shared.YLength,
                                    directionHelper.Direction.SharedDirection.Divisor, directionHelper.Direction.SpeedList,
                                    circularDirection.CanSwitchList, circularDirection.NumberOfTimes, circularDirection.CanSwitch,
                                    directionHelper.Direction.Speed));
        }
Example #5
0
        // Find the direction opposite to this direction.
        // The opposite direction starts on the last point of this direction.
        public R2Direction <IDirection> GetOppositeDirection(R2Point lastPoint)
        {
            int newDirection;

            switch (direction.MyDirection)
            {
            case 1:
                newDirection = 8;
                break;

            case 2:
                newDirection = 3;
                break;

            case 3:
                newDirection = 2;
                break;

            case 4:
                newDirection = 5;
                break;

            case 5:
                newDirection = 4;
                break;

            case 6:
                newDirection = 7;
                break;

            case 7:
                newDirection = 6;
                break;

            default:
                newDirection = 1;
                break;
            }

            SharedDirection shared = (SharedDirection)direction.SharedDirection;

            return(new R2Direction <IDirection>(lastPoint, newDirection,
                                                shared.XLength, shared.YLength, direction.SharedDirection.Divisor,
                                                direction.SpeedList, direction.Speed));
        }
Example #6
0
        public R2CircularLetter(SharedDirection shareDirection)
        {
            onPlane = R2Plane.GetR2Plane();

            letter    = 'C';
            direction = 8;

            _startingPoint    = new R2Point().Position;
            smaller           = true;
            duration          = new Dictionary <int, int>();
            canShootList      = new List <bool>();
            numberOfRotations = 1;


            AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
            AddDirection(new R2Point(), 2, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
            AddDirection(new R2Point(), 8, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
        }
Example #7
0
        protected R2CircularLetter(Point _startingPoint, char letter, Plane onPlane, bool smaller, int letterDirection,
                                   List <bool> canShootList, Dictionary <int, int> duration, int letterDimension, int numberOfRotations, SharedDirection shareDirection)
            : base(_startingPoint, letter, onPlane, smaller, letterDirection,
                   canShootList, duration, letterDimension, numberOfRotations)
        {
            switch (Letter)
            {
            case 'C':

                AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 2, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);


                break;

            case 'L':

                AddDirection(new R2Point(), 1, 10, 1, canShootList, duration, numberOfRotations);

                break;

            case 'M':

                AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 2, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 2, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);


                break;

            case 'N':

                AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 2, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);



                break;

            case 'O':

                AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 2, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);

                break;

            case 'R':

                AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 2, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);



                break;

            case 'S':

                AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 2, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);



                break;

            case 'W':

                AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 2, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);

                break;
            }
            AddDirection(new R2Point(), letterDirection, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
        }
Example #8
0
        public R2CircularLetter(R2Point startingPoint, char letter,
                                int letterDirection, bool smaller, Dictionary <int, int> duration,
                                int numberOfRotations, SharedDirection shareDirection)
            : base(startingPoint.Position, letter, letterDirection, R2Plane.GetR2Plane(),
                   smaller, duration, 2, numberOfRotations)
        {
            switch (Letter)
            {
            case 'C':

                AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 2, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);


                break;

            case 'L':

                AddDirection(new R2Point(), 1, 10, 1, canShootList, duration, numberOfRotations);

                break;

            case 'M':

                AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 2, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 2, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);


                break;

            case 'N':

                AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 2, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);



                break;

            case 'O':

                AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 2, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);

                break;

            case 'R':

                AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 2, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);



                break;

            case 'S':

                AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 2, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);



                break;

            case 'W':

                AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 1, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
                AddDirection(new R2Point(), 2, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);

                break;
            }
            AddDirection(new R2Point(), letterDirection, shareDirection.DirectionLength, shareDirection.Divisor, canShootList, duration, numberOfRotations);
        }
Example #9
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);
        }