Example #1
0
 public ClueBoardGameMainViewModel(CommandContainer commandContainer,
                                   ClueBoardGameMainGameClass mainGame,
                                   ClueBoardGameVMData model,
                                   BasicData basicData,
                                   TestOptions test,
                                   IGamePackageResolver resolver,
                                   IStandardRollProcesses roller,
                                   ClueBoardGameGameContainer gameContainer,
                                   GameBoardProcesses gameBoard
                                   )
     : base(commandContainer, mainGame, model, basicData, test, resolver, roller)
 {
     _mainGame      = mainGame;
     _model         = model;
     _basicData     = basicData;
     _gameContainer = gameContainer;
     _gameBoard     = gameBoard;
     _gameContainer.SpaceClickedAsync = MoveSpaceAsync;
     _gameContainer.RoomClickedAsync  = MoveRoomAsync;
     _model.Pile.SendEnableProcesses(this, () => false);
     _model.HandList.ObjectClickedAsync += HandList_ObjectClickedAsync;
     _model.HandList.SendEnableProcesses(this, () => _mainGame.SaveRoot.GameStatus == EnumClueStatusList.FindClues);
 }
        public ClueBoardGameMainView(IEventAggregator aggregator,
                                     TestOptions test,
                                     ClueBoardGameVMData model,
                                     GameBoardGraphicsCP graphicsCP,
                                     IGamePackageRegister register,
                                     ClueBoardGameMainGameClass mainGame,
                                     ClueBoardGameGameContainer gameContainer
                                     )
        {
            _mainGame      = mainGame;
            _gameContainer = gameContainer;
            _aggregator    = aggregator;
            _model         = model;
            _aggregator.Subscribe(this);
            register.RegisterControl(_board.ThisElement, "");
            graphicsCP.LinkBoard();
            _piece = new PawnPiecesXF <EnumColorChoice>();
            _piece.HeightRequest = 80;
            _piece.WidthRequest  = 80;
            _piece.Init();
            _pile       = new BasePileXF <CardInfo, CardCP, CardXF>();
            _hand       = new BaseHandXF <CardInfo, CardCP, CardXF>();
            _detective  = new DetectiveNotebookXF();
            _prediction = new PredictionAccusationXF();
            StackLayout             mainStack = new StackLayout();
            ParentSingleUIContainer?restoreP  = null;

            if (test.SaveOption == EnumTestSaveCategory.RestoreOnly)
            {
                restoreP = new ParentSingleUIContainer(nameof(ClueBoardGameMainViewModel.RestoreScreen));
            }
            _predictionButton = GetSmallerButton("Predict", nameof(ClueBoardGameMainViewModel.MakePredictionAsync));
            _accusationButton = GetSmallerButton("Accusation", nameof(ClueBoardGameMainViewModel.MakeAccusationAsync));

            StackLayout firstStack = new StackLayout();

            firstStack.Orientation = StackOrientation.Horizontal;
            firstStack.Children.Add(_board);

            firstStack.Children.Add(_piece);
            mainStack.Children.Add(firstStack);
            Grid tempGrid = new Grid();

            AddLeftOverColumn(tempGrid, 50);
            AddLeftOverColumn(tempGrid, 50);
            AddAutoColumns(tempGrid, 1);
            mainStack.Children.Add(tempGrid);
            AddControlToGrid(tempGrid, _prediction, 0, 0);
            _board.HorizontalOptions = LayoutOptions.Start;
            _board.VerticalOptions   = LayoutOptions.Start;
            Label label = new Label();

            label.FontSize       = 30;
            label.TextColor      = Color.White;
            label.FontAttributes = FontAttributes.Bold;
            label.SetBinding(Label.TextProperty, new Binding(nameof(ClueBoardGameMainViewModel.LeftToMove)));
            StackLayout tempStack = new StackLayout();

            var thisRoll = GetSmallerButton("Roll Dice", nameof(ClueBoardGameMainViewModel.RollDiceAsync));

            _diceControl = new DiceListControlXF <SimpleDice>();
            var endButton = GetSmallerButton("End Turn", nameof(ClueBoardGameMainViewModel.EndTurnAsync));

            endButton.HorizontalOptions = LayoutOptions.Start;
            tempStack.Children.Add(label);
            tempStack.Children.Add(thisRoll);
            tempStack.Children.Add(endButton);
            tempStack.Children.Add(_pile);
            tempStack.Children.Add(_diceControl);
            AddControlToGrid(tempGrid, _detective, 0, 1);
            AddControlToGrid(tempGrid, tempStack, 0, 2);
            SimpleLabelGridXF firstInfo = new SimpleLabelGridXF();

            firstInfo.AddRow("Turn", nameof(ClueBoardGameMainViewModel.NormalTurn));
            firstInfo.AddRow("Instructions", nameof(ClueBoardGameMainViewModel.Instructions));
            _details = firstInfo.GetContent;
            if (restoreP != null)
            {
                //todo:  figure out where to place the restore ui if there is a restore option.
                mainStack.Children.Add(restoreP); //default add to grid but does not have to.
            }
            Content = mainStack;
        }
