EffectBaseManager.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Video;
  5. public class EffectBaseManager : MonoBehaviour
  6. {
  7. //影片组
  8. [SerializeField]
  9. private VideoClip[] clips;
  10. [SerializeField]
  11. private PopType[] clipTypes;
  12. //荧幕
  13. [SerializeField]
  14. private EffectScreen eScreen;
  15. private Dictionary<PopType, VideoClip> clipDict = new Dictionary<PopType, VideoClip>();
  16. void Start()
  17. {
  18. MessageCenterController.Instance.Register(GameEnum.MESSAGE_HIDE_POP_BY_TYPE, HidePop);//影藏弹框
  19. MessageCenterController.Instance.Register(GameEnum.MESSAGE_SHOW_POP_BY_TYPE, ShowPop);//显示弹框
  20. for (int i = 0; i < clips.Length; i++)
  21. {
  22. if(clipTypes.Length < i -1)
  23. {
  24. CDebug.Log("报错" + i);
  25. }
  26. clipDict.Add(clipTypes[i], clips[i]);
  27. }
  28. }
  29. // Update is called once per frame
  30. void Update()
  31. {
  32. if(Input.GetKeyDown(KeyCode.P))
  33. {
  34. ChangeMovie();
  35. }
  36. }
  37. private void HidePop(System.Object data = null)
  38. {
  39. PopType t = (PopType)data;
  40. }
  41. private void ShowPop(System.Object data = null)
  42. {
  43. ShowPopData t = data as ShowPopData;
  44. if(clipDict.ContainsKey(t.t))
  45. {
  46. eScreen.ChangeMoive(clipDict[t.t]);
  47. }
  48. }
  49. //换片
  50. private void ChangeMovie()
  51. {
  52. eScreen.ChangeMoive(clips[Random.Range(0, clips.Length)]);
  53. }
  54. }