public void StraightRoadTest()
        {
            OriginNode origin = SetupOriginNode("E", new int[2] {
                0, 0
            });

            PathNode[] nodes = SetupPathNodesWithCoordinates(new int[][] { new int[2] {
                                                                               0, 0
                                                                           }, new int[2] {
                                                                               1, 0
                                                                           }, new int[2] {
                                                                               2, 0
                                                                           }, new int[2] {
                                                                               3, 0
                                                                           } });
            nodes[0].connectedNodes = new int[] { 1 };
            nodes[1].connectedNodes = new int[] { 0, 2 };
            nodes[2].connectedNodes = new int[] { 1, 3 };
            nodes[3].connectedNodes = new int[] { 2 };

            var roadDrawer = _container.Resolve <RoadDrawer>();

            GameObject[] gameObjects = roadDrawer.SetupRoadSegments(nodes);
            AssertThatRoadSegmentIsCorrect(gameObjects[0], "DeadEnd(Clone)", new Vector3(0, 0, 0), Direction.East);
            AssertThatRoadSegmentIsCorrect(gameObjects[1], "Straight(Clone)", new Vector3(1, 0, 0), Direction.East);
            AssertThatRoadSegmentIsCorrect(gameObjects[2], "Straight(Clone)", new Vector3(2, 0, 0), Direction.East);
            AssertThatRoadSegmentIsCorrect(gameObjects[3], "DeadEnd(Clone)", new Vector3(3, 0, 0), Direction.West);
        }
Esempio n. 2
0
    private GameObject SetupOrigin(OriginNode origin)
    {
        Direction  direction = RoadDrawer.StringToDirection(origin.direction);
        Coordinate coords    = origin.coords;

        return(Instantiate(roadTiles.cfcTile, new Vector3(translator.translateToSceneRow(coords.x), translator.translateToSceneColumn(coords.y), 0f),
                           Quaternion.Euler(0, 0, (float)direction)) as GameObject);
    }
        private OriginNode SetupOriginNode(string direction, int[] coordinate)
        {
            OriginNode origin = new OriginNode();

            origin.coordinate = coordinate;
            origin.direction  = direction;
            return(origin);
        }
        public void SetupOriginTest()
        {
            var originNode = new OriginNode();

            originNode.coordinate = new int[2] {
                10, 3
            };
            originNode.direction = "E";
            var roadDrawer       = _container.Resolve <RoadDrawer>();
            var originGameObject = roadDrawer.SetupOrigin(originNode);

            Assert.AreEqual("CFC(Clone)", originGameObject.name);
            Assert.AreEqual(new Vector3(10, 3, 0), originGameObject.transform.position);
        }
        public void SmallestRoadTest()
        {
            var originNode = new OriginNode();

            originNode.coordinate = new int[2] {
                0, 0
            };
            originNode.direction = "E";
            var nodes = SetupPathNodesWithCoordinates(new int[2][] { new int[2] {
                                                                         0, 0
                                                                     }, new int[2] {
                                                                         1, 0
                                                                     } });

            nodes[0].connectedNodes = new int[] { 1 };
            nodes[1].connectedNodes = new int[] { 0 };

            var roadDrawer = _container.Resolve <RoadDrawer>();

            GameObject[] gameObjects = roadDrawer.SetupRoadSegments(nodes);
            AssertThatRoadSegmentIsCorrect(gameObjects[0], "DeadEnd(Clone)", new Vector3(0, 0, 0), Direction.East);
            AssertThatRoadSegmentIsCorrect(gameObjects[1], "DeadEnd(Clone)", new Vector3(1, 0, 0), Direction.West);
        }
            /// <remarks>
            ///     Constraint: Implicit suffixes must have BeginIndex < words[wordNum].Length
            /// </remarks>
            public void Canonicalize()
            {
                if (IsImplicit)
                {
                    bool          haveValuesChanged = false;
                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine("  Canonicalize: Entering");
                    // sb.AppendLine(tree.ToString());

                    int origNodeId, begin, end;
                    origNodeId = this.OriginNode.Id;
                    begin      = this.beginIndex;
                    end        = this.endIndex;

                    GstEdge edge = OriginNode.GetChildEdge(tree.GetWordChar(WordNum, BeginIndex));
                    while (edge.Span() <= Span)
                    {
                        sb.Append(String.Format(
                                      "    Canonicalize: Active suffix changed from {0:s}",
                                      ToSuffixString(origNodeId, begin, end)));
                        this.beginIndex  += edge.Span() + 1;
                        this.OriginNode   = edge.ChildNode;
                        haveValuesChanged = true;
                        sb.AppendLine(String.Format(" to {0:s}",
                                                    ToSuffixString(OriginNode.Id, beginIndex, endIndex)));
                        if (Span >= 0)
                        {
                            edge = edge.ChildNode.GetChildEdge(tree.GetWordChar(0, BeginIndex));
                        }
                    }
                    sb.AppendLine("  Canonicalize: Exiting");
                    if (haveValuesChanged)
                    {
                        GstUtil.Write(GstVerbosityLevel.Verbose, sb.ToString());
                    }
                }
            }
Esempio n. 7
0
 public override int GetHashCode()
 {
     return(OriginNode.GetHashCode());
 }