Make a property, which allows logic inside of it. That would be a good place to add this kind of functionality:
private static int kills = 0;
public static int Kills
{
get
{
return kills;
}
set
{
this.kills = value;
this.OnVarChange();
}
}
A better option would be to implement INotifyPropertyChanged, which is an interface that UI and other parts of the framework can pick up and act on.
public class X : INotifyPropertyChanged
{
private int kills = 0;
public int Kills
{
get
{
return kills;
}
set
{
this.kills = value;
this.OnPropertyChanged();
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged([System.Runtime.CompilerServices.CallerMemberName] string propertyName = "")
{
PropertyChangedEventHandler pc = this.PropertyChanged;
if (pc != null)
{
pc(this, new PropertyChangedEventArgs(propertyName));
}
}
}