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;
        }
Beispiel #2
0
 public Player(PlayersName name, uint point, int value, bool ans)
 {
     Name = name;
     NumberOfVictories = point;
     NewValueCard      = value;
     Answer            = ans;
 }
Beispiel #3
0
        // set the text box to change the names of players
        private TextBox setTextBox(int row, int col, int nameIndex)
        {
            TextBox aBox = new TextBox();

            aBox.Text              = PlayersName.getName(nameIndex);
            aBox.BorderThickness   = new Thickness(0, 0, 0, 0);
            aBox.VerticalAlignment = System.Windows.VerticalAlignment.Center;
            aBox.FontSize          = Styles.WindowSizeGenerator.fontSizeMedium;
            aBox.SetValue(Grid.RowProperty, row);
            aBox.SetValue(Grid.ColumnProperty, col);
            aBox.Background = new SolidColorBrush(Colors.Transparent);
            aBox.Focus();

            return(aBox);
        }
Beispiel #4
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);
        }
Beispiel #5
0
        public DualModePage(gameMode[] modeSels) : base()
        {
            // layout definition
            InitializeComponent();

            p1mode = modeSels[0];
            p2mode = modeSels[1];
            // game grid definition
            outerGrid.Width  = Styles.WindowSizeGenerator.screenWidth;
            outerGrid.Height = Styles.WindowSizeGenerator.screenHeight;

            ColumnDefinition aCol = new ColumnDefinition();

            aCol.Width = new GridLength(Styles.WindowSizeGenerator.dualGameModuleRight,
                                        GridUnitType.Pixel);
            outerGrid.ColumnDefinitions.Add(aCol);

            aCol       = new ColumnDefinition();
            aCol.Width = new GridLength(1, GridUnitType.Auto);
            outerGrid.ColumnDefinitions.Add(aCol);

            aCol       = new ColumnDefinition();
            aCol.Width = new GridLength(Styles.WindowSizeGenerator.dualAdditionModuleWidth,
                                        GridUnitType.Star);
            outerGrid.ColumnDefinitions.Add(aCol);

            aCol       = new ColumnDefinition();
            aCol.Width = new GridLength(1, GridUnitType.Auto);
            outerGrid.ColumnDefinitions.Add(aCol);

            aCol       = new ColumnDefinition();
            aCol.Width = new GridLength(Styles.WindowSizeGenerator.dualGameModuleRight,
                                        GridUnitType.Pixel);
            outerGrid.ColumnDefinitions.Add(aCol);

            Border border1 = new Border();

            border1.BorderBrush     = new SolidColorBrush(Colors.Gray);
            border1.BorderThickness = new Thickness(2, 2, 2, 2);

            Border border2 = new Border();

            border2.BorderBrush     = new SolidColorBrush(Colors.Gray);
            border2.BorderThickness = new Thickness(2, 2, 2, 2);

            games = t.NewDuelGame(
                p1mode.player == 1?"":PlayersName.getName(0),
                p2mode.player == 1?"":PlayersName.getName(1)
                );
            int[] gridSize = new int[2]
            {
                games.Item1.Height, games.Item1.Width
            };


            // game grid
            GameGrid gameGrid1 = new GameGrid(gridSize);

            border1.Child = gameGrid1;
            outerGrid.Children.Add(border1);
            border1.SetValue(Grid.RowProperty, 1);
            border1.SetValue(Grid.ColumnProperty, 1);

            GameGrid gameGrid2 = new GameGrid(gridSize);

            border2.Child = gameGrid2;
            outerGrid.Children.Add(border2);
            border2.SetValue(Grid.RowProperty, 1);
            border2.SetValue(Grid.ColumnProperty, 3);

            games.Item1.AddDisplay(gameGrid1);
            games.Item2.AddDisplay(gameGrid2);


            // set score board and next block board
            Grid scoreNextBlockGrid = new Grid();

            aCol       = new ColumnDefinition();
            aCol.Width = new GridLength(1, GridUnitType.Star);
            scoreNextBlockGrid.ColumnDefinitions.Add(aCol);

            aCol       = new ColumnDefinition();
            aCol.Width = new GridLength(1, GridUnitType.Auto);
            scoreNextBlockGrid.ColumnDefinitions.Add(aCol);

            aCol       = new ColumnDefinition();
            aCol.Width = new GridLength(1, GridUnitType.Star);
            scoreNextBlockGrid.ColumnDefinitions.Add(aCol);

            aCol       = new ColumnDefinition();
            aCol.Width = new GridLength(1, GridUnitType.Auto);
            scoreNextBlockGrid.ColumnDefinitions.Add(aCol);

            aCol       = new ColumnDefinition();
            aCol.Width = new GridLength(1, GridUnitType.Star);
            scoreNextBlockGrid.ColumnDefinitions.Add(aCol);

            RowDefinition aRow = new RowDefinition();

            aRow.Height = new GridLength(1, GridUnitType.Auto);
            scoreNextBlockGrid.RowDefinitions.Add(aRow);

            aRow        = new RowDefinition();
            aRow.Height = new GridLength(Styles.WindowSizeGenerator.screenHeight / 30,
                                         GridUnitType.Pixel);
            scoreNextBlockGrid.RowDefinitions.Add(aRow);

            aRow        = new RowDefinition();
            aRow.Height = new GridLength(1, GridUnitType.Auto);
            scoreNextBlockGrid.RowDefinitions.Add(aRow);

            outerGrid.Children.Add(scoreNextBlockGrid);

            scoreNextBlockGrid.SetValue(Grid.ColumnProperty, 2);
            scoreNextBlockGrid.SetValue(Grid.RowProperty, 1);

            double scoreHeight = Styles.WindowSizeGenerator.scoreBoardHeight;
            double scoreWidth  = Styles.WindowSizeGenerator.scoreBoardWidth;

            ScoreGrid score1 = new ScoreGrid(scoreHeight, scoreWidth);
            ScoreGrid score2 = new ScoreGrid(scoreHeight, scoreWidth);

            // set next block board
            double    nextBlockHeight = Styles.WindowSizeGenerator.nextBoardHeight;
            double    nextBlockWidth  = Styles.WindowSizeGenerator.nextBoardWidth;
            NextBlock nextBlock1      = new NextBlock(nextBlockHeight, nextBlockWidth);
            NextBlock nextBlock2      = new NextBlock(nextBlockHeight, nextBlockWidth);

            scoreNextBlockGrid.Children.Add(nextBlock1);
            nextBlock1.SetValue(Grid.ColumnProperty, 1);
            nextBlock1.SetValue(Grid.RowProperty, 2);
            nextBlock1.SetValue(Grid.HorizontalAlignmentProperty, HorizontalAlignment.Left);
            nextBlock1.SetValue(Grid.VerticalAlignmentProperty, VerticalAlignment.Top);

            scoreNextBlockGrid.Children.Add(nextBlock2);
            nextBlock2.SetValue(Grid.ColumnProperty, 3);
            nextBlock2.SetValue(Grid.RowProperty, 2);
            nextBlock2.SetValue(Grid.HorizontalAlignmentProperty, HorizontalAlignment.Left);
            nextBlock2.SetValue(Grid.VerticalAlignmentProperty, VerticalAlignment.Top);

            games.Item1.AddDisplay(nextBlock1);
            games.Item2.AddDisplay(nextBlock2);

            scoreNextBlockGrid.Children.Add(score1);
            scoreNextBlockGrid.Children.Add(score2);

            score1.SetValue(Grid.ColumnProperty, 1);
            score1.SetValue(Grid.RowProperty, 0);
            score1.SetValue(Grid.HorizontalAlignmentProperty, HorizontalAlignment.Left);
            score1.SetValue(Grid.VerticalAlignmentProperty, VerticalAlignment.Top);

            score2.SetValue(Grid.ColumnProperty, 3);
            score2.SetValue(Grid.RowProperty, 0);
            score2.SetValue(Grid.HorizontalAlignmentProperty, HorizontalAlignment.Left);
            score2.SetValue(Grid.VerticalAlignmentProperty, VerticalAlignment.Top);

            score1.DataContext = games.Item1.ScoreSystem;
            score2.DataContext = games.Item2.ScoreSystem;

            // set background pictures.

            PicGen pic = new Cat3Gen();

            double picSizeRatio = 1.1;

            PicGenGrid pg1 = new PicGenGrid(pic, SquareGenerator.picSquareSize / picSizeRatio);

            aCanvas.Children.Add(pg1);
            pg1.SetValue(Canvas.ZIndexProperty, 0);

            Canvas.SetLeft(pg1, (Styles.WindowSizeGenerator.screenWidth -
                                 pg1.getPicSize()[1] * SquareGenerator.picSquareSize / picSizeRatio) / 2);
            Canvas.SetBottom(pg1, Styles.WindowSizeGenerator.gameModuleTop +
                             (-1 * pg1.getPicSize()[0] *
                              SquareGenerator.picSquareSize / picSizeRatio) / 2.2);

            aRect1        = new Rectangle();
            aRect1.Fill   = new SolidColorBrush(Colors.Transparent);
            aRect1.Width  = gameGrid1.getGameGridSize()[1];
            aRect1.Height = gameGrid1.getGameGridSize()[0];
            outerGrid.Children.Add(aRect1);
            aRect1.SetValue(Grid.ColumnProperty, 1);
            aRect1.SetValue(Grid.RowProperty, 1);
            //game.GameEndEvent += gameEnd;
            games.DuelGameEndEvent += gameEndEffect;

            // set the mask rect (used when game is over)
            aRect2        = new Rectangle();
            aRect2.Fill   = new SolidColorBrush(Colors.Transparent);
            aRect2.Width  = gameGrid1.getGameGridSize()[1];
            aRect2.Height = gameGrid1.getGameGridSize()[0];
            outerGrid.Children.Add(aRect2);
            aRect2.SetValue(Grid.ColumnProperty, 3);
            aRect2.SetValue(Grid.RowProperty, 1);
        }
