Пример #1
0
    // PlayerChangingChunk Event method.
    void PlayerChangingChunk(object source, MyEventArgs e)
    {
        Vector3 testPosition = UnityTools.Ceiling(transform.position, chunkLength / 2);

        lastChunk          = currentChunk;
        currentChunk       = UnityTools.ClosestWithTag(this.gameObject, "Chunk");
        currentChunk.layer = 9;
        lastChunk.layer    = 8;
    }
Пример #2
0
    // FacingChunkChanged Event method.
    void FacingChunkChanged(object source, MyEventArgs e)
    {
        Vector3 fwd = transform.TransformDirection(Vector3.forward);

        RaycastHit hit;
        Ray        ray = new Ray(transform.position, fwd);

        if (Physics.Raycast(ray, out hit, chunkLength / 2, 8))
        {
            pointingChunk = hit.transform.parent.gameObject;
        }
        Vector3 testPosition = UnityTools.Ceiling(transform.position + (transform.forward * ((chunkLength / 2) - 1)), chunkLength);
    }
Пример #3
0
    // A coroutine that tries to grow the amount of active chunks.
    IEnumerator TryToGrowChunks()
    {
        while (true)
        {
            List <Vector3> chunkCheckPositions = new List <Vector3>();
            foreach (Vector3 vec3 in localChunkPositions)
            {
                Vector3 key = vec3 + transform.position;
                key = UnityTools.Ceiling(key, chunkLength);
                if (!master.GetComponent <MasterController>().chunkData.ContainsKey(key))
                {
                    chunkCheckPositions.Add(key);
                }
            }

            chunkCheckPositions.ForEach(x => TryToAddChunk(x));
            CheckLoadedChunks(chunkCheckPositions);
            yield return(new WaitForSeconds(2f));
        }
    }
Пример #4
0
 // PlayerAtEdge Event method.
 void PlayerAtEdge(object source, MyEventArgs e)
 {
     Vector3 testPosition = UnityTools.Ceiling(transform.position + (transform.forward * ((chunkLength / 2) - 1)), chunkLength);
 }