コード例 #1
0
        public static void makeMove()
        {
            int[] coords = clickedBoard.getCoords();

            var tempAvailableMoves = Figure.getTempCoords();

            var x = tempAvailableMoves.Find(x => { return(x[0] == coords[0] && x[1] == coords[1]); });

            if (x == null)
            {
                return;            // hit on not available field
            }
            clearHighlightedFields();


            ChosenFigure = nowSelected.getFigure();

            clickedBoard.setFigure(ChosenFigure);

            nowSelected.setFigure(null);

            nowSelected = null;

            nowSelectedTeam = (nowSelectedTeam == 1) ? 2 : 1;

            Figure.clearTempCoords();
        }
コード例 #2
0
        public static void selectBoardField(ChessBoardField nowClickedBoard)
        {
            clickedBoard = nowClickedBoard;

            if (gameStart)
            {
                if (nowSelected == null)
                {
                    if (!nowClickedBoard.hasFigure())
                    {
                        return;
                    }

                    if (nowClickedBoard.getTeam() != nowSelectedTeam)
                    {
                        return;
                    }

                    nowSelected = nowClickedBoard;

                    showAvailableMoves();
                }
                else if (nowSelected != null)
                {
                    if (TryToSelectTheSameFigure())
                    {
                        nowSelected = null;

                        clearHighlightedFields();
                        Figure.clearTempCoords();

                        return;
                    }

                    makeMove();
                }
            }
            else
            {
                if (clickedBoard != null)
                {
                    Figure newFigure = choosenFigureToAdd.generateFigure();
                    nowClickedBoard.setFigure(newFigure);
                }
            }
        }