TipPanel.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. using System.Collections.Generic;
  2. using Mono.UI.Core;
  3. using UnityEngine;
  4. using UnityEngine.Playables;
  5. using UnityEngine.SceneManagement;
  6. using UnityEngine.Timeline;
  7. using UnityEngine.UI;
  8. namespace Mono
  9. {
  10. [UIBinding(prefab = "TipPanel")]
  11. public class TipPanel : UIPanel
  12. {
  13. public Text Text_00;
  14. public Typewriter Text_01;
  15. public override void GetUIData()
  16. {
  17. Text_00 = UIData.Get<Text>("Text_00");
  18. Text_01 = UIData.Get<Typewriter>("Text_01");
  19. }
  20. private PlayableDirector playableDirector;
  21. public override void Show()
  22. {
  23. base.Show();
  24. index = 0;
  25. Text_01.StringContent = "龙泉剑\n在白帝城偶遇诗仙李白获赠的随身佩剑";
  26. Text_01.SetContent();
  27. playableDirector = GameObject.Find("timeline").gameObject.GetComponent<PlayableDirector>();
  28. ResetTrackAsset(playableDirector);
  29. }
  30. private int index = 0;
  31. /// <summary>
  32. /// 所有的轨道组
  33. /// </summary>
  34. public List<TrackAsset> trackGroups = new List<TrackAsset>();
  35. public void ResetTrackAsset(PlayableDirector pd)
  36. {
  37. trackGroups.Clear();
  38. TimelineAsset ta = (TimelineAsset)pd.playableAsset;
  39. for (int i = 0; i < ta.rootTrackCount; i++)
  40. {
  41. TrackAsset trackAsset = ta.GetRootTrack(i);
  42. trackAsset.muted = true;
  43. trackGroups.Add(trackAsset);
  44. }
  45. }
  46. private void MuteAll()
  47. {
  48. foreach (TrackAsset trackGroup in trackGroups)
  49. {
  50. // trackGroup.
  51. trackGroup.muted = true;
  52. }
  53. }
  54. public void DBJNext()
  55. {
  56. MuteAll();
  57. foreach (var trackGroup in trackGroups)
  58. {
  59. switch (index)
  60. {
  61. case 0:
  62. if (trackGroup.name == "1")
  63. {
  64. trackGroup.muted = false;
  65. }
  66. break;
  67. case 1:
  68. if (trackGroup.name == "2")
  69. {
  70. trackGroup.muted = false;
  71. }
  72. break;
  73. }
  74. }
  75. playableDirector.time = 0;
  76. playableDirector.Play();
  77. index++;
  78. if (index > 1)
  79. {
  80. TimeComponent.Instance.AddTimer(1.8f, () =>
  81. {
  82. UIManager.Instance.HideUIPanel<TipPanel>();
  83. SceneManager.LoadScene("baidicheng");
  84. TimeComponent.Instance.AddTimer(23f, () => { UIManager.Instance.LoadAndOpenPanel<ChatPanel>(UIManager.UILayer.Middle); });
  85. });
  86. }
  87. }
  88. }
  89. }