Exemple #1
0
    private void GenerateVerticalFillMesh()
    {
        this.m_fillAmount = Mathf.Clamp01(this.m_fillAmount);
        if (this.m_fillAmount <= 0f)
        {
            return;
        }
        Vector3 localPosition = base.transform.localPosition;

        this.m_mesh.MarkDynamic();
        float num  = 0f;
        float num2 = 0f;

        if (this.m_alignHoriontal == Sprite3D.EnumHoriontal.Center)
        {
            num = -0.5f * this.m_width;
        }
        else if (this.m_alignHoriontal == Sprite3D.EnumHoriontal.Right)
        {
            num = -this.m_width;
        }
        if (this.m_alignVertical == Sprite3D.EnumVertical.Middle)
        {
            num2 = -0.5f * this.m_height;
        }
        else if (this.m_alignVertical == Sprite3D.EnumVertical.Top)
        {
            num2 = -this.m_height;
        }
        Vector3[] vertices = new Vector3[]
        {
            new Vector3(num, num2 + this.m_height * this.m_fillAmount, 0f),
            new Vector3(num + this.m_width, num2 + this.m_height * this.m_fillAmount, 0f),
            new Vector3(num, num2, 0f),
            new Vector3(num + this.m_width, num2, 0f)
        };
        Vector2[] uv = new Vector2[]
        {
            MMGame_Math.Lerp(this.m_uv.uvBL, this.m_uv.uvTL, this.m_fillAmount),
            MMGame_Math.Lerp(this.m_uv.uvBR, this.m_uv.uvTR, this.m_fillAmount),
            this.m_uv.uvBL,
            this.m_uv.uvBR
        };
        Color[] colors = new Color[]
        {
            this.m_color,
            this.m_color,
            this.m_color,
            this.m_color
        };
        int[] triangles = new int[]
        {
            0,
            1,
            2,
            3,
            2,
            1
        };
        this.m_mesh.vertices  = vertices;
        this.m_mesh.uv        = uv;
        this.m_mesh.colors    = colors;
        this.m_mesh.triangles = triangles;
        this.RecaculateDepth();
    }
Exemple #2
0
    private void GenerateRadial360FillMesh()
    {
        this.m_fillAmount = Mathf.Clamp01(this.m_fillAmount);
        if (this.m_fillAmount <= 0f)
        {
            return;
        }
        Vector3 localPosition = base.transform.localPosition;

        this.m_mesh.MarkDynamic();
        float num  = 0f;
        float num2 = 0f;

        if (this.m_alignHoriontal == Sprite3D.EnumHoriontal.Center)
        {
            num = -0.5f * this.m_width;
        }
        else if (this.m_alignHoriontal == Sprite3D.EnumHoriontal.Right)
        {
            num = -this.m_width;
        }
        if (this.m_alignVertical == Sprite3D.EnumVertical.Middle)
        {
            num2 = -0.5f * this.m_height;
        }
        else if (this.m_alignVertical == Sprite3D.EnumVertical.Top)
        {
            num2 = -this.m_height;
        }
        int   num3 = (int)(this.m_segments * this.m_fillAmount) + 1;
        float num4 = 2f * (this.width + this.height) / this.m_segments;

        Vector3[] array  = new Vector3[num3 + 1];
        Vector2[] array2 = new Vector2[num3 + 1];
        array[0]  = new Vector3(num + 0.5f * this.m_width, num2 + 0.5f * this.height, 0f);
        array2[0] = MMGame_Math.Lerp(this.m_uv.uvTL, this.m_uv.uvBR, 0.5f);
        int   num5 = 0;
        int   num6 = 0;
        float num7 = 0f;

        for (int i = 0; i < num3; i++)
        {
            if (num5 == 0)
            {
                float num8 = num + 0.5f * this.width + (float)num6 * num4;
                if (num8 >= num + this.width)
                {
                    num7 = num8 - num - this.width;
                    num8 = num + this.width;
                    num5 = 1;
                    num6 = 1;
                }
                else
                {
                    num6++;
                }
                array[i + 1] = new Vector3(num8, num2 + this.height, 0f);
            }
            else if (num5 == 1)
            {
                float num9 = num2 + this.height - (float)num6 * num4 - num7;
                if (num9 <= num2)
                {
                    num7 = num2 - num9;
                    num9 = num2;
                    num5 = 2;
                    num6 = 1;
                }
                else
                {
                    num6++;
                }
                array[i + 1] = new Vector3(num + this.width, num9, 0f);
            }
            else if (num5 == 2)
            {
                float num10 = num + this.width - (float)num6 * num4 - num7;
                if (num10 <= num)
                {
                    num7  = num - num10;
                    num10 = num;
                    num5  = 3;
                    num6  = 1;
                }
                else
                {
                    num6++;
                }
                array[i + 1] = new Vector3(num10, num2, 0f);
            }
            else if (num5 == 3)
            {
                float num11 = num2 + (float)num6 * num4 + num7;
                if (num11 >= num2 + this.height)
                {
                    num7  = num11 - num2 - this.height;
                    num11 = num2 + this.height;
                    num5  = 4;
                    num6  = 1;
                }
                else
                {
                    num6++;
                }
                array[i + 1] = new Vector3(num, num11);
            }
            else if (num5 == 4)
            {
                float num12 = num + (float)num6 * num4 + num7;
                if (num12 > num + 0.5f * this.width)
                {
                    num12 = num + 0.5f * this.width;
                }
                num6++;
                array[i + 1] = new Vector3(num12, num2 + this.height, 0f);
            }
            float x = array[i + 1].x;
            float y = array[i + 1].y;
            array2[i + 1] = new Vector2(Mathf.Lerp(this.m_uv.uvTL.x, this.m_uv.uvTR.x, (x - num) / this.width), Mathf.Lerp(this.m_uv.uvBL.y, this.m_uv.uvTL.y, (y - num2) / this.height));
        }
        Color[] array3 = new Color[num3 + 1];
        for (int j = 0; j < array3.Length; j++)
        {
            array3[j] = this.m_color;
        }
        int[] array4 = new int[(num3 - 1) * 3];
        for (int k = 0; k < num3 - 1; k++)
        {
            array4[k * 3]     = 0;
            array4[k * 3 + 1] = k + 1;
            array4[k * 3 + 2] = k + 2;
        }
        this.m_mesh.vertices  = array;
        this.m_mesh.uv        = array2;
        this.m_mesh.colors    = array3;
        this.m_mesh.triangles = array4;
        this.RecaculateDepth();
    }