before first release

This commit is contained in:
Natlinux81
2022-02-28 23:11:01 +01:00
parent f7dae93596
commit 15ca9c9abe
2 changed files with 65 additions and 27 deletions

View File

@@ -67,7 +67,8 @@
Content="🗕" Click="BtnMinimizeClick"/> Content="🗕" Click="BtnMinimizeClick"/>
<Button Style="{StaticResource ModernButton}" <Button x:Name="BtnStartRoll"
Style="{StaticResource ModernButton}"
Grid.Column="1" Grid.Column="1"
Grid.Row="1" Grid.Row="1"
VerticalAlignment="Bottom" VerticalAlignment="Bottom"
@@ -92,22 +93,22 @@
<Border Grid.Row="1" <Border Grid.Row="1"
Grid.Column="1" Grid.Column="1"
Margin="0,30" Margin="15,40"
VerticalAlignment="Top" VerticalAlignment="Top"
HorizontalAlignment="Left" HorizontalAlignment="Left"
Width="100" Width="80"
Height="100"> Height="80">
<Border.Background> <Border.Background>
<ImageBrush x:Name="Dice1" ImageSource="/Images/DiceSix.png"/> <ImageBrush x:Name="Dice1" ImageSource="/Images/DiceSix.png"/>
</Border.Background> </Border.Background>
</Border> </Border>
<Border Margin="0,30" <Border Margin="0,40,15,0"
Grid.Row="1" Grid.Row="1"
Grid.Column="1" Grid.Column="1"
VerticalAlignment="Top" VerticalAlignment="Top"
HorizontalAlignment="Right" HorizontalAlignment="Right"
Width="100" Width="80"
Height="100"> Height="80">
<Border.Background> <Border.Background>
<ImageBrush x:Name="Dice2" ImageSource="/Images/DiceSix.png"/> <ImageBrush x:Name="Dice2" ImageSource="/Images/DiceSix.png"/>
</Border.Background> </Border.Background>
@@ -118,7 +119,7 @@
Grid.Column="1" Grid.Column="1"
Grid.Row="1"> Grid.Row="1">
<TextBlock <TextBlock
FontSize="16" FontSize="20"
FontWeight="Bold" FontWeight="Bold"
FontFamily="Comic Sans MS" FontFamily="Comic Sans MS"
Text="Round: "/> Text="Round: "/>
@@ -130,7 +131,7 @@
FontWeight="Bold" FontWeight="Bold"
Background="Transparent" Background="Transparent"
BorderThickness="0 " BorderThickness="0 "
FontSize="16" FontSize="20"
Height="30" Height="30"
FontFamily="Comic Sans MS"/> FontFamily="Comic Sans MS"/>
</WrapPanel> </WrapPanel>
@@ -256,7 +257,7 @@
<TextBlock <TextBlock
Margin="10,30,0,0" Margin="10,30,0,0"
FontSize="16" FontSize="16"
Text="Total Resul: " Text="Total Result: "
FontFamily="Comic Sans MS"/> FontFamily="Comic Sans MS"/>
<TextBox x:Name="p1TotalResult" <TextBox x:Name="p1TotalResult"
@@ -368,7 +369,7 @@
<TextBlock <TextBlock
Margin="10,30,0,0" Margin="10,30,0,0"
FontSize="16" FontSize="16"
Text="Total Resul: " Text="Total Result: "
FontFamily="Comic Sans MS"/> FontFamily="Comic Sans MS"/>
<TextBox x:Name="p2TotalResult" <TextBox x:Name="p2TotalResult"
@@ -392,7 +393,7 @@
Grid.Row="2" Grid.Row="2"
Grid.Column="0" Grid.Column="0"
Grid.ColumnSpan="3"> Grid.ColumnSpan="3">
<Button Click="Button_Click" BorderBrush="Black" Background="{x:Null}"/> <Button Click="Button_Click" BorderBrush="Black" Background="Red"/>
<Button Click="Button_Click" Background="Red" Grid.Row="1" BorderBrush="Black"/> <Button Click="Button_Click" Background="Red" Grid.Row="1" BorderBrush="Black"/>
<Button Click="Button_Click" Background="Red" Grid.Row="2" BorderBrush="Black"/> <Button Click="Button_Click" Background="Red" Grid.Row="2" BorderBrush="Black"/>
<Button Click="Button_Click" Background="Red" Grid.Row="3" BorderBrush="Black"/> <Button Click="Button_Click" Background="Red" Grid.Row="3" BorderBrush="Black"/>

