Exemple #1
0
 public static void SetSettingDataByPrefab(CUIGraphIRViewScript irView, stStateHeatmapStorage st, int srcWidth, int srcHeight)
 {
     st.radius            = irView.radius;
     st.workRadius        = irView.workRadius;
     st.intensity         = irView.intensity;
     st.defaultCtrlRect.x = (irView.transform as RectTransform).rect.width;
     st.defaultCtrlRect.y = (irView.transform as RectTransform).rect.height;
     st.mapOrgRect.x      = (float)srcWidth;
     st.mapOrgRect.y      = (float)srcHeight;
     if (irView.gradientColorImage != null)
     {
         Texture2D texture = irView.gradientColorImage.texture;
         irView.m_gradientColor = new Color[texture.width];
         irView.m_gradientColor = texture.GetPixels(0, texture.height / 2, texture.width, 1);
     }
 }
Exemple #2
0
        public static void StoreTextureData(List <Vector3> vertexs, stStateHeatmapStorage st, bool isUpdate = false)
        {
            if (vertexs == null)
            {
                return;
            }
            int num  = (int)st.mapOrgRect.x;
            int num2 = (int)st.mapOrgRect.y;

            if (st.displayRates == null)
            {
                isUpdate = false;
            }
            if (!isUpdate)
            {
                st.maxRate = 0f;
                int num3 = (int)st.defaultCtrlRect.x + 1;
                int num4 = (int)st.defaultCtrlRect.y + 1;
                st.crossLen = num3 * num3 + num4 * num4;
                st.myVertex.Clear();
                st.displayRates = new float[num3][];
                for (int i = 0; i < num3; i++)
                {
                    st.displayRates[i] = new float[num4];
                }
            }
            else if (st.myVertex.get_Count() > vertexs.get_Count())
            {
                Debug.LogError("IRView should not use update way");
            }
            int count = st.myVertex.get_Count();

            for (int j = st.myVertex.get_Count(); j < vertexs.get_Count(); j++)
            {
                float   value  = (vertexs.get_Item(j).x + (float)(num / 2)) * st.defaultCtrlRect.x / (float)num;
                float   value2 = (vertexs.get_Item(j).z + (float)(num2 / 2)) * st.defaultCtrlRect.y / (float)num2;
                float   x      = Mathf.Clamp(value, 0f, (float)(st.displayRates.Length - 1));
                float   y      = Mathf.Clamp(value2, 0f, (float)(st.displayRates[0].Length - 1));
                Vector2 vector = new Vector2(x, y);
                st.myVertex.Add(vector);
            }
            int     num5 = (int)((float)st.displayRates.Length * st.workRadius);
            Vector2 p    = new Vector2(0f, 0f);

            for (int k = count; k < st.myVertex.get_Count(); k++)
            {
                for (int l = -num5; l < num5; l++)
                {
                    p.x = st.myVertex.get_Item(k).x + (float)l;
                    if (p.x >= 0f && p.x < (float)st.displayRates.Length)
                    {
                        for (int m = -num5; m < num5; m++)
                        {
                            p.y = st.myVertex.get_Item(k).y + (float)m;
                            if (p.y >= 0f && p.y < (float)st.displayRates[0].Length)
                            {
                                float num6 = CUIGraphIRViewScript.GetDistance(p, st.myVertex.get_Item(k)) / (float)st.crossLen;
                                float num7 = st.displayRates[(int)p.x][(int)p.y] += (1f - Mathf.Clamp(num6 / st.radius, 0f, 1f)) * st.intensity;
                                if (num7 > st.maxRate)
                                {
                                    st.maxRate = num7;
                                }
                            }
                        }
                    }
                }
            }
        }