Exemplo n.º 1
0
 public void Dispose()
 {
     if (List != null)
     {
         List.Remove(this);
         DebugOnly.Check(List == null, "Handle was not properly removed from the list.");
     }
 }
Exemplo n.º 2
0
        public void Push(ISceneState state)
        {
            DebugOnly.Check(!states.Contains(state), $"GameState is already on the stack.");

            states.Add(state);
            statesListChanged = true;
            (state as ISceneStateInternal)?.InternalActivate();
        }
        internal void InternalInit(AudioMixer mixer)
        {
            channelEnabled = PlayerPrefs.GetInt($"{Name}Enabled", 1) != 0;
            volume         = PlayerPrefs.GetFloat($"{Name}Volume", 1.0f);
            volumeChanged  = true;

            var groups = mixer.FindMatchingGroups(Name);

            DebugOnly.Check(groups.Length > 0, $"Didn't find mixer group for \"{Name}\".");
            mixerGroup = groups[0];
        }
        void Awake()
        {
            channelDict = new Dictionary <string, ISoundChannel>();
            foreach (var channel in Channels)
            {
                DebugOnly.Check(!channelDict.ContainsKey(channel.Name), $"Duplicate channel name: '{channel.Name}'.");
                channelDict[channel.Name] = channel;
                channel.InternalInit(Mixer);
            }

            Sfx   = GetChannel("Sfx");
            Music = GetChannel("Music");
        }
Exemplo n.º 5
0
        public void Pop(ISceneState state)
        {
            statesListChanged = true;
            states.Remove(state);

            if (CurrentState == state)
            {
                (CurrentState as ISceneStateInternal)?.InternalResignTopmost();
                CurrentState = null;
            }

            (state as ISceneStateInternal)?.InternalDeactivate();

            DebugOnly.Check(states.Count != 0, "GameState stack is empty.");
        }
Exemplo n.º 6
0
        public void Add(ref ObserverHandle handle, T observer)
        {
            if (handle == null)
            {
                handle = new ObserverHandle();
            }

            DebugOnly.Check(observer != null, "Observer is null.");
            DebugOnly.Check(handle.List == null, "Handle is already in use.");

            handle.Index = list.Count;
            handle.List  = this;
            list.Add(new Item {
                handle = handle, observer = observer
            });
        }
Exemplo n.º 7
0
        public void Remove(ObserverHandle handle)
        {
            DebugOnly.Check(handle != null, "Handle is null.");
            DebugOnly.Check(handle.List == this, "Handle is not registered with this list.");

            int lastIndex = list.Count - 1;

            if (handle.Index != lastIndex)
            {
                var replacement = list[lastIndex];
                list[handle.Index]       = replacement;
                replacement.handle.Index = handle.Index;
            }

            handle.List = null;
            list.RemoveAt(lastIndex);
        }
Exemplo n.º 8
0
 public void DOKill(bool complete)
 {
     DebugOnly.Check(IsValid, "Attempted to kill tweens with an invalid SoundHandle.");
     Source.DOKill(complete);
 }
Exemplo n.º 9
0
 public Tweener DOFade(float endValue, float time)
 {
     DebugOnly.Check(IsValid, "Attempted to fade volume with an invalid SoundHandle.");
     return(Source.DOFade(endValue, time));
 }