public abstract class Attribute {
private int min;
private int current;
private int max;
public delegate void ChangeAction (int amount);
public event ChangeAction OnMinChange;
public event ChangeAction OnCurrentChange;
public event ChangeAction OnMaxChange;
public Attribute () {
this.min = 0;
this.current = 0;
this.max = 0;
}
public int Min {
get {
return this.min;
}
set {
this.min = Math.Min(value, this.max);
this.current = Math.Max(value, this.current);
if (this.OnMinChange != null) {
this.OnMinChange(value);
}
}
}
public int Current {
get {
return this.current;
}
set {
this.current = Math.Min(value, this.max);
this.current = Math.Max(value, this.min);
if (this.OnCurrentChange != null) {
this.OnCurrentChange(value);
}
}
}
public int Max {
get {
return this.max;
}
set {
this.max = Math.Max(value, this.min);
this.current = Math.Min(value, this.current);
if (this.OnMaxChange != null) {
this.OnMaxChange(value);
}
}
}
}