Пример #1
0
        public MainPage()
        {
            listBox = new BoxView[4, 4];
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    listBox[i, j] = new BoxView()
                    {
                        Color = Color.White
                    }
                }
            }
            ;

            listLabel = new Label[4, 4];
            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    listLabel[i, j] = new Label()
                    {
                        Text                    = "",
                        WidthRequest            = 70,
                        HeightRequest           = 70,
                        FontSize                = Device.GetNamedSize(NamedSize.Large, typeof(Label)),
                        TextColor               = Color.Black,
                        VerticalTextAlignment   = TextAlignment.Center,
                        HorizontalTextAlignment = TextAlignment.Center,
                        HorizontalOptions       = LayoutOptions.CenterAndExpand,
                        VerticalOptions         = LayoutOptions.CenterAndExpand
                    }
                }
            }
            ;

            InitializeComponent();



            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    grid.Children.Add(listBox[i, j], j, i);
                }
            }

            for (int i = 0; i < 4; i++)
            {
                for (int j = 0; j < 4; j++)
                {
                    grid.Children.Add(listLabel[i, j], j, i);
                }
            }
            SwipeListener swipeListener = new SwipeListener(mainStckCube, this);
        }
Пример #2
0
        public MainPage()
        {
            InitializeComponent();

            this.updateGrid();
            SwipeListener swipeListener = new SwipeListener(overlay, this);

            this.gameBoard         = this.generateBoard();
            this.previousGameBoard = this.generateBoard();
            this.numberToColor.Add(0, "bbada0");
            this.numberToColor.Add(2, "eee4da");
            this.numberToColor.Add(4, "ede0c8");
            this.numberToColor.Add(8, "f2b179");
            this.numberToColor.Add(16, "f59563");
            this.numberToColor.Add(32, "f67c5f");
            this.numberToColor.Add(64, "f65e3b");
            this.numberToColor.Add(128, "edcf72");
            this.numberToColor.Add(256, "edcc61");
            this.numberToColor.Add(512, "edc850");
            this.numberToColor.Add(1024, "edc53f");
            this.numberToColor.Add(2048, "edc22e");
            this.addNumber(true);
            this.addNumber(true);
        }