public void TestIsIntersect()
        {
            //Not itersected path
            List <PointDir> List1  = new List <PointDir>();
            List <PointDir> List2  = new List <PointDir>();
            PointDir        point1 = new PointDir(1, 2, PointDir.PointDirection.N);
            PointDir        point2 = new PointDir(1, 3, PointDir.PointDirection.E);
            PointDir        point3 = new PointDir(2, 2, PointDir.PointDirection.S);
            PointDir        point4 = new PointDir(3, 2, PointDir.PointDirection.N);

            List1.Add(point1);
            List1.Add(point2);
            List2.Add(point3);
            List2.Add(point4);
            //Intersected path
            List <PointDir> List3  = new List <PointDir>();
            List <PointDir> List4  = new List <PointDir>();
            PointDir        point5 = new PointDir(1, 2, PointDir.PointDirection.N);
            PointDir        point6 = new PointDir(1, 3, PointDir.PointDirection.E);
            PointDir        point7 = new PointDir(1, 2, PointDir.PointDirection.S);
            PointDir        point8 = new PointDir(2, 2, PointDir.PointDirection.N);

            List3.Add(point5);
            List3.Add(point6);
            List4.Add(point7);
            List4.Add(point7);

            Assert.IsFalse(PointsManager.IsIntersect(List1, List2));
            Assert.IsTrue(PointsManager.IsIntersect(List3, List4));
        }
Beispiel #2
0
        // Note: parent should be the top left node
        public Field(int length, Node parentNode, Node connectedNode)
        {
            Length        = Math.Abs(length);
            ParentNode    = parentNode;
            ConnectedNode = connectedNode;

            Overlap = new HashSet <Field>();

            Direction = parentNode.GetDirection(connectedNode);
            parentNode.Fields.Add(Direction, this);
            connectedNode.Fields.Add(Direction.Opposite(), this);

            PointDir          = new PointDir(Position, Direction);
            ConnectedPointDir = new PointDir(ConnectedPosition, Direction.Opposite());
        }
        public void TestGetFinalPositionAndPath()
        {
            PointDir point1   = new PointDir(1, 2, PointDir.PointDirection.N);
            PointDir point2   = new PointDir(3, 3, PointDir.PointDirection.E);
            string   Command1 = "LMLMLMLMM";
            string   Command2 = "MMRMMRMRRM";
            string   Result   = string.Empty;

            PointDir CurrentPoint1 = PointsManager.GetFinalPositionAndPath(point1, Command1)["FinalPosition"][0];
            PointDir CurrentPoint2 = PointsManager.GetFinalPositionAndPath(point2, Command2)["FinalPosition"][0];

            Result = CurrentPoint1.Position.X.ToString() + " " + CurrentPoint1.Position.Y.ToString() + " " + CurrentPoint1.Direction.ToString();
            StringAssert.Contains(Result, "1 3 N");

            Result = CurrentPoint2.Position.X.ToString() + " " + CurrentPoint2.Position.Y.ToString() + " " + CurrentPoint2.Direction.ToString();
            StringAssert.Contains(Result, "5 1 E");
        }
Beispiel #4
0
 public bool Equals(Field other)
 {
     return(PointDir.Equals(other.PointDir));
 }
Beispiel #5
0
 public override int GetHashCode()
 {
     return(PointDir.GetHashCode());
 }
Beispiel #6
0
 public FieldView this[PointDir pointDir] => _fieldMap[pointDir];
Beispiel #7
0
 /// <summary>
 /// Gets the hexagon point that is in the specified direction.
 /// </summary>
 public HexPoint GetPoint(PointDir direction)
 {
     return GetPoints()[(int)direction];
 }
Beispiel #8
0
 public ArcView this[PointDir pointDir] => _arcMap[pointDir];
Beispiel #9
0
 public bool Equals(PointDir other)
 {
     return(Point.Equals(other.Point) && Direction == other.Direction);
 }