Example #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="nodeNetwork">NodeNetwork which will be modified</param>
        /// <returns></returns>
        public override List<Node> CreateCustomNodeNetwork(NodeNetwork nodeNetwork)
        {
            // Create NodeInfo array for all the new nodes that need to be created.
            List<NodeInfo> nodeInfoList = GetNodeInfoArray(nodeNetwork);

            // Create the first node of the linearPathNetwork.
            NodeInfo nodeInfo = nodeInfoList[0];
            Node currentNode = nodeNetwork.CreateCustomNode(nodeInfo.Layer, nodeInfo.WorldPosition);

            linearPathNetwork = new List<Node>();
            linearPathNetwork.Add(currentNode);

            ConnectStartToNetwork(currentNode, nodeNetwork);

            // Create the other nodes and connect them to the linear path network.
            int length = nodeInfoList.Count;
            for (int i = 1; i < length; i++)
            {
                nodeInfo = nodeInfoList[i];
                // Create new node in the linearPathNetwork.
                currentNode = nodeNetwork.CreateCustomNode(nodeInfo.Layer, nodeInfo.WorldPosition);
                currentNode.CanSimplify = false;

                // Connect the last 2 nodes.
                Node previousNode = linearPathNetwork[i - 1];
                currentNode.AddConnection(previousNode);
                previousNode.AddConnection(currentNode);

                linearPathNetwork.Add(currentNode);
            }

            ConnectEndToNetwork(currentNode, nodeNetwork);

            return linearPathNetwork;
        }