私はカードゲームの戦争を書くことに取り組んでおり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);
}
}
}