Esempio n. 1
0
        private void AddRandomToPlaybackQueue(AudioBuddyRandom random)
        {
            RemoveFirstIfInList(random);
            BuddyRandomEntry draft = random.GetRandomSound();

            _playbackList.Insert(0, new PlaybackEntry(draft.SoundObject, 0));
            OnRandomPick?.Invoke(draft.SoundObject, draft.Chance);
            _deleteNext = false;
        }
Esempio n. 2
0
        public float GetLeftoverChance(BuddyRandomEntry targetEntry)
        {
            float sum = 0;

            foreach (BuddyRandomEntry entry in RandomList)
            {
                if (entry != targetEntry && entry.LockChance)
                {
                    sum += entry.Chance;
                }
            }
            return(0.99999f - sum);
        }
Esempio n. 3
0
        public void DrawEntryObjectFields(BuddyRandomEntry entry)
        {
            EditorGUILayout.BeginHorizontal();
            entry.SoundObject = (AudioBuddyObject)EditorGUILayout.ObjectField(entry.SoundObject, typeof(AudioBuddyObject), false);
            if (entry.SoundObject != null)
            {
                entry.NameInRandom = entry.SoundObject.name;
                if (GUILayout.Button("Reset"))
                {
                    entry.SoundObject = null;
                }
            }
            EditorGUILayout.EndHorizontal();

            if (entry.SoundObject == null)
            {
                GUILayout.Label("Please assign a valid Audio Buddy Object", EditorStyles.centeredGreyMiniLabel);
            }
            else    //Draw Weights and Chances
            {
                EditorGUILayout.BeginHorizontal();
                Rect ControllRect = EditorGUILayout.GetControlRect();
                Rect _firstThird  = ControllRect;
                _firstThird.width /= 3.1f;
                Rect _secondThird = _firstThird;
                _secondThird.x += ControllRect.width / 3f;
                Rect _thirdThird = _secondThird;
                _thirdThird.x += ControllRect.width / 3f;

                float _originalWidth = EditorGUIUtility.labelWidth;
                EditorGUIUtility.labelWidth = 80;

                if (entry.LockChance)
                {
                    EditorGUI.FloatField(_firstThird, "Weight", entry.Weight, EditorStyles.helpBox);
                    entry.Chance = Mathf.Clamp(EditorGUI.FloatField(_secondThird, "Chance", entry.Chance), 0, randomObject.GetLeftoverChance(entry));
                }
                else
                {
                    entry.Weight = Mathf.Max(EditorGUI.FloatField(_firstThird, "Weight", entry.Weight), 0);
                    EditorGUI.FloatField(_secondThird, "Chance", entry.Chance, EditorStyles.helpBox);
                }
                entry.LockChance = EditorGUI.Toggle(_thirdThird, "Lock Chance", entry.LockChance);
                EditorGUILayout.EndHorizontal();
                EditorGUIUtility.labelWidth = _originalWidth;
            }
        }
Esempio n. 4
0
        public void DrawRandomEntry(BuddyRandomEntry entry)
        {
            EditorGUILayout.BeginVertical(AudioBuddy.SubtleBG);
            {
                EditorGUILayout.BeginHorizontal();
                {
                    EditorGUILayout.LabelField(entry.NameInRandom, EditorStyles.whiteLabel);
                    if (GUILayout.Button("X"))
                    {
                        _forDelete.Add(entry);
                    }
                }
                EditorGUILayout.EndHorizontal();

                DrawEntryObjectFields(entry);

                //DrawEntryDuration(entry);
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.Space(3);
        }