fix some buggs

This commit is contained in:
Natlinux81
2022-03-08 00:15:09 +01:00
parent 5b465179f8
commit 0ff0576609
3 changed files with 101 additions and 43 deletions

View File

@@ -13,5 +13,6 @@ namespace MathColoringGame
/// </summary>
public partial class App : Application
{
}
}

View File

@@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MathColoringGame"
mc:Ignorable="d"
Title="MainWindow" Height="780" Width="650"
Title="MainWindow" Height="780" Width="900"
WindowStyle="None"
Background="Transparent"
AllowsTransparency="True"
@@ -24,7 +24,7 @@
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition Width="230"/>
<ColumnDefinition Width="460"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
@@ -168,7 +168,7 @@
<TextBlock
Margin="10,30,0,0"
FontSize="16"
Text="Resuld Round 1: "
Text="Result Round 1: "
FontFamily="Comic Sans MS"/>
<TextBox x:Name="p1round1" Text="0"
@@ -185,7 +185,7 @@
<TextBlock
Margin="10,30,0,0"
FontSize="16"
Text="Resuld Round 2: "
Text="Result Round 2: "
FontFamily="Comic Sans MS"/>
<TextBox x:Name="p1round2"
@@ -203,7 +203,7 @@
<TextBlock
Margin="10,30,0,0"
FontSize="16"
Text="Resuld Round 3: "
Text="Result Round 3: "
FontFamily="Comic Sans MS"/>
<TextBox x:Name="p1round3"
@@ -221,7 +221,7 @@
<TextBlock
Margin="10,30,0,0"
FontSize="16"
Text="Resuld Round 4: "
Text="Result Round 4: "
FontFamily="Comic Sans MS"/>
<TextBox x:Name="p1round4"
@@ -239,7 +239,7 @@
<TextBlock
Margin="10,30,0,0"
FontSize="16"
Text="Resuld Round 5: "
Text="Result Round 5: "
FontFamily="Comic Sans MS"/>
<TextBox x:Name="p1round5"
@@ -279,7 +279,7 @@
<TextBlock
Margin="10,30,0,0"
FontSize="16"
Text="Resuld Round 1: "
Text="Result Round 1: "
FontFamily="Comic Sans MS"/>
<TextBox x:Name="p2round1"
@@ -297,7 +297,7 @@
<TextBlock
Margin="10,30,0,0"
FontSize="16"
Text="Resuld Round 2: "
Text="Result Round 2: "
FontFamily="Comic Sans MS"/>
<TextBox x:Name="p2round2"
@@ -315,7 +315,7 @@
<TextBlock
Margin="10,30,0,0"
FontSize="16"
Text="Resuld Round 3: "
Text="Result Round 3: "
FontFamily="Comic Sans MS"/>
<TextBox x:Name="p2round3"
@@ -333,7 +333,7 @@
<TextBlock
Margin="10,30,0,0"
FontSize="16"
Text="Resuld Round 4: "
Text="Result Round 4: "
FontFamily="Comic Sans MS"/>
<TextBox x:Name="p2round4"
@@ -351,7 +351,7 @@
<TextBlock
Margin="10,30,0,0"
FontSize="16"
Text="Resuld Round 5: "
Text="Result Round 5: "
FontFamily="Comic Sans MS"/>
<TextBox x:Name="p2round5"
@@ -381,12 +381,30 @@
FontSize="16"
Height="30"
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>
<Grid x:Name="Container"
Width="250"
Width="450"
Height="450"
VerticalAlignment="Top"
Margin="28"
@@ -411,6 +429,9 @@
<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="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.Row="1" Grid.Column="1" BorderBrush="Black"/>
@@ -430,6 +451,9 @@
<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="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.Row="1" Grid.Column="2" BorderBrush="Black"/>
@@ -602,10 +626,23 @@
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>

View File

@@ -24,6 +24,7 @@ namespace MathColoringGame
int cellCounter;
int roundCounter;
int diceResult;
private MarkTyp[] mResults;
private bool mPlayer1Turn;
@@ -35,6 +36,7 @@ namespace MathColoringGame
cellCounter = 0;
roundCounter = 1;
// Create a new blanck aray of free cells
mResults = new MarkTyp[180];
@@ -57,8 +59,8 @@ namespace MathColoringGame
{
if (roundCounter >= 6)
{
CheckWinner();
Round.Text = "5";
CheckWinner();
ClearAll();
NewGame();
@@ -151,6 +153,7 @@ namespace MathColoringGame
{
cellCounter++;
p1round1.Text = cellCounter.ToString();
}
if (!(mPlayer1Turn) && roundCounter == 1)
{
@@ -245,6 +248,8 @@ namespace MathColoringGame
string finalImage1 = "DiceSix.png";
string finalImage2 = "DiceOne.png";
// Gernerate Numbers in Range
int number1 = dice.Next(1, 7);
int number2 = dice.Next(1, 7);
@@ -301,14 +306,25 @@ namespace MathColoringGame
break;
}
Dice2.ImageSource = new BitmapImage(new Uri("Images/" + finalImage2, UriKind.Relative));
diceResult = number1 * number2;
testbox.Text = diceResult.ToString();
}
// Handesl Cell click event
private void Button_Click(object sender, RoutedEventArgs e)
{
if (diceResult > 0 && diceResult != cellCounter)
{
//cast the sender to Cell
var button = (Button)sender;
// bind the cells position in the array
var column = Grid.GetColumn(button);
var row = Grid.GetRow(button);
@@ -324,16 +340,20 @@ namespace MathColoringGame
// set cell color to the result
button.Background = mPlayer1Turn ? Brushes.Red : Brushes.Blue;
//count selectet cells per player
CountCells();
}
}
// Handel count cells
private void BtnEndTurnClick(object sender, RoutedEventArgs e)
{
BtnStartRoll.Visibility = Visibility.Visible;
diceResult = 0;
// check how many cells the Player marks
PlayerResult();