예제 #1
0
        public bool CanDropCard(IntPoint gridPos, CardBase card)
        {
            if (MyCardGrid.IsOccupied(gridPos.Y, gridPos.X))
            {
                return(false);
            }

            CardNeighbours neighbours = MyCardGrid.GetNeighbours(gridPos.Y, gridPos.X);

            if (neighbours.NumNeighbours() == 0)
            {
                return(false);
            }

            if (neighbours.North != null)
            {
                if (!CardEdgesEqual(neighbours.North.EdgeSouth, card.EdgeNorth))
                {
                    return(false);
                }
            }
            if (neighbours.East != null)
            {
                if (!CardEdgesEqual(neighbours.East.EdgeWest, card.EdgeEast))
                {
                    return(false);
                }
            }
            if (neighbours.West != null)
            {
                if (!CardEdgesEqual(neighbours.West.EdgeEast, card.EdgeWest))
                {
                    return(false);
                }
            }
            if (neighbours.South != null)
            {
                if (!CardEdgesEqual(neighbours.South.EdgeNorth, card.EdgeSouth))
                {
                    return(false);
                }
            }

            return(true);
        }