コード例 #1
0
 protected virtual void OnDestroy()
 {
     if (mRevealer != null)
     {
         FOWSystem.DeleteRevealer(mRevealer);
         mRevealer = null;
     }
 }
コード例 #2
0
ファイル: FOWRevealer.cs プロジェクト: whztt07/mobahero_src
 public void DoDestroy()
 {
     if (this.onlygrass)
     {
         return;
     }
     FOWSystem.DeleteRevealer(this.mRevealer);
     this.mRevealer = null;
 }
コード例 #3
0
    public static void DeleteRevealer(FOWSystem.Revealer rev)
    {
        BetterList <FOWSystem.Revealer> obj = FOWSystem.mRemoved;

        lock (obj)
        {
            FOWSystem.mRemoved.Add(rev);
        }
    }
コード例 #4
0
    public void RemoveRevealer(FOWSystem.Revealer rev)
    {
        BetterList <FOWSystem.Revealer> obj = FOWSystem.staticRevealers;

        lock (obj)
        {
            FOWSystem.staticRevealers.Remove(rev);
        }
        this.RefreshStaticRevealer();
    }
コード例 #5
0
    public static void CreateStaticTimeRevealer(Vector3 pos, float rad, float tim)
    {
        FOWSystem.Revealer revealer = new FOWSystem.Revealer();
        revealer.los      = FOWSystem.LOSChecks.OnlyOnce;
        revealer.isActive = true;
        FOWSystem.Revealer arg_1F_0 = revealer;
        revealer.outer = rad;
        arg_1F_0.inner = rad;
        revealer.time  = tim;
        revealer.pos   = pos;
        BetterList <FOWSystem.Revealer> obj = FOWSystem.mAdded;

        lock (obj)
        {
            FOWSystem.mAdded.Add(revealer);
        }
    }
コード例 #6
0
ファイル: FOWRevealer.cs プロジェクト: whztt07/mobahero_src
 public void Create(Transform transform, float rad, FOWSystem.LOSChecks typ = FOWSystem.LOSChecks.EveryUpdate, bool _onlygrass = false)
 {
     this.mTrans    = transform;
     this.onlygrass = _onlygrass;
     if (!_onlygrass)
     {
         this.range.y            = rad;
         this.range.x            = 2f;
         this.lineOfSightCheck   = typ;
         this.mRevealer          = FOWSystem.CreateRevealer(typ);
         this.mRevealer.outer    = rad;
         this.mRevealer.los      = typ;
         this.mRevealer.pos      = transform.position;
         this.mRevealer.prvpos   = this.mRevealer.pos;
         this.mRevealer.isActive = true;
         this.isActive           = true;
     }
     this.unit = transform.gameObject.GetComponent <Units>();
 }
コード例 #7
0
 public static FOWSystem.Revealer CreateRevealer(FOWSystem.LOSChecks ls = FOWSystem.LOSChecks.EveryUpdate)
 {
     FOWSystem.Revealer revealer = new FOWSystem.Revealer();
     revealer.isActive = false;
     revealer.los      = ls;
     if (ls != FOWSystem.LOSChecks.Static)
     {
         BetterList <FOWSystem.Revealer> obj = FOWSystem.mAdded;
         lock (obj)
         {
             FOWSystem.mAdded.Add(revealer);
         }
     }
     else
     {
         FOWSystem.staticRevealers.Add(revealer);
     }
     return(revealer);
 }
コード例 #8
0
    private void RevealUsingBCache(FOWSystem.Revealer r, float worldToTex, bool imm = false)
    {
        Vector3 vector = r.pos - this.mOrigin;
        int     num    = Mathf.RoundToInt((vector.x - r.outer) * worldToTex);
        int     num2   = Mathf.RoundToInt((vector.z - r.outer) * worldToTex);
        int     num3   = Mathf.RoundToInt((vector.x + r.outer) * worldToTex);
        int     num4   = Mathf.RoundToInt((vector.z + r.outer) * worldToTex);
        int     num5   = Mathf.RoundToInt(vector.x * worldToTex);
        int     num6   = Mathf.RoundToInt(vector.z * worldToTex);

        num5 = Mathf.Clamp(num5, 0, this.textureSize - 1);
        num6 = Mathf.Clamp(num6, 0, this.textureSize - 1);
        int   num7 = Mathf.RoundToInt(r.outer * r.outer * worldToTex * worldToTex);
        float num8 = (float)this.worldSize / (float)this.textureSize;

        for (int i = num2; i < num4; i++)
        {
            if (i > -1 && i < this.textureSize)
            {
                for (int j = num; j < num3; j++)
                {
                    if (j > -1 && j < this.textureSize)
                    {
                        int num9  = j - num5;
                        int num10 = i - num6;
                        int num11 = num9 * num9 + num10 * num10;
                        int num12 = j + i * this.textureSize;
                        if (num11 < num7)
                        {
                            Color color = this.mBuffer2[num12];
                            this.mBuffer1[num12] = color;
                            if (imm)
                            {
                                this.mBuffer0[num12] = color;
                            }
                        }
                    }
                }
            }
        }
    }
コード例 #9
0
    private void RevealUsingRadius(FOWSystem.Revealer r, float worldToTex, bool imm = false)
    {
        Vector3 vector = r.pos - this.mOrigin;
        int     num    = Mathf.RoundToInt((vector.x - r.outer) * worldToTex);
        int     num2   = Mathf.RoundToInt((vector.z - r.outer) * worldToTex);
        int     num3   = Mathf.RoundToInt((vector.x + r.outer) * worldToTex);
        int     num4   = Mathf.RoundToInt((vector.z + r.outer) * worldToTex);
        int     num5   = Mathf.RoundToInt(vector.x * worldToTex);
        int     num6   = Mathf.RoundToInt(vector.z * worldToTex);

        num5 = Mathf.Clamp(num5, 0, this.textureSize - 1);
        num6 = Mathf.Clamp(num6, 0, this.textureSize - 1);
        int num7 = Mathf.RoundToInt(r.outer * r.outer * worldToTex * worldToTex);

        for (int i = num2; i < num4; i++)
        {
            if (i > -1 && i < this.textureSize)
            {
                int num8 = i * this.textureSize;
                for (int j = num; j < num3; j++)
                {
                    if (j > -1 && j < this.textureSize)
                    {
                        int num9  = j - num5;
                        int num10 = i - num6;
                        int num11 = num9 * num9 + num10 * num10;
                        if (num11 < num7)
                        {
                            this.mBuffer1[j + num8].r = 1f;
                            if (imm)
                            {
                                this.mBuffer0[j + num8].r = 1f;
                            }
                        }
                    }
                }
            }
        }
    }
コード例 #10
0
    private void RevealUsingCache(FOWSystem.Revealer r, float worldToTex, bool imm = false)
    {
        if (r.cachedBuffer == null)
        {
            this.RevealIntoCache(r, worldToTex);
        }
        int i   = r.cachedY;
        int num = r.cachedY + r.cachedSize;

        while (i < num)
        {
            if (i > -1 && i < this.textureSize)
            {
                int num2 = i * this.textureSize;
                int num3 = (i - r.cachedY) * r.cachedSize;
                int j    = r.cachedX;
                int num4 = r.cachedX + r.cachedSize;
                while (j < num4)
                {
                    if (j > -1 && j < this.textureSize)
                    {
                        int num5 = j - r.cachedX + num3;
                        if (r.cachedBuffer[num5])
                        {
                            this.mBuffer1[j + num2].r = 1f;
                            this.mBuffer2[j + num2].r = 1f;
                            if (imm)
                            {
                                this.mBuffer0[j + num2].r = 1f;
                            }
                        }
                    }
                    j++;
                }
            }
            i++;
        }
    }
