Ejemplo n.º 1
0
        public GamesViewModel()
        {
            LoginViewModel      = new LoginViewModel();
            ScoreboardViewModel = new ScoreboardViewModel();
            TicTacToeViewModel  = new TicTacToeViewModel();
            PairGameViewModel   = new PairGameViewModel();
            RatingViewModel     = new RatingViewModel();
            SnakeViewModel      = new SnakeViewModel();
            DoorsGameViewModel  = new DoorsGameViewModel();
            MoneyViewModel      = new MoneyViewModel();

            _playerManager = new PlayerManager();


            NewGameCommand = new RelayCommand(param => StartGame((string)param));

            ShopCommand = new RelayCommand(param =>
            {
                ShopWindow shopWindow = new ShopWindow();
                shopWindow.ShowDialog();
            });

            ScoreboardCommand = new RelayCommand(param =>
            {
                ScoreboardViewModel.Refresh();
                ScoreboardView scoreboardView = new ScoreboardView();
                scoreboardView.ShowDialog();
            });

            RatingCommand = new RelayCommand(param =>
            {
                RatingView ratingView = new RatingView();
                ratingView.ShowDialog();
            });

            PlayerEditCommand = new RelayCommand(param =>
            {
                EditView editView = new EditView();
                editView.ShowDialog();
            });

            AddMoneyCommand = new RelayCommand(param =>
            {
                MoneyView moneyView = new MoneyView();
                moneyView.ShowDialog();
            });

            StartGameTestingCommand = new RelayCommand(param => { StartGameTesting((string)param); });


            BuyItemCommand = new RelayCommand(param =>
            {
                if (int.Parse(param.ToString()) > Money)
                {
                    MessageBox.Show("You do not have enough to buy this game.\n Consider adding money to your balance.",
                                    "Message", MessageBoxButton.OK);
                }
                else
                {
                    _playerManager.AddMoney(LoginViewModel.Player.Id, -int.Parse(param.ToString()));
                    Money = Money;
                }
            });
        }