public override void AfterSwitch(FageStateMachine stateMachine, string beforeId) { base.AfterSwitch(stateMachine, beforeId); FageAudioSourceControl fsm = stateMachine as FageAudioSourceControl; fsm.SetAudioStatus(FageAudioStatus.PAUSED); }
public void Play(string nodeId, string resourcePath, bool loop = false) { FageAudioNode node = FageAudioNode.Find(nodeId); FageAudioSourceControl audioSourceControl = (_hashtable[node] as FageAudioPooler).GetFreeAudioSourceControl(); audioSourceControl.Play(CachedResource.Load <AudioClip>(resourcePath), loop, node.GetVolume(), false); }
public override void Excute (FageStateMachine stateMachine) { base.Excute (stateMachine); FageAudioSourceControl fsm = stateMachine as FageAudioSourceControl; if (fsm.audioSource.isPlaying) { fsm.ReserveState("FageAudioSourcePlaying"); } }
public override void AfterSwitch(FageStateMachine stateMachine, string beforeId) { base.AfterSwitch(stateMachine, beforeId); FageAudioSourceControl fsm = stateMachine as FageAudioSourceControl; fsm.SetAudioStatus(FageAudioStatus.PLAYING); _timeSamples = fsm.audioSource.timeSamples; }
public void Play(string nodeId, string clip, ref FageAudioSourceControl audioSourceControl, bool loop = false) { FageAudioXML audioXML = _audioRoot.Find (nodeId); AudioClip ac = FageBundleLoader.Instance.Load (clip) as AudioClip; if (ac != null) { audioSourceControl = audioXML.GetControl (); audioSourceControl.Play (ac, loop, audioXML.GetVolume(), true); } }
public void Play(string nodeId, string clip, ref FageAudioSourceControl audioSourceControl, bool loop = false) { FageAudioXML audioXML = _audioRoot.Find(nodeId); AudioClip ac = FageBundleLoader.Instance.Load(clip) as AudioClip; if (ac != null) { audioSourceControl = audioXML.GetControl(); audioSourceControl.Play(ac, loop, audioXML.GetVolume(), true); } }
public FageAudioSourceControl GetControl() { FageAudioSourceControl result = null; if (channels > 0) { result = _controls[_index]; _index = (_index + 1) % channels; } return(result); }
public FageAudioPooler(FageAudioNode node, GameObject listener) { _node = node; _index = 0; _controls = new FageAudioSourceControl[node.channels]; for (int i = 1; i <= _node.channels; i++) { GameObject child = new GameObject(node.name + " " + i.ToString(), typeof(AudioSource), typeof(FageAudioSourceControl)); child.transform.SetParent(listener.transform); FageAudioSourceControl control = child.GetComponent <FageAudioSourceControl>(); control.enabled = false; _controls[i - 1] = control; } }
public void GenerateControl(AudioListener listener) { float newV = GetVolume(); _controls = new List <FageAudioSourceControl> (); for (int i = 1; i <= channels; i++) { GameObject go = new GameObject(this.id + i.ToString(), typeof(AudioSource), typeof(FageAudioSourceControl)); go.transform.SetParent(listener.transform); FageAudioSourceControl control = go.GetComponent <FageAudioSourceControl>(); _controls.Add(control); control.volume = newV; } _index = 0; }
public FageAudioSourceControl GetFreeAudioSourceControl() { if (_node.channels == 0) { return(null); } FageAudioSourceControl control = _controls [_index]; if (control.audioStatus == FageAudioStatus.PLAYING) { control.Stop(); } _index = (_index + 1) % _node.channels; return(control); }
public override void Excute(FageStateMachine stateMachine) { base.Excute(stateMachine); FageAudioSourceControl fsm = stateMachine as FageAudioSourceControl; if (!fsm.audioSource.isPlaying) { if (fsm.audioSource.timeSamples > 0) { fsm.ReserveState("FageAudioSourcePaused"); } else { fsm.ReserveState("FageAudioSourceReady"); } } else if (_timeSamples > fsm.audioSource.timeSamples) { fsm.NotifyLoop(); } _timeSamples = fsm.audioSource.timeSamples; }
public void Play(string nodeId, string resourcePath, ref FageAudioSourceControl audioSourceControl, bool loop = false) { FageAudioNode node = FageAudioNode.Find(nodeId); audioSourceControl = (_hashtable[node] as FageAudioPooler).GetFreeAudioSourceControl(); audioSourceControl.Play(CachedResource.Load<AudioClip>(resourcePath), loop, node.GetVolume(), true); }