コード例 #1
0
    void Update()
    {
        base.Update();
        if (updateLandscape == true)
        {
            m_terrainGrid[curCyclicIndexX, curCyclicIndexZ].GetComponent <Collider>().enabled   = true;     //Slow operation
            m_terrainGrid[prevCyclicIndexX, prevCyclicIndexZ].GetComponent <Collider>().enabled = false;

            UpdateTerrainNeighbors();
            UpdateTerrainPositions();
        }

        if (PatchManager.patchQueue.Count != 0)
        {
            terrainIsFlushed = false;
            if (patchIsFilling == false)
            {
                patchToBeFilled = PatchManager.patchQueue.Dequeue();
                StartCoroutine(CountdownForPatch());
            }
            if (patchToBeFilled != null)
            {
                patchToBeFilled.ExecutePatch();
                patchToBeFilled = null;
            }
        }
        else if (PatchManager.patchQueue.Count == 0 && terrainIsFlushed == false)
        {
            StartCoroutine(FlushTerrain());
            terrainIsFlushed = true;
        }
    }
コード例 #2
0
    protected override void Update()
    {
        base.Update();

        /*
         * //-------Just debugging--------
         * if(updateRound)
         * {
         *      // previous was updateRound
         *      float executionTime = Time.time - StartTime;
         *      //Debug.Log(updatecounter + ": ----------------------------------------> Execution time " + executionTime);
         *      updateRound = false;
         * }
         * updateRound = updateLandscape;
         * StartTime = Time.deltaTime;
         * //--------Just debugging ends -------
         */

        if (updateLandscape == true)
        {
            m_terrainGrid[curCyclicIndexX, curCyclicIndexZ].GetComponent <Collider>().enabled = true;        //Slow operation

            // for displaying data in UI:
            Terrain current = m_terrainGrid[curCyclicIndexX, curCyclicIndexZ];
            //Debug.Log("-------> entering " + current.name);

            terrainName.text = current.name;
            int massType = InfiniteTerrain.GetOrAssignLandMassTypes(current.name);

            hillsValue.text           = (massType & 1) > 0 ? "yes": "no";
            mountainsValue.text       = (massType & 2) > 0 ? "yes": "no";
            ridgedMountainsValue.text = (massType & 4) > 0 ? "yes" : "no";
            plainsValue.text          = (massType & 8) > 0 ? "yes" : "no";

            m_terrainGrid[prevCyclicIndexX, prevCyclicIndexZ].GetComponent <Collider>().enabled = false;

            UpdateTerrainNeighbors();
            UpdateTerrainPositions();
        }

        if (PatchManager.patchQueue.Count != 0)
        {
            terrainIsFlushed = false;
            if (patchIsFilling == false)
            {
                patchToBeFilled = PatchManager.patchQueue.Dequeue();
                StartCoroutine(CountdownForPatch());
            }
            if (patchToBeFilled != null)
            {
                //float execTime = Time.time - oneUpdateTime;

                /*
                 * if(patchToBeFilled is TerrainPatch)
                 * Debug.Log( execTime + "     Executed TerrainPatch...");
                 * if (patchToBeFilled is SplatDetailPatch)
                 * Debug.Log(execTime + "     Executed SplatDetailPatch...");
                 * if (patchToBeFilled is TreePatch)
                 * Debug.Log(execTime + "     Execute TreePatch...");
                 */

                /*
                 * if(execTime > 0.1f)
                 * {
                 * Debug.Log(Time.time +  "------------------> exec time " + execTime);
                 * }
                 */

                //for debugging
                //oneUpdateTime = Time.time;

                patchToBeFilled.ExecutePatch();
                patchToBeFilled = null;
            }
        }
        else if (PatchManager.patchQueue.Count == 0 && terrainIsFlushed == false)
        {
            StartCoroutine(FlushTerrain());
            terrainIsFlushed = true;
        }
    }