View File

@@ -24,10 +24,9 @@ namespace MathColoringGame
int cellCounter; int cellCounter;
int roundCounter; int roundCounter;
private MarkTyp[] mResults; private MarkTyp[] mResults;
private bool mPlayer1Turn; private bool mPlayer1Turn;
//private bool mGameEnded;
//Starts a new game an clear all values back to the start //Starts a new game an clear all values back to the start
public void NewGame() public void NewGame()
@@ -50,10 +49,7 @@ namespace MathColoringGame
{ {
// Change background to default values // Change background to default values
button.Background = Brushes.White; button.Background = Brushes.White;
}); });
// make sure the game hasn´t finished
//mGameEnded = false;
} }
// Ends the game // Ends the game
@@ -61,16 +57,35 @@ namespace MathColoringGame
{ {
if (roundCounter >= 6) if (roundCounter >= 6)
{ {
Round.Text = "5"; CheckWinner();
MessageBox.Show("Ende"); Round.Text = "5";
//mGameEnded = true;
ClearAll(); ClearAll();
NewGame(); NewGame();
mPlayer1Turn ^= true; mPlayer1Turn ^= true;
} }
} }
public void CheckWinner()
{
int endResult1 = int.Parse(p1TotalResult.Text);
int endResult2 = int.Parse(p2TotalResult.Text);
if (endResult1 > endResult2)
{
MessageBox.Show("The Winner is Player 1!");
}
if(endResult1 < endResult2)
{
MessageBox.Show("The Winner is Player 2!");
}
if(endResult1 == endResult2)
{
MessageBox.Show("The Game ended in a draw!");
}
}
// reset all fields // reset all fields
private void ClearAll() private void ClearAll()
{ {
@@ -107,22 +122,40 @@ namespace MathColoringGame
// add Totalresulst by Player selectet cells // add Totalresulst by Player selectet cells
public void PlayerResult() public void PlayerResult()
{ {
// text to int
int p1result1 = int.Parse(p1round1.Text);
int p1result2 = int.Parse(p1round2.Text);
int p1result3 = int.Parse(p1round3.Text);
int p1result4 = int.Parse(p1round4.Text);
int p1result5 = int.Parse(p1round5.Text);
int p2result1 = int.Parse(p2round1.Text);
int p2result2 = int.Parse(p2round2.Text);
int p2result3 = int.Parse(p2round3.Text);
int p2result4 = int.Parse(p2round4.Text);
int p2result5 = int.Parse(p2round5.Text);
int totalResult1 = p1result1 + p1result2 + p1result3 + p1result4 + p1result5;
p1TotalResult.Text = Convert.ToString(totalResult1);
int totalResult2 = p2result1 + p2result2 + p2result3 + p2result4 + p2result5;
p2TotalResult.Text = Convert.ToString(totalResult2);
} }
// count cells by player click cell // count cells by player click cell
public void CountCells() public void CountCells()
{ {
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)
{ {
cellCounter++; cellCounter++;
p2round1.Text = cellCounter.ToString(); p2round1.Text = cellCounter.ToString();
} }
if (mPlayer1Turn && roundCounter == 2) if (mPlayer1Turn && roundCounter == 2)
@@ -207,6 +240,8 @@ namespace MathColoringGame
// shuffle the dices // shuffle the dices
private void BtnRollClick(object sender, RoutedEventArgs e) private void BtnRollClick(object sender, RoutedEventArgs e)
{ {
BtnStartRoll.Visibility = Visibility.Hidden;
string finalImage1 = "DiceSix.png"; string finalImage1 = "DiceSix.png";
string finalImage2 = "DiceOne.png"; string finalImage2 = "DiceOne.png";
@@ -297,6 +332,8 @@ namespace MathColoringGame
// Handel count cells // Handel count cells
private void BtnEndTurnClick(object sender, RoutedEventArgs e) private void BtnEndTurnClick(object sender, RoutedEventArgs e)
{ {
BtnStartRoll.Visibility = Visibility.Visible;
// check how many cells the Player marks // check how many cells the Player marks
PlayerResult(); PlayerResult();