Example #3
0
        public ClueBoardGameMainView(IEventAggregator aggregator,
                                     TestOptions test,
                                     ClueBoardGameVMData model,
                                     GameBoardGraphicsCP graphicsCP,
                                     IGamePackageRegister register,
                                     ClueBoardGameMainGameClass mainGame,
                                     ClueBoardGameGameContainer gameContainer
                                     )
        {
            _mainGame      = mainGame;
            _gameContainer = gameContainer;
            _aggregator    = aggregator;
            _model         = model;
            _aggregator.Subscribe(this);
            register.RegisterControl(_board.ThisElement, "");
            graphicsCP.LinkBoard();
            _piece        = new PawnPiecesWPF <EnumColorChoice>();
            _piece.Height = 60;
            _piece.Width  = 60;
            _piece.Init();
            _pile       = new BasePileWPF <CardInfo, CardCP, CardWPF>();
            _hand       = new BaseHandWPF <CardInfo, CardCP, CardWPF>();
            _detective  = new DetectiveNotebookWPF();
            _prediction = new PredictionAccusationWPF();

            StackPanel mainStack  = new StackPanel();
            StackPanel finalStack = new StackPanel()
            {
                Orientation = Orientation.Horizontal
            };

            ParentSingleUIContainer?restoreP = null;

            if (test.SaveOption == EnumTestSaveCategory.RestoreOnly)
            {
                restoreP = new ParentSingleUIContainer()
                {
                    Name = nameof(ClueBoardGameMainViewModel.RestoreScreen)
                };
            }

            var thisRoll         = GetGamingButton("Roll Dice", nameof(ClueBoardGameMainViewModel.RollDiceAsync));
            var preButton        = GetGamingButton("Predict", nameof(ClueBoardGameMainViewModel.MakePredictionAsync));
            var accusationButton = GetGamingButton("Accusation", nameof(ClueBoardGameMainViewModel.MakeAccusationAsync));

            StackPanel otherStack = new StackPanel();

            otherStack.Orientation = Orientation.Horizontal;
            _diceControl           = new DiceListControlWPF <SimpleDice>();
            var endButton = GetGamingButton("End Turn", nameof(ClueBoardGameMainViewModel.EndTurnAsync));

            endButton.HorizontalAlignment = HorizontalAlignment.Left;


            SimpleLabelGrid firstInfo = new SimpleLabelGrid();

            firstInfo.AddRow("Turn", nameof(ClueBoardGameMainViewModel.NormalTurn));
            firstInfo.AddRow("Status", nameof(ClueBoardGameMainViewModel.Status));

            StackPanel firstRowStack = new StackPanel();

            firstRowStack.Children.Add(_board);
            otherStack.Children.Add(_piece);
            otherStack.Children.Add(firstInfo.GetContent);
            firstRowStack.Children.Add(otherStack);
            finalStack.Children.Add(firstRowStack);
            StackPanel secondRowStack = new StackPanel();

            finalStack.Children.Add(secondRowStack);
            StackPanel thirdRowStack = new StackPanel();

            finalStack.Children.Add(thirdRowStack);
            otherStack             = new StackPanel();
            otherStack.Orientation = Orientation.Horizontal;
            otherStack.Children.Add(_hand);
            otherStack.Children.Add(_pile);
            secondRowStack.Children.Add(otherStack);
            _prediction.Margin = new Thickness(0, 0, 0, 30);
            secondRowStack.Children.Add(_prediction);
            secondRowStack.Children.Add(_detective);
            AddVerticalLabelGroup("Instructions", nameof(ClueBoardGameMainViewModel.Instructions), thirdRowStack);

            otherStack             = new StackPanel();
            otherStack.Orientation = Orientation.Horizontal;
            otherStack.Children.Add(_diceControl);
            TextBlock label = new TextBlock();

            label.FontSize   = 100;
            label.Foreground = Brushes.White;
            label.FontWeight = FontWeights.Bold;
            label.SetBinding(TextBlock.TextProperty, new Binding(nameof(ClueBoardGameMainViewModel.LeftToMove)));
            otherStack.Children.Add(label);
            thirdRowStack.Children.Add(otherStack);
            thirdRowStack.Children.Add(thisRoll);

            thirdRowStack.Children.Add(preButton);
            thirdRowStack.Children.Add(accusationButton);
            thirdRowStack.Children.Add(endButton);
            var nextInfo = new SimpleLabelGrid();

            nextInfo.AddRow("Room", nameof(ClueBoardGameMainViewModel.CurrentRoomName));
            nextInfo.AddRow("Character", nameof(ClueBoardGameMainViewModel.CurrentCharacterName));
            nextInfo.AddRow("Weapon", nameof(ClueBoardGameMainViewModel.CurrentWeaponName));
            thirdRowStack.Children.Add(nextInfo.GetContent);
            mainStack.Children.Add(finalStack);

            if (restoreP != null)
            {
                //todo:  figure out where to place the restore ui if there is a restore option.
                mainStack.Children.Add(restoreP); //default add to grid but does not have to.
            }
            Content = mainStack;
        }