Exemplo n.º 1
0
    // Start is called before the first frame update
    void Start()
    {
        meshFilter = GetComponent <MeshFilter>();

        Vector3[] positions = MeshSpawner.GetSpawnPosition(meshFilter.mesh, transform, Vector3.up, 45, 100);

        for (int i = 0; i < positions.Length; i++)
        {
            Vector3    pos  = transform.TransformPoint(positions[i]);
            GameObject objt = Instantiate(obj, pos, Random.rotation);
            objt.transform.localScale = Vector3.one * Random.Range(0.5f, 1.5f);
        }
    }
Exemplo n.º 2
0
    public void GeneratePlayerStart()
    {
        bool       validPos = false;
        GameObject chunk;

        while (!validPos)
        {
            Vector3Int objChunk = Vector3Int.CeilToInt((Random.insideUnitSphere * 500) / ChunkSize);
            chunk = LoadChunk(objChunk);
            Vector3[] listPos = MeshSpawner.GetSpawnPosition(chunk.GetComponent <MeshFilter>().mesh, chunk.transform, Vector3.up, 20, 50.0f);

            if (listPos.Length > 10)
            {
                validPos = true;
                player.transform.position = listPos[0] + chunk.transform.position + Vector3.up;
            }
        }
    }
Exemplo n.º 3
0
    public void GenerateObjectif()
    {
        bool       validPos = false;
        GameObject chunk;

        while (!validPos)
        {
            Vector3Int objChunk = Vector3Int.CeilToInt((player.transform.position + Random.onUnitSphere * 50) / ChunkSize);
            chunk = LoadChunk(objChunk);
            chunk.GetComponent <Chunk>().Unused = true;
            Vector3[] listPos = MeshSpawner.GetSpawnPosition(chunk.GetComponent <MeshFilter>().mesh, chunk.transform, Vector3.up, 20, 1);

            if (listPos.Length > 0)
            {
                validPos = true;
                GameObject tempObj = Instantiate(Objectif, listPos[0] + chunk.transform.position, Quaternion.identity);
                chunk.GetComponent <Chunk>().objectives.Add(tempObj);

                objectifChunk = chunk;
                chunk.GetComponent <Chunk>().Unused = false;
                GameManager.Instance.ChunkManager.ModifiedChunkList[chunk.GetComponent <Chunk>().Coordonnate.ToString()] = new Chunk_Data(chunk);
            }
        }
    }