Beispiel #1
0
 public CardBase()
 {
     Pos2GridConv  = new CardPosition2CardGridConverter();
     RotationState = CardRotation.Deg0;
     GridPosition  = new IntPoint(-1, -1);
     Position      = new BindPoint();
 }
Beispiel #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);
        }
Beispiel #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);
        }
Beispiel #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);
        }