Ejemplo n.º 1
0
        public void UpdateGraph(ICellMap map, ICellFragment cellFragment, HierarchicalMap graph, NeighbourMode neighbourMode)
        {
            var        clusterMatrix = graph.ZeroLevelClusters;
            int        clusterWidth  = graph.ClusterDefaultWidth;
            int        clusterHeight = graph.ClusterDefaultHeight;
            Vector2Int fragmentSize  = new Vector2Int(cellFragment.Width, cellFragment.Height);

            Vector2Int leftBottomClusterPosition = GetContainingClusterPosition(clusterMatrix, clusterWidth, clusterHeight, cellFragment.LeftBottom);
            Vector2Int rightTopClusterPosition   = GetContainingClusterPosition(clusterMatrix, clusterWidth, clusterHeight, cellFragment.LeftBottom + fragmentSize);

            int iMin = leftBottomClusterPosition.X;
            int iMax = rightTopClusterPosition.X;
            int jMin = leftBottomClusterPosition.Y;
            int jMax = rightTopClusterPosition.Y;

            for (int i = iMin; i <= iMax; i++)
            {
                for (int j = jMin; j <= jMax; j++)
                {
                    CellCluster currentCluster = clusterMatrix[i, j];

                    int prevI = i - 1;
                    int prevJ = j - 1;
                    int nextJ = j + 1;
                    if (prevI >= iMin)
                    {
                        CellCluster neighbourCluster = clusterMatrix[prevI, j];
                        RemoveTransitionNodes(currentCluster, neighbourCluster, graph);
                        ProceedNeighbourClusters(currentCluster, neighbourCluster, graph);
                    }

                    if (prevJ >= jMin)
                    {
                        CellCluster neighbourCluster = clusterMatrix[i, prevJ];
                        RemoveTransitionNodes(currentCluster, neighbourCluster, graph);
                        ProceedNeighbourClusters(currentCluster, neighbourCluster, graph);
                    }
                }
            }

            for (int i = iMin; i <= iMax; i++)
            {
                for (int j = jMin; j <= jMax; j++)
                {
                    CellCluster currentCluster = clusterMatrix[i, j];
                    currentCluster.CalculatePaths(neighbourMode, null);
                }
            }
        }
Ejemplo n.º 2
0
 public void AddObstacle(ICellFragment cellCluster)
 {
     _layeredCellMap.AddFragment(cellCluster);
 }
Ejemplo n.º 3
0
 public void AddFragment(ICellFragment fragment)
 {
     _layers.Add(fragment);
     _layerOffsets.Add(fragment.LeftBottom);
 }
Ejemplo n.º 4
0
 public void AddObstacle(ICellFragment cellCluster)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 5
0
 public void AddObstacle(ICellFragment cellCluster)
 {
     _userObstacles.Add(cellCluster);
 }