Esempio n. 1
0
    public List <Moves> getMoves(Pices[,] pices)
    {
        bool isForced = pice.IsForceToMove(pices, x, y);

        move = new List <Moves>();
        if (pice != null)
        {
            if (isForced)
            {
                if (Trymove2(x, y, x + 2, y + 2, pice, pices))
                {
                    nextX = x + 2;
                    nextY = y + 2;
                    Moves m = new Moves(pice, x, y, nextX, nextY);
                    move.Add(m);
                }
                if (Trymove2(x, y, x - 2, y - 2, pice, pices))
                {
                    nextX = x - 2;
                    nextY = y - 2;
                    Moves m = new Moves(pice, x, y, nextX, nextY);
                    move.Add(m);
                }
                if (Trymove2(x, y, x + 2, y - 2, pice, pices))
                {
                    nextX = x + 2;
                    nextY = y - 2;
                    Moves m = new Moves(pice, x, y, nextX, nextY);
                    move.Add(m);
                }
                if (Trymove2(x, y, x - 2, y + 2, pice, pices))
                {
                    nextX = x - 2;
                    nextY = y + 2;
                    Moves m = new Moves(pice, x, y, nextX, nextY);
                    move.Add(m);
                }
            }
            else
            {
                if (Trymove2(x, y, x + 1, y + 1, pice, pices))
                {
                    nextX = x + 1;
                    nextY = y + 1;
                    Moves m = new Moves(pice, x, y, nextX, nextY);
                    move.Add(m);
                }
                if (Trymove2(x, y, x - 1, y - 1, pice, pices))
                {
                    nextX = x - 1;
                    nextY = y - 1;
                    Moves m = new Moves(pice, x, y, nextX, nextY);
                    move.Add(m);
                }
                if (Trymove2(x, y, x + 1, y - 1, pice, pices))
                {
                    nextX = x + 1;
                    nextY = y - 1;
                    Moves m = new Moves(pice, x, y, nextX, nextY);
                    move.Add(m);
                }
                if (Trymove2(x, y, x - 1, y + 1, pice, pices))
                {
                    nextX = x - 1;
                    nextY = y + 1;
                    Moves m = new Moves(pice, x, y, nextX, nextY);
                    move.Add(m);
                }
            }
        }
        return(move);
    }