private void UpdateUnitRotation(Unit unit, double rotationSpeed)
        {
            if (unit.RotationTarget.HasValue)
            {
                var diff = GeometryMethods.GetAnglesDifference(unit.Rotation, unit.RotationTarget.Value);

                if (Math.Abs(diff).LessOrEqual(rotationSpeed))
                {
                    unit.Rotation       = unit.RotationTarget.Value;
                    unit.RotationTarget = null;
                }
                else
                {
                    unit.Rotation += rotationSpeed * Math.Sign(diff);
                }
            }
        }
Exemplo n.º 2
0
        public void GetAnglesDifference_TestCase(double a1, double a2, double expected)
        {
            var result = GeometryMethods.GetAnglesDifference(a1, a2);

            Assert.AreEqual(expected, result, 0.01);
        }