Example #1
0
        public void a050_IsDirectConnectedTest()
        {
            Wire[] wires = PrepareWireArray(8);
            wires[0].transform.position = new Vector3(0.5f, 0, 1);
            wires[0]._direction         = Wire.Direction.XZ_X;
            wires[1].transform.position = new Vector3(1.5f, 0, 1);
            wires[1]._direction         = Wire.Direction.XZ_X;
            wires[2].transform.position = new Vector3(2.5f, 0, 1);
            wires[2]._direction         = Wire.Direction.XZ_X;
            wires[3].transform.position = new Vector3(5.5f, 0, 5);
            wires[3]._direction         = Wire.Direction.XZ_X;
            wires[4].transform.position = new Vector3(5, 0, 5.5f);
            wires[4]._direction         = Wire.Direction.XZ_Z;
            wires[5].transform.position = new Vector3(5, 0, 6.5f);
            wires[5]._direction         = Wire.Direction.XZ_Z;
            wires[6].transform.position = new Vector3(4.5f, 0, 6);
            wires[6]._direction         = Wire.Direction.XZ_X;
            wires[7].transform.position = new Vector3(5.5f, 0, 6);
            wires[7]._direction         = Wire.Direction.XZ_X;

            GraphPath graphPath = GraphPath.Build(wires);

            //          7
            //          |
            //        8-6-9
            //          |
            // 0-1-2-3, 4-5

            Assert.True(graphPath.IsDirectConnected(graphPath.GetNodeById(0), graphPath.GetNodeById(1)));
            Assert.True(graphPath.IsDirectConnected(graphPath.GetNodeById(1), graphPath.GetNodeById(2)));
            Assert.True(graphPath.IsDirectConnected(graphPath.GetNodeById(2), graphPath.GetNodeById(3)));
            Assert.False(graphPath.IsDirectConnected(graphPath.GetNodeById(3), graphPath.GetNodeById(4)));
            Assert.True(graphPath.IsDirectConnected(graphPath.GetNodeById(4), graphPath.GetNodeById(5)));
            Assert.False(graphPath.IsDirectConnected(graphPath.GetNodeById(5), graphPath.GetNodeById(6)));
            Assert.True(graphPath.IsDirectConnected(graphPath.GetNodeById(6), graphPath.GetNodeById(7)));
            Assert.True(graphPath.IsDirectConnected(graphPath.GetNodeById(6), graphPath.GetNodeById(8)));
            Assert.True(graphPath.IsDirectConnected(graphPath.GetNodeById(6), graphPath.GetNodeById(9)));
            Assert.False(graphPath.IsDirectConnected(graphPath.GetNodeById(6), graphPath.GetNodeById(5)));
            Assert.False(graphPath.IsDirectConnected(graphPath.GetNodeById(6), graphPath.GetNodeById(1)));
            Assert.False(graphPath.IsDirectConnected(graphPath.GetNodeById(7), graphPath.GetNodeById(8)));
            Assert.False(graphPath.IsDirectConnected(graphPath.GetNodeById(8), graphPath.GetNodeById(9)));
            Assert.False(graphPath.IsDirectConnected(graphPath.GetNodeById(8), graphPath.GetNodeById(8)));
        }