예제 #1
0
    void GetHeatmapFromText(string text)
    {
        // Debug.Log(text);
        string[] HeatMaps = text.Split('|');
        foreach (var HeatMap in HeatMaps)
        {
            string[] entries = HeatMap.Split('\n');

            foreach (var entry in entries)
            {
                if (entry != "")
                {
                    i = int.Parse(entry.Substring(1, 1));
                    if (entry.Substring(4, 1) == ")")
                    {
                        j     = int.Parse(entry.Substring(3, 1));
                        value = float.Parse(entry.Substring(6));
                    }
                    else
                    {
                        j     = int.Parse(entry.Substring(3, 2));
                        value = float.Parse(entry.Substring(7));
                    }

                    heatMapArray[i, j] += value;
                }
            }
        }
        for (int i = 0; i < heatMapArray.GetLength(0); i++)
        {
            for (int j = 0; j < heatMapArray.GetLength(1); j++)
            {
                if (highest < heatMapArray[i, j])
                {
                    highest = heatMapArray[i, j];
                }
            }
        }

        for (int i = 0; i < heatMapArray.GetLength(0); i++)
        {
            for (int j = 0; j < heatMapArray.GetLength(1); j++)
            {
                heatMapArray[i, j] = heatMapArray[i, j] / highest;
            }
        }
        control.instance.overAllHeatMap = heatMapArray;
    }