Пример #1
0
    // Use this for initialization
    //void Start()
    //{



    //}
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Debug.Log("Pressed left click.");
        }
        if (Input.GetMouseButtonDown(1))
        {
            Debug.Log("Pressed right click.");
            float maxHeight = 15;
            for (float height = 0; height < maxHeight; height = height + 0.5f)
            {
                float length = maxHeight - height;
                for (float x = -length; x <= length; x++)
                {
                    for (float z = -length; z <= length; z++)
                    {
                        if (Mathf.Abs(x) == length || Mathf.Abs(z) == length)
                        {
                            Color color = new Color(Random.Range(0.6f, 0.65f), Random.Range(0.32f, 0.33f), 0.1f, 0.15f);
                            float size  = Random.Range(1f, 1f);
                            VoxelTools.MakeCube(x, height, z, color, size);
                        }
                    }
                }
            }
        }
        if (Input.GetMouseButtonDown(2))
        {
            Debug.Log("Pressed middle click.");
        }
    }
Пример #2
0
    public static Color GetRandomColor()
    {
        VoxelTools.MakeCube(1, 2, 3);
        float r = Random.Range(0f, 1f);
        float g = Random.Range(0f, 1f);
        float b = Random.Range(0f, 1f);

        //make grey/sludge colors less likely
        for (int i = 0; i < Random.Range(1, 3); i++)
        {
            if (Random.Range(0, 10) > 1)
            {
                int a = Random.Range(0, 3);
                if (a == 0)
                {
                    r = 0;
                }
                if (a == 1)
                {
                    g = 0;
                }
                if (a == 2)
                {
                    b = 0;
                }
            }
        }

        return(new Color(r, g, b));
    }
    public void InstantiateBricks(BrickItConfiguration cfg)
    {
        var buildingBlocks = GetBuildingBlocks(cfg);

        foreach (BuildingBlock bb in buildingBlocks)
        {
            Vector3 position = new Vector3(bb.pos.x, bb.pos.y * GlobalConstants.VoxelHeight, bb.pos.z);

            if (bb.isFlipped)
            {
                VoxelTools.MakeCube(position, bb.blockColor, new Vector3(bb.extends.z, bb.extends.y * GlobalConstants.VoxelHeight, bb.extends.x));
            }
            else
            {
                VoxelTools.MakeCube(position, bb.blockColor, new Vector3(bb.extends.x, bb.extends.y * GlobalConstants.VoxelHeight, bb.extends.z));
            }
        }
        var cubeContainer = GameObject.Find(GlobalConstants.cubeContainerName);

        cubeContainer.transform.parent        = GameObject.Find("ModelsContainer").transform;
        cubeContainer.transform.localRotation = Quaternion.identity;
        var boundsHandler = cubeContainer.AddComponent <BoundsHandler>();

        cubeContainer.tag    = GlobalConstants.containerTag;
        cubeContainer.layer  = 9;
        boundsHandler.Bounds = new Vector3(lastExtends[1] - lastExtends[0], lastExtends[3] - lastExtends[2], lastExtends[5] - lastExtends[4]);
        cubeContainer.transform.localPosition = new Vector3(-(boundsHandler.Bounds.x / 2), -(boundsHandler.Bounds.y / 2), -(boundsHandler.Bounds.z / 2));
        lastBricked = cubeContainer;
    }
Пример #4
0
 void Start()
 {
     for (int i = 0; i < 8; i++)
     {
         for (int j = 0; j < 8; j++)
         {
             for (int k = 0; k < 8; k++)
             {
                 VoxelTools.MakeCube(i, j, k);
             }
         }
     }
 }
Пример #5
0
 // Use this for initialization
 void Start()
 {
     for (int i = 0; i < 8; i++)
     {
         for (int j = 0; j < 8; j++)
         {
             for (int k = 0; k < 8; k++)
             {
                 VoxelTools.MakeCube(i + 150, j + 20, k + 150);
             }
         }
     }
 }
Пример #6
0
    public static GameObject MakeCube(Vector3 position, Color color, float size)
    {
        cubeCount++;
        if (cubeContainer == null)
        {
            cubeContainer = new GameObject("cube container");
            cubes         = new List <GameObject>();
        }

        GameObject cube = Instantiate(GetCubePrefab()) as GameObject;

        cubes.Add(cube);
        cube.transform.position = position;
        cube.transform.parent   = cubeContainer.transform;
        cube.name = "cube " + cubeCount;

        cube.GetComponent <Renderer>().material.color = color;
        cube.transform.localScale = new Vector3(size, size, size);

        return(cube);

        VoxelTools.MakeCube(1, 2, 3);
    }
Пример #7
0
    // Start is called before the first frame update
    void Start()
    {
        //between -6 and 6
        int     radius = 6;
        Vector3 center = Vector3.zero;

        for (int i = -radius; i < radius; i++)
        {
            for (int j = -radius; j < radius; j++)
            {
                for (int k = -radius; k < radius; k++)
                {
                    Vector3 position = new Vector3(i, j, k);
                    float   distance = Vector3.Distance(position, center);
                    if (distance < radius)
                    {
                        //calls the makecube() function of voxeltools
                        VoxelTools.MakeCube(i, j, k);
                    }
                }
            }
        }
    }
Пример #8
0
    void AddTerrainCube(float h, int i, int k)
    {
        Color voxColor = SandColor;

        if (h > GrassLevel)
        {
            voxColor = GrassColor;
        }
        if (h > RockLevel)
        {
            voxColor = RockColor;
        }
        if (h > SnowLevel)
        {
            voxColor = SnowColor;
        }
        if (h < WaterLevel)
        {
            voxColor = WaterColor;
            h        = WaterLevel;
        }

        VoxelTools.MakeCube(i, h, k, voxColor);
    }