/// <summary>
/// ModifiedStat.cs
/// High Sword
/// July 27, 2012
///
/// This is the base class for all stats that will be modifiable by attributes
/// </summary>
using System.Collections.Generic; // Generic was added so we can use the List<>
public class ModifiedStat : BaseStat {
private List<ModifyingAttribute> _mods; // A list of Attributes that modify this stat
private int _modValue; // The amount added to the baseValue from the modifiers
/// <summary>
/// Initializes a new instance of the <see cref="ModifiedStat"/> class.
/// </summary>
public ModifiedStat () {
_mods = new List<ModifyingAttribute>();
_modValue = 0;
}
/// <summary>
/// add a ModifyingAttribute to our list of mods for this ModifiedStat
/// </summary>
/// <param name='mod'>
/// Mod.
/// </param>
public void AddModifier(ModifyingAttribute mod) {
_mods.Add (mod);
}
/// <summary>
/// Reset _modValue to zero.
/// Check to see if we have at least one ModifyingAttribute in our list of mods.
/// If we do, then iterate the list and add the AdjustedBaseValue * ratio to our _modValue.
/// </summary>
private void CalculateModValue () {
_modValue = 0;
if (_mods.Count > 0)
foreach (ModifyingAttribute att in _mods)
_modValue += (int)(att.attribute.AdjustedBaseValue * att.ratio);
}
// Override "AdjustedBaseValue" in BaseStat.cs
/// <summary>
/// This function is overriding the AdjustedBaseValue in the BaseStat class.
/// Calculate the AdjustedBaseValue from the BaseValue + BuffValue + _modValue
/// </summary>
/// <value>
/// The adjusted base value.
/// </value>
public new int AdjustedBaseValue {
get{return BaseValue + BuffValue + _modValue;}
}
/// <summary>
/// Update this instance.
/// </summary>
public void Update () {
CalculateModValue();
}
public string GetModifyingAttributeString () {
string temp = "";
// UnityEngine.Debug.Log(_mods.Count);
for (int cnt = 0; cnt < _mods.Count; cnt++) {
temp += _mods[cnt].attribute.Name;
temp += "_";
temp += _mods[cnt].ratio;
// Cut entry seperately
if (cnt < _mods.Count - 1)
temp += "|";
UnityEngine.Debug.Log(temp);
}
return temp;
}
}
/// <summary>
/// A structure that will hold an Attribute and ratio that will be added as a modifying attribute to our ModifiedStats
/// </summary>
public struct ModifyingAttribute {
public Attribute attribute; // the attribute to be used as a modifier
public float ratio; // the percent of attributes AdjustedBaseValue that will be applied to the modifiedStat
/// <summary>
/// Initializes a new instance of the <see cref="ModifyingAttribute"/> struct.
/// </summary>
/// <param name='att'>
/// Att. the attribute to be used
/// </param>
/// <param name='rat'>
/// Rat. the ratio to use
/// </param>
public ModifyingAttribute(Attribute att, float rat) {
attribute = att;
ratio = rat;
}
}
分享到:
相关推荐
包括AccessHelper.cs、DataAccess.cs、FormatStr.cs、MessageBox.cs、SaveViewState.cs、SqlHelper.cs
BarCodeToHTML.cs CacheHelper.cs Captcha.cs CNDate.cs ConvertJson.cs CsvHelper.cs EcanConvertToCh.cs Encrypt.cs ExcelHelper.cs FileDown.cs FileManager.cs FileUp.cs FTPClient.cs FTPHelper....
C#自动生成.cs文件
edu.umd.cs.findbugs.plugin.eclipse_1.3.9.20090821.rar
edu.stanford.cs106_2.0.1.201603271702.jar stanford公开课使用eclipse需要的插件
DataHelper.cs 完全 DataHelper.cs 完全 DataHelper.cs 完全 DataHelper.cs 完全 DataHelper.cs 完全 DataHelper.cs 完全
SqlHelper.cs 微软官方版本 ===========================================================================
.NET 中 JavaScript 帮助类
asp.net
mssqlhelper.cs和jshelper.cs的jshelper.cs
有很多sqlHelper.cs版本的文件,但是不全。其中会用到systemError.cs,现在在将两者的完整内容上传,以便共享!
mssqlhelper.cs和jshelper.cs 的mssqlhelper.cs
Properties.Resources.Designer.cs.dll
包含两个mssql数据库操作类文件DBOperate.csDBsql.cs
photoshop.cs5..cs5.5汉化包
作C#桌面程序时,有时我们会遇到很复杂的功能,如果所有功能的实现都写在一个.cs文件中,会让这个.cs文件显得很臃肿,而且不便于以后管理。本程序提供一种方法,可以将不同功能分写在不同的.cs文件文件中。即能将很...
xna VideoPlayer.cs xna VideoPlayer.cs xna VideoPlayer.cs
公共类文件,分别是DataOperate.cs、CommClass.cs、GlobalProperty.cs、MD5Encrypt.cs和ReadFile.cs。
PS.CS4汉化包+PS.CS4汉化+PS.CS4汉化+PS.CS4汉化+PS.CS4汉化+PS.CS4汉化
把DLL反编译为.cs类代码,方便使用,不用再愁用别人写的DLL不知道其内部结构了