Exemplo n.º 1
0
        public AchievementPage()
        {
            // initialize the layout
            InitializeComponent();
            this.FontSize           = WindowSizeGenerator.fontSizeMedium;
            onePersonLabel.FontSize = WindowSizeGenerator.fontSizeLarge;
            foreach (FrameworkElement i in this.onePerson.Children)
            {
                i.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            }
            foreach (FrameworkElement i in this.AllPeople.Children)
            {
                i.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            }
            CustomizedButton2 backButton = new CustomizedButton2("后 退",
                                                                 SquareGenerator.colorMap[2]);

            contentGrid.Children.Add(backButton);
            backButton.SetValue(Grid.ColumnProperty, 2);
            backButton.SetValue(Grid.RowProperty, 3);
            backButton.button.Click       += back_Click;
            backButton.Width               = 200;
            backButton.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;

            name.Focus();
            name.Text = PlayersName.getName(0);

            okay.Click += okay_Click;

            areYouSomebody.FontSize = WindowSizeGenerator.fontSizeLarge;
        }
Exemplo n.º 2
0
        public NavigationPage()
        {
            InitializeComponent();

            int colorNum = 6;

            Color[] colors = SquareGenerator.randomColor(colorNum);

            CustomizedButton2 exitButton =
                new CustomizedButton2("退  出", colors[0]);

            exitButton.button.Click += exitGame_Click;
            exitButton.SetValue(Grid.RowProperty, 3);

            CustomizedButton2 startGameButton =
                new CustomizedButton2("开始游戏", colors[1]);

            startGameButton.button.Click += gotoGameModeSel_Click;
            startGameButton.SetValue(Grid.RowProperty, 0);

            CustomizedButton2 achievementButton =
                new CustomizedButton2("成就系统", colors[2]);

            achievementButton.button.Click += gotoAchievement_Click;
            achievementButton.SetValue(Grid.RowProperty, 1);


            CustomizedButton2 settingsButton =
                new CustomizedButton2("设  置", colors[3]);

            settingsButton.button.Click += gotoSetting_Click;
            settingsButton.SetValue(Grid.RowProperty, 2);

            ButtonsGrid.Children.Add(startGameButton);
            ButtonsGrid.Children.Add(achievementButton);
            ButtonsGrid.Children.Add(settingsButton);
            ButtonsGrid.Children.Add(exitButton);


            StringGrid title = new StringGrid("Tetris", SquareGenerator.squareSize / 1.1);

            outerGrid.Children.Add(title);

            title.SetValue(Grid.RowProperty, 1);

            title.SetValue(Grid.ColumnProperty, 1);

            title.noAnimation();

            Pic.Cat2Gen    pic = new Pic.Cat2Gen();
            Pic.PicGenGrid pg  = new Pic.PicGenGrid(pic, SquareGenerator.picSquareSize / 1.2);
            aCanvas.Children.Add(pg);
            pg.SetValue(Canvas.ZIndexProperty, 0);

            Canvas.SetRight(pg, 2);
            Canvas.SetBottom(pg, 2);
        }
Exemplo n.º 3
0
        // the single mode setting
        private Grid ButtonGridSingle(Grid holder)
        {
            Grid aGrid = new Grid();

            setGrid(2, 3, aGrid);

            int colorNum = 6;

            Color[] colors = SquareGenerator.randomColor(colorNum);

            CustomizedLabel whoAreYouPlayer1 = whoAreYouLabel(0, colors[0], "昵称:");

            TextBox aBox = setTextBox(0, 1, 0);

            CustomizedButton2 goButton =
                new CustomizedButton2("开始游戏", colors[1]);

            //goButton.Width = 100;
            goButton.button.Click += new RoutedEventHandler(
                delegate
            {
                PlayersName.setName(0, aBox.Text);
                nav = NavigationService.GetNavigationService(this);
                SingleModePage nextPage = new SingleModePage();
                nextPage.holderWin      = holderWin;
                nav.Navigate(nextPage);
            });
            goButton.SetValue(Grid.RowProperty, 1);

            CustomizedButton2 backButton =
                new CustomizedButton2("后  退", colors[2]);

            //backButton.Width = 100;
            backButton.button.Click += new RoutedEventHandler(
                delegate
            {
                Grid nextGrid = ButtonGrid1(holder);
                switchGrid(aGrid, nextGrid, holder, backButton.button);
            });
            backButton.SetValue(Grid.RowProperty, 3);

            aGrid.Children.Add(whoAreYouPlayer1);
            aGrid.Children.Add(aBox);
            aGrid.Children.Add(goButton);
            aGrid.Children.Add(backButton);

            return(aGrid);
        }
