/// <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;
}
}
分享到:
相关推荐
在ASP.NET WebForm开发中,`.designer.cs`文件是一个非常关键的部分,它与`.aspx`页面对应,用于存储自动生成的控件声明和事件处理程序。当你删除了`.designer.cs`文件,需要手动恢复这个文件并重新设计及绑定服务端...
在C#编程中,自动生成.cs文件是一种常见的需求,它可以帮助开发者提高效率,减少重复劳动,尤其是在处理大量相似代码或需要遵循特定模板时。本文将深入探讨如何在C#环境中自动生成.cs文件,并涵盖相关技术点。 首先...
在`MsSqlHelper.cs`文件中,这些方法通常会包含以下步骤: - 连接字符串的获取:通过配置文件或者硬编码来获取数据库连接字符串。 - SqlConnection对象的创建:使用连接字符串初始化数据库连接。 - SqlCommand对象的...
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....
SqlHelper.cs 微软官方版本 ===========================================================================
IniConfig.cs(C# INI文件读写,自动生成配置文件,实际内容根据项目自定义)
海康威视下载视频方法需要的CHCNetSDK_X64.cs配置文件,海康威视下载图片方法需要的CHCNetSDK_X64.cs配置文件。
edu.stanford.cs106_2.0.1.201603271702.jar stanford公开课使用eclipse需要的插件
.NET 中 JavaScript 帮助类
最新的雷赛运动控制卡SDK,LTDMC.cs带中文注释
DataHelper.cs 完全 DataHelper.cs 完全 DataHelper.cs 完全 DataHelper.cs 完全 DataHelper.cs 完全 DataHelper.cs 完全
作C#桌面程序时,有时我们会遇到很复杂的功能,如果所有功能的实现都写在一个.cs文件中,会让这个.cs文件显得很臃肿,而且不便于以后管理。本程序提供一种方法,可以将不同功能分写在不同的.cs文件文件中。即能将很...
mssqlhelper.cs和jshelper.cs的jshelper.cs
mssqlhelper.cs和jshelper.cs 的mssqlhelper.cs
C#数据库连接类库DbHelp.cs DbHelp.cs是一个C#数据库连接类库,用于实现数据库的连接、插入、更新和删除操作。该类库提供了多个方法来执行SQL语句,包括插入、更新和删除操作。下面是DbHelp.cs类库的详细知识点: ...
《IK Multimedia T-RackS CS Complete v4.10 - 音频处理的恐龙级工具》 IK Multimedia的T-RackS CS Complete v4.10是一款备受推崇的专业级音频处理软件,被誉为“恐龙级”的音频插件。这款强大的工具集涵盖了混音、...
C#通过s7通讯,读写plc内部寄存器数值,可做上位机通讯
Properties.Resources.Designer.cs.dll
xna VideoPlayer.cs xna VideoPlayer.cs xna VideoPlayer.cs
http://www.cs.waikato.ac.nz/ml/weka/ weka主页