public void UpdateDistance(float distance)
        {
            var newZone = DistanceZone.None;

            if (distance < _reachDistance)
            {
                newZone = DistanceZone.Close;
            }
            else if (distance < _closeDistance)
            {
                newZone = DistanceZone.Close;
            }
            else if (distance < _midDistance)
            {
                newZone = DistanceZone.Mid;
            }
            else if (distance < _farDistance)
            {
                newZone = DistanceZone.Far;
            }

            if (newZone != CurrentZone)
            {
                CurrentZone = newZone;
                ZoneChange?.Invoke(CurrentZone);
            }
        }
        private void OnDistanceZoneChange(DistanceZone zone)
        {
            _audioTickTickTween.Kill();
            float interval;
            int   clip;

            switch (zone)
            {
            case DistanceZone.Far:
                interval = Constants.EnemyFarClipInterval;
                clip     = GameAudio.BoundFar;
                break;

            case DistanceZone.Mid:
                interval = Constants.EnemyMidClipInterval;
                clip     = GameAudio.BoundMid;
                break;

            case DistanceZone.Close:
                interval = Constants.EnemyCloseClipInterval;
                clip     = GameAudio.BoundClose;
                break;

            default:
                return;
            }

            _audioTickTickTween = DOVirtual.DelayedCall(interval, () => _audioManager.Play(clip)).SetLoops(-1);
        }
Exemple #3
0
        public double this[DistanceZone zone]
        {
            get
            {
                if (zone == DistanceZone.None)
                {
                    throw new InvalidOperationException("Cannot specify None as a distance zone");
                }

                return(limits_[(int)zone - 1]);
            }
            set
            {
                if (zone == DistanceZone.None)
                {
                    throw new InvalidOperationException("Cannot specify None as a distance zone");
                }

                limits_[(int)zone - 1] = value;
            }
        }