Exemplo n.º 4
0
        // the first group of setting
        private Grid ButtonGrid1(Grid holder)
        {
            Grid aGrid = new Grid();

            setGrid(1, 3, aGrid);

            int colorNum = 6;

            Color[] colors = SquareGenerator.randomColor(colorNum);

            CustomizedButton2 singleModeButton =
                new CustomizedButton2("单人游戏", colors[0]);

            singleModeButton.button.Click += new RoutedEventHandler(
                delegate {
                Grid nextGrid = this.ButtonGridSingle(holder);
                switchGrid(aGrid, nextGrid, holder, singleModeButton.button);
            });
            singleModeButton.SetValue(Grid.RowProperty, 0);

            CustomizedButton2 dualModeButton =
                new CustomizedButton2("双人游戏", colors[1]);

            dualModeButton.button.Click += new RoutedEventHandler(
                delegate
            {
                Grid nextGrid = this.ButtonGridDual(holder);
                switchGrid(aGrid, nextGrid, holder, dualModeButton.button);
            });
            dualModeButton.SetValue(Grid.RowProperty, 1);

            CustomizedButton2 backButton =
                new CustomizedButton2("后  退", colors[2]);

            backButton.button.Click += back_Click;
            backButton.SetValue(Grid.RowProperty, 3);

            aGrid.Children.Add(singleModeButton);
            aGrid.Children.Add(dualModeButton);
            aGrid.Children.Add(backButton);

            return(aGrid);
        }
Exemplo n.º 5
0
        // the dual mode setting
        private Grid ButtonGridDual(Grid holder)
        {
            String[] contents1 = new string[2] {
                "  人  ", "电  脑"
            };
            String[] contents2 = new string[3] {
                "低难度", "中难度", "高难度"
            };

            Grid aGrid = new Grid();

            setGrid(2, 6, aGrid);

            int colorNum = 6;

            Color[] colors = SquareGenerator.randomColor(colorNum);

            CustomizedLabel player1 = whoAreYouLabel(0, colors[5], "玩家1:");

            SwitchLabel player1Sel = setSwitchLabel(0, contents1, 1);

            CustomizedLabel whoAreYouPlayer1 = whoAreYouLabel(1, colors[0], "昵称:");
            CustomizedLabel difficulty1      = whoAreYouLabel(1, colors[0], "难  度:");

            difficulty1.Opacity = 0;

            TextBox aBox1 = setTextBox(1, 1, 0);

            SwitchLabel dif1Sel = setSwitchLabel(1, contents2, 0);

            CustomizedLabel player2 = whoAreYouLabel(2, colors[3], "玩家2:");

            SwitchLabel player2Sel = setSwitchLabel(2, contents1, 1);

            CustomizedLabel whoAreYouPlayer2 = whoAreYouLabel(3, colors[4], "昵称:");
            CustomizedLabel difficulty2      = whoAreYouLabel(3, colors[4], "难  度:");

            difficulty2.Opacity = 0;

            TextBox     aBox2   = setTextBox(3, 1, 1);
            SwitchLabel dif2Sel = setSwitchLabel(3, contents2, 0);

            DualModePage.gameMode[] pModes = new DualModePage.gameMode[2];

            CustomizedButton2 goButton =
                new CustomizedButton2("开始游戏", colors[2]);

            // used to store the settings and go to dual game
            goButton.button.Click += new RoutedEventHandler(
                delegate
            {
                if (player1Sel.getLabelIndex() == 0)     // player1 is 人
                {
                    PlayersName.setName(0, aBox1.Text);
                    pModes[0] = new DualModePage.gameMode(0, 0);
                }
                else
                {
                    PlayersName.setName(0, "");
                    pModes[0] = new DualModePage.gameMode(1, dif1Sel.getLabelIndex());
                }
                if (player2Sel.getLabelIndex() == 0)     // player2 is 人
                {
                    PlayersName.setName(1, aBox2.Text);
                    pModes[1] = new DualModePage.gameMode(0, 0);
                }
                else
                {
                    PlayersName.setName(1, "");
                    pModes[1] = new DualModePage.gameMode(1, dif2Sel.getLabelIndex());
                }

                nav = NavigationService.GetNavigationService(this);
                DualModePage nextPage = new DualModePage(pModes);
                nextPage.holderWin    = holderWin;
                nav.Navigate(nextPage);
            });

            goButton.SetValue(Grid.RowProperty, 4);

            CustomizedButton2 backButton =
                new CustomizedButton2("后  退", colors[1]);

            backButton.button.Click += new RoutedEventHandler(
                delegate
            {
                Grid nextGrid = ButtonGrid1(holder);
                switchGrid(aGrid, nextGrid, holder, backButton.button);
            });
            backButton.SetValue(Grid.RowProperty, 6);

            aGrid.Children.Add(player1);
            aGrid.Children.Add(player2);
            aGrid.Children.Add(player1Sel);
            aGrid.Children.Add(whoAreYouPlayer1);
            aGrid.Children.Add(aBox1);
            aGrid.Children.Add(player2Sel);
            aGrid.Children.Add(whoAreYouPlayer2);
            aGrid.Children.Add(aBox2);
            aGrid.Children.Add(goButton);
            aGrid.Children.Add(backButton);

            setClickSwitch(whoAreYouPlayer1, difficulty1, aBox1, dif1Sel, player1Sel, aGrid);
            setClickSwitch(whoAreYouPlayer2, difficulty2, aBox2, dif2Sel, player2Sel, aGrid);

            return(aGrid);
        }
