Exemplo n.º 1
0
        public Board()
        {
            InitializeComponent();
            BOARD_WIDTH = Wallscape.Models.Settings.getInstance().getWidth();
            BOARD_HEIGHT = Wallscape.Models.Settings.getInstance().getHeight();
            TOKEN_SIZE = 94 - BOARD_HEIGHT * 4;
            xClick1 = 0; yClick1 = 0;  
            initializeGrid();

            controller = new GameControl();
            player1 = new List<Button>();
            player2 = new List<Button>();
            walls = new List<Rectangle>();
            
            turn = -1;
            wallClick2 = false;
            refreshTokens();
            takeTurn();

            //controller.actionCounter = 1;
            Canvas.SetZIndex(rectangle1, -1);
            Canvas.SetZIndex(rectangle2, -1);
            Canvas.SetZIndex(rectangle3, -10);
            player1Name.Text = controller.getPlayers()[0].getName();
            player2Name.Text = controller.getPlayers()[1].getName();
                      
            //Create the wall connector buttons
            createWallButtons();
            
            //Insert the walls on the sides
            createSideWalls();                       
        }
Exemplo n.º 2
0
        private void takeTurn()
        {
            TURNLABEL.Text = "OPERATION";
            if (controller.actionCounter < controller.actionsPerTurn)
            {
                if (turn < 0) { turn++; controller.actionCounter = (controller.actionsPerTurn + 1) / 2; }
                else { controller.actionCounter++; }
            }
            else
            {
                controller.actionCounter = 1;
                turn++;
            }
            actionLeft.Text = controller.actionCounter + " / " + controller.actionsPerTurn;
            if (turn % 2 == 0)
            {
                foreach (Button other in player1) { other.IsEnabled = true; }
                foreach (Button other in player2) { other.IsEnabled = false; }
                SolidColorBrush _highlightBrush = MainPage.GetColorFromHexa("#6129C7F5");
                player2tokens.Foreground = _highlightBrush;
                player2Name.Foreground = _highlightBrush;
                _highlightBrush = MainPage.GetColorFromHexa("#FFC5D118");
                player1tokens.Foreground = _highlightBrush;
                player1Name.Foreground = _highlightBrush;
                
                //Turn Labels
                TURNLABEL.Foreground = _highlightBrush;
                TURNLABEL.Text = "OPERATION";
                p1TurnArrow.Foreground = _highlightBrush;
                p1TurnArrow.Text = "<";
                p2TurnArrow.Text = "";
                actionLeft.Foreground = _highlightBrush;
            }
            else
            {
                foreach (Button other in player1) { other.IsEnabled = false; }
                foreach (Button other in player2) { other.IsEnabled = true; }
                SolidColorBrush _highlightBrush = MainPage.GetColorFromHexa("#61C5D118");
                player1tokens.Foreground = _highlightBrush;
                player1Name.Foreground = _highlightBrush;
                _highlightBrush = MainPage.GetColorFromHexa("#FF29C7F5");
                player2tokens.Foreground = _highlightBrush;
                player2Name.Foreground = _highlightBrush;

                //Turn Labels
                TURNLABEL.Foreground = _highlightBrush;
                TURNLABEL.Text = "OPERATION";
                p2TurnArrow.Foreground = _highlightBrush;
                p2TurnArrow.Text = ">";
                p1TurnArrow.Text = "";
                actionLeft.Foreground = _highlightBrush;
            }

            foreach (Player p in controller.getPlayers())
            {
                if (p.hasWon())
                {
                    MessageBox.Show(p.getName() + " has escaped to safety!", "VICTORY", MessageBoxButton.OK);
                    foreach (Button b1 in player1) { b1.Visibility = Visibility.Collapsed; }
                    foreach (Button b2 in player2) { b2.Visibility = Visibility.Collapsed; }
                    foreach (Rectangle r in walls) { r.Visibility = Visibility.Collapsed; }

                    controller = new GameControl();
                    player1 = new List<Button>();
                    player2 = new List<Button>();
                    walls = new List<Rectangle>();

                    //turn = -1;
                    turn++;
                    controller.actionCounter++;
                    wallClick2 = false;
                    refreshTokens();
                    takeTurn();
                    createSideWalls();
                }
            }
            wallClick2 = false;
        }