private void PlaySound(TurbineAnimationType type) { switch (type) { case TurbineAnimationType.Rotate: { _startAudioCoroutine = StartCoroutine(StartAudioCoroutine()); break; } case TurbineAnimationType.Move: { if (_audioSource != null) { _audioSource.PlayOneShot(_disassembleClip); } break; } case TurbineAnimationType.StopRotation: { StopCoroutine(_startAudioCoroutine); if (_audioSource != null) { _audioSource.Stop(); _audioSource.PlayOneShot(_stopClip); } break; } } }
public void StartAnimations(TurbineAnimationType type) { if (type != TurbineAnimationType.RevertCutoff) { _delayedAnimationType = TurbineAnimationType.None; } switch (SceneState) { case TurbineState.Default: break; case TurbineState.Cut: if (_currentAnimationType != TurbineAnimationType.StopRotation) { _delayedAnimationType = type; type = TurbineAnimationType.StopRotation; } break; case TurbineState.Exploded: _delayedAnimationType = type; type = TurbineAnimationType.RevertMove; break; } _currentAnimationType = type; if (type != TurbineAnimationType.Rotate && type != TurbineAnimationType.None) { IsAnimating = true; } AnimationControllers.ForEach(x => x.Play(type)); PlaySound(type); }
private void EndReverseAnimation() { _currentAnimationType = TurbineAnimationType.None; SceneState = TurbineState.Default; if (_delayedAnimationType != TurbineAnimationType.None) { StartAnimations(_delayedAnimationType); } }
private void PlaySound(TurbineAnimationType type) { var audioSource = FindObjectOfType <AudioSource>(); switch (type) { case TurbineAnimationType.Rotate: { _startAudioCoroutine = StartCoroutine(StartAudioCoroutine()); break; } case TurbineAnimationType.Move: { if (audioSource && audioSource.gameObject.activeInHierarchy) { audioSource.PlayOneShot(_disassembleClip); } break; } case TurbineAnimationType.StopRotation: { if (_startAudioCoroutine != null) { StopCoroutine(_startAudioCoroutine); } if (audioSource != null && audioSource.gameObject.activeInHierarchy) { audioSource.Stop(); audioSource.PlayOneShot(_stopClip); } break; } } }
public virtual void Play(TurbineAnimationType type) { _isReverse = type == TurbineAnimationType.RevertCutoff || type == TurbineAnimationType.RevertMove || type == TurbineAnimationType.StopRotation; GetComponent <Animator>().Play(type.ToString()); }