Skip to content
Snippets Groups Projects
Commit 5d2984db authored by itpark.team's avatar itpark.team
Browse files

done clicker

parent d30c76fb
Branches master
No related merge requests found
......@@ -14,10 +14,10 @@
<TextBlock x:Name="textBlockScoreIncrement" HorizontalAlignment="Left" Margin="104,109,0,0" TextWrapping="Wrap" Text="Очков за клик: 1" VerticalAlignment="Top"/>
<Button x:Name="buttonBuyUpgrade" Content="Купить обновление" HorizontalAlignment="Left" Margin="108,155,0,0" VerticalAlignment="Top" Click="buttonBuyUpgrade_Click"/>
<TextBlock x:Name="textBlockTimerScoreIncrement" HorizontalAlignment="Left" Margin="111,229,0,0" TextWrapping="Wrap" Text="Очки за тик: 1" VerticalAlignment="Top"/>
<TextBlock x:Name="textBlockTimerScoreIncrement" HorizontalAlignment="Left" Margin="111,229,0,0" TextWrapping="Wrap" Text="Очки за тик: 0" VerticalAlignment="Top"/>
<TextBlock x:Name="textBlockTimerUpgradeCost" HorizontalAlignment="Left" Margin="110,249,0,0" TextWrapping="Wrap" Text="Стоимость обновления: 20" VerticalAlignment="Top"/>
<TextBlock HorizontalAlignment="Left" Margin="111,268,0,0" TextWrapping="Wrap" Text="Интервал таймера: 5 сек." VerticalAlignment="Top"/>
<Button x:Name="buttonBuyTimerUpgrade" Content="Купить обновление таймера" HorizontalAlignment="Left" Margin="115,294,0,0" VerticalAlignment="Top"/>
<Button x:Name="buttonBuyTimerUpgrade" Content="Купить обновление таймера" HorizontalAlignment="Left" Margin="115,294,0,0" VerticalAlignment="Top" Click="buttonBuyTimerUpgrade_Click"/>
</Grid>
</Window>
......@@ -38,7 +38,7 @@ namespace WpfAppFirstProj
clickScoreIncrement = 1;
clickUpgradeCost = 2;
timerScoreIncrement = 1;
timerScoreIncrement = 0;
timerUpgradeCost = 20;
timer = new DispatcherTimer();
......@@ -75,5 +75,28 @@ namespace WpfAppFirstProj
textBlockScore.Text = score.ToString();
}
private void buttonBuyTimerUpgrade_Click(object sender, RoutedEventArgs e)
{
if (score < timerUpgradeCost)
{
MessageBox.Show("У вас недостаточно очков для покупки");
return;
}
if (timer.IsEnabled == false)
{
timer.Start();
}
timerScoreIncrement++;
score -= timerUpgradeCost;
timerUpgradeCost *= 2;
textBlockTimerScoreIncrement.Text = $"Очки за тик: {timerScoreIncrement}";
textBlockTimerUpgradeCost.Text = $"Стоимость обновления: {timerUpgradeCost}";
textBlockScore.Text = score.ToString();
}
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment