Пример #1
0
    // Start is called before the first frame update
    void Start()
    {
        Init();
        GameObject floorplane   = GameObject.CreatePrimitive(PrimitiveType.Plane);
        GameObject ceilingplane = GameObject.CreatePrimitive(PrimitiveType.Plane);

        floorplane.transform.localScale   = new Vector3(0.4f * ((mapSize.x * worldSize.x) / 2), 1.0f, 0.4f * ((mapSize.z * worldSize.y) / 2));
        floorplane.transform.position     = new Vector3(0, 0, ((worldSize.y / 2) * (mapSize.z * bounds.size.z * scl)));
        ceilingplane.transform.localScale = new Vector3(0.4f * ((mapSize.x * worldSize.x) / 2), 1.0f, 0.4f * ((mapSize.z * worldSize.y) / 2));
        ceilingplane.transform.position   = new Vector3(0, bounds.size.y, ((worldSize.y / 2) * (mapSize.z * bounds.size.z * scl)));
        ceilingplane.transform.rotation   = new Quaternion(0, 0, 90, 1);

        MakeNoise();

        for (int x = 0; x < worldSize.x; x++)
        {
            for (int y = 0; y < worldSize.x; y++)
            {
                var chunkPosX = (((x + 1) / 2) * ((((x + 1) % 2) * 2) - 1));
                MapInit(x, y);
                chunk     = new GameObject("Chunk" + (4 + chunkPosX).ToString() + y.ToString());
                chunk.tag = "chunk";
                MapGenerate();
                mapCtl.SetBounds(bounds);
                mapCtl.SetScl(scl);
                chunk.transform.position        = new Vector3((mapSize.x * (bounds.size.x * scl)) * chunkPosX, 0.0f, (mapSize.z * (bounds.size.z * scl)) * y);
                mapCtl.chunks[4 + chunkPosX][y] = chunk;
            }
        }
    }