ShowTextPanel.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using Excel2Json;
  2. using Mono.UI.Core;
  3. using UnityEngine;
  4. using UnityEngine.SceneManagement;
  5. using UnityEngine.UI;
  6. namespace Mono
  7. {
  8. [UIBinding(prefab = "ShowTextPanel")]
  9. public class ShowTextPanel : UIPanel
  10. {
  11. public Typewriter Text_ShowTIP;
  12. public Button Btn_Next;
  13. public int Index;
  14. public Animator ShowTextAni;
  15. public Image BG;
  16. public override void GetUIData()
  17. {
  18. Text_ShowTIP = UIData.Get<Typewriter>("Text_ShowTIP");
  19. Btn_Next = UIData.Get<Button>("Btn_Next");
  20. ShowTextAni = UIData.Get<Animator>("ShowTextAni");
  21. BG = UIData.Get<Image>("BG");
  22. }
  23. public override void Show()
  24. {
  25. base.Show();
  26. }
  27. public override void AddButtonEvent()
  28. {
  29. Btn_Next.onClick.AddListener(ChangeScene);
  30. }
  31. public void ShowText(int id)
  32. {
  33. ShowTextAni.Play("open");
  34. TimeComponent.Instance.AddTimer(0.5f, () =>
  35. {
  36. ShowTextAni.Play("idle");
  37. ShowTextConfig showTextConfig = ConfigComponent.Instance.Get<ShowTextConfig>(id);
  38. Text_ShowTIP.StringContent = showTextConfig.name;
  39. Text_ShowTIP.SetContent();
  40. Index = id;
  41. });
  42. }
  43. public void ChangeScene()
  44. {
  45. if (!Text_ShowTIP.IsOver)
  46. {
  47. return;
  48. }
  49. switch (Index)
  50. {
  51. case 1:
  52. SceneManager.LoadScene("baidicheng");
  53. UIManager.Instance.PlayBGM("Scene04");
  54. TimeComponent.Instance.AddTimer(22f, () => { UIManager.Instance.LoadAndOpenPanel<ChatPanel>(UIManager.UILayer.Middle); });
  55. break;
  56. }
  57. TimeComponent.Instance.AddTimer(0.2f, () => { ShowTextAni.Play("close"); });
  58. TimeComponent.Instance.AddTimer(1f, () =>
  59. {
  60. Color color = BG.color;
  61. color.a = 0;
  62. BG.color = color;
  63. Color color1 = Text_ShowTIP.Showtext.color;
  64. color.a = 0;
  65. Text_ShowTIP.Showtext.color = color1;
  66. Text_ShowTIP.Showtext.text = "";
  67. Text_ShowTIP.StringContent = "";
  68. UIManager.Instance.HideUIPanel<ShowTextPanel>();
  69. // switch (Index)
  70. // {
  71. // case 1:
  72. // UIManager.Instance.HideUIPanel<ShowTextPanel>();
  73. // break;
  74. // case 2:
  75. // UIManager.Instance.HideUIPanel<ShowTextPanel>();
  76. // break;
  77. // case 3:
  78. // UIManager.Instance.HideUIPanel<ShowTextPanel>();
  79. // break;
  80. // }
  81. });
  82. }
  83. }
  84. }