在 C# XNA 中选择问题

Issues with picking in c# XNA

我正在尝试制作一个国际象棋游戏,使用拾取来移动棋子,因此用户单击一个棋子将其设置为所选棋子,然后在他们想要将其移动到的方格上。这是第一次工作,但是当您单击另一块使其成为选定的块,然后单击一个空方块来移动它时,它会移动第一个选定的块。这是我的代码,在此先感谢任何可以提供帮助的人。

string[,] Board =
    {
        {"BRook1", "BKnight1", "BBisop1", "BQueen", "BKing", "BBishop2", "BKnight2", "BRook2"},
        {"BPawn1", "BPawn2", "BPawn3", "BPawn4", "BPawn5", "BPawn6", "BPawn7", "BPawn8"},
        {null, null, null, null, null, null, null, null },
        {null, null, null, null, null, null, null, null },
        {null, null, null, null, null, null, null, null },
        {null, null, null, null, null, null, null, null },
        {"WPawn1", "WPawn2", "WPawn3", "WPawn4", "WPawn5", "WPawn6", "WPawn7", "WPawn8"},
        {"WRook1", "WKnight1", "WBishop1", "WQueen", "WKing", "WBishop2", "WKnight2", "WRook2"},
    };

        MouseState mouseState = Mouse.GetState();
        decimal decMousex = mouseState.X;
        decimal decMousey = mouseState.Y;
        y = Convert.ToInt32(Math.Floor(decMousex / 75));
        x = Convert.ToInt32(Math.Floor(decMousey / 75));
        

        if (mouseState.LeftButton == ButtonState.Pressed
            && Board[x,y] != null && pieceSelected == null)
        {
            pieceSelected = Board[x, y];
            selectedX = x;
            selectedY = y;
        }

        else if (mouseState.LeftButton == ButtonState.Pressed
                && Board[x,y] == null && pieceSelected != null)
        {
            Board[selectedX, selectedY] = null;
            Board[x, y] = pieceSelected;
            pieceSelected = null;
        }

看看当鼠标在一个空方块上按下时发生了什么,pieceSelected 会移动到那里,但下一轮立即又变成 pieceSelected 因为鼠标仍然处于按下状态,除非你的点击速度非常快。