示例#1
0
        private AudioClipData GetCorrectClipData <TEnum, TSoundToPlay>(PlayAudioTypeEvent <TEnum, TSoundToPlay> @event)
            where TEnum : struct, Enum
            where TSoundToPlay : struct, Enum
        {
            //TODO: make proper, this is garbage

            if (@event.EnumName is Awesomenaut awesomenaut)
            {
                NautSetPerNaut setPerEnum = nautClips.First(set => set.Key == awesomenaut);

                if (@event.SoundTypeToPlay is NautSound sound)
                {
                    return(setPerEnum.Value.GetAudioClipData(sound));
                }

                throw new InvalidEnumArgumentException($"{typeof(TSoundToPlay)} is not a NautSound");
            }

            if (@event.EnumName is Announcer announcer)
            {
                AnnouncerSetPerAnnouncer setPerEnum = announcerClips.First(set => set.Key == announcer);

                if (@event.SoundTypeToPlay is AnnouncerSound sound)
                {
                    return(setPerEnum.Value.GetAudioClipData(sound));
                }

                throw new InvalidEnumArgumentException($"{typeof(TSoundToPlay)} is not an AnnouncerSound");
            }

            throw new InvalidEnumArgumentException($"{typeof(TEnum)} is not valid");
        }
示例#2
0
 private void OnPlayAudioTypeEvent <TEnum, TSoundToPlay>(PlayAudioTypeEvent <TEnum, TSoundToPlay> @event)
     where TEnum : struct, Enum
     where TSoundToPlay : struct, Enum
 {
     EventManager.Instance.RaiseEvent(new PlayAudioClipEvent(GetCorrectClipData(@event)));
 }