TimeLineControl.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class TimeLineControl : MonoBehaviour {
  5. public static TimeLineControl Instance;
  6. public List<TimeLineChange> mTimeLineChange = new List<TimeLineChange>();
  7. private void Awake()
  8. {
  9. Instance = this;
  10. }
  11. public TimeLineControlType ControlType = TimeLineControlType.E_None;
  12. public int CurIndex = 0;
  13. public bool isOpen = false;
  14. public TimeLineChange CurTimeLineChange
  15. {
  16. get{ return mTimeLineChange[CurIndex]; }
  17. }
  18. void Start() {
  19. MessageCenterController.Instance.Register(GameEnum.MESSAGE_EXPLAIN_CLICK, OnEXPLAIN);
  20. MessageCenterController.Instance.Register(GameEnum.MESSAGE_PARCTICE_CLICK, OnPARCTICE);
  21. MessageCenterController.Instance.Register(GameEnum.MESSAGE_TAB_CHANGE, OnEnd);
  22. }
  23. private void OnDestroy()
  24. {
  25. MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_EXPLAIN_CLICK, OnEXPLAIN);
  26. MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_PARCTICE_CLICK, OnPARCTICE);
  27. MessageCenterController.Instance.UnRegister(GameEnum.MESSAGE_TAB_CHANGE, OnEnd);
  28. }
  29. void OnEXPLAIN(System.Object o)
  30. {
  31. CurTimeLineChange.CloseAllTimeLine();
  32. CurIndex = (int)o;
  33. ControlType = TimeLineControlType.E_Explain;
  34. CurTimeLineChange.SwitchDirector(ControlType);
  35. isOpen = true;
  36. TaskCanvas.Instance.gameObject.SetActive(false);
  37. }
  38. void OnPARCTICE(System.Object o)
  39. {
  40. CurTimeLineChange.CloseAllTimeLine();
  41. CurIndex = (int)o;
  42. ControlType = TimeLineControlType.E_StudentPractice;
  43. CurTimeLineChange.SwitchDirector(ControlType);
  44. TaskCanvas.Instance.gameObject.SetActive(true);
  45. isOpen = true;
  46. }
  47. void OnEnd(System.Object o)
  48. {
  49. CurTimeLineChange.CloseAllTimeLine();
  50. CurIndex = 0;
  51. ControlType = TimeLineControlType.E_None;
  52. isOpen = false;
  53. TaskCanvas.Instance.gameObject.SetActive(false);
  54. }
  55. private void Update()
  56. {
  57. if (!isOpen)
  58. { return; }
  59. }
  60. }
  61. public enum TimeLineControlType
  62. {
  63. E_Explain, //讲解
  64. E_StudentPractice, //学生练习
  65. E_None,
  66. }