Ejemplo n.º 1
0
        /// <summary>
        /// Connects the first node of the linear path to the NodeNetwork
        /// </summary>
        /// <param name="startNode">First node of the linear path</param>
        /// <param name="nodeNetwork">NodeNetwork which will be modified</param>
        private void ConnectStartToNetwork(Node startNode, NodeNetwork nodeNetwork)
        {
            if (!_useScale)
            {
                Node connectionNode = nodeNetwork.GetNodeBelow(startNode);
                if (connectionNode == startNode)
                    Debug.LogError("We have a problem.");
                Debug.Log("ConnectionNode: " + connectionNode.WorldPosition);
                if (connectionNode != null)
                {
                    startNode.AddConnection(connectionNode);
                    connectionNode.AddConnection(startNode);
                }
                return;
            }
            // Gets the entire area covered by the collider.
            List<Node> innerNetwork = base.CreateCustomNodeNetwork(nodeNetwork);
            if (_pathTransforms.Length == 0 || innerNetwork.Count == 0)
                throw new System.Exception("No pathTransforms or innerNetwork found.");

            // Connect the first Node of the linearPathNetwork to all Nodes of the innerNetwork.
            foreach (var node in innerNetwork)
            {
                startNode.AddConnection(node);
                node.AddConnection(startNode);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Connects the last node of the linear path to the NodeNetwork
 /// </summary>
 /// <param name="startNode">Last node of the linear path</param>
 /// <param name="nodeNetwork">NodeNetwork which will be modified</param>
 private void ConnectEndToNetwork(Node endNode, NodeNetwork nodeNetwork)
 {
     Node connectionNode;
     
     // Depending on the connection type, the last Node will search a compatible node below it to create a network connection with.
     switch (_connectionType)
     {
         case ConnectionType.TwoWay:
             // Connects the last Node and Node below both ways. This creates a 2-way connection.
             connectionNode = nodeNetwork.GetNodeBelow(endNode);
             if (connectionNode != null)
             {
                 endNode.AddConnection(connectionNode);
                 connectionNode.AddConnection(endNode);
             }
             else
                 throw new System.Exception("Cannot find node below.");
             break;
         case ConnectionType.OneWay:
             // Connects the last Node and Node below one ways. This creates a 1-way connection from start to end.
             connectionNode = nodeNetwork.GetNodeBelow(endNode);
             if (connectionNode != null)
             {
                 endNode.AddConnection(connectionNode);
             }
             else
                 throw new System.Exception("Cannot find node below.");
             break;
         case ConnectionType.Manual:                  
             // No connection made at all. Create another linearPathNetwork and connect it's end to this linearPathNetwork's end.
             // This creates a 2-way connection with both having an innerNetwork connected to their respective starts.
             break;
         default:
             break;
     }
 }