We combined multiple gradients and effects to create an attractive 2D gauge. Now, we are going to make the necessary changes to calculate and show a score while running the 3D game:
1. Open the project
3DInvadersSilverlight
in Visual Studio or Visual C#.2. Expand
ScoreGauge.xaml
in the Solution Explorer and openScoreGauge.xaml.cs
—the C# code forScoreGauge.xaml
. We need to add a method.3. Add the following lines of code in the
public partial class ScoreGauge : UserControl
, to change the score shown in the gauge:public void SetScore(int newScore) { tbkScore.Text = newScore.ToString(); }
4. Now, expand
MainPage.xaml
in the Solution Explorer and openMainPage.xaml.cs
—the C# code forMainPage.xaml
.5. Add the following
private
variable in thepublic partial class MainPage : UserControl
, to hold aScoreGauge
instance:private ScoreGauge _scoreGauge;
6. Add the following
public
method to update the score shown in theScoreGauge
instance:public void SetScore...