Question by
tonyyaza · Sep 05, 2016 at 09:37 AM ·
if statementfailure
if statement fail to check the bool,I create card game for dealer hand but bool function fail to check by if statement.
public bool keepGoing=true; void Update() { if (dealersHand >= 17) { keepGoing = false; } else { keepGoing = true; } } if (dh2 == true && keepGoing == true ) { GameObject dealer2 = DealCard (); dealer2.transform.position = dpos2.transform.position; dealer2.name = "dealerScond"; dealerSecondCard = GameObject.Find ("dealerScond"); int dCard2 = dealerSecondCard.GetComponent ().cardNumber; if (dCard2 == 11) {
dealerAces += 1;
dealersHand += 11;
} else
{
dealersHand += dCard2;
}
checkDealerSum ();
dh3 = true;
}
if (dh3 == true && keepGoing == true )
{
GameObject dealer3 = DealCard ();
dealer3.transform.position = dpos3.transform.position;
dealer3.name = "dealer3";
dealerThirdCard = GameObject.Find ("dealer3");
int dCard3 = dealerThirdCard.GetComponent<whatCard> ().cardNumber;
if (dCard3 == 11)
{
dealerAces += 1;
dealersHand += 11;
}
else
{
dealersHand += dCard3;
}
checkDealerSum ();
dh4 = true;
}
if (dh4 == true && keepGoing == true )
{
GameObject dealer4 = DealCard ();
dealer4.transform.position = dpos4.transform.position;
dealer4.name = "dealer4";
dealer4Card = GameObject.Find ("dealer4");
int dCard4 = dealer4Card.GetComponent<whatCard> ().cardNumber;
if (dCard4 == 11)
{
dealerAces += 1;
dealersHand += 11;
}
else
{
dealersHand += dCard4;
}
checkDealerSum ();
dh5 = true;
}
if (dh5 == true && keepGoing == true )
{
GameObject dealer5 = DealCard ();
dealer5.transform.position = dpos5.transform.position;
dealer5.name = "dealer5Card";
dealer5Card = GameObject.Find ("dealer5Card");
int dCard5 = dealer5Card.GetComponent<whatCard> ().cardNumber;
if (dCard5 == 11)
{
dealerAces += 1;
dealersHand += 11;
}
else
{
dealersHand += dCard5;
}
checkDealerSum ();
dh6 = true;
}
if (dh6 == true && keepGoing == true )
{
GameObject dealer6 = DealCard ();
dealer6.transform.position = dpos6.transform.position;
dealer6.name = "dealer6Card";
dealer6Card = GameObject.Find ("dealer6Card");
int dCard6 = dealer6Card.GetComponent<whatCard> ().cardNumber;
if (dCard6 == 11)
{
dealerAces += 1;
dealersHand += 11;
}
else
{
dealersHand += dCard6;
}
checkDealerSum ();
dh7 = true;
}
if (dh7 == true && keepGoing == true )
{
GameObject dealer7 = DealCard ();
dealer7.transform.position = dpos7.transform.position;
dealer7.name = "dealer6Card";
dealer7Card = GameObject.Find ("dealer6Card");
int dCard7 = dealer7Card.GetComponent<whatCard> ().cardNumber;
if (dCard7 == 11)
{
dealerAces += 1;
dealersHand += 11;
}
else
{
dealersHand += dCard7;
}
checkDealerSum ();
}
}
Comment
Your answer
Follow this Question
Related Questions
Unity is not playing the game in the game window. 0 Answers
[Help]Import point cache to unity3d with Megafier 1 Answer
Unity: failed to insert item. Name XXXXX 0 Answers
Delete duplicates in a list of vectors 1 Answer
CS1023 An embedded statement may not be a declaration or labeled statement help 1 Answer