Exemplo n.º 1
0
        public MobileWindow(int P, Game g)
        {
            InitializeComponent();
            ThisPlayer = P;
            game       = g;
            game.Subs(this);
            GameState.GSInstance.OnStateChanged += OnStateChanged;
            this.Title         = "Player " + (P + 1) + " - MobileScrabble";
            ListSwapRackButton = new List <Button>();
            RackTileButtons    = new List <Button>();
            // Adding board buttons
            for (int i = 0; i < 15; ++i)
            {
                for (int j = 0; j < 15; ++j)
                {
                    Button b = new Button();
                    b.Click   += Copier;
                    b.FontSize = 9;
                    BoardGrid.Children.Add(b);
                    b.FontWeight       = FontWeights.Bold;
                    b.FontFamily       = new FontFamily("Century Gothic");
                    b.Content          = '\0';
                    b.Background       = BoardTiles.DetermineColor(i, j);
                    BoardButtons[i, j] = b;
                }
            }
            // Adding rack buttons
            for (int i = 0; i < 7; ++i)
            {
                Button t = new Button();
                t.Click   += Poster;
                t.FontSize = 18;
                HandGrid.Children.Add(t);
                t.Background = Brushes.Chocolate;
                t.Content    = '\0';
                RackTileButtons.Add(t);
            }

            for (int i = 0; i < RackTileButtons.Count; ++i)
            {
                char c = GameState.GSInstance.ListOfPlayers[ThisPlayer].PlayingTiles[i].TileChar;
                RackTileButtons[i].Content = c;
                if (GameState.GSInstance.PlayerNow == ThisPlayer)
                {
                    RackTileButtons[i].IsEnabled = true; EnableAll();
                }

                else
                {
                    RackTileButtons[i].IsEnabled = false; DisableAll();
                }
            }
            StorageLbl.Content = '\0';
        }
        public MainWindow()
        {
            InitializeComponent();
            TextWindow tw = new TextWindow();

            tw.Show();
            ListSwapRackButton = new List <Button>();
            RackTileButtons    = new List <Button>();
            // Adding board buttons
            for (int i = 0; i < 15; ++i)
            {
                for (int j = 0; j < 15; ++j)
                {
                    Button b = new Button();
                    b.Click   += Copier;
                    b.FontSize = 33;
                    BoardGrid.Children.Add(b);
                    b.Content          = '\0';
                    b.Background       = BoardTiles.DetermineColor(i, j);
                    BoardButtons[i, j] = b;
                    //Binding bind = new Binding();
                    //Console.Write("\"BTD{0}{1}\",", (char)(i + 65), j.ToString());
                    //bind.Path = new PropertyPath("BTD{0}{1}", (char)(i + 65), j.ToString());
                    //bind.Mode = BindingMode.OneWay;
                    //bind.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
                    //BindingOperations.SetBinding(b, Button.ContentProperty, bind);
                    //b.SetBinding(Button.CommandProperty, new Binding("ClickBoardTile"));
                }
            }
            // Adding rack buttons
            for (int i = 0; i < 7; ++i)
            {
                Button t = new Button();
                t.Click   += Poster;
                t.FontSize = 33;
                HandGrid.Children.Add(t);
                t.Background = Brushes.Chocolate;
                t.Content    = '\0';
                RackTileButtons.Add(t);
                //bind bind = new Binding();
                //bind.Path = new PropertyPath("RackTileDisplay");
                //bind.Mode = BindingMode.OneWay;
                //t.SetBinding(Button.CommandProperty, new Binding("ClickRackTile"));
                //bind.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
                //BindingOperations.SetBinding(t, Button.ContentProperty, bind);
            }
            game = new Game();
            LogBoardWriter(Welcome.WelcomeText);
            ValidateButton.IsEnabled = false;
            StorageLbl.Content       = '\0';
        }
Exemplo n.º 3
0
        public DesktopWindow(int P, Game g)
        {
            InitializeComponent();
            ThisPlayer = P;
            game       = g;
            game.Subs(this);
            GameState.GSInstance.OnStateChanged += OnStateChanged;
            this.Title         = "Player " + (P + 1) + " - ScrabbleDesktop";
            ListSwapRackButton = new List <Button>();
            RackTileButtons    = new List <Button>();
            // Adding board buttons
            for (int i = 0; i < 15; ++i)
            {
                for (int j = 0; j < 15; ++j)
                {
                    Button b = new Button();
                    b.Click   += Copier;
                    b.FontSize = 33;
                    BoardGrid.Children.Add(b);
                    b.Content          = '\0';
                    b.Background       = BoardTiles.DetermineColor(i, j);
                    BoardButtons[i, j] = b;
                }
            }
            // Adding rack buttons
            for (int i = 0; i < 7; ++i)
            {
                Button t = new Button();
                t.Click   += Poster;
                t.FontSize = 33;
                HandGrid.Children.Add(t);
                t.Background = Brushes.Chocolate;
                t.Content    = '\0';
                RackTileButtons.Add(t);
            }
            LogBoardWriter(Welcome.WelcomeText);
            LogBoardWriter("Game starts...");
            LogBoardWriter("This is a " + GameState.GSInstance.NumOfPlayers + " players game.");

            foreach (KeyValuePair <int, Tile> kvp in GameStartDraw.Drawn)
            {
                LogBoardWriter("Player " + (kvp.Key + 1) + " gets " + kvp.Value.TileChar + "!");
            }
            LogBoardWriter("Player " + (GameState.GSInstance.PlayerNow + 1) + " first!");

            for (int i = 0; i < RackTileButtons.Count; ++i)
            {
                char c = GameState.GSInstance.ListOfPlayers[ThisPlayer].PlayingTiles[i].TileChar;
                RackTileButtons[i].Content = c;
                if (GameState.GSInstance.PlayerNow == ThisPlayer)
                {
                    RackTileButtons[i].IsEnabled = true; EnableAll();
                }

                else
                {
                    RackTileButtons[i].IsEnabled = false; DisableAll();
                }
            }
            StorageLbl.Content = '\0';
        }