我一直在写纸牌游戏战争,Unity
在战争功能中,我失去了 2 张牌。有没有更简单的方法可以做到这一点,或者任何人都可以让我知道我做错了什么?
while(Flipped1[Flipped1.length-1].CardValue == Flipped2[Flipped2.length-1].CardValue)
{
for(var i= 0; i < 3; i++)
{
//adds a card from the players hand to the flipped pile
Flipped1.Add(playerOneCards[0]);
Flipped2.Add(playerTwoCards[0]);
//removes card from the array.
playerOneCards.RemoveAt(0);
playerTwoCards.RemoveAt(0);
}
p1War = Flipped1[Flipped1.length-1].img;
p2War = Flipped2[Flipped2.length-1].img;
Debug.Log(Flipped1[i].CardValue);
Debug.Log(Flipped2[i].CardValue);
Debug.Log(Flipped1[0].CardValue);
Debug.Log(Flipped2[0].CardValue);
if(Flipped1[i].CardValue < Flipped2[i].CardValue)
{
for(var j =0; j < Flipped1.length +2 || j < Flipped2.length+2; j++)
{
playerTwoCards.Add(Flipped1[0]);
playerTwoCards.Add(Flipped2[0]);
//removes card from the array.
Flipped1.RemoveAt(0);
Flipped2.RemoveAt(0);
}
}
else
{
for(var q =0; q < Flipped1.length+2|| q < Flipped2.length+2; q++)
{
playerOneCards.Add(Flipped2[0]);
playerOneCards.Add(Flipped1[0]);
//removes card from the array.
Flipped1.RemoveAt(0);
Flipped2.RemoveAt(0);
}
}
}