public GameControlViewModel(
            IStringsProvider stringsProvider, HamburgerMenuViewModel hamburgerMenuViewModel,
            GameBoardViewModel gameBoardViewModel, QuestionViewModel questionViewModel, IGameService gameService,
            PlayersViewModel playersViewModel, IEventAggregator eventAggregator)
            : base(stringsProvider)
        {
            _eventAggregator = eventAggregator;

            GameService = gameService;
            GameService.Categories.Sync <Category, Category>(Categories, x => x, (x, y) => x.Id == y.Id);
            GameService.GameFinished += OnGameFinishedAsync;
            GameService.GameChanged  += OnGameChanged;

            PlayersViewModel                    = playersViewModel;
            HamburgerMenuViewModel              = hamburgerMenuViewModel;
            GameBoardViewModel                  = gameBoardViewModel;
            QuestionViewModel                   = questionViewModel;
            QuestionViewModel.QuestionAnswered += OnQuestionAnswered;

            CreateGameCommand = new DelegateCommand <double?>(x =>
            {
                var gameTime = x != null
                    ? (int)x
                    : 0;
                if (gameTime > 0)
                {
                    var _ = CreateGameAsync(gameTime);
                }
            });

            StartCommand = new DelegateCommand(() =>
            {
                var _ = StartAsync();
            });
            StopCommand = new DelegateCommand(() =>
            {
                var _ = StopAsync();
            });
            RestartCommand = new DelegateCommand(() =>
            {
                var _ = RestartAsync();
            });

            MovePlayerToCommand = new DelegateCommand <Category>(x =>
            {
                var _ = MovePlayerToAsync(x);
            });

            StartTimerCommand = new DelegateCommand(StartTimer);
            StopTimerCommand  = new DelegateCommand(StopTimer);
        }
Exemple #2
0
        public IActionResult GameBoard()
        {
            var shuffledCards = new List <Card>();

            shuffledCards.AddRange(_cardData.GoalCards);
            shuffledCards.AddRange(_cardData.KeeperCards);
            shuffledCards.AddRange(_cardData.RuleCards);

            var connectedIds = ChatHub.ConnectedIds;

            var viewModel = new GameBoardViewModel(shuffledCards);

            return(View(viewModel));
        }
        //private BackgroundGrid _background;
        //private Friend ClientFriendInstance;

        public MainPage()
        {
            InitializeComponent();

            var mainPageViewModel = MainPageViewModel.GetInstance();

            DataContext = mainPageViewModel;

            UserStatsUI.DataContext = Settings.userInstance;

            var gameBoardViewModel = GameBoardViewModel.GetInstance();

            MatchmakingPane.DataContext = gameBoardViewModel;

            //_background = new BackgroundGrid();
        }
Exemple #4
0
        public async Task NewGameAsync(GameBoardViewModel guess)
        {
            //hopefully no need to hide solution anymore since another class is responsible for it now.
            bool canRepeat = _level.LevelChosen == 2 || _level.LevelChosen == 4 || _level.LevelChosen == 6;
            int  level     = _level.LevelChosen;
            CustomBasicList <Bead> possibleList = new CustomBasicList <Bead>();

            if (level == 5 || level == 6)
            {
                possibleList.Add(new Bead(EnumColorPossibilities.Aqua));
                possibleList.Add(new Bead(EnumColorPossibilities.Black));
            }
            possibleList.Add(new Bead(EnumColorPossibilities.Blue));
            possibleList.Add(new Bead(EnumColorPossibilities.Green));
            if (level > 2)
            {
                possibleList.Add(new Bead(EnumColorPossibilities.Purple));
            }
            possibleList.Add(new Bead(EnumColorPossibilities.Red));
            possibleList.Add(new Bead(EnumColorPossibilities.White));
            if (level > 2)
            {
                possibleList.Add(new Bead(EnumColorPossibilities.Yellow));
            }
            ICustomBasicList <Bead> tempList;

            if (canRepeat == false)
            {
                tempList = possibleList.GetRandomList(false, 4);
            }
            else
            {
                int x;
                tempList = new CustomBasicList <Bead>();
                for (x = 1; x <= 4; x++)
                {
                    var ThisBead = possibleList.GetRandomItem();
                    tempList.Add(ThisBead); // can have repeat
                }
            }
            _global.Solution = tempList.ToCustomBasicList();
            await guess.NewGameAsync();

            await guess.StartNewGuessAsync();

            _global.ColorList = possibleList.Select(items => items.ColorChosen).ToCustomBasicList();
        }
        //Manages request when a player wants to play new game
        public IActionResult PlayAgain()
        {
            //Reset the click proprty and gamestatus
            clicks     = 0;
            gameStatus = "In Progress";

            //Setup the game board
            gameBoard = gameRules.SetupGame(10, gameBoard);


            //Create game board view model
            GameBoardViewModel game = new GameBoardViewModel();

            game.GameBoard  = gameBoard;
            game.UserName   = userName;
            game.numOfClick = clicks;

            return(View("Index", game));
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            //
            // Set up Timer UI.
            //
            var viewModel = GameBoardViewModel.GetInstance();

            viewModel.MatchmakingWaitTime = 0;
            _timer          = new DispatcherTimer();
            _timer.Interval = new TimeSpan(0, 0, 1);
            _timer.Tick    += OnTimerTick;
            _timer.Start();


            //
            // Hook up the Matchmaking Message Processor Events
            //
            MatchmakingMessageProcessor.GameFoundEvent    += OnGameFoundEvent;
            MatchmakingMessageProcessor.GameNotFoundEvent += OnGameNotFoundEvent;

            base.OnNavigatedTo(e);
        }
        public MovementListSelectVariationViewModel(GameBoardViewModel gameBoardViewModel, MovementFigureModel movement)
        {
            // Crea la colección
            Variations = new ObservableCollection <MovementSelectVariationViewModel>();
            // Añade las variaciones que se pueden seleccionar
            foreach (MovementVariationModel variation in movement.Variations)
            {
                bool isAdded = false;

                // Añade el primer movimiento de figura de la variación
                foreach (MovementBaseModel movementVariation in variation.Movements)
                {
                    if (!isAdded && movementVariation is MovementFigureModel movementFigure)
                    {
                        // Añade la variación
                        Variations.Add(new MovementSelectVariationViewModel(gameBoardViewModel, variation, movementFigure));
                        // Indica que se ha añadido
                        isAdded = true;
                    }
                }
            }
        }
