fix some buggs
This commit is contained in:
@@ -13,5 +13,6 @@ namespace MathColoringGame
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class App : Application
|
public partial class App : Application
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:local="clr-namespace:MathColoringGame"
|
xmlns:local="clr-namespace:MathColoringGame"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="MainWindow" Height="780" Width="650"
|
Title="MainWindow" Height="780" Width="900"
|
||||||
WindowStyle="None"
|
WindowStyle="None"
|
||||||
Background="Transparent"
|
Background="Transparent"
|
||||||
AllowsTransparency="True"
|
AllowsTransparency="True"
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
|
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition/>
|
<ColumnDefinition/>
|
||||||
<ColumnDefinition Width="230"/>
|
<ColumnDefinition Width="460"/>
|
||||||
<ColumnDefinition/>
|
<ColumnDefinition/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
@@ -89,8 +89,8 @@
|
|||||||
FontSize="18"
|
FontSize="18"
|
||||||
FontWeight="Bold"
|
FontWeight="Bold"
|
||||||
FontFamily="Comic Sans MS"
|
FontFamily="Comic Sans MS"
|
||||||
Content="End Turn" Click="BtnEndTurnClick"/>
|
Content="End Turn" Click="BtnEndTurnClick"/>
|
||||||
|
|
||||||
<Border Grid.Row="1"
|
<Border Grid.Row="1"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
Margin="15,40"
|
Margin="15,40"
|
||||||
@@ -168,7 +168,7 @@
|
|||||||
<TextBlock
|
<TextBlock
|
||||||
Margin="10,30,0,0"
|
Margin="10,30,0,0"
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
Text="Resuld Round 1: "
|
Text="Result Round 1: "
|
||||||
FontFamily="Comic Sans MS"/>
|
FontFamily="Comic Sans MS"/>
|
||||||
|
|
||||||
<TextBox x:Name="p1round1" Text="0"
|
<TextBox x:Name="p1round1" Text="0"
|
||||||
@@ -185,7 +185,7 @@
|
|||||||
<TextBlock
|
<TextBlock
|
||||||
Margin="10,30,0,0"
|
Margin="10,30,0,0"
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
Text="Resuld Round 2: "
|
Text="Result Round 2: "
|
||||||
FontFamily="Comic Sans MS"/>
|
FontFamily="Comic Sans MS"/>
|
||||||
|
|
||||||
<TextBox x:Name="p1round2"
|
<TextBox x:Name="p1round2"
|
||||||
@@ -203,7 +203,7 @@
|
|||||||
<TextBlock
|
<TextBlock
|
||||||
Margin="10,30,0,0"
|
Margin="10,30,0,0"
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
Text="Resuld Round 3: "
|
Text="Result Round 3: "
|
||||||
FontFamily="Comic Sans MS"/>
|
FontFamily="Comic Sans MS"/>
|
||||||
|
|
||||||
<TextBox x:Name="p1round3"
|
<TextBox x:Name="p1round3"
|
||||||
@@ -221,7 +221,7 @@
|
|||||||
<TextBlock
|
<TextBlock
|
||||||
Margin="10,30,0,0"
|
Margin="10,30,0,0"
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
Text="Resuld Round 4: "
|
Text="Result Round 4: "
|
||||||
FontFamily="Comic Sans MS"/>
|
FontFamily="Comic Sans MS"/>
|
||||||
|
|
||||||
<TextBox x:Name="p1round4"
|
<TextBox x:Name="p1round4"
|
||||||
@@ -239,7 +239,7 @@
|
|||||||
<TextBlock
|
<TextBlock
|
||||||
Margin="10,30,0,0"
|
Margin="10,30,0,0"
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
Text="Resuld Round 5: "
|
Text="Result Round 5: "
|
||||||
FontFamily="Comic Sans MS"/>
|
FontFamily="Comic Sans MS"/>
|
||||||
|
|
||||||
<TextBox x:Name="p1round5"
|
<TextBox x:Name="p1round5"
|
||||||
@@ -279,7 +279,7 @@
|
|||||||
<TextBlock
|
<TextBlock
|
||||||
Margin="10,30,0,0"
|
Margin="10,30,0,0"
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
Text="Resuld Round 1: "
|
Text="Result Round 1: "
|
||||||
FontFamily="Comic Sans MS"/>
|
FontFamily="Comic Sans MS"/>
|
||||||
|
|
||||||
<TextBox x:Name="p2round1"
|
<TextBox x:Name="p2round1"
|
||||||
@@ -297,7 +297,7 @@
|
|||||||
<TextBlock
|
<TextBlock
|
||||||
Margin="10,30,0,0"
|
Margin="10,30,0,0"
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
Text="Resuld Round 2: "
|
Text="Result Round 2: "
|
||||||
FontFamily="Comic Sans MS"/>
|
FontFamily="Comic Sans MS"/>
|
||||||
|
|
||||||
<TextBox x:Name="p2round2"
|
<TextBox x:Name="p2round2"
|
||||||
@@ -315,7 +315,7 @@
|
|||||||
<TextBlock
|
<TextBlock
|
||||||
Margin="10,30,0,0"
|
Margin="10,30,0,0"
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
Text="Resuld Round 3: "
|
Text="Result Round 3: "
|
||||||
FontFamily="Comic Sans MS"/>
|
FontFamily="Comic Sans MS"/>
|
||||||
|
|
||||||
<TextBox x:Name="p2round3"
|
<TextBox x:Name="p2round3"
|
||||||
@@ -333,7 +333,7 @@
|
|||||||
<TextBlock
|
<TextBlock
|
||||||
Margin="10,30,0,0"
|
Margin="10,30,0,0"
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
Text="Resuld Round 4: "
|
Text="Result Round 4: "
|
||||||
FontFamily="Comic Sans MS"/>
|
FontFamily="Comic Sans MS"/>
|
||||||
|
|
||||||
<TextBox x:Name="p2round4"
|
<TextBox x:Name="p2round4"
|
||||||
@@ -351,7 +351,7 @@
|
|||||||
<TextBlock
|
<TextBlock
|
||||||
Margin="10,30,0,0"
|
Margin="10,30,0,0"
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
Text="Resuld Round 5: "
|
Text="Result Round 5: "
|
||||||
FontFamily="Comic Sans MS"/>
|
FontFamily="Comic Sans MS"/>
|
||||||
|
|
||||||
<TextBox x:Name="p2round5"
|
<TextBox x:Name="p2round5"
|
||||||
@@ -380,13 +380,31 @@
|
|||||||
BorderThickness="0 "
|
BorderThickness="0 "
|
||||||
FontSize="16"
|
FontSize="16"
|
||||||
Height="30"
|
Height="30"
|
||||||
FontFamily="Comic Sans MS"/>
|
FontFamily="Comic Sans MS"/>
|
||||||
</WrapPanel>
|
|
||||||
|
|
||||||
|
</WrapPanel>
|
||||||
|
<WrapPanel>
|
||||||
|
<TextBlock
|
||||||
|
Margin="10,30,0,0"
|
||||||
|
FontSize="16"
|
||||||
|
Text="dice Result: "
|
||||||
|
FontFamily="Comic Sans MS"/>
|
||||||
|
|
||||||
|
<TextBox x:Name="testbox"
|
||||||
|
Text="0"
|
||||||
|
Margin="0,29,0,0"
|
||||||
|
FontWeight="Bold"
|
||||||
|
Background="Transparent"
|
||||||
|
BorderThickness="0 "
|
||||||
|
FontSize="16"
|
||||||
|
Height="30"
|
||||||
|
FontFamily="Comic Sans MS"/>
|
||||||
|
|
||||||
|
</WrapPanel>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<Grid x:Name="Container"
|
<Grid x:Name="Container"
|
||||||
Width="250"
|
Width="450"
|
||||||
Height="450"
|
Height="450"
|
||||||
VerticalAlignment="Top"
|
VerticalAlignment="Top"
|
||||||
Margin="28"
|
Margin="28"
|
||||||
@@ -411,7 +429,10 @@
|
|||||||
<Button Click="Button_Click" Background="White" Grid.Row="15" BorderBrush="Black"/>
|
<Button Click="Button_Click" Background="White" Grid.Row="15" BorderBrush="Black"/>
|
||||||
<Button Click="Button_Click" Background="White" Grid.Row="16" BorderBrush="Black"/>
|
<Button Click="Button_Click" Background="White" Grid.Row="16" BorderBrush="Black"/>
|
||||||
<Button Click="Button_Click" Background="White" Grid.Row="17" BorderBrush="Black"/>
|
<Button Click="Button_Click" Background="White" Grid.Row="17" BorderBrush="Black"/>
|
||||||
|
<Button Click="Button_Click" Background="White" Grid.Row="18" BorderBrush="Black"/>
|
||||||
|
<Button Click="Button_Click" Background="White" Grid.Row="19" BorderBrush="Black"/>
|
||||||
|
<Button Click="Button_Click" Background="White" Grid.Row="20" BorderBrush="Black"/>
|
||||||
|
|
||||||
<Button Click="Button_Click" Background="Red" Grid.Column="1" BorderBrush="Black"/>
|
<Button Click="Button_Click" Background="Red" Grid.Column="1" BorderBrush="Black"/>
|
||||||
<Button Click="Button_Click" Background="Red" Grid.Row="1" Grid.Column="1" BorderBrush="Black"/>
|
<Button Click="Button_Click" Background="Red" Grid.Row="1" Grid.Column="1" BorderBrush="Black"/>
|
||||||
<Button Click="Button_Click" Background="Red" Grid.Row="2" Grid.Column="1" BorderBrush="Black"/>
|
<Button Click="Button_Click" Background="Red" Grid.Row="2" Grid.Column="1" BorderBrush="Black"/>
|
||||||
@@ -430,7 +451,10 @@
|
|||||||
<Button Click="Button_Click" Background="White" Grid.Row="15" Grid.Column="1" BorderBrush="Black"/>
|
<Button Click="Button_Click" Background="White" Grid.Row="15" Grid.Column="1" BorderBrush="Black"/>
|
||||||
<Button Click="Button_Click" Background="White" Grid.Row="16" Grid.Column="1" BorderBrush="Black"/>
|
<Button Click="Button_Click" Background="White" Grid.Row="16" Grid.Column="1" BorderBrush="Black"/>
|
||||||
<Button Click="Button_Click" Background="White" Grid.Row="17" Grid.Column="1" BorderBrush="Black"/>
|
<Button Click="Button_Click" Background="White" Grid.Row="17" Grid.Column="1" BorderBrush="Black"/>
|
||||||
|
<Button Click="Button_Click" Background="White" Grid.Row="18" Grid.Column="1" BorderBrush="Black"/>
|
||||||
|
<Button Click="Button_Click" Background="White" Grid.Row="19" Grid.Column="1" BorderBrush="Black"/>
|
||||||
|
<Button Click="Button_Click" Background="White" Grid.Row="20" Grid.Column="1" BorderBrush="Black"/>
|
||||||
|
|
||||||
<Button Click="Button_Click" Background="Red" Grid.Column="2" BorderBrush="Black"/>
|
<Button Click="Button_Click" Background="Red" Grid.Column="2" BorderBrush="Black"/>
|
||||||
<Button Click="Button_Click" Background="Red" Grid.Row="1" Grid.Column="2" BorderBrush="Black"/>
|
<Button Click="Button_Click" Background="Red" Grid.Row="1" Grid.Column="2" BorderBrush="Black"/>
|
||||||
<Button Click="Button_Click" Background="Red" Grid.Row="2" Grid.Column="2" BorderBrush="Black"/>
|
<Button Click="Button_Click" Background="Red" Grid.Row="2" Grid.Column="2" BorderBrush="Black"/>
|
||||||
@@ -602,10 +626,23 @@
|
|||||||
<RowDefinition/>
|
<RowDefinition/>
|
||||||
<RowDefinition/>
|
<RowDefinition/>
|
||||||
<RowDefinition/>
|
<RowDefinition/>
|
||||||
|
<RowDefinition/>
|
||||||
|
<RowDefinition/>
|
||||||
|
<RowDefinition/>
|
||||||
</Grid.RowDefinitions>
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition />
|
<ColumnDefinition/>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
<ColumnDefinition/>
|
||||||
|
<ColumnDefinition/>
|
||||||
<ColumnDefinition/>
|
<ColumnDefinition/>
|
||||||
<ColumnDefinition/>
|
<ColumnDefinition/>
|
||||||
<ColumnDefinition/>
|
<ColumnDefinition/>
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ namespace MathColoringGame
|
|||||||
|
|
||||||
int cellCounter;
|
int cellCounter;
|
||||||
int roundCounter;
|
int roundCounter;
|
||||||
|
int diceResult;
|
||||||
|
|
||||||
private MarkTyp[] mResults;
|
private MarkTyp[] mResults;
|
||||||
private bool mPlayer1Turn;
|
private bool mPlayer1Turn;
|
||||||
|
|
||||||
@@ -34,6 +35,7 @@ namespace MathColoringGame
|
|||||||
{
|
{
|
||||||
cellCounter = 0;
|
cellCounter = 0;
|
||||||
roundCounter = 1;
|
roundCounter = 1;
|
||||||
|
|
||||||
|
|
||||||
// Create a new blanck aray of free cells
|
// Create a new blanck aray of free cells
|
||||||
mResults = new MarkTyp[180];
|
mResults = new MarkTyp[180];
|
||||||
@@ -57,8 +59,8 @@ namespace MathColoringGame
|
|||||||
{
|
{
|
||||||
if (roundCounter >= 6)
|
if (roundCounter >= 6)
|
||||||
{
|
{
|
||||||
CheckWinner();
|
Round.Text = "5";
|
||||||
Round.Text = "5";
|
CheckWinner();
|
||||||
ClearAll();
|
ClearAll();
|
||||||
NewGame();
|
NewGame();
|
||||||
|
|
||||||
@@ -89,7 +91,7 @@ namespace MathColoringGame
|
|||||||
// reset all fields
|
// reset all fields
|
||||||
private void ClearAll()
|
private void ClearAll()
|
||||||
{
|
{
|
||||||
Round.Text = "1";
|
Round.Text = "1";
|
||||||
|
|
||||||
p1round1.Text = "0";
|
p1round1.Text = "0";
|
||||||
p1round2.Text = "0";
|
p1round2.Text = "0";
|
||||||
@@ -150,7 +152,8 @@ namespace MathColoringGame
|
|||||||
if (mPlayer1Turn && roundCounter == 1)
|
if (mPlayer1Turn && roundCounter == 1)
|
||||||
{
|
{
|
||||||
cellCounter++;
|
cellCounter++;
|
||||||
p1round1.Text = cellCounter.ToString();
|
p1round1.Text = cellCounter.ToString();
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!(mPlayer1Turn) && roundCounter == 1)
|
if (!(mPlayer1Turn) && roundCounter == 1)
|
||||||
{
|
{
|
||||||
@@ -236,7 +239,7 @@ namespace MathColoringGame
|
|||||||
|
|
||||||
// Instantiate random number generator.
|
// Instantiate random number generator.
|
||||||
private readonly Random dice = new Random();
|
private readonly Random dice = new Random();
|
||||||
|
|
||||||
// shuffle the dices
|
// shuffle the dices
|
||||||
private void BtnRollClick(object sender, RoutedEventArgs e)
|
private void BtnRollClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
@@ -245,6 +248,8 @@ namespace MathColoringGame
|
|||||||
string finalImage1 = "DiceSix.png";
|
string finalImage1 = "DiceSix.png";
|
||||||
string finalImage2 = "DiceOne.png";
|
string finalImage2 = "DiceOne.png";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Gernerate Numbers in Range
|
// Gernerate Numbers in Range
|
||||||
int number1 = dice.Next(1, 7);
|
int number1 = dice.Next(1, 7);
|
||||||
int number2 = dice.Next(1, 7);
|
int number2 = dice.Next(1, 7);
|
||||||
@@ -267,9 +272,9 @@ namespace MathColoringGame
|
|||||||
case 5:
|
case 5:
|
||||||
finalImage1 = "DiceFive.png";
|
finalImage1 = "DiceFive.png";
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
finalImage1 = "DiceSix.png";
|
finalImage1 = "DiceSix.png";
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
finalImage1 = "DiceSix.png";
|
finalImage1 = "DiceSix.png";
|
||||||
break;
|
break;
|
||||||
@@ -301,32 +306,45 @@ namespace MathColoringGame
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Dice2.ImageSource = new BitmapImage(new Uri("Images/" + finalImage2, UriKind.Relative));
|
Dice2.ImageSource = new BitmapImage(new Uri("Images/" + finalImage2, UriKind.Relative));
|
||||||
|
|
||||||
|
diceResult = number1 * number2;
|
||||||
|
testbox.Text = diceResult.ToString();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Handesl Cell click event
|
// Handesl Cell click event
|
||||||
private void Button_Click(object sender, RoutedEventArgs e)
|
private void Button_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
//cast the sender to Cell
|
|
||||||
var button = (Button)sender;
|
|
||||||
|
|
||||||
// bind the cells position in the array
|
if (diceResult > 0 && diceResult != cellCounter)
|
||||||
var column = Grid.GetColumn(button);
|
{
|
||||||
var row = Grid.GetRow(button);
|
//cast the sender to Cell
|
||||||
|
var button = (Button)sender;
|
||||||
|
|
||||||
var index = column + (row * 10);
|
|
||||||
|
|
||||||
// dont`t do anything if the cellalready has a value in it
|
// bind the cells position in the array
|
||||||
if (mResults[index] != MarkTyp.Free)
|
var column = Grid.GetColumn(button);
|
||||||
return;
|
var row = Grid.GetRow(button);
|
||||||
|
|
||||||
// set the cell value based on which players turn it is (Compact if else statement)
|
var index = column + (row * 10);
|
||||||
mResults[index] = mPlayer1Turn ? MarkTyp.Player1Red : MarkTyp.Player2Blue;
|
|
||||||
|
|
||||||
// set cell color to the result
|
// dont`t do anything if the cellalready has a value in it
|
||||||
button.Background = mPlayer1Turn ? Brushes.Red : Brushes.Blue;
|
if (mResults[index] != MarkTyp.Free)
|
||||||
|
return;
|
||||||
|
|
||||||
//count selectet cells per player
|
// set the cell value based on which players turn it is (Compact if else statement)
|
||||||
CountCells();
|
mResults[index] = mPlayer1Turn ? MarkTyp.Player1Red : MarkTyp.Player2Blue;
|
||||||
|
|
||||||
|
// set cell color to the result
|
||||||
|
button.Background = mPlayer1Turn ? Brushes.Red : Brushes.Blue;
|
||||||
|
//count selectet cells per player
|
||||||
|
CountCells();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handel count cells
|
// Handel count cells
|
||||||
@@ -334,6 +352,8 @@ namespace MathColoringGame
|
|||||||
{
|
{
|
||||||
BtnStartRoll.Visibility = Visibility.Visible;
|
BtnStartRoll.Visibility = Visibility.Visible;
|
||||||
|
|
||||||
|
diceResult = 0;
|
||||||
|
|
||||||
// check how many cells the Player marks
|
// check how many cells the Player marks
|
||||||
PlayerResult();
|
PlayerResult();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user