public void Remove(BonusTypes name) { if (_bonus.ContainsKey(name.ToString())) { _bonus.Remove(name.ToString()); } }
/// <summary> /// Adds an amount (positive or negative) to the type specified. Passing in zero or null for the time will make this bonus never expire. /// </summary> /// <param name="name"></param> /// <param name="amount"></param> /// <param name="time"></param> public void Add(BonusTypes name, double amount, int time = 0) { if (_bonus.ContainsKey(name.ToString())) { _bonus[name.ToString()] = new Tuple<double, DateTime>(_bonus[name.ToString()].Item1 + amount, time == 0 ? DateTime.MaxValue : _bonus[name.ToString()].Item2.AddSeconds(time)); } else { _bonus.Add(name.ToString(), new Tuple<double, DateTime>(amount, time == 0 ? DateTime.MaxValue : DateTime.Now.AddSeconds(time))); } }
public double GetBonus(BonusTypes type) { double bonus = 0.0d; if (_bonus.ContainsKey(type.ToString())) { bonus = _bonus[type.ToString()].Item1; } return(bonus); }
/// <summary> /// Adds an amount (positive or negative) to the type specified. Passing in zero or null for the time will make this bonus never expire. /// </summary> /// <param name="name"></param> /// <param name="amount"></param> /// <param name="time"></param> public void Add(BonusTypes name, double amount, int time = 0) { if (_bonus.ContainsKey(name.ToString())) { _bonus[name.ToString()] = new Tuple <double, DateTime>(_bonus[name.ToString()].Item1 + amount, time == 0 ? DateTime.MaxValue : _bonus[name.ToString()].Item2.AddSeconds(time)); } else { _bonus.Add(name.ToString(), new Tuple <double, DateTime>(amount, time == 0 ? DateTime.MaxValue : DateTime.Now.AddSeconds(time))); } }
////////////////////////////////////////// /// GetBonusAmount() /// Returns the bonus amount, depending /// on all its criteria. May return 0. ////////////////////////////////////////// public int GetBonusAmount(CharacterModel i_modelSelf, CharacterModel i_modelTarget) { // start out pessimistic int nBonus = 0; // decide which character we will be looking at for the bonus based on the bonus' target CharacterModel model = Target == CombatTargets.Self ? i_modelSelf : i_modelTarget; // do a different kind of check depending on the bonus type if (BonusType == BonusTypes.ForEvery) { // this type of bonus awards its Bonus Amount for every CheckAmount for the given Stat int nCheckValue = model.GetTotalModification(Stat); if (nCheckValue > 0) { int nApplications = nCheckValue / nCheckValue; nBonus = BonusAmount * nApplications; } } else { Debug.LogError("Unhandled bonus type: " + BonusType.ToString()); } return(nBonus); }
private BonusMethod GetMethod(BonusTypes type) { string typeString = GetType().Namespace + "." + type.ToString(); dynamic product = Activator.CreateInstance(Type.GetType(typeString)); return(product as BonusMethod); }
public void ExportToXML(XmlElement parent_ele) { XmlDocument doc = parent_ele.OwnerDocument; XmlElement bonus_ele = doc.CreateElement("BonusInfo"); parent_ele.AppendChild(bonus_ele); bonus_ele.SetAttribute("bonusType", BonusType.ToString()); ChildrenExportToXML(bonus_ele); }
public double GetBonus(BonusTypes type) { double bonus = 0.0d; if (_bonus.ContainsKey(type.ToString())) { bonus = _bonus[type.ToString()].Item1; } return bonus; }
public void CountBonus(BonusTypes bonus, Dictionary<string, int> counterSet) { string bonusName = bonus.ToString(); if (counterSet.ContainsKey(bonusName)) counterSet[bonusName] = counterSet[bonusName] + 1; else counterSet[bonusName] = 1; }