コード例 #1
0
 public void Remove(BonusTypes name)
 {
     if (_bonus.ContainsKey(name.ToString()))
     {
         _bonus.Remove(name.ToString());
     }
 }
コード例 #2
0
ファイル: Bonuses.cs プロジェクト: vadian/Novus
 /// <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)));
     }
 }
コード例 #3
0
        public double GetBonus(BonusTypes type)
        {
            double bonus = 0.0d;

            if (_bonus.ContainsKey(type.ToString()))
            {
                bonus = _bonus[type.ToString()].Item1;
            }

            return(bonus);
        }
コード例 #4
0
 /// <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)));
     }
 }
コード例 #5
0
    //////////////////////////////////////////
    /// 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);
    }
コード例 #6
0
        private BonusMethod GetMethod(BonusTypes type)
        {
            string  typeString = GetType().Namespace + "." + type.ToString();
            dynamic product    = Activator.CreateInstance(Type.GetType(typeString));

            return(product as BonusMethod);
        }
コード例 #7
0
ファイル: Bonus.cs プロジェクト: Biang2016/Mech-Storm
    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);
    }
コード例 #8
0
ファイル: Bonuses.cs プロジェクト: vadian/Novus
        public double GetBonus(BonusTypes type)
        {
            double bonus = 0.0d;
            if (_bonus.ContainsKey(type.ToString())) {
                bonus = _bonus[type.ToString()].Item1;
            }

            return bonus;
        }
コード例 #9
0
ファイル: Bonuses.cs プロジェクト: vadian/Novus
 public void Remove(BonusTypes name)
 {
     if (_bonus.ContainsKey(name.ToString())) {
         _bonus.Remove(name.ToString());
     }
 }
コード例 #10
0
ファイル: BalanceReport.cs プロジェクト: novice-rb/civ-tools
 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;
 }