コード例 #11
0
    private void RevealIntoCache(FOWSystem.Revealer r, float worldToTex)
    {
        Vector3 vector = r.pos - this.mOrigin;
        int     num    = Mathf.RoundToInt((vector.x - r.outer) * worldToTex);
        int     num2   = Mathf.RoundToInt((vector.z - r.outer) * worldToTex);
        int     num3   = Mathf.RoundToInt((vector.x + r.outer) * worldToTex);
        int     num4   = Mathf.RoundToInt((vector.z + r.outer) * worldToTex);
        int     num5   = Mathf.RoundToInt(vector.x * worldToTex);
        int     num6   = Mathf.RoundToInt(vector.z * worldToTex);

        num5 = Mathf.Clamp(num5, 0, this.textureSize - 1);
        num6 = Mathf.Clamp(num6, 0, this.textureSize - 1);
        int num7 = Mathf.RoundToInt((float)(num3 - num));

        r.cachedBuffer = new bool[num7 * num7];
        r.cachedSize   = num7;
        r.cachedX      = num;
        r.cachedY      = num2;
        int i    = 0;
        int num8 = num7 * num7;

        while (i < num8)
        {
            r.cachedBuffer[i] = false;
            i++;
        }
        int num9        = Mathf.RoundToInt(r.inner * r.inner * worldToTex * worldToTex);
        int num10       = Mathf.RoundToInt(r.outer * r.outer * worldToTex * worldToTex);
        int sightHeight = (int)this.WorldToGridHeight(r.pos.y);
        int ingrass     = (this.mHeights[num5 + num6 * this.textureSize] < 200) ? 0 : 1;

        for (int j = num2; j < num4; j++)
        {
            if (j > -1 && j < this.textureSize)
            {
                for (int k = num; k < num3; k++)
                {
                    if (k > -1 && k < this.textureSize)
                    {
                        int num11 = k - num5;
                        int num12 = j - num6;
                        int num13 = num11 * num11 + num12 * num12;
                        int num14 = k - num + (j - num2) * num7;
                        int num15 = k + j * this.textureSize;
                        if (this.mBuffer1[num15].b == 1f)
                        {
                            if (num14 < r.cachedBuffer.Length && num14 >= 0)
                            {
                                r.cachedBuffer[num14] = true;
                            }
                        }
                        else if (num13 < num9)
                        {
                            if (num14 < r.cachedBuffer.Length && num14 >= 0)
                            {
                                r.cachedBuffer[num14] = true;
                            }
                        }
                        else if (num13 < num10)
                        {
                            Vector2 a = new Vector2((float)num11, (float)num12);
                            a.Normalize();
                            a *= r.inner;
                            int num16 = num5 + Mathf.RoundToInt(a.x);
                            int num17 = num6 + Mathf.RoundToInt(a.y);
                            if (num16 > -1 && num16 < this.textureSize && num17 > -1 && num17 < this.textureSize && this.IsVisible(num16, num17, k, j, sightHeight, (int)this.margin, ingrass) && num14 < r.cachedBuffer.Length && num14 >= 0)
                            {
                                r.cachedBuffer[num14] = true;
                            }
                        }
                    }
                }
            }
        }
    }
コード例 #12
0
    private void RevealUsingLOS(FOWSystem.Revealer r, float worldToTex, bool imm = false)
    {
        Vector3 vector = r.pos - this.mOrigin;
        int     num    = Mathf.RoundToInt((vector.x - r.outer) * worldToTex);
        int     num2   = Mathf.RoundToInt((vector.z - r.outer) * worldToTex);
        int     num3   = Mathf.RoundToInt((vector.x + r.outer) * worldToTex);
        int     num4   = Mathf.RoundToInt((vector.z + r.outer) * worldToTex);
        int     num5   = Mathf.RoundToInt(vector.x * worldToTex);
        int     num6   = Mathf.RoundToInt(vector.z * worldToTex);

        num5 = Mathf.Clamp(num5, 0, this.textureSize - 1);
        num6 = Mathf.Clamp(num6, 0, this.textureSize - 1);
        int   num7        = Mathf.RoundToInt(r.inner * r.inner * worldToTex * worldToTex);
        int   num8        = Mathf.RoundToInt(r.outer * r.outer * worldToTex * worldToTex);
        int   sightHeight = (int)this.WorldToGridHeight(r.pos.y);
        int   ingrass     = (this.mHeights[num5 + num6 * this.textureSize] < 200) ? 0 : 1;
        float num9        = (float)this.worldSize / (float)this.textureSize;

        for (int i = num2; i < num4; i++)
        {
            if (i > -1 && i < this.textureSize)
            {
                for (int j = num; j < num3; j++)
                {
                    if (j > -1 && j < this.textureSize)
                    {
                        int num10 = j - num5;
                        int num11 = i - num6;
                        int num12 = num10 * num10 + num11 * num11;
                        int num13 = j + i * this.textureSize;
                        if (this.mBuffer1[num13].b == 1f)
                        {
                            this.mBuffer1[num13].r = 1f;
                            this.mBuffer1[num13].g = 0f;
                            this.mBuffer2[num13].r = 1f;
                            this.mBuffer2[num13].g = 0f;
                            if (imm)
                            {
                                this.mBuffer0[num13].r = 1f;
                                this.mBuffer0[num13].g = 0f;
                            }
                        }
                        else if (num12 < num7)
                        {
                            this.mBuffer1[num13].r = 1f;
                            this.mBuffer1[num13].g = 0f;
                            this.mBuffer2[num13].r = 1f;
                            this.mBuffer2[num13].g = 0f;
                            if (imm)
                            {
                                this.mBuffer0[num13].r = 1f;
                                this.mBuffer0[num13].g = 0f;
                            }
                        }
                        else if (num12 < num8)
                        {
                            Vector2 a = new Vector2((float)num10, (float)num11);
                            a.Normalize();
                            a *= r.inner;
                            int num14 = num5 + Mathf.RoundToInt(a.x);
                            int num15 = num6 + Mathf.RoundToInt(a.y);
                            if (num14 > -1 && num14 < this.textureSize && num15 > -1 && num15 < this.textureSize && this.IsVisible(num14, num15, j, i, sightHeight, (int)this.margin, ingrass))
                            {
                                this.mBuffer1[num13].r = 1f;
                                this.mBuffer1[num13].g = 0f;
                                this.mBuffer2[num13].r = 1f;
                                this.mBuffer2[num13].g = 0f;
                                if (imm)
                                {
                                    this.mBuffer0[num13].r = 1f;
                                    this.mBuffer0[num13].g = 0f;
                                }
                            }
                            else
                            {
                                this.mBuffer1[num13].g = 1f;
                                this.mBuffer2[num13].g = 1f;
                            }
                        }
                    }
                }
            }
        }
    }
