DIRECTION GetWallDirection(GraphConnection <PositionalGraphNode> connection)
 {
     if (connection.nodeA.position.z == connection.nodeB.position.z)
     {
         return(DIRECTION.horizontal);
     }
     else
     {
         return(DIRECTION.vertical);
     }
 }
예제 #2
0
        public void ConnectNodes(T nodeA, T nodeB)
        {
            GraphConnection <T> connection = new GraphConnection <T>(nodeA, nodeB);

            if (nodeA != nodeB && FindConnection(connection) == null)
            {
                nodeA.AddConnectedNode(nodeB);
                nodeB.AddConnectedNode(nodeA);
                connections.Add(connection);
            }
        }
        Cube GenerateWallCube(GraphConnection <PositionalGraphNode> connection)
        {
            DIRECTION wallDirection = GetWallDirection(connection);

            Vector3 position = (connection.nodeA.position + connection.nodeB.position) / 2;

            position.y += wallHeight / 2;
            Vector3 vectorDistance = connection.nodeA.position - connection.nodeB.position;
            float   distance       = vectorDistance.magnitude;

            if (wallDirection == DIRECTION.horizontal)
            {
                return(new Cube(position, distance, wallWidth, wallHeight));
            }
            else
            {
                return(new Cube(position, wallWidth, distance, wallHeight));
            }
        }
예제 #4
0
        public GraphConnection <T> FindConnection(GraphConnection <T> connection)
        {
            foreach (GraphConnection <T> existingConnection in connections) //TODO - this would be better served by a custom equality operator?
            {
                if (existingConnection.nodeA == connection.nodeA &&
                    existingConnection.nodeB == connection.nodeB)
                {
                    return(existingConnection);
                }

                if (existingConnection.nodeA == connection.nodeB &&
                    existingConnection.nodeB == connection.nodeA)
                {
                    return(existingConnection);
                }
            }

            return(null);
        }
예제 #5
0
        public GraphConnection <T> FindConnection(T nodeA, T nodeB)
        {
            GraphConnection <T> connection = new GraphConnection <T>(nodeA, nodeB);

            return(FindConnection(connection));
        }
예제 #6
0
        public void DisconnectNodes(T nodeA, T nodeB)
        {
            GraphConnection <T> connection = new GraphConnection <T>(nodeA, nodeB);

            DisconnectNodes(connection);
        }
예제 #7
0
 public void DisconnectNodes(GraphConnection <T> connection)
 {
     connections.Remove(FindConnection(connection));
     connection.nodeA.RemoveConnectedNode(connection.nodeB);
     connection.nodeB.RemoveConnectedNode(connection.nodeA);
 }