Esempio n. 1
0
    private void CreatPathCell(Path newPath, int x, int y)
    {
        //startedPlacingCells = true;
        float      height = perlinRoomGenerator.GetFloorHeightAt(new Vector2Int(x, y));
        GameObject plane  = GameObject.CreatePrimitive(PrimitiveType.Cube);

        //plane.transform.localScale = Vector3.one * 0.1f;
        plane.transform.SetParent(transform);
        plane.transform.localPosition            = new Vector3(x, height * 1.5f - 0.5f, y);
        plane.GetComponent <Renderer>().material = environment.FloorMat;
        plane.layer = ShiftingHelper.ShiftBack(environment.FloorLayer);
        Cell cell = plane.AddComponent <Cell>();

        cell.Position = new Vector2Int(x, y);
        cells[x, y]   = cell;
        newPath.Cells.Add(cell);
        cell.Group = newPath;
        cell.transform.SetParent(newPath.transform);
    }
Esempio n. 2
0
 private void GenerateLine(int x, int y)
 {
     while (y >= 0)
     {
         float height = GetFloorHeightAt(new Vector2Int(x, y));
         if ((height > threshold) != invert)
         {
             GameObject plane = GameObject.CreatePrimitive(PrimitiveType.Cube);
             //plane.transform.localScale = Vector3.one * 0.1f;
             plane.transform.SetParent(transform);
             float planeHeight = useHeight ? height * 1.5f - 0.5f : 0;
             plane.transform.localPosition            = new Vector3(x, planeHeight, y);
             plane.GetComponent <Renderer>().material = environment.FloorMat;
             plane.layer = ShiftingHelper.ShiftBack(environment.FloorLayer);
             Cell cell = plane.AddComponent <Cell>();
             cell.Position = new Vector2Int(x, y);
             cells[x, y]   = cell;
         }
         y--;
     }
 }