コード例 #1
0
    private AudioData CategoryToAudioData(ClipCategory category)
    {
        AudioData data = category switch
        {
            ClipCategory.ChangeArea => _profile.changeArea,
            ClipCategory.BookInteract => _profile.bookInteract,
            ClipCategory.PlantHarvested => _profile.plantHarvested,

            // Library
            ClipCategory.CrystalPickup => _profile.crystalPickup,

            // Cauldron
            ClipCategory.IngredientBurn => _profile.ingredientBurn,
            ClipCategory.IngredientGood => _profile.ingredientGood,

            // Observatory
            ClipCategory.ObservatoryTock => _profile.observatoryTock,
            ClipCategory.ObservatoryTick => _profile.observatoryTick,
            ClipCategory.CorrectZodiac => _profile.correctZodiac,
            ClipCategory.ZodiacMoved => _profile.zodiacMoved,

            _ => null,
        };

        if (data == null)
        {
            Debug.LogWarning($"No AudioData set up for {category}!");
        }

        return(data);
    }
コード例 #2
0
    public static AudioSource PlaySoundAt(ClipCategory category,
                                          Vector3 position,
                                          float volume = 1.0f,
                                          float delay  = 0.0f)
    {
        if (!_instance)
        {
            CreateInstance();

            return(null);
        }

        // Select the correct data source.
        AudioData audioData = _instance.CategoryToAudioData(category);

        return(PlaySoundAt(audioData, position, volume, delay));
    }