Ejemplo n.º 1
0
        private void AddEdgeToMap(Cell origin, Cell connection, CellContentData data)
        {
            //Debuger_K.AddLine(origin.centerV3, SomeMath.MidPoint(data.leftV3, data.centerV3), Color.blue);
            //Debuger_K.AddLine(origin.centerV3, SomeMath.MidPoint(data.rightV3, data.centerV3), Color.red);

            tempCellDataMapValue = new CellDataMapValue(origin, connection, data);
            DDARasterization.DrawLine(data.a.x - chunk.realX, data.a.z - chunk.realZ, data.b.x - chunk.realX, data.b.z - chunk.realZ, PathFinder.CELL_GRID_SIZE / PathFinder.gridSize, AddEdgeToMapDelegate);
        }
Ejemplo n.º 2
0
        public List <Cell>[][] GenerateCellMap(int librarySize, List <Cell> cells)
        {
            bool[]          tempMap   = new bool[librarySize * librarySize];
            List <Cell>[][] cellMap   = new List <Cell> [librarySize][];
            Vector2         chunkPos  = template.chunkData.realPositionV2;
            float           totalSize = PathFinder.gridSize;
            float           pixelSize = totalSize / librarySize;

            for (int x = 0; x < librarySize; x++)
            {
                cellMap[x] = new List <Cell> [librarySize];
                for (int z = 0; z < librarySize; z++)
                {
                    cellMap[x][z] = new List <Cell>();
                }
            }

            foreach (var cell in cells)
            {
                foreach (var edge in cell.data)
                {
                    //DDARasterization.Rasterize(chunkPos, ref tempMap, librarySize, pixelSize, cell.centerV2, edge.leftV2, edge.rightV2);
                    DDARasterization.Rasterize(tempMap, librarySize, pixelSize,
                                               cell.centerV2.x, cell.centerV2.y,
                                               edge.leftV2.x, edge.leftV2.y,
                                               edge.rightV2.x, edge.rightV2.y,
                                               chunkPos.x, chunkPos.y);
                }

                for (int x = 0; x < librarySize; x++)
                {
                    for (int z = 0; z < librarySize; z++)
                    {
                        if (tempMap[x * librarySize + z])
                        {
                            cellMap[x][z].Add(cell);
                            tempMap[x * librarySize + z] = false;
                        }
                    }
                }
            }

            //for (int x = 0; x < librarySize + 1; x++) {
            //    Vector3 A = template.chunkData.realPositionV3 + new Vector3(x * pixelSize, 0, 0);
            //    Vector3 B = template.chunkData.realPositionV3 + new Vector3(x * pixelSize, 0, totalSize);
            //    PFDebuger.Debuger_K.AddLine(A, B, Color.red);
            //}

            //for (int z = 0; z < librarySize + 1; z++) {
            //    Vector3 A = template.chunkData.realPositionV3 + new Vector3(0, 0, z * pixelSize);
            //    Vector3 B = template.chunkData.realPositionV3 + new Vector3(totalSize, 0, z * pixelSize);
            //    PFDebuger.Debuger_K.AddLine(A, B, Color.red);
            //}

            //for (int x = 0; x < librarySize; x++) {
            //    for (int z = 0; z < librarySize; z++) {
            //        Vector3 pixelPos = template.chunkData.realPositionV3 + (new Vector3(x + 0.5f, 0, z + 0.5f) * pixelSize);
            //        PFDebuger.Debuger_K.AddDot(pixelPos, Color.cyan);
            //        PFDebuger.Debuger_K.AddLabel(pixelPos, cellMap[x][z].Count);

            //        foreach (var cell in cellMap[x][z]) {
            //            PFDebuger.Debuger_K.AddLine(pixelPos, cell.centerV3, Color.cyan);
            //        }
            //    }
            //}

            return(cellMap);
        }
Ejemplo n.º 3
0
 private void RemoveEdgeFromMap(Cell connection, CellContentData data)
 {
     tempCellConnection = connection;
     DDARasterization.DrawLine(data.a.x - chunk.realX, data.a.z - chunk.realZ, data.b.x - chunk.realX, data.b.z - chunk.realZ, PathFinder.CELL_GRID_SIZE / PathFinder.gridSize, RemoveEdgeFromMapDelegate);
 }