Beispiel #1
0
    void randomFillMap()
    {
        if (useRandomSeed)
        {
            meshGen = GetComponent <GenerateTiledCilinderChunk2>();
            seed    = Time.time.ToString() + meshGen.chunkIndex.ToString();
        }
        System.Random Random = new System.Random(seed.GetHashCode());

        for (int x = 0; x < chunkSize.x; x++)
        {
            for (int y = 0; y < chunkSize.y; y++)
            {
                if (false /*x == 0 || x == chunkSize.x - 1 /*|| y == 0 || y == chunkSize.y -1*/)
                {
                    walls[x, y] = true;
                }
                else if (y < 3 || y > chunkSize.y - 3)
                {
                    walls[x, y] = false;
                }
                else
                {
                    walls[x, y] = (Random.Next(0, 100) < randomFillPercent) ? true : false;
                }
            }
        }
    }
Beispiel #2
0
    void UpdatePosition()
    {
        GenerateTiledCilinderChunk2 chunkMeshGen = currentChunk.GetComponent <GenerateTiledCilinderChunk2>();

        float deg = ((2 * Mathf.PI) / (chunkMeshGen.chunkCount * chunkMeshGen.chunkLength));
        float dir = (deg * (chunkPos.y + .5f)) + (deg * chunkMeshGen.chunkLength * chunkMeshGen.chunkIndex);

        float radius = (chunkMeshGen.chunkCount * currentChunk.chunkSize.y) / (2 * Mathf.PI) - .5f;

        transform.position = new Vector3(chunkPos.x + .5f, Mathf.Sin(dir) * radius, Mathf.Cos(dir) * radius);

        transform.rotation = Quaternion.Euler(-dir * 57.3f, 0, 0);
    }
Beispiel #3
0
    void Update()
    {
        GenerateTiledCilinderChunk2 currentchunk = player.currentChunk.GetComponent <GenerateTiledCilinderChunk2>();
        int chunkcount  = currentchunk.chunkCount;
        int chunklength = currentchunk.chunkLength;

        float radius = (chunkcount * chunklength) / (2 * Mathf.PI) * Distance;

        float deg = ((2 * Mathf.PI) / (chunkcount * chunklength));
        float dir = (-deg * yPos) + (deg * chunklength * 1.7f);

        DEATH.position = new Vector3(currentchunk.chunkWidth / 2 + .5f, Mathf.Cos(dir) * radius, Mathf.Sin(dir) * radius);

        DEATH.rotation = Quaternion.Euler(dir * 57.3f, 0, 0);;
    }
Beispiel #4
0
    void LateUpdate()
    {
        GenerateTiledCilinderChunk2 currentchunk = player.currentChunk.GetComponent <GenerateTiledCilinderChunk2>();

        float radius = (currentchunk.chunkCount * currentchunk.chunkLength) / (2 * Mathf.PI) * cameraDistance;

        float deg = ((2 * Mathf.PI) / (currentchunk.chunkCount * currentchunk.chunkLength));
        float dir = (deg * -player.chunkPos.y) + (deg * currentchunk.chunkLength * (-currentchunk.chunkIndex)) + 1.8f;

        camera.position = new Vector3(currentchunk.chunkWidth / 2 + .5f, Mathf.Cos(dir) * radius, Mathf.Sin(dir) * radius);

        Vector3 rot = player.transform.rotation.eulerAngles;

        camera.rotation = player.transform.rotation;
        camera.Rotate(new Vector3(-40, 180, 0));
    }
 void Start()
 {
     chunkGen = GetComponent <GenerateTiledCilinderChunk2>();
     GenerateEnviroment();
 }