PlayVoiceAtBattle.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using GameWorld;
  3. using UnityEngine;
  4. public class PlayVoiceAtBattle : BaseBehaviour
  5. {
  6. private void Start()
  7. {
  8. if (this.gate != null)
  9. {
  10. this.gate.openType = SceneGate.OpenType.None;
  11. }
  12. }
  13. private void OnEnable()
  14. {
  15. EventManager.RegisterEvent<BattleEventArgs>("Battle", new EventManager.FBEventHandler<BattleEventArgs>(this.BattleOver), EventManager.ListenerQueue.Game);
  16. }
  17. private void OnDisable()
  18. {
  19. EventManager.UnregisterEvent<BattleEventArgs>("Battle", new EventManager.FBEventHandler<BattleEventArgs>(this.BattleOver), EventManager.ListenerQueue.Game);
  20. }
  21. private bool BattleOver(string eventName, object sender, BattleEventArgs args)
  22. {
  23. if (args.Status == BattleEventArgs.BattleStatus.Begin)
  24. {
  25. R.Audio.PlayVoiceOver(this.beginVoice, null, false);
  26. }
  27. if (args.Status == BattleEventArgs.BattleStatus.End)
  28. {
  29. R.Audio.PlayVoiceOver(this.endVoice, null, false);
  30. }
  31. return true;
  32. }
  33. public string beginVoice;
  34. public string endVoice;
  35. [SerializeField]
  36. private SceneGate gate;
  37. }