CourseEffectBgManager.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Video;
  5. public class CourseEffectBgManager : MonoBehaviour
  6. {
  7. //影片组
  8. [SerializeField]
  9. private VideoClip[] clips;
  10. //荧幕
  11. [SerializeField]
  12. private EffectScreen eScreen;
  13. void Start()
  14. {
  15. MessageCenterController.Instance.Register(GameEnum.MESSAGE_ENTER_COURSE, ShowEffect);//进入房间
  16. MessageCenterController.Instance.Register(GameEnum.MESSAGE_EXIT_COURSE, HideEffect);//关闭房间
  17. //MessageCenter.Instance.Register(GameEnum.MESSAGE_SHOW_COURSE, ShowEffect);//显示房间
  18. //MessageCenter.Instance.Register(GameEnum.MESSAGE_HIDE_COURSE, HideEffect);//隐藏房间
  19. HideEffect();
  20. }
  21. private void OnDestroy()
  22. {
  23. MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_ENTER_COURSE, ShowEffect);//进入房间
  24. MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_EXIT_COURSE, HideEffect);//关闭房间
  25. //MessageCenter.Instance.UnRegister(GameEnum.MESSAGE_SHOW_COURSE, ShowEffect);//显示房间
  26. //MessageCenter.Instance.UnRegister(GameEnum.MESSAGE_HIDE_COURSE, HideEffect);//隐藏房间
  27. }
  28. private void ShowEffect(System.Object data = null)
  29. {
  30. if (GamePlayerData.Instance.room_data != null && GamePlayerData.Instance.room_data.CurOnlineData.subject_id <= clips.Length)
  31. {
  32. CDebug.Log("subject_id " + GamePlayerData.Instance.room_data.CurOnlineData.subject_id);
  33. eScreen.ChangeMoive(clips[GamePlayerData.Instance.room_data.CurOnlineData.subject_id - 1]);
  34. }
  35. }
  36. private void HideEffect(System.Object data = null)
  37. {
  38. eScreen.ChangeMoive(null);
  39. }
  40. // Update is called once per frame
  41. void Update()
  42. {
  43. if(Input.GetKeyDown(KeyCode.P))
  44. {
  45. ChangeMovie();
  46. }
  47. }
  48. //换片
  49. private void ChangeMovie()
  50. {
  51. eScreen.ChangeMoive(clips[Random.Range(0, clips.Length)]);
  52. }
  53. }