示例#1
0
        private void _resetButton_Click(object sender, RoutedEventArgs e)
        {
            pacManGrid.Children.Clear();

            _ellipse.Name = "_ellipse";
            _ellipse.Fill = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 225, 225, 0));
            pacManGrid.Children.Add(_ellipse);
            Grid.SetColumn(_ellipse, 0);
            Grid.SetRow(_ellipse, 0);

            var seed = ((DateTime.UtcNow.Millisecond + DateTime.UtcNow.Second));

            _seed.Text = seed.ToString();

            var pmc = new PacManCreator();

            m_walls = pmc.SetWalls(seed);

            for (var i = 0; i < N; i++)
            {
                for (var j = 0; j < N; j++)
                {
                    var r = new Rectangle();
                    var v = m_walls.GetValue(i, j);
                    if ((int)v == 1)
                    {
                        r.Fill = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 0, 0, 0));
                    }

                    pacManGrid.Children.Add(r);
                    Grid.SetColumn(r, j);
                    Grid.SetRow(r, i);
                }
            }
        }
示例#2
0
        public MainPage()
        {
            this.InitializeComponent();

            var seed = ((DateTime.UtcNow.Millisecond + DateTime.UtcNow.Second));

            _seed.Text = seed.ToString();

            var pmc = new PacManCreator();

            m_walls = pmc.SetWalls(seed);


            for (var i = 0; i < N; i++)
            {
                for (var j = 0; j < N; j++)
                {
                    var r = new Rectangle();
                    var v = m_walls.GetValue(i, j);
                    if ((int)v == 1)
                    {
                        r.Fill = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 0, 0, 0));
                    }

                    pacManGrid.Children.Add(r);
                    Grid.SetColumn(r, j);
                    Grid.SetRow(r, i);
                }
            }

            _ellipse.Name = "_ellipse";
            _ellipse.Fill = new SolidColorBrush(Windows.UI.Color.FromArgb(255, 225, 225, 0));
            pacManGrid.Children.Add(_ellipse);

            var end = new TextBlock();

            end.Text     = "End";
            end.FontSize = 32;

            pacManGrid.Children.Add(end);
            Grid.SetColumn(end, 7);
            Grid.SetRow(end, 7);
        }