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); }
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); }
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); }
private ActiveWarningAudio GetCorrespondentWarningAudioSource(ActiveWarningObstacle obstacle) { return(audioSources[0].obstacleConfig == obstacle.obstacleConfig ? audioSources[0] : audioSources[1]); }