public void Init(CommanderData data, List <TestMonster> listMonsters) { //가져온 데이터를 참조합니다 this.data = data; this.calculatedDamage = FormulaCalculator.GetInstance().AllCalculatedDamage_Commander(data.id); this.calculatedAspd = FormulaCalculator.GetInstance().AllCalculatedAspd_Commander(data.id); if (this.animator == null) { this.animator = this.gameObject.GetComponentInChildren <Animator>(); } //effectEvents를 초기화합니다 this.effectEvents = this.GetComponentInChildren <EffectEvents>(); //Debug.Log("============================"); //Debug.Log(effectEvents); //boxCollider를 붙입니다(Hero Merge를 위함) this.boxCollider = this.gameObject.AddComponent <BoxCollider>(); this.boxCollider.size = new Vector3(1, 3, 1); this.boxCollider.center = new Vector3(0, 1.2f, 0); this.boxCollider.isTrigger = true; //몬스터 리스트 참조를 가져옵니다 this.listMonsters = listMonsters; this.ChangeBehavior(eCommanderState.SEARCH); }
IEnumerator FollowImpl() { SetNavAgentEnable(false); switch ((eMonsterType)data.attackType) { case (eMonsterType.RunTwoAttack): { this.animator.Play("Monster_Run"); } break; case (eMonsterType.WalkOneAttack): { this.animator.Play("Monster_Walk"); } break; case (eMonsterType.CrawlBiting): { this.animator.Play("Monster_Crawl"); } break; } while (true) { yield return(null); var moveSpeed = FormulaCalculator.GetInstance().CalculateDecreasedMoveSpeed(data.moveSpeed, decreasedPercentage); this.gameObject.transform.position += Vector3.back * moveSpeed * Time.deltaTime; this.gameObject.transform.rotation = Quaternion.Euler(0, 180, 0); } }
public static FormulaCalculator GetInstance() { if (FormulaCalculator.Instance == null) { FormulaCalculator.Instance = new FormulaCalculator(); } return(FormulaCalculator.Instance); }
private void SetNavAgentDatas() { this.agent.destination = navDestination; var moveSpeed = FormulaCalculator.GetInstance().CalculateDecreasedMoveSpeed(data.moveSpeed, decreasedPercentage); this.agent.speed = moveSpeed; this.agent.stoppingDistance = 2f; }
public void SetInfoFromLv() { foreach (var kv in dicCommanderinfo) { var data = dicCommanderData[kv.Value.commander_id]; kv.Value.damageTotal = FormulaCalculator.GetInstance().CalculateDamage(data.damage, kv.Value.damageLv); kv.Value.atkSpeedTotal = FormulaCalculator.GetInstance().CalculateAspd(data.atkSpeed, kv.Value.atkSpeedLV); } }
private FormulaCalculator getFormulaCalculator(ExpressionCalculator calculator, string expression) { //分割出标表达式和参数 Regex reg = new Regex(@"\{\$([A-Za-z0-9][A-Za-z0-9_]+)\((.*)\)\}", RegexOptions.None); var match = reg.Match(expression); if (match == null || !match.Success || match.Groups.Count != 3) { var fragment = new TextFragment() { Code = TextCodes.ExpressionFormatError, DefaultFormatting = "在名称为{0}的表达式计算器中,表达式格式不正确,表达式为{1}", ReplaceParameters = new List <object>() { calculator.Name, expression } }; throw new UtilityException((int)Errors.ExpressionFormatError, fragment); } //获取表达式名 var strName = match.Groups[1].Value; //获取参数集 var strParameters = match.Groups[2].Value; //分割多个参数 Regex regex = new Regex(@"(?<!\\),"); var arrayParamaters = regex.Split(strParameters); FormulaCalculator formula = new FormulaCalculator() { Name = strName }; foreach (var item in arrayParamaters) { formula.ParameterExpressions.Add(item); } return(formula); }
IEnumerator IdleImpl() { targetedMonster = null; //Debug.Log("IdleImpl"); while (true) { this.animator.Play($"{data.anim_name}_Idle"); //Debug.Log("아이들링"); var idleTime = FormulaCalculator.GetInstance().CalculateIdleTime(this.calculatedAspd, this.bySelfDecreaedDelay, this.byOtherDecreasedDelay); Debug.Log($"idleTime: {idleTime}"); yield return(new WaitForSeconds(idleTime)); OnIdleComplete(); break; } }
protected void Grid1_RowDataBound(object sender, GridRowEventArgs e) { DataRowView item = e.DataItem as DataRowView; if (e.RowIndex != (Grid1.DataSource as DataTable).Rows.Count - 1) { string Fcode = item["FCode"].ToString(); LHTubePrice price = CustomerpriceService.Where(p => p.FCode == txtFCode.Text && p.FBill == "销售").FirstOrDefault(); decimal payW = string.IsNullOrWhiteSpace(item["FPayTemperature"].ToString()) ? 0 : Convert.ToDecimal(item["FPayTemperature"].ToString()); decimal payY = string.IsNullOrWhiteSpace(item["FPayPressure"].ToString()) ? 0 : Convert.ToDecimal(item["FPayPressure"].ToString()); decimal recW = string.IsNullOrWhiteSpace(item["FReceiveTemperature"].ToString()) ? 0 : Convert.ToDecimal(item["FReceiveTemperature"].ToString()); decimal recY = string.IsNullOrWhiteSpace(item["FReceivePressure"].ToString()) ? 0 : Convert.ToDecimal(item["FReceivePressure"].ToString()); double dpayW = string.IsNullOrWhiteSpace(item["FPayTemperature"].ToString()) ? 0 : Convert.ToDouble(item["FPayTemperature"].ToString()); double dpayY = string.IsNullOrWhiteSpace(item["FPayPressure"].ToString()) ? 0 : Convert.ToDouble(item["FPayPressure"].ToString()); double drecW = string.IsNullOrWhiteSpace(item["FReceiveTemperature"].ToString()) ? 0 : Convert.ToDouble(item["FReceiveTemperature"].ToString()); double drecY = string.IsNullOrWhiteSpace(item["FReceivePressure"].ToString()) ? 0 : Convert.ToDouble(item["FReceivePressure"].ToString()); decimal v = Convert.ToDecimal(item["waterspace"].ToString()); string fmeno = item["FMemo"].ToString(); Regex reg = new Regex("[*][0-9]{0,2}[支]"); if (reg.IsMatch(fmeno)) { fmeno = fmeno.Replace(reg.Match(fmeno).Value, ""); } if (!string.IsNullOrWhiteSpace(fmeno)) { e.Values[2] = fmeno; } //压缩因子 string FZ1 = "0"; string FZ2 = "0"; //取压缩因子系数 //客户专用压缩因子 LHFactor startFZ = FactorService.Where(p => p.FCompanyCode == txtFCode.Text && p.FTemperature == payW && p.FBar == payY).FirstOrDefault(); LHFactor EndFZ = FactorService.Where(p => p.FCompanyCode == txtFCode.Text && p.FTemperature == recW && p.FBar == recY).FirstOrDefault(); //通用压缩因子 LHFactor TSFZ = FactorService.Where(p => p.FCompanyCode == "" && p.FTemperature == payW && p.FBar == payY).FirstOrDefault(); LHFactor TEFZ = FactorService.Where(p => p.FCompanyCode == "" && p.FTemperature == recW && p.FBar == recY).FirstOrDefault(); //通用赋值 if (TSFZ != null) { FZ1 = TSFZ.FDivisor.ToString(CultureInfo.InvariantCulture); } if (TEFZ != null) { FZ2 = TEFZ.FDivisor.ToString(CultureInfo.InvariantCulture); } //专用赋值 if (startFZ != null) { FZ1 = startFZ.FDivisor.ToString(CultureInfo.InvariantCulture); } if (startFZ != null) { FZ2 = EndFZ.FDivisor.ToString(CultureInfo.InvariantCulture); } //取客户对应排管车罐号、水溶积 LHWaterSpace waterSpace = WatorSpaceService.Where(p => p.FCompanyCode == txtFCode.Text && p.FGCode == fmeno).FirstOrDefault(); if (waterSpace != null) { e.Values[2] = waterSpace.FChassisNo; e.Values[3] = waterSpace.FGCode; e.Values[3] = waterSpace.FGCode; v = waterSpace.FM3; } string[] c1 = price.FFormula.Replace("\n", "").Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); string s1 = c1[0].Replace("\n", ""); decimal qt; int i = 1; List <object> clist = new List <object>(); while (i < c1.Length) { string cq = ""; //替换后公式 string[] sp = c1[i].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); //提取表达式及保留小数位数 string[] sp1; if (i + 1 < c1.Length) { sp1 = c1[i + 1].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); //提取表达式及保留小数位数 cq = sp1[0].Replace("$W3", payW.ToString(CultureInfo.InvariantCulture)) // .Replace("$W4", recW.ToString(CultureInfo.InvariantCulture)) // .Replace("$Y3", payY.ToString(CultureInfo.InvariantCulture)) // .Replace("$Y4", recY.ToString(CultureInfo.InvariantCulture)) // .Replace("$Y4", recY.ToString(CultureInfo.InvariantCulture)) // .Replace("$YZ1", FZ1) // .Replace("$YZ2", FZ2) // .Replace("$V", v.ToString(CultureInfo.InvariantCulture)) .Replace("\n", ""); qt = Convert.ToDecimal(FormulaCalculator.Eval(cq)); if (sp1[1].ToString() != "0") { qt = Math.Round(qt, int.Parse(sp1[1])); } sp[0] = string.Format(sp[0], qt); //计算替换公式 qt = Convert.ToDecimal(FormulaCalculator.Eval(sp[0])); if (sp[1].ToString() != "0") { qt = Math.Round(qt, int.Parse(sp[1])); } clist.Add(qt.ToString()); i = i + 2; } else { sp = c1[i + 1].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); //提取表达式及保留小数位数 cq = sp[0].Replace("$W3", payW.ToString(CultureInfo.InvariantCulture)) // .Replace("$W4", recW.ToString(CultureInfo.InvariantCulture)) // .Replace("$Y3", payY.ToString(CultureInfo.InvariantCulture)) // .Replace("$Y4", recY.ToString(CultureInfo.InvariantCulture)) // .Replace("$Y4", recY.ToString(CultureInfo.InvariantCulture)) // .Replace("$YZ1", FZ1) // .Replace("$YZ2", FZ2) // .Replace("$V", v.ToString(CultureInfo.InvariantCulture)) .Replace("\n", ""); qt = Convert.ToDecimal(FormulaCalculator.Eval(cq)); if (sp[1].ToString() != "0") { qt = Math.Round(qt, int.Parse(sp[1])); } sp[0] = string.Format(sp[0], qt); clist.Add(qt.ToString()); } } // string [] sp= c1[i].Split(new char[]{','},StringSplitOptions.RemoveEmptyEntries); // string cp= sp[0].Replace("$W3", payW.ToString(CultureInfo.InvariantCulture))// // .Replace("$W4", recW.ToString(CultureInfo.InvariantCulture))// // .Replace("$Y3", payY.ToString(CultureInfo.InvariantCulture))// // .Replace("$Y4", recY.ToString(CultureInfo.InvariantCulture))// // .Replace("$Y4", recY.ToString(CultureInfo.InvariantCulture))// // .Replace("$YZ1", FZ1)// // .Replace("$YZ2", FZ2)// // .Replace("$V", v.ToString(CultureInfo.InvariantCulture)); // decimal qt = Convert.ToDecimal(FormulaCalculator.Eval(cp)); // if (sp[1].ToString()!="0") // { // qt = Math.Round(qt, int.Parse(sp[1])); // } // s1 = string.Format(s1,qt); //} //计算容积 最终结果 c1[0] = string.Format(c1[0], clist.ToArray()); string cp = c1[0].Replace("$W3", payW.ToString(CultureInfo.InvariantCulture)) // .Replace("$W4", recW.ToString(CultureInfo.InvariantCulture)) // .Replace("$Y3", payY.ToString(CultureInfo.InvariantCulture)) // .Replace("$Y4", recY.ToString(CultureInfo.InvariantCulture)) // .Replace("$Y4", recY.ToString(CultureInfo.InvariantCulture)) // .Replace("$YZ1", FZ1) // .Replace("$YZ2", FZ2) // .Replace("$V", v.ToString(CultureInfo.InvariantCulture)); decimal qty = Convert.ToDecimal(FormulaCalculator.Eval(cp)); e.Values[9] = decimal.Round(qty, 2); Totalm3 += qty; //计算金额 if (!string.IsNullOrWhiteSpace(txtPrice.Text)) { e.Values[10] = decimal.Parse(txtPrice.Text); } e.Values[11] = decimal.Round(qty * decimal.Parse(e.Values[10].ToString()), 3); TotallPrice += decimal.Parse(e.Values[11].ToString()); //LHCustomerPrice price = CustomerpriceService.Where(p => p.FCode == item["FCode"].ToString(),o=>o.FCreateDate,OrderingOrders.DESC).FirstOrDefault(); } else { e.Values[9] = string.Format("<span style=\"color:{0}\">{1}</span>", "red", decimal.Round(Totalm3, 2)); e.Values[11] = string.Format("<span style=\"color:{0}\">{1}</span>", "red", decimal.Round(TotallPrice, 2)); } //e.Values[3] = string.Format("<span class=\"{0}\">{1}</span>", "colorred", ""); //e.Values[4] = string.Format("<span class=\"{0}\">{1}</span>", "colorred", ""); }
public void Init(HeroData data, List <TestMonster> listMonsters, UIRoot uiRoot) { //가져온 데이터를 참조합니다 this.uiRoot = uiRoot; this.data = data; this.bySelfDecreaedDelay = 0; this.byOtherDecreasedDelay = 0; this.calculatedDamage = FormulaCalculator.GetInstance().AllCalculatedDamage_Hero(data.id); this.calculatedAspd = FormulaCalculator.GetInstance().AllCalculatedAspd_Hero(data.id); this.defaultPos = this.transform.position; if (this.model == null) { this.model = this.gameObject.transform.GetChild(0).gameObject; } this.model.transform.localPosition = Vector3.zero; if (this.animator == null) { this.animator = this.gameObject.GetComponentInChildren <Animator>(); } if (this.GetComponentInChildren <EffectEvents>() != null) { this.effectEvents = this.GetComponentInChildren <EffectEvents>(); } //레이어를 Hero로 만듦 this.gameObject.layer = LayerMask.NameToLayer("Hero"); if (this.boxCollider == null) { //boxCollider를 붙입니다(Hero Merge를 위함) this.boxCollider = this.gameObject.AddComponent <BoxCollider>(); this.boxCollider.size = new Vector3(2f, 2, 2f); this.boxCollider.center = new Vector3(0, 1.2f, 0); this.boxCollider.isTrigger = true; } //몬스터 리스트 참조를 가져옵니다 this.listMonsters = listMonsters; if (uIPopup_HeroLevel == null) { NewUiPopup_HeroLevel(); } SetPositionUIPopup_Hero(); var type = 0; if (data.type < 6) { type = 1; } else if (data.type < 11) { type = 2; } else if (data.type < 16) { type = 3; } uIPopup_HeroLevel.SetLevel(type); this.ChangeBehavior(eHeroState.SEARCH); }
public static void MyClassInitialize(TestContext testContext) { _formulaCalculator = new FormulaCalculator(); }