예제 #1
0
        private void SetWarningConfig(ActiveWarningObstacle obstacle, Vector3 position, Vector3 feetPosition, bool gotFeetPosition)
        {
            var closestPoint = obstacle.obstacle.ClosestPoint(position);

            obstacle.closestPoint     = closestPoint;
            obstacle.distanceToPlayer = (position - closestPoint).magnitude;

            if (!gotFeetPosition)
            {
                obstacle.warningConfig = GetWarningConfig(obstacle);
                return;
            }

            var closestFeetPoint = obstacle.obstacle.ClosestPoint(feetPosition);
            var distance         = (feetPosition - closestFeetPoint).magnitude;

            if (!(distance < obstacle.distanceToPlayer))
            {
                obstacle.warningConfig = GetWarningConfig(obstacle);
                return;
            }

            obstacle.closestPoint     = closestFeetPoint;
            obstacle.distanceToPlayer = distance;

            obstacle.warningConfig = GetWarningConfig(obstacle);
        }
예제 #2
0
        private void AddObstacle(Collider other, ObstacleConfig obstacleConfig)
        {
            Log($"AddObstacle | {other.name} | ObstacleConfig {obstacleConfig.name}", false);

            var activeObstacle = new ActiveWarningObstacle
            {
                obstacle       = other,
                obstacleConfig = obstacleConfig
            };

            activeObstacles.Add(activeObstacle);
        }
예제 #3
0
        private WarningConfig GetWarningConfig(ActiveWarningObstacle activeWarningObstacle)
        {
            foreach (var warningRange in activeWarningObstacle.obstacleConfig.warningRanges)
            {
                Log($"{activeWarningObstacle.obstacleConfig.name}: {activeWarningObstacle.distanceToPlayer} <> {warningRange.range}");
                if (warningRange.range > activeWarningObstacle.distanceToPlayer)
                {
                    Log($"{activeWarningObstacle.obstacleConfig.name}: Set warning range: {warningRange.audioCue}, range: {warningRange.range}", false);
                    return(warningRange);
                }
            }

            return(null);
        }
예제 #4
0
 private ActiveWarningAudio GetCorrespondentWarningAudioSource(ActiveWarningObstacle obstacle)
 {
     return(audioSources[0].obstacleConfig == obstacle.obstacleConfig ? audioSources[0] : audioSources[1]);
 }