Esempio n. 1
0
        public MineButton GetNeighbor(RelativePositions position)
        {
            MineButton neighbor = null;

            switch (position)
            {
            case RelativePositions.Bottom:
                neighbor = board.GetButton(X, Y + 1);
                break;

            case RelativePositions.BottomLeft:
                neighbor = board.GetButton(X - 1, Y + 1);
                break;

            case RelativePositions.BottomRight:
                neighbor = board.GetButton(X + 1, Y + 1);
                break;

            case RelativePositions.Left:
                neighbor = board.GetButton(X - 1, Y);
                break;

            case RelativePositions.Right:
                neighbor = board.GetButton(X + 1, Y);
                break;

            case RelativePositions.Top:
                neighbor = board.GetButton(X, Y - 1);
                break;

            case RelativePositions.TopLeft:
                neighbor = board.GetButton(X - 1, Y - 1);
                break;

            case RelativePositions.TopRight:
                neighbor = board.GetButton(X + 1, Y - 1);
                break;
            }

            return(neighbor);
        }