コード例 #13
0
    private void UpdateBuffer()
    {
        this.updatating = true;
        bool flag = false;

        if (FOWSystem.mAdded.size > 0)
        {
            BetterList <FOWSystem.Revealer> obj = FOWSystem.mAdded;
            lock (obj)
            {
                while (FOWSystem.mAdded.size > 0)
                {
                    int num = FOWSystem.mAdded.size - 1;
                    FOWSystem.mRevealers.Add(FOWSystem.mAdded.buffer[num]);
                    FOWSystem.mAdded.RemoveAt(num);
                }
            }
        }
        Color[] array = this.mBuffer2;
        this.mBuffer2 = this.mBuffer1;
        this.mBuffer1 = array;
        if (FOWSystem.mRemoved.size > 0)
        {
            BetterList <FOWSystem.Revealer> obj2 = FOWSystem.mRemoved;
            lock (obj2)
            {
                while (FOWSystem.mRemoved.size > 0)
                {
                    int num2 = FOWSystem.mRemoved.size - 1;
                    FOWSystem.Revealer revealer = FOWSystem.mRemoved.buffer[num2];
                    if (revealer.los != FOWSystem.LOSChecks.Static)
                    {
                        FOWSystem.mRevealers.Remove(revealer);
                        FOWSystem.mRemoved.RemoveAt(num2);
                    }
                    else if (FOWSystem.staticRevealers.Contains(revealer))
                    {
                        flag = true;
                        FOWSystem.staticRevealers.Remove(revealer);
                        FOWSystem.mRemoved.RemoveAt(num2);
                    }
                }
            }
            if (flag)
            {
                this.RefreshStaticRevealer();
            }
        }
        float num3 = this.mElapsed * 100f;

        if (FOWSystem.effectVisible)
        {
            int i    = 0;
            int num4 = this.mBuffer1.Length;
            while (i < num4)
            {
                Color color  = this.mBuffer0[i];
                Color color2 = this.mBuffer1[i];
                if (color.r < color2.r)
                {
                    this.mBuffer0[i].r = Mathf.Lerp(this.mBuffer0[i].r, color2.r, num3 * 1f);
                }
                else
                {
                    this.mBuffer0[i].r = Mathf.Lerp(this.mBuffer0[i].r, color2.r, num3 * (0.2f + color2.g));
                }
                color2.g           = Mathf.Lerp(color2.g, 0f, num3);
                this.mBuffer1[i].r = color2.b;
                this.mBuffer1[i].g = color2.g;
                this.mBuffer2[i].g = color2.g;
                i++;
            }
        }
        else
        {
            int j    = 0;
            int num5 = this.mBuffer1.Length;
            while (j < num5)
            {
                Color color3 = this.mBuffer0[j];
                Color color4 = this.mBuffer1[j];
                this.mBuffer0[j]   = color4;
                color4.g           = Mathf.Lerp(color4.g, 0f, num3);
                this.mBuffer1[j].r = color4.b;
                this.mBuffer1[j].g = color4.g;
                this.mBuffer2[j].g = color4.g;
                j++;
            }
        }
        float worldToTex = (float)this.textureSize / (float)this.worldSize;

        for (int k = 0; k < FOWSystem.mRevealers.size; k++)
        {
            FOWSystem.Revealer revealer2 = FOWSystem.mRevealers[k];
            if (revealer2.isActive)
            {
                if (revealer2.los == FOWSystem.LOSChecks.None || GlobalSettings.FogMode == 4)
                {
                    this.RevealUsingRadius(revealer2, worldToTex, revealer2.immidate);
                }
                else if (revealer2.los == FOWSystem.LOSChecks.OnlyOnce)
                {
                    revealer2.time -= this.mElapsed * 100f;
                    if (revealer2.time <= 0f)
                    {
                        revealer2.time = 0f;
                        BetterList <FOWSystem.Revealer> obj3 = FOWSystem.mRemoved;
                        lock (obj3)
                        {
                            FOWSystem.mRemoved.Add(revealer2);
                        }
                        goto IL_49C;
                    }
                    this.RevealUsingCache(revealer2, worldToTex, revealer2.immidate);
                }
                else if (revealer2.moved)
                {
                    this.RevealUsingLOS(revealer2, worldToTex, revealer2.immidate);
                    revealer2.moved = false;
                }
                else
                {
                    this.RevealUsingBCache(revealer2, worldToTex, revealer2.immidate);
                }
                revealer2.immidate = false;
            }
            IL_49C :;
        }
        if (FOWSystem.effectVisible)
        {
            this.BlurVisibility1();
        }
        this.updatating = false;
    }
