예제 #1
0
        /// <summary>
        /// Constructor of the graph class
        /// </summary>
        /// <param name="rootPosition">Position of the first node</param>
        /// <param name="data">Data-Structure containing the matrix where the information about the environment is saved</param>
        /// <param name="nodeObj">Model of the node that will be spawned</param>
        /// <param name="deadNodeMaterial">Material assigned to the node once it has been deactivated</param>
        /// <param name="doNotSpawnAnything">If TRUE indicates that the node doesn't spawn the model and the archs between nodes</param>
        public Graph(Vector3 rootPosition, dataCollector.Data data, GameObject nodeObj, Material deadNodeMaterial, bool doNotSpawnAnything = false)
        {
            this.nodeObj            = nodeObj;
            this.deadNodeMaterial   = deadNodeMaterial;
            this.doNotSpawnAnything = doNotSpawnAnything;

            root        = new Node(rootPosition, nodeObj, deadNodeMaterial, this, null, doNotSpawnAnything);
            activeNodes = new LinkedList <Node>();
            activeNodes.AddFirst(root);
            allNodes = new List <Node>();
            allNodes.Add(root);
            this.data = data;

            // sectors structure inizialization
            upperLeftPoint = data.indxToV3(new dataCollector.indx(0, 0));
            float totalLengthOfExplorableZone = Mathf.Abs(upperLeftPoint.x - data.indxToV3(new dataCollector.indx(data.getArraySize() - 1, 0)).x);

            sectorWidth = totalLengthOfExplorableZone * sectorPercentualWidth;
            sectorsDim  = (int)(1 / sectorPercentualWidth);
            sectors     = new List <Node> [sectorsDim, sectorsDim];
            for (int i = 0; i < sectorsDim; i++)
            {
                for (int j = 0; j < sectorsDim; j++)
                {
                    sectors[i, j] = new List <Node>();
                }
            }

            assignNodeToSector(root);
        }
예제 #2
0
 /// <summary>
 /// Sets the matrix containing the information that the dataDrawer will use to paint a map
 /// </summary>
 /// <param name="data">Matrix where the information is contained</param>
 public void setData(dataCollector.Data data)
 {
     this.data = data; dirtyList = data.getDirtyValuesList();
 }