Hi everyone,
I know there's a section designated for Mobile Development but, that's really dead and It wouldn't hurt anyone if I posted here - It's a C# related question anyway.
I'm making a Naughts and Crosses game on my Windows Mobile - HTC.
The game works fine, I can put the naughts and crosses in well that works brilliantly.
But....I've made an if statement that checks if someone has won and that if statement never gets executed....
As you can imagine, a typical naughts and crosses grid is 3x3, so that's 9 entries. I've made 9 buttons and named them their respective location. Let's concentrate on the right most, middle button:
private void RightBottom_Click(object sender, RoutedEventArgs e)
{
if (RightBottom.Content == null) //Check if it is initially empty
{
if (whosGo == "X") //Check if it's X's turn
{
RightBottom.Content = "X"; //If it is X's turn AND the content is null, put X inside the button
whosGo = "O"; //Swap it back to O's turn
if ((MiddleBottom.Content == "X") && (LeftBottom.Content == "X") || (RightMiddle.Content == "X") && (RightTop.Content == "X") || (MiddleMiddle.Content == "X") && (LeftTop.Content == "X")) //This is where it all happens, this if statement NEVER gets called for some reason. Even when I make sure that the buttons DO contain X.
{
PageTitle.Text = "X Wins";
}
}
else if (whosGo == "O")
{
RightBottom.Content = "O";
whosGo = "X";
if ((MiddleBottom.Content == "O") && (LeftBottom.Content == "O") || (RightMiddle.Content == "O") && (RightTop.Content == "O") || (MiddleMiddle.Content == "O") && (LeftTop.Content == "O"))
{
PageTitle.Text = "O Wins";
}
}
}
}
I ran the debugger and when the compiler reaches the big if statement, it steps over it like it's not true when I clearly made the buttons within the if in to X...No idea why it's not working, no idea at all. The coding is there clear as day...(oh by the way, Silverlight doesn't like Button.Text...It only allows Button.Content for some reason...)
Any help is appreciated, a lot!
Thank you.