示例#1
0
 protected void UpdateRevealers(int deltaMS)
 {
     for (int i = m_revealers.Count - 1; i >= 0; i--)
     {
         IFOWRevealer revealer = m_revealers[i];
         revealer.Update(deltaMS);
         if (!revealer.IsValid())
         {
             m_revealers.RemoveAt(i);
             FOWSystem.RemoveRevealer(revealer);
             revealer.Release();
         }
     }
 }
示例#2
0
    /// <summary>
    /// Update the fog of war's visibility.
    /// </summary>

    void UpdateBuffer()
    {
        // Add all items scheduled to be added
        if (mAdded.size > 0)
        {
            lock (mAdded)
            {
                while (mAdded.size > 0)
                {
                    int index = mAdded.size - 1;
                    mRevealers.Add(mAdded.buffer[index]);
                    mAdded.RemoveAt(index);
                }
            }
        }

        // Remove all items scheduled for removal
        if (mRemoved.size > 0)
        {
            lock (mRemoved)
            {
                while (mRemoved.size > 0)
                {
                    int index = mRemoved.size - 1;
                    mRevealers.Remove(mRemoved.buffer[index]);
                    mRemoved.RemoveAt(index);
                }
            }
        }

        // Use the texture blend time, thus estimating the time this update will finish
        // Doing so helps avoid visible changes in blending caused by the blended result being X milliseconds behind.
        //使用纹理混合时间,从而估计此更新将完成的时间
        //这样做有助于避免由于混合结果落后X毫秒而导致混合中的可见变化。
        float factor = (textureBlendTime > 0f) ? Mathf.Clamp01(mBlendFactor + mElapsed / textureBlendTime) : 1f;

        //// Clear the buffer's red channel (channel used for current visibility -- it's updated right after)
        ////清除缓冲区的红色通道(用于当前可见性的通道-此通道将在之后立即更新)
        for (int i = 0, imax = mBuffer0.Length; i < imax; ++i)
        {
            mBuffer0[i]   = Color32.Lerp(mBuffer0[i], mBuffer1[i], factor);
            mBuffer1[i].r = 0;
        }

        // For conversion from world coordinates to texture coordinates
        //用于从世界坐标转换为纹理坐标
        float worldToTex = (float)textureSize / worldSize;

        // Update the visibility buffer, one revealer at a time
        //更新可见性缓冲区,一次显示一个
        for (int i = 0; i < mRevealers.size; ++i)
        {
            IFOWRevealer rev = mRevealers[i];
            if (rev.IsValid())
            {
                RevealUsingRadius(rev, worldToTex);
            }
        }

        // Blur the final visibility data
        for (int i = 0; i < blurIterations; ++i)
        {
            BlurVisibility();
        }

        // Reveal the map based on what's currently visible
        RevealMap();

        // Merge two buffer to one
        MergeBuffer();
    }
示例#3
0
    /// <summary>
    /// Update the fog of war's visibility.
    /// </summary>

    void UpdateBuffer()
    {
        // Add all items scheduled to be added
        if (mAdded.Count > 0)
        {
            lock (mAdded)
            {
                while (mAdded.Count > 0)
                {
                    int index = mAdded.Count - 1;
                    mRevealers.Add(mAdded[index]);
                    mAdded.RemoveAt(index);
                }
            }
        }

        // Remove all items scheduled for removal
        if (mRemoved.Count > 0)
        {
            lock (mRemoved)
            {
                while (mRemoved.Count > 0)
                {
                    int index = mRemoved.Count - 1;
                    mRevealers.Remove(mRemoved[index]);
                    mRemoved.RemoveAt(index);
                }
            }
        }

        // Use the texture blend time, thus estimating the time this update will finish
        // Doing so helps avoid visible changes in blending caused by the blended result being X milliseconds behind.
        float factor = (textureBlendTime > 0f) ? Mathf.Clamp01(mBlendFactor + mElapsed / textureBlendTime) : 1f;

        // Clear the buffer's red channel (channel used for current visibility -- it's updated right after)
        for (int i = 0, imax = mBuffer0.Length; i < imax; ++i)
        {
            mBuffer0[i]   = Color32.Lerp(mBuffer0[i], mBuffer1[i], factor);
            mBuffer1[i].r = 0;
        }

        // For conversion from world coordinates to texture coordinates
        float worldToTex = (float)textureSize / worldSize;

        // Update the visibility buffer, one revealer at a time
        for (int i = 0; i < mRevealers.Count; ++i)
        {
            IFOWRevealer rev = mRevealers[i];
            if (rev.IsValid())
            {
                RevealUsingRadius(rev, worldToTex);
            }
        }

        // Blur the final visibility data
        for (int i = 0; i < blurIterations; ++i)
        {
            BlurVisibility();
        }

        // Reveal the map based on what's currently visible
        RevealMap();

        // Merge two buffer to one
        MergeBuffer();
    }