public float CalcFormula(string formula) { if (!CheckFormula(formula)) { return(0.00f); } if (!m_formulaParser.ContainsKey(formula)) { FormulaParserManager.Instance.RegistFormula(formula); } FormulaParser formulaParser = m_formulaParser[formula]; return(formulaParser.Value()); }
/// <summary> /// 根据手动传值来计算公式 /// </summary> /// <param name="dic"></param> /// <param name="formula"></param> /// <returns></returns> public float CalcFormula(Dictionary <string, float> dic, string formula) { if (!CheckFormula(formula) || dic == null) { return(0.00f); } if (!m_formulaParser.ContainsKey(formula)) { FormulaParserManager.Instance.RegistFormula(formula); } FormulaParser formulaParser = m_formulaParser[formula]; formulaParser.SetParameter(dic); return(formulaParser.Value()); }
// 计算公式值 public float CalcFormula(IObject obj, string formula) { if (!CheckFormula(formula) || obj == null) { return(0.00f); } if (!m_formulaParser.ContainsKey(formula)) { FormulaParserManager.Instance.RegistFormula(formula); //return 0.00f; } FormulaParser formulaParser = m_formulaParser[formula]; formulaParser.SetSelfObj(obj); return(formulaParser.Value()); }
// 计算战斗相关公式 public float CalcSkillFormula(IObject self, IObject selfSkill, IObject target, IObject targetSkill, string formula) { if (!CheckFormula(formula) || self == null || selfSkill == null) { return(0.00f); } if (!m_formulaParser.ContainsKey(formula)) { FormulaParserManager.Instance.RegistFormula(formula); } FormulaParser formulaParser = m_formulaParser[formula]; formulaParser.SetSelfObj(self); formulaParser.SetSelfSkill(selfSkill); formulaParser.SetTargetObj(target); formulaParser.SetTargetSkill(targetSkill); return(formulaParser.Value()); }