コード例 #1
0
 private void InitMap()
 {
     for (int row = 0; row < HeatMapData.GRID_SIZE; row++)
     {
         for (int col = 0; col < HeatMapData.GRID_SIZE; col++)
         {
             heatMap[row, col] = new HeatMapData(row, col);
         }
     }
 }
コード例 #2
0
        private bool GetSurroundedAverage(HeatMapData heatMapData)
        {
            int row = heatMapData.Row;
            int col = heatMapData.Column;
            List <HeatMapData> surroundedList = new List <HeatMapData>();

            if (row != 0)
            {
                if (heatMap[row - 1, col].DataSize != 0)
                {
                    surroundedList.Add(heatMap[row - 1, col]);
                }
            }

            if (row != HeatMapData.GRID_SIZE - 1)
            {
                if (heatMap[row + 1, col].DataSize != 0)
                {
                    surroundedList.Add(heatMap[row + 1, col]);
                }
            }

            if (col != 0)
            {
                if (heatMap[row, col - 1].DataSize != 0)
                {
                    surroundedList.Add(heatMap[row, col - 1]);
                }
            }

            if (col != HeatMapData.GRID_SIZE - 1)
            {
                if (heatMap[row, col + 1].DataSize != 0)
                {
                    surroundedList.Add(heatMap[row, col + 1]);
                }
            }

            if (surroundedList.Count < 3)
            {
                return(false);
            }


            heatMapData.DataSize = surroundedList.Sum(hmd => hmd.DataSize);
            heatMapData.DataSum  = surroundedList.Sum(hmd => hmd.DataSum);
            return(true);
        }