Exemplo n.º 1
0
        private void IntializeGame()
        {
            CardsOnBoard.Clear();
            _occupiedBoardPositions = new bool[_numBoardPositionsRow, _numBoardPositionsRow];

            MyCardGrid  = new CardGrid();
            _myCardDeck = new CardDeck();


            CurrentCard = _myCardDeck.DrawCard();

            CardBase card0 = _myCardDeck.DrawCard();

            card0.Position = new BindPoint(_cardWidth * CenterCol, _cardHeight * CenterRow);


            IntPoint gridPos = (IntPoint)pos2GridConv.Convert(card0.Position, null, _cardWidth, null);

            AddCardToBoard(card0);

            Players = new ObservableCollection <PlayerBase> {
                new PlayerThisHuman(),
                new PlayerPc(),
                new PlayerOtherHuman()
            };

            CurrentPlayer = Players[0];
        }
Exemplo n.º 2
0
        public CardNeighbours GetNeighbours(CardBase card)
        {
            CardNeighbours neighbours = new CardNeighbours();

            BindPoint p = card.Position;
            CardPosition2CardGridConverter conv = card.Pos2GridConv;
            IntPoint gridPos = conv.Convert(p, null, null, null) as IntPoint;

            if (gridPos != null)
            {
                neighbours = GetNeighbours(gridPos.Y, gridPos.X);
            }

            return(neighbours);
        }
Exemplo n.º 3
0
        private void CardDrop(CardBase card, Point mousePos)
        {
            double x = Math.Round((mousePos.X - CardBase.Width / 2) / CardBase.Width) * CardBase.Width;
            double y = Math.Round((mousePos.Y - CardBase.Height / 2) / CardBase.Height) * CardBase.Height;
            CardPosition2CardGridConverter pos2GridConv = new CardPosition2CardGridConverter();
            IntPoint gridPos = (IntPoint)pos2GridConv.Convert(new BindPoint(x, y), null, CardBase.Width, null);

            if (!viewModel.CanDropCard(gridPos, card))
            {
                return;
            }

            card.Position = new BindPoint(x, y);

            viewModel.AddCardToBoard(card);
        }
Exemplo n.º 4
0
        private void MeepleDrop(MeepleBase meeple, Point mousePos)
        {
            double x = Math.Round((mousePos.X - CardBase.Width / 2) / CardBase.Width) * CardBase.Width;
            double y = Math.Round((mousePos.Y - CardBase.Height / 2) / CardBase.Height) * CardBase.Height;
            CardPosition2CardGridConverter pos2GridConv = new CardPosition2CardGridConverter();
            IntPoint gridPos = (IntPoint)pos2GridConv.Convert(new BindPoint(x, y), null, CardBase.Width, null);

            CardBase card = viewModel.MyCardGrid.GetCardAt(gridPos.Y, gridPos.X);

            if (card == null)
            {
                return;
            }

            if (card != viewModel.MyCardGrid.GetLastCard())
            {
                return;
            }
            // The meeple can only be dropped at the most recently card that was added to the board.

            card.Meeple = meeple;
            viewModel.CurrentPlayer.MeepleFromStackToBoard(meeple);
        }