Beispiel #6
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);
        }
Beispiel #7
0
        public SingleModePage()
        {
            InitializeComponent();

            int[] nextBlockSize = new int[] { 4, 3 };

            ColumnDefinition aCol = new ColumnDefinition();

            aCol.Width = new GridLength(50, GridUnitType.Star);
            outerGrid.ColumnDefinitions.Add(aCol);

            aCol       = new ColumnDefinition();
            aCol.Width = new GridLength(50, GridUnitType.Auto);
            outerGrid.ColumnDefinitions.Add(aCol);

            aCol       = new ColumnDefinition();
            aCol.Width = new GridLength(50, GridUnitType.Star);
            outerGrid.ColumnDefinitions.Add(aCol);

            outerGrid.Width  = Styles.WindowSizeGenerator.screenWidth;
            outerGrid.Height = Styles.WindowSizeGenerator.screenHeight;

            Border border = new Border();

            border.BorderBrush     = new SolidColorBrush(Colors.Gray);
            border.BorderThickness = new Thickness(2, 2, 2, 2);

            game = t.NewGame(PlayersName.getName(0));

            int[] gridSize = new int[2] {
                game.Height, game.Width
            };

            gameGrid = new GameGrid(gridSize);

            game.AddDisplay(gameGrid);

            border.Child = gameGrid;
            outerGrid.Children.Add(border);
            border.SetValue(Grid.RowProperty, 1);
            border.SetValue(Grid.ColumnProperty, 1);


            // set left crocodile
            PicGen pic = new CrocodileGen();

            PicGenGrid pg1 = new PicGenGrid(pic, SquareGenerator.picSquareSize);

            aCanvas.Children.Add(pg1);
            pg1.SetValue(Canvas.ZIndexProperty, 0);

            Canvas.SetLeft(pg1, (Styles.WindowSizeGenerator.screenWidth
                                 - gameGrid.getGameGridSize()[1]) / 6);

            Canvas.SetBottom(pg1, (Styles.WindowSizeGenerator.screenHeight -
                                   gameGrid.getGameGridSize()[0]) / 2 - 0.2 * pg1.getPicSize()[0]);

            // set right crocodile
            pic = new CrocodileGen();
            PicGenGrid pg2 = new PicGenGrid(pic, SquareGenerator.picSquareSize);

            aCanvas.Children.Add(pg2);
            pg2.SetValue(Canvas.ZIndexProperty, 0);

            Canvas.SetRight(pg2, (Styles.WindowSizeGenerator.screenWidth
                                  - gameGrid.getGameGridSize()[1]) / 4);
            Canvas.SetBottom(pg2, (Styles.WindowSizeGenerator.screenHeight -
                                   gameGrid.getGameGridSize()[0]) / 2 - 0.2 * pg2.getPicSize()[0]);

            // set little sun
            pic = new SunGen();
            PicGenGrid pg3 = new PicGenGrid(pic, SquareGenerator.picSquareSize / 1.1);

            aCanvas.Children.Add(pg3);
            pg3.SetValue(Canvas.ZIndexProperty, 0);

            Canvas.SetLeft(pg3, -40);
            Canvas.SetTop(pg3, -40);

            // set score board
            double scoreHeight  = Styles.WindowSizeGenerator.scoreBoardHeight;
            double scoreWidth   = Styles.WindowSizeGenerator.scoreBoardWidth;
            double scoreLeftLoc = Styles.WindowSizeGenerator.scoreBoardLeft
                                  + (Styles.WindowSizeGenerator.screenWidth + gameGrid.getGameGridSize()[1]) / 2;
            double scoreBottomLoc = gameGrid.getGameGridSize()[0] +
                                    Styles.WindowSizeGenerator.gameModuleTop - scoreHeight;

            score = new ScoreGrid(scoreHeight, scoreWidth);

            Grid scoreNextBlockGrid = new Grid();

            aCol       = new ColumnDefinition();
            aCol.Width = new GridLength(0.5 * scoreWidth, GridUnitType.Pixel);
            scoreNextBlockGrid.ColumnDefinitions.Add(aCol);
            aCol = new ColumnDefinition();
            scoreNextBlockGrid.ColumnDefinitions.Add(aCol);

            RowDefinition aRow = new RowDefinition();

            aRow.Height = new GridLength(1, GridUnitType.Auto);
            scoreNextBlockGrid.RowDefinitions.Add(aRow);

            aRow        = new RowDefinition();
            aRow.Height = new GridLength(0.2 * scoreHeight, GridUnitType.Pixel);
            scoreNextBlockGrid.RowDefinitions.Add(aRow);

            aRow        = new RowDefinition();
            aRow.Height = new GridLength(1, GridUnitType.Star);
            scoreNextBlockGrid.RowDefinitions.Add(aRow);

            scoreNextBlockGrid.Children.Add(score);
            score.SetValue(Grid.ColumnProperty, 1);
            score.SetValue(Grid.RowProperty, 0);
            score.SetValue(Grid.HorizontalAlignmentProperty, HorizontalAlignment.Left);
            score.SetValue(Grid.VerticalAlignmentProperty, VerticalAlignment.Top);

            outerGrid.Children.Add(scoreNextBlockGrid);
            scoreNextBlockGrid.SetValue(Grid.ColumnProperty, 2);
            scoreNextBlockGrid.SetValue(Grid.RowProperty, 1);

            score.DataContext = game.ScoreSystem;

            // set next block board
            double    nextBlockHeight = Styles.WindowSizeGenerator.nextBoardHeight;
            double    nextBlockWidth  = Styles.WindowSizeGenerator.nextBoardWidth;
            double    nextLeftLoc     = scoreLeftLoc;
            double    nextBottomLoc   = scoreBottomLoc + nextBlockHeight + 10;
            NextBlock nextBlock       = new NextBlock(nextBlockHeight, nextBlockWidth);

            Console.WriteLine(nextBlockHeight + " block h");

            double[] nextSize = nextBlock.getSize();

            scoreNextBlockGrid.Children.Add(nextBlock);
            nextBlock.SetValue(Grid.RowProperty, 2);
            nextBlock.SetValue(Grid.ColumnProperty, 1);
            nextBlock.SetValue(Grid.HorizontalAlignmentProperty, HorizontalAlignment.Left);
            nextBlock.SetValue(Grid.VerticalAlignmentProperty, VerticalAlignment.Top);

            game.AddDisplay(nextBlock);

            aRect        = new Rectangle();
            aRect.Fill   = new SolidColorBrush(Colors.Transparent);
            aRect.Width  = gameGrid.getGameGridSize()[1];
            aRect.Height = gameGrid.getGameGridSize()[0];
            outerGrid.Children.Add(aRect);
            aRect.SetValue(Grid.ColumnProperty, 1);
            aRect.SetValue(Grid.RowProperty, 1);
            game.GameEndEvent += gameEndEffect;
        }