예제 #1
0
 private void AddNeighbor(VoronoiGridChunk chunk)
 {
     if (!_neighbors.Contains(chunk))
     {
         _neighbors.Add(chunk);
     }
 }
예제 #2
0
    private void HandleInput()
    {
        Ray        inputRay = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(inputRay, out hit))
        {
            VoronoiGridChunk currentChunk = hit.transform.parent.GetComponent <VoronoiGridChunk> ();
            VoronoiCell      currentCell  = VoronoiGrid.GetCell(hit.point, currentChunk.GetNeighborhood());

            if (_previousCell && _previousCell != currentCell)
            {
                ValidateDrag(currentCell);
            }
            else
            {
                _isDrag = false;
            }

            EditCells(currentCell);
            _previousCell = currentCell;
        }
        else
        {
            _previousCell = null;
        }
    }
예제 #3
0
    private void CreateChunk(int i, Vector3 position)
    {
        VoronoiGridChunk chunk = _chunks[i] = Instantiate(ChunkPrefab);

        chunk.name = "Voronoi Grid Chunk " + i;
        chunk.transform.SetParent(transform, false);
        chunk.AddCell(GetCell(position));
        chunk.AddToAtmosphere(_atmosphere);
    }