C# 如何让我的作品在《蛇与梯子》c中上升到下一排# 我在移动棋子时遇到了麻烦,它只移动了四个棋子,而不是随机移动,当它移动时,它只会直线移动,不会向上移动到下一列\u dicerll=4若要移动网格上的项目,需要将其从网格的子项中删除,然后将其重新插入新行/列
如何让我的作品在《蛇与梯子》c中上升到下一排#C# 如何让我的作品在《蛇与梯子》c中上升到下一排# 我在移动棋子时遇到了麻烦,它只移动了四个棋子,而不是随机移动,当它移动时,它只会直线移动,不会向上移动到下一列\u dicerll=4若要移动网格上的项目,需要将其从网格的子项中删除,然后将其重新插入新行/列,c#,xamarin.forms,C#,Xamarin.forms,如何让我的作品在《蛇与梯子》c中上升到下一排# 我在移动棋子时遇到了麻烦,它只移动了四个棋子,而不是随机移动,当它移动时,它只会直线移动,不会向上移动到下一列\u dicerll=4若要移动网格上的项目,需要将其从网格的子项中删除,然后将其重新插入新行/列 namespace SnakeNLadder { public partial class MainPage : ContentPage { const int START_ROW = 11;
我在移动棋子时遇到了麻烦,它只移动了四个棋子,而不是随机移动,当它移动时,它只会直线移动,不会向上移动到下一列
\u dicerll=4
若要移动网格上的项目,需要将其从网格的子项中删除,然后将其重新插入新行/列
namespace SnakeNLadder
{
public partial class MainPage : ContentPage
{
const int START_ROW = 11;
int _diceRoll;
int _currPlayer;
public MainPage()
{
InitializeComponent();
_currPlayer = 1;
}
private void btnDiceRoll_Clicked(object sender, EventArgs e)
{
// generate a random number right here
_diceRoll = 4;
//Update label here
lblDiceRoll.Text = _diceRoll.ToString();
//move the piece by resetting the row and column values
MovePiece();
}
private void MovePiece()
{
// first thing to do who to move
// bvP1 - string name. #
string playerName = "bvP" + _currPlayer.ToString();
BoxView curr = (BoxView)GrdBoard.FindByName(playerName);
int currCol = (int)curr.GetValue(Grid.ColumnProperty);
// First move
if (START_ROW == (int)curr.GetValue(Grid.RowProperty))
{
curr.SetValue(Grid.RowProperty, START_ROW - 1);
_diceRoll--;
}
//else
//{
// currCol++;
//}
curr.SetValue(Grid.ColumnProperty, currCol + _diceRoll);
}
}
}