예제 #1
0
        private float GetPitchDelta(float dt)
        {
            var remaining = Euler.Diff(TotalPitch, TargetPitch);
            var sign      = Math.Sign(remaining);
            var delta     = Math.Min(AimingSpeed * dt, Mathf.Abs(remaining));

            return((Pitch + delta * sign).Clamp360());
        }
예제 #2
0
        private void Update(float dt)
        {
            UpdateTargetPitch();
            Pitch           = GetPitchDelta(dt);
            _lastUpdateTime = _timeManager.GetTime();

            IsAimed = Mathf.Abs(Euler.Diff(TotalPitch, TargetPitch)) < 0.1f;
            if (IsAimed)
            {
                CompleteAiming();
            }
        }
예제 #3
0
        private double CalculateWeight(Unit candidate)
        {
            double result = 0;

            if (_targeting.CurrentTarget == candidate)
            {
                return(double.MaxValue);
            }

            var targetPitch            = _aimer.CalculatePitch(candidate.Navigation.Position);
            var remainingPitch         = Mathf.Abs(Euler.Diff(_aimer.TotalPitch, targetPitch));
            var relativeRemainingPitch = remainingPitch / 180;

            result += Group(1 - relativeRemainingPitch, 4);
            result *= 10;

            var distance         = Vector3.Distance(candidate.Navigation.Position, _navigation.Position);
            var relativeDistance = distance / _range;

            result += Group(1 - relativeDistance, 3);
            result *= 10;

            return(result);
        }