/// <summary> /// 找到离目标最近的移动点 /// </summary> public Vector2Int GetMovingTargetPos(BattleUnit unit, Vector2Int targetPos) { standingGrid = mapGrids[unit.Position.x][unit.Position.y]; targetGrid = standingGrid; walkableRange = CircleTargets(unit.Steps); int distance = 0; int temp; int index = 0; bool isStraight; bool tempStraight; distance = MathCalculator.GetBattleGridDistance(targetPos, walkableRange[0].Position, out isStraight); Debug.Log("Total range = " + walkableRange.Count + "," + walkableRange[0].Position + "," + distance + "," + isStraight); for (int i = 1; i < walkableRange.Count; i++) { Debug.Log(walkableRange[i].Position + "," + walkableRange[i].Walkable); if (!walkableRange[i].Walkable) { continue; } temp = MathCalculator.GetBattleGridDistance(targetPos, walkableRange[i].Position, out tempStraight); Debug.Log(walkableRange[i].Position + "," + distance + "," + isStraight); if (temp < distance || (!isStraight && tempStraight)) { distance = temp; isStraight = tempStraight; index = i; } } return(walkableRange[index].Position); }
//2.外伤,返回伤害值 int PhysicalDamage(BattleUnit attacker, string param, BattleUnit target) { //闪避 if (MathCalculator.IsDodge(target.Dodge)) { return(0); } int value = int.Parse(param) * (attacker.Attack - target.Defence) / 10000; //生命盾 if (value > 0 && target.Shield > 0) { DamageAfterShield(target, ref value); } value = Mathf.Max(0, value); //内力盾 if (target.DamageToManaShiled > 0) { target.DamageToManaShiled--; value -= target.DamageMp(value); } //造成伤害 if (value > 0) { target.Damage(value); } Debug.Log("PhysicalDamage" + value); return(value); }
static void Main(string[] args) { var mathOperationsContainer = new MathOperationsContainer(); var parser = new Parser(); var notationConverter = new NotationConverter(); var mathProcessor = new MathProcessor(); var calculator = new MathCalculator(parser, notationConverter, mathProcessor, mathOperationsContainer); Console.WriteLine("Calculator"); Console.WriteLine("To complete the work, type exit."); while (true) { Console.Write("Enter a math expression: "); var expression = Console.ReadLine(); if (expression == "exit") { Console.WriteLine("Work completed."); break; } var result = calculator.Calculate(expression); Console.WriteLine("Result: {0}", result); } }
public void VerifySubtractMethodWorkingProperly() { var calculator = new MathCalculator(); var result = calculator.Subtract(20, 10); Assert.AreEqual(10, result); }
public void Add_OneIntOneNull_ReturnsZero() { var mathCalculator = new MathCalculator(); var zero = mathCalculator.Add(2, null); Assert.AreEqual(0, zero); }
public void Test() { float x = 10; var mathCalculator = new MathCalculator(); var result = mathCalculator.Add(1, 2); }
public void VerifyAddMethodWorkingProperly() { var calculator = new MathCalculator(); var result = calculator.Add(10, 20); Assert.AreEqual(30, result); }
public MathCalculatorUnitTests() { _mathOperationsContainer = new MathOperationsContainer(); _mockParser = new Mock <IParser>(); _mockNotationConverter = new Mock <INotationConverter>(); _mockMathProcessor = new Mock <IMathProcessor>(); _calculator = new MathCalculator(_mockParser.Object, _mockNotationConverter.Object, _mockMathProcessor.Object, _mathOperationsContainer); }
public void WhenSumFiveAndThreeThenGotEight() { // Arrange MathCalculator calculator = new MathCalculator(); // Act var result = calculator.Sum(Five, Three); // Assert Assert.Equal(8, result); }
public void WhenNegSubFiveAndThreeThaenGotEight() { // Arrange MathCalculator calculator = new MathCalculator(); // Act var result = calculator.Sub(-Five, Three); // Assert Assert.Equal(-8, result); }
public void WhenSumMuniusFiveAndThreeThenGotMuniusTwo() { // Arrange(Подготовка данных) MathCalculator calculator = new MathCalculator(); // Act int results = calculator.Sum(-Five, Three); // Assert Assert.Equal(-Five + Three, results); }
public void WhenSubThreeFromFiveThenGotTwo() { // Arrange MathCalculator calculator = new MathCalculator(); // Act var result = calculator.Sub(Five, Three); // Assert Assert.Equal(2, result); }
// Method_Schenario_ExpectedBehaviour public void Add_TwoInts_ReturnsAdd() { // Arrange: Create objets var mathCalculator = new MathCalculator(); // Act: Call a method var seven = mathCalculator.Add(2, 5); // Aset: Verify result Assert.AreEqual(7, seven.Value); }
public void SumSimpleInput() { List <int> simpleList = new List <int>() { 1, 2, 3, 4, 4 }; double actual = MathCalculator.Sum(simpleList); double expected = 14; Assert.AreEqual(expected, actual); }
public void AverageSimpleInput() { List <int> simpleList = new List <int>() { 1, 2, 3, 4, 4 }; double actual = MathCalculator.Average(simpleList); double expected = 2.8; Assert.AreEqual(expected, actual); }
private void button1_Click(object sender, EventArgs e) { ValideteInputs(); double angle = double.Parse(txtAngle.Text); double height = double.Parse(txtHight.Text); int sensitivity = int.Parse(txtSensitivity.Text); MathCalculator calculator = new MathCalculator(angle, height, sensitivity); double area = calculator.Area; double radius = calculator.Radius; this.dataGridView1.Rows.Insert(0, angle, height, radius, area); }
public void SumWithEmptyListShouldThrowArgumentException() { List <int> emptyList = new List <int>(); MathCalculator.Sum(emptyList); }
public void SumWithNullListShouldThrowArgumentException() { MathCalculator.Sum(null); }
public void AverageWithNullInputShouldThrowArgumentException() { MathCalculator.Average(null); }
public void Setup() { // Arrange mathCalculator = new MathCalculator(); }
public void Setup() { mathCalculator = new MathCalculator(); }
public MathCalculatorUnitTests() { mathCalculator = new MathCalculator(); }
public MathCaculatorTests() { mathCalculator = new MathCalculator(); }