TipPanel.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. //
  28. playableDirector = GameObject.Find("timeline").gameObject.GetComponent<PlayableDirector>();
  29. ResetTrackAsset(playableDirector);
  30. }
  31. private int index = 0;
  32. /// <summary>
  33. /// 所有的轨道组
  34. /// </summary>
  35. public List<TrackAsset> trackGroups = new List<TrackAsset>();
  36. public void ResetTrackAsset(PlayableDirector pd)
  37. {
  38. trackGroups.Clear();
  39. TimelineAsset ta = (TimelineAsset)pd.playableAsset;
  40. for (int i = 0; i < ta.rootTrackCount; i++)
  41. {
  42. TrackAsset trackAsset = ta.GetRootTrack(i);
  43. trackAsset.muted = true;
  44. trackGroups.Add(trackAsset);
  45. }
  46. }
  47. private void MuteAll()
  48. {
  49. foreach (TrackAsset trackGroup in trackGroups)
  50. {
  51. // trackGroup.
  52. trackGroup.muted = true;
  53. }
  54. }
  55. public void DBJNext()
  56. {
  57. MuteAll();
  58. foreach (var trackGroup in trackGroups)
  59. {
  60. switch (index)
  61. {
  62. case 0:
  63. if (trackGroup.name == "1")
  64. {
  65. trackGroup.muted = false;
  66. }
  67. break;
  68. case 1:
  69. if (trackGroup.name == "2")
  70. {
  71. trackGroup.muted = false;
  72. }
  73. UIManager.Instance.PlayAudioClip("SowrdDraw");
  74. break;
  75. }
  76. }
  77. playableDirector.Stop();
  78. playableDirector.time = 0;
  79. playableDirector.Play();
  80. index++;
  81. if (index > 1)
  82. {
  83. TimeComponent.Instance.AddTimer(1.5f, () =>
  84. {
  85. UIManager.Instance.HideUIPanel<TipPanel>();
  86. SceneManager.LoadScene("baidicheng");
  87. UIManager.Instance.PlayBGM("Scene04");
  88. TimeComponent.Instance.AddTimer(22f, () => { UIManager.Instance.LoadAndOpenPanel<ChatPanel>(UIManager.UILayer.Middle); });
  89. });
  90. }
  91. }
  92. }
  93. }