Exemplo n.º 1
0
        private readonly SorryCardGameGameContainer _gameContainer; //if we don't need it, take it out.

        public SorryCardGameMainGameClass(IGamePackageResolver mainContainer,
                                          IEventAggregator aggregator,
                                          BasicData basicData,
                                          TestOptions test,
                                          SorryCardGameVMData currentMod,
                                          IMultiplayerSaveState state,
                                          IAsyncDelayer delay,
                                          ICardInfo <SorryCardGameCardInformation> cardInfo,
                                          CommandContainer command,
                                          SorryCardGameGameContainer gameContainer)
            : base(mainContainer, aggregator, basicData, test, currentMod, state, delay, cardInfo, command, gameContainer)
        {
            _model         = currentMod;
            _command       = command;
            _gameContainer = gameContainer;
        }
        public SorryCardGameMainView(IEventAggregator aggregator,
                                     TestOptions test,
                                     SorryCardGameVMData model,
                                     SorryCardGameGameContainer gameContainer
                                     )
        {
            _aggregator = aggregator;
            _model      = model;
            _aggregator.Subscribe(this);
            _gameContainer = gameContainer;
            _deckGPile     = new BaseDeckXF <SorryCardGameCardInformation, SorryCardGameGraphicsCP, CardGraphicsXF>();
            _discardGPile  = new BasePileXF <SorryCardGameCardInformation, SorryCardGameGraphicsCP, CardGraphicsXF>();
            _score         = new ScoreBoardXF();
            _playerHandWPF = new BaseHandXF <SorryCardGameCardInformation, SorryCardGameGraphicsCP, CardGraphicsXF>();
            _boardStack    = new StackLayout();
            _otherPileXF   = new BasePileXF <SorryCardGameCardInformation, SorryCardGameGraphicsCP, CardGraphicsXF>();
            _boardList     = new CustomBasicList <BoardXF>();

            StackLayout             mainStack = new StackLayout();
            ParentSingleUIContainer?restoreP  = null;

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

            StackLayout otherStack = new StackLayout();

            otherStack.Orientation = StackOrientation.Horizontal;
            otherStack.Children.Add(_score);
            otherStack.Children.Add(_deckGPile);
            otherStack.Children.Add(_discardGPile); // can reposition or not even have as well.
            otherStack.Children.Add(_otherPileXF);
            var tempLabel = GetDefaultLabel();

            tempLabel.FontSize       = 35;
            tempLabel.FontAttributes = FontAttributes.Bold;
            tempLabel.SetBinding(Label.TextProperty, new Binding(nameof(SorryCardGameMainViewModel.UpTo)));
            otherStack.Children.Add(tempLabel);
            mainStack.Children.Add(otherStack);

            _score.AddColumn("Cards Left", false, nameof(SorryCardGamePlayerItem.ObjectCount)); //very common.
            SimpleLabelGridXF firstInfo = new SimpleLabelGridXF();

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

            otherStack             = new StackLayout();
            otherStack.Orientation = StackOrientation.Horizontal;
            otherStack.Children.Add(_playerHandWPF);
            otherStack.Children.Add(firstInfo.GetContent);
            mainStack.Children.Add(otherStack);
            mainStack.Children.Add(_boardStack);



            _deckGPile.Margin    = new Thickness(5, 5, 5, 5);
            _otherPileXF.Margin  = new Thickness(5, 5, 5, 5);
            _discardGPile.Margin = new Thickness(5, 5, 5, 5);

            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;
        }