`
duoerbasilu
  • 浏览: 1485577 次
文章分类
社区版块
存档分类
最新评论

BaseStat.cs

 
阅读更多
/// <summary>
/// BaseStat.cs
/// High Sword
/// July 27, 2012
/// 
/// This is the base class for a stats in game
/// </summary>
public class BaseStat {
	public const int STARTING_EXP_COST = 100;	// publicly accessable value for all base stats to start at 
	
	private int _baseValue;						// the base value of this stat(base ability for character)
	private int _buffValue;						// range of adjust base value
	private int _expToLevel;					// the total amount of experience needed to raise this skill
	private float _levelModifier;				// the modifier applied to the experience to raise the skill
	
	
	/// <summary>
	/// Initializes a new instance of the <see cref="BaseStat"/> class.
	/// </summary>
	public BaseStat () {
		_baseValue = 0;
		_buffValue = 0;
		_levelModifier = 1.1f;
		_expToLevel = STARTING_EXP_COST;
	}

#region Basic Setters and Getters
	/// <summary>
	/// Gets or sets the _baseValue.
	/// </summary>
	/// <value>
	/// The _baseValue.
	/// </value>
	public int BaseValue {
		get{ return _baseValue; }
		set{ _baseValue = value; }
	}
	
	/// <summary>
	/// Gets or sets the _buffValue.
	/// </summary>
	/// <value>
	/// The _buffValue.
	/// </value>
	public int BuffValue {
		get{ return _buffValue; }
		set{ _buffValue = value; }
	}
	
	/// <summary>
	/// Gets or sets the _expToLevel.
	/// </summary>
	/// <value>
	/// The _expToLevel.
	/// </value>
	public int ExpToLevel {
		get{ return _expToLevel; }
		set{ _expToLevel = value; }
	}

	/// <summary>
	/// Gets or sets the _levelModifier.
	/// </summary>
	/// <value>
	/// The _levelModifier.
	/// </value>
	public float LevelModifier {
		get{ return _levelModifier; }
		set{ _levelModifier = value; }
	}
#endregion

	// Calculate experience needed for the next level
	/// <summary>
	/// Calculates the exp to level.
	/// </summary>
	/// <returns>
	/// The exp to level.
	/// </returns>
	private int CalculateExpToLevel () {
		return (int)(_expToLevel * _levelModifier);
	}
	
	/// <summary>
	/// Assign the new value to _expToLevel and then increase the _baseValue by one
	/// </summary>
	public void LevelUp () {
		_expToLevel = CalculateExpToLevel();
		_baseValue++;
	}
	
	/// <summary>
	/// Recalculate the adjuste base value and return it
	/// </summary>
	/// <value>
	/// The adjusted base value.
	/// </value>
	public int AdjustedBaseValue {
		get{return _baseValue + _buffValue;}
	}
}

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics