示例#1
0
        private static AudioSubItem[] _ChooseSubItems(AudioItem audioItem, AudioPickSubItemMode pickMode, AudioObject useExistingAudioObj)
        {
            if (audioItem.SubItems == null)
            {
                return(null);
            }
            var length = audioItem.SubItems.Length;

            if (length == 0)
            {
                return(null);
            }
            var index1     = 0;
            var flag       = useExistingAudioObj != null;
            var lastChosen = !flag ? audioItem.LastChosen : useExistingAudioObj.LastChosenSubItemIndex;

            if (length > 1)
            {
                switch (pickMode)
                {
                case AudioPickSubItemMode.Disabled:
                    return(null);

                case AudioPickSubItemMode.Random:
                    index1 = _ChooseRandomSubitem(audioItem, true, lastChosen);
                    break;

                case AudioPickSubItemMode.RandomNotSameTwice:
                    index1 = _ChooseRandomSubitem(audioItem, false, lastChosen);
                    break;

                case AudioPickSubItemMode.Sequence:
                    index1 = (lastChosen + 1) % length;
                    break;

                case AudioPickSubItemMode.SequenceWithRandomStart:
                    index1 = lastChosen != -1 ? (lastChosen + 1) % length : Random.Range(0, length);
                    break;

                case AudioPickSubItemMode.AllSimultaneously:
                    var audioSubItemArray = new AudioSubItem[length];
                    for (var index2 = 0; index2 < length; ++index2)
                    {
                        audioSubItemArray[index2] = audioItem.SubItems[index2];
                    }
                    return(audioSubItemArray);

                case AudioPickSubItemMode.TwoSimultaneously:
                    return(new[]
                    {
                        _ChooseSingleSubItem(audioItem, AudioPickSubItemMode.RandomNotSameTwice, useExistingAudioObj),
                        _ChooseSingleSubItem(audioItem, AudioPickSubItemMode.RandomNotSameTwice, useExistingAudioObj)
                    });

                case AudioPickSubItemMode.StartLoopSequenceWithFirst:
                    index1 = !flag ? 0 : (lastChosen + 1) % length;
                    break;

                case AudioPickSubItemMode.RandomNotSameTwiceOddsEvens:
                    index1 = _ChooseRandomSubitem(audioItem, false, lastChosen, true);
                    break;
                }
            }
            if (flag)
            {
                useExistingAudioObj.LastChosenSubItemIndex = index1;
            }
            else
            {
                audioItem.LastChosen = index1;
            }
            return(new[] { audioItem.SubItems[index1] });
        }
示例#2
0
 public static AudioSubItem[] _ChooseSubItems(AudioItem audioItem, AudioObject useExistingAudioObj)
 {
     return(_ChooseSubItems(audioItem, audioItem.SubItemPickMode, useExistingAudioObj));
 }
示例#3
0
 public static AudioSubItem _ChooseSingleSubItem(AudioItem audioItem, AudioPickSubItemMode pickMode, AudioObject useExistingAudioObj)
 {
     return(_ChooseSubItems(audioItem, pickMode, useExistingAudioObj)[0]);
 }