Пример #1
0
    private void RippleOneNeighbor()
    {
        Debug.Log("ripple a neigbor");
        // set doRipple to true for one neighbor, the one with the lowest y-value if transform.position
        float lowestY      = Mathf.Infinity;
        int   lowestYidx   = 0;
        bool  someOneFound = false;

        for (int i = 0; i < neighbors.Count; i++)
        {
            RippleColumn rp_nb = neighbors[i].GetComponent <RippleColumn>();
            if (neighbors[i].transform.position.y < lowestY && !rp_nb.doingPathing && !rp_nb.pathingDone)
            {
                lowestY      = neighbors[i].transform.position.y;
                lowestYidx   = i;
                someOneFound = true;
            }
        }
        if (someOneFound)
        {
            // then do the pathing, if this is false that means every columns is done with the pathing
            neighbors[lowestYidx].GetComponent <RippleColumn>().doPathing = true;
            Debug.Log("found! at " + neighbors[lowestYidx].transform.position);
        }
        Debug.Log("ripple a neigbor done");
    }
Пример #2
0
 private void FindCellNeighbors()
 {
     for (int i = 0; i < voronoi.voronoiCells.Count; i++)
     {
         if (voronoi.voronoiCells[i].isValid)
         {
             // only do this to valid cells that create meshes
             List <GameObject> neighbors = new List <GameObject>();
             for (int j = 0; j < voronoi.voronoiCells.Count; j++)
             {
                 if (i != j && voronoi.voronoiCells[j].isValid &&
                     voronoi.voronoiCells[i].ShareEdge(voronoi.voronoiCells[j]))
                 {
                     // this cell is a neighbor to the cell above if both are valid and they share an edge
                     neighbors.Add(voronoi.voronoiCells[j].theMeshObject);
                 }
             }
             if (VERBOSE)
             {
                 Debug.Log("Neighbors: " + neighbors.Count);
             }
             RippleColumn ripple = voronoi.voronoiCells[i].theMeshObject.GetComponent <RippleColumn>();
             ripple.SetValues(neighbors, rippleMoveLength, rippleLerpTime, percStartRipple);
         }
     }
 }