コード例 #14
0
 protected virtual void Start()
 {
     mTrans    = transform;
     mRevealer = FOWSystem.CreateRevealer();
 }
コード例 #15
0
	void Awake ()
	{
		mTrans = transform;
		mRevealer = FOWSystem.CreateRevealer();
	}
コード例 #16
0
    public void RefreshStaticRevealer()
    {
        float   num = 3.2f;
        Vector3 b   = this.mOrigin;

        b.y = 0f;
        float num2 = (float)this.worldSize / (float)this.textureSize;
        float num3 = (float)this.textureSize / (float)this.worldSize;

        for (int i = 0; i < this.textureSize; i++)
        {
            b.z = this.mOrigin.z + (float)i * num2;
            for (int j = 0; j < this.textureSize; j++)
            {
                b.x = this.mOrigin.x + (float)j * num2;
                for (int k = 0; k < FOWSystem.staticRevealers.size; k++)
                {
                    FOWSystem.Revealer revealer = FOWSystem.staticRevealers[k];
                    Vector3            pos      = revealer.pos;
                    pos.y = 0f;
                    Vector3 vector = revealer.pos - this.mOrigin;
                    float   num4   = Vector3.Distance(pos, b);
                    if (num4 <= revealer.outer)
                    {
                        int num5 = Mathf.RoundToInt(vector.x * num3);
                        int num6 = Mathf.RoundToInt(vector.z * num3);
                        num5 = Mathf.Clamp(num5, 0, this.textureSize - 1);
                        num6 = Mathf.Clamp(num6, 0, this.textureSize - 1);
                        int num7 = j - num5;
                        int num8 = i - num6;
                        int num9 = num7 * num7 + num8 * num8;
                        if ((float)num9 < num)
                        {
                            this.mBuffer1[j + i * this.textureSize].b = 1f;
                            this.mBuffer1[j + i * this.textureSize].g = 0f;
                            this.mBuffer2[j + i * this.textureSize].b = 1f;
                            this.mBuffer2[j + i * this.textureSize].g = 0f;
                        }
                        else
                        {
                            Vector2 a = new Vector2((float)num7, (float)num8);
                            a.Normalize();
                            a *= num;
                            int sx          = num5 + Mathf.RoundToInt(a.x);
                            int sy          = num6 + Mathf.RoundToInt(a.y);
                            int sightHeight = (int)this.WorldToGridHeight(vector.y);
                            if (this.mBuffer1[j + i * this.textureSize].b == 1f)
                            {
                                this.mBuffer1[j + i * this.textureSize].g = 0f;
                                this.mBuffer2[j + i * this.textureSize].g = 0f;
                            }
                            else if (this.IsVisible(sx, sy, j, i, sightHeight, 0, 0))
                            {
                                this.mBuffer1[j + i * this.textureSize].b = 1f;
                                this.mBuffer1[j + i * this.textureSize].g = 0f;
                                this.mBuffer2[j + i * this.textureSize].b = 1f;
                                this.mBuffer2[j + i * this.textureSize].g = 0f;
                            }
                        }
                    }
                }
            }
        }
    }
コード例 #17
0
	void OnDestroy ()
	{
		FOWSystem.DeleteRevealer(mRevealer);
		mRevealer = null;
	}
コード例 #18
0
 public bool IsVisible(FOWSystem.Revealer rev)
 {
     return(true);
 }
コード例 #19
0
 void OnDestroy()
 {
     FOWSystem.DeleteRevealer(mRevealer);
     mRevealer = null;
 }
コード例 #20
0
 void Awake()
 {
     mTrans    = transform;
     mRevealer = FOWSystem.CreateRevealer();
 }