Ejemplo n.º 1
0
 public PlayerUI(Player player, StackPanel deck, TableUI tableUI)
 {
     this.player  = player;
     this.deck    = deck;
     this.tableUI = tableUI;
     Update();
 }
Ejemplo n.º 2
0
        public GameFieldUI(GameFieldView view)
        {
            this.view = view;

            tableUI = new TableUI(gameField, view.Table);

            playerUI = new PlayerUI(gameField.Players[0], view.PlayerDeck, tableUI);
            gameField.EventStartTurn += () =>
            {
                if (gameField.CurrentPlayer == gameField.Players[0])
                {
                    view.PlayerDeck.IsEnabled = true;
                }
                else
                {
                    view.PlayerDeck.IsEnabled = false;
                }
            };

            botUI = new BotUI((Bot)gameField.Players[1], view.BotDeck, gameField);
            gameField.EventStartTurn += () =>
            {
                if (gameField.CurrentPlayer == gameField.Players[1])
                {
                    botUI.MakeMove();
                }
            };

            gameField.EventGameOver  += (state) => EndGame(state);
            gameField.EventGetDomino += () => view.GetButton.Content = $"Get({gameField.Pool.Count})";

            view.GetButton.Content = $"Get({gameField.Pool.Count})";
            view.GetButton.Click  += playerUI.GetButtonClick;

            view.SkipButton.Click += (s, e) =>
            {
                if (gameField.CheckPlayerForNoMoves(gameField.Players[0]) && !gameField.CanTakeDomino(gameField.Players[0]))
                {
                    gameField.Players[0].EndMove();
                }
            };

            gameField.StartGame();
        }