Exemplo n.º 6
0
        public SettingPage()
        {
            InitializeComponent();

            this.FontSize = WindowSizeGenerator.fontSizeMedium;
            p1l.FontSize  = WindowSizeGenerator.fontSizeLarge;
            p2l.FontSize  = WindowSizeGenerator.fontSizeLarge;

            refDict1.Add(down1.Name, TetrisGame.GameAction.Down);
            refDict1.Add(left1.Name, TetrisGame.GameAction.Left);
            refDict1.Add(right1.Name, TetrisGame.GameAction.Right);
            refDict1.Add(rotate1.Name, TetrisGame.GameAction.Rotate);
            refDict1.Add(stop1.Name, TetrisGame.GameAction.Pause);

            refDict2.Add(down2.Name, TetrisGame.GameAction.Down);
            refDict2.Add(left2.Name, TetrisGame.GameAction.Left);
            refDict2.Add(right2.Name, TetrisGame.GameAction.Right);
            refDict2.Add(rotate2.Name, TetrisGame.GameAction.Rotate);
            refDict2.Add(stop2.Name, TetrisGame.GameAction.Pause);

            initializeMap(down1, refDict1, config1); // bind the option, the key and the action
            initializeMap(left1, refDict1, config1);
            initializeMap(right1, refDict1, config1);
            initializeMap(rotate1, refDict1, config1);
            initializeMap(stop1, refDict1, config1);

            initializeMap(down2, refDict2, config2);
            initializeMap(left2, refDict2, config2);
            initializeMap(right2, refDict2, config2);
            initializeMap(rotate2, refDict2, config2);
            initializeMap(stop2, refDict2, config2);

            CustomizedButton2 okayButton =
                new CustomizedButton2("确  定", SquareGenerator.colorMap[3]);

            okayButton.button.Click += okay_Click;
            okayButton.SetValue(Grid.RowProperty, 3);
            okayButton.SetValue(Grid.ColumnProperty, 1);
            okayButton.button.Focusable = false;

            CustomizedButton2 backButton =
                new CustomizedButton2("后  退", SquareGenerator.colorMap[5]);

            backButton.button.Click += back_Click;
            backButton.SetValue(Grid.RowProperty, 3);
            backButton.SetValue(Grid.ColumnProperty, 2);
            backButton.button.Focusable = false;

            contentGrid.Children.Add(backButton);
            contentGrid.Children.Add(okayButton);

            foreach (FrameworkElement i in player1.Children)
            {
                i.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            }

            foreach (FrameworkElement i in player2.Children)
            {
                i.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            }
        }