Example #1
0
        public CardNeighbours GetNeighbours(int row, int col)
        {
            CardNeighbours neighbours = new CardNeighbours();

            int nCards = GridPos.Count;

            for (int i = 0; i < nCards; i++)
            {
                IntPoint pos  = GridPos[i];
                CardBase card = _cardPos[i];
                int      dRow = pos.Y - row;
                int      dCol = pos.X - col;

                if (dRow == 1 && dCol == 0)
                {
                    neighbours.South = card;
                }
                if (dRow == -1 && dCol == 0)
                {
                    neighbours.North = card;
                }
                if (dRow == 0 && dCol == 1)
                {
                    neighbours.East = card;
                }
                if (dRow == 0 && dCol == -1)
                {
                    neighbours.West = card;
                }
            }
            return(neighbours);
        }
Example #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);
        }