예제 #1
0
        private bool CreateSelectedMaze(IGrid grid)
        {
            var algo = (string)cbAlgorithm.SelectedItem;

            var type = Assembly.GetExecutingAssembly().GetTypes().FirstOrDefault(t => t.Name == algo);

            if (type == null)
            {
                MessageBox.Show("No algorithm type for " + algo);
                return(false);
            }
            if (pbMask.Image != null && (type == typeof(Sidewinder) || type == typeof(BinaryTree)))
            {
                MessageBox.Show("Cannot use masks with Sidewinder and BinaryTree algorithms");
            }

            type.GetMethod("Maze", new[] { typeof(Grid), typeof(int) }).Invoke(null, new object[] { grid, (int)nudRNGSeed.Value });

            grid.Braid((double)nudBraid.Value);

            return(true);
        }