コード例 #1
0
        private void GetObstacles()
        {
            var obstacles = ObstacleFactory.ObstacleProfiles;

            //var obstacles = Enum.GetValues(typeof(ObstacleType)).Cast<ObstacleType>();

            foreach (var profile in obstacles)
            {
                var obst = new Obstacle(profile);
                Obstacles.Add(obst.ToObstacleViewModel());
            }
        }
コード例 #2
0
 private static void SetObstacles(List<List<Cell>> pCells, Bitmap pBitmap, Obstacle pDefaultObstacle)
 {
     for (int i = 0; i < pCells.Count; i++)
     {
         for(int j = 0; j < pCells[i].Count; j++ )
         {
             SetObstacleInCell(pCells[i][j], i, j, pBitmap, pDefaultObstacle);
         }
     }
 }
コード例 #3
0
        private static void SetObstacleInCell(Cell pCell, int cellY, int cellX, Bitmap pBitmap, Obstacle pDefaultObstacle)
        {
            var height = Blueprint.Instance.CellHeight;
            var width = Blueprint.Instance.CellWidth;
            var whitePixels = 0;
            var blackPixels = 0;

            for (int i = cellX * (int)width; i < (cellX * (int)width) + width; i++)
            {
                for (int j = cellY * (int)height; j < cellY * (int)height + height; j++)
                {
                    var color = pBitmap.GetPixel(i, j);

                    if (color.ToArgb() != Color.White.ToArgb())
                        blackPixels++;
                    else
                        whitePixels++;
                }
            }

            var mean = (double)blackPixels / (whitePixels + blackPixels);

            if(mean > 0.0)
                pCell.Obstacle = pDefaultObstacle;
        }
        private void GetObstacles()
        {
            var obstacles = ObstacleProfiles;

            foreach (var profile in obstacles)
            {
                var obst = new Obstacle(profile);
                if (obst.Type == "Brak") continue;

                Obstacles.Add(obst.ToObstacleViewModel());
            }
        }