Exemple #8
0
        async Task IFinishGuess.FinishGuessAsync(int howManyCorrect, GameBoardViewModel board)
        {
            bool handled = false;

            if (howManyCorrect == 4)
            {
                await UIPlatform.ShowMessageAsync("Congratuations, you won");

                handled = true;
            }
            if (board.GuessList.Last().IsCompleted)
            {
                await UIPlatform.ShowMessageAsync("You ran out of guesses.");

                handled = true;
            }
            if (handled)
            {
                await this.SendGameOverAsync();

                return;
            }
            await board.StartNewGuessAsync();
        }
Exemple #9
0
 private void NewGame_Click(object sender, EventArgs e)
 {
     MainBoard.GameBoard = GameBoardViewModel.LoadNewPuzzle();
 }
Exemple #10
0
 public GameBoardActivity(IManager manager, BattleshipLogic battleshipLogic, List <Ship> ships, List <Square> currentSquares) : base(manager)
 {
     gameBoardModel       = new GameBoardViewModel(5, 18);
     this.battleshipLogic = battleshipLogic;
     this.currentSquares  = currentSquares;
 }
Exemple #11
0
 /// <summary>
 ///		Modifica el juego seleccionado
 /// </summary>
 private void UpdateSelectedGame()
 {
     GameBoardViewModel.LoadMovements(SelectedGame?.Game);
 }
Exemple #12
0
 /// <summary>
 ///		Inicializa el ViewModel
 /// </summary>
 public void Init(GameBoardViewModel gameBoardViewModel)
 {
     DataContext = ViewModel = gameBoardViewModel;
 }
        void OnTimerTick(object sender, object e)
        {
            var viewModel = GameBoardViewModel.GetInstance();

            viewModel.MatchmakingWaitTime++;
        }
        private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
        {
            // GameBoard
            GameBoard gameBoard = new GameBoard(Rows, Cols);

            _gameBoardViewModel = new GameBoardViewModel(gameBoard, _statistics);

            GameBoardCanvas gameBoardCanvas = new GameBoardCanvas(gameBoard, BlockSizeInPixels, BlockBrushes)
            {
                Height = Rows * BlockSizeInPixels, // Usually 500px
                Width  = Cols * BlockSizeInPixels  // Usually 250px
            };

            Border gameBoardCanvasBorder = BuildBorderForFrameworkElement(gameBoardCanvas, ElementsBorderThickness);

            gameBoardCanvasBorder.Margin = new Thickness(ElementsSpacing);

            // NextPiece
            NextPieceViewModel nextPieceViewModel = new NextPieceViewModel(gameBoard, NextPieceBlockSizeInPixels, NextPieceRows, NextPieceCols);

            NextPieceCanvas nextPieceCanvas = new NextPieceCanvas(nextPieceViewModel, BlockBrushes)
            {
                Height = NextPieceRows * NextPieceBlockSizeInPixels, // Usually 120px
                Width  = NextPieceCols * NextPieceBlockSizeInPixels  // Usually 120px
            };

            Border nextPieceCanvasBorder = BuildBorderForFrameworkElement(nextPieceCanvas, ElementsBorderThickness);

            nextPieceCanvasBorder.Margin = new Thickness(gameBoardCanvasBorder.Width + 2 * ElementsSpacing, ElementsSpacing, ElementsSpacing, ElementsSpacing);

            // Statistics
            StatisticsViewModel statisticsViewModel = new StatisticsViewModel(_statistics);

            StatisticsUserControl statisticsUserControl = new StatisticsUserControl(statisticsViewModel)
            {
                Height = 94,
                Width  = nextPieceCanvas.Width // Usually 120px
            };

            Border statisticsCanvasBorder = BuildBorderForFrameworkElement(statisticsUserControl, ElementsBorderThickness);

            statisticsCanvasBorder.Margin = new Thickness(gameBoardCanvasBorder.Width + 2 * ElementsSpacing, nextPieceCanvasBorder.Height + 2 * ElementsSpacing, ElementsSpacing, ElementsSpacing);

            // HighScores
            HighScoresViewModel highScoresViewModel = new HighScoresViewModel(_highScoreList);

            HighScoresUserControl highScoresUserControl = new HighScoresUserControl(highScoresViewModel)
            {
                Height = 135,
                Width  = nextPieceCanvas.Width // Usually 120px
            };

            Border highScoresCanvasBorder = BuildBorderForFrameworkElement(highScoresUserControl, ElementsBorderThickness);

            highScoresCanvasBorder.Margin = new Thickness(gameBoardCanvasBorder.Width + 2 * ElementsSpacing, nextPieceCanvasBorder.Height + statisticsCanvasBorder.Height + 3 * ElementsSpacing, ElementsSpacing, ElementsSpacing);

            // ButtonsUserControl
            _buttonsUserControl = new ButtonsUserControl
            {
                Height = gameBoardCanvasBorder.Height - nextPieceCanvasBorder.Height - statisticsCanvasBorder.Height - highScoresCanvasBorder.Height - 3 * ElementsSpacing - 2 * ElementsBorderThickness,
                Width  = nextPieceCanvas.Width // Usually 120px
            };

            Border buttonsUserControlBorder = BuildBorderForFrameworkElement(_buttonsUserControl, ElementsBorderThickness);

            buttonsUserControlBorder.Margin = new Thickness(gameBoardCanvasBorder.Width + 2 * ElementsSpacing, nextPieceCanvasBorder.Height + statisticsCanvasBorder.Height + highScoresCanvasBorder.Height + 4 * ElementsSpacing, ElementsSpacing, ElementsSpacing);

            // Make all backgrounds black
            gameBoardCanvas.Background       = Brushes.Black;
            nextPieceCanvas.Background       = Brushes.Black;
            statisticsUserControl.Background = Brushes.Black;
            highScoresUserControl.Background = Brushes.Black;
            _buttonsUserControl.Background   = Brushes.Black;

            // Add controls to grid
            Grid2.Children.Add(gameBoardCanvasBorder);
            Grid2.Children.Add(nextPieceCanvasBorder);
            Grid2.Children.Add(statisticsCanvasBorder);
            Grid2.Children.Add(highScoresCanvasBorder);
            Grid2.Children.Add(buttonsUserControlBorder);

            // Event handling
            _buttonsUserControl.ButtonNewGame.Click     += ButtonsUserControl_ButtonNewGame_Click;
            _buttonsUserControl.ButtonPauseResume.Click += ButtonsUserControl_ButtonPauseResume_Click;
            gameBoard.GameOver += GameBoard_GameOver;
            HighScoreInputUserControl1.ButtonOk.Click += HighScoreInputUserControl1_ButtonOk_Click;
            GameOverUserControl1.ButtonNewGame.Click  += GameOverUserControl1_ButtonNewGame_Click;
        }
        public MatchmakingWaitPage()
        {
            this.InitializeComponent();

            DataContext = GameBoardViewModel.GetInstance();
        }
Exemple #16
0
 public GameBoardView(GameBoardViewModel viewModel)
 {
     InitializeComponent();
     DataContext = viewModel;
 }
Exemple #17
0
 public MovementListViewModel(GameBoardViewModel gameBoardViewModel)
 {
     GameBoardViewModel = gameBoardViewModel;
 }
Exemple #18
0
 public MainWindow()
 {
     InitializeComponent();
     DataContext = new GameBoardViewModel();
 }
Exemple #19
0
 public ScapesBoardViewModel(GameBoardViewModel viewModel)
 {
     ViewModel = viewModel;
 }
 public GameViewModel(GameBoardViewModel gameBoard)
 {
     GameBoard = gameBoard;
 }
 /// <summary>
 ///		Ejecuta un movimiento
 /// </summary>
 private void ExecuteMovement()
 {
     GameBoardViewModel.GoToVariation(Variation, Movement);
 }
 public HomeController()
 {
     gb = new GameBoardViewModel();
 }