zoukankan      html  css  js  c++  java
  • UWP开发:自动生成迷宫&自动寻路算法(2)

    之后我们编写一个类,同时创建一个List,将List与前端的Rectangle绑定。

    public static List<Rect> Rects { get; set; }
    Rects = new List<Rect>();
     public class Rect
            {
                public int X { get; set; }
                public int Y { get; set; }//以左上角为1,1
                public string Color { get; set; }
            }
    for (int x = 0; x < 325; x++)//25*14
                {
                    var rect = new Rect() { X = x / 25, Y = x % 25 };
                    switch (mazeMap[rect.X + 1, rect.Y + 1]) {
                        case 0:
                            rect.Color = "Blue";
                            break;
                        case 1:
                            rect.Color = "Gray";
                            break;
                        case 2:
                            rect.Color = "Red";
                            break;
                    }
                    Rects.Add(rect);
                }
                GridView.ItemsSource = Rects;

    这里的代码,处理了方块的排布,根据mazeMap这个二维数组存储的数据,来进行Rect对象的颜色变换。

    同时绑定了ItemSource,将325个方块装填到Rects类中。

    ======================================

    之后我们就要开始编写mazeMap的生成了。

  • 相关阅读:
    有向无环图
    2016
    Permutation Descent Counts(递推)
    Rikka with Subset
    hihoCoder 1549 或运算和
    Young Maids
    1925: [Sdoi2010]地精部落
    Problem H. Hotel in Ves Lagos
    改变presentModalView大小
    no such file to load -- bundler/setup
  • 原文地址:https://www.cnblogs.com/ldzhangyx/p/6101197.html
Copyright © 2011-2022 走看看