示例#1
0
    void AddMove(Pieces from, GridIndex to)
    {
        var seq = from.QueryMovable(MoveType.StandardMove);

        seq.Build(board, MoveType.StandardMove);

        if (seq.ContainsMove(to))
        {
            var fromIndex = from.CellIndex;
            var action    = from.MoveTo(to);

            undoStack.Push(ActionCommand.SimpleMove(action));
            redoStack.Clear();
            GenericAction();
            board.Turnover();
        }


        else if (from is King king)
        {
            AddCastling(king, to);
        }


        else if (from is Pawn pawn)
        {
            AddEnpassant(pawn, to);
        }
    }
示例#2
0
    void AddAttack(Pieces from, Pieces to)
    {
        if (from.Team == to.Team)
        {
            if (from == to)
            {
                selection = null;
            }
            else
            {
                selection = to.CellIndex;
            }
        }
        else
        {
            var seq = from.QueryMovable(MoveType.Attack);
            seq.Build(board, MoveType.Attack);

            if (seq.ContainsMove(to.CellIndex))
            {
                var fromIndex = from.CellIndex;
                var action    = from.MoveTo(to.CellIndex);

                undoStack.Push(ActionCommand.SimpleMove(action));
                redoStack.Clear();
                GenericAction();
                board.Turnover();
            }
        }
    }
示例#3
0
    public void BuildAttackHighlight(Pieces piece)
    {
        ClearAttackHighlight();

        var attackSeq = piece.QueryMovable(MoveType.Attack);

        attackSeq.Build(board, MoveType.Attack);

        for (int i = 0; i < attackSeq.SequenceCount; ++i)
        {
            var single = attackSeq[i];
            for (int j = 0; j < single.Count; ++j)
            {
                movableGlows.Add(CreateGlow(GlowType.UnderAttack, single[j]));
            }
        }
    }
示例#4
0
    public void BuildMoveHighlight(Pieces piece)
    {
        ClearMoveHighlight();

        var moveSeq = piece.QueryMovable(MoveType.StandardMove);

        moveSeq.Build(board, MoveType.StandardMove);

        for (int i = 0; i < moveSeq.SequenceCount; ++i)
        {
            var single = moveSeq[i];
            for (int j = 0; j < single.Count; ++j)
            {
                movableGlows.Add(CreateGlow(GlowType.Movable, single[j]));
            }
        }

        movableGlows.Add(CreateGlow(GlowType.Movable, piece.CellIndex));
    }