UIStatsComponentSystem.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading.Tasks;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. using static System.Net.Mime.MediaTypeNames;
  7. namespace ET.Client
  8. {
  9. [FriendOf(typeof(UIStatsComponent))]
  10. public static class UIStatsComponentSystem
  11. {
  12. [ObjectSystem]
  13. public class UIStatsComponentAwakeSystem : AwakeSystem<UIStatsComponent>
  14. {
  15. protected override void Awake(UIStatsComponent self, params object[] param)
  16. {
  17. ReferenceCollector rc = self.GetParent<UI>().GameObject.GetComponent<ReferenceCollector>();
  18. self.playListObj = rc.Get<GameObject>("playListObj");
  19. self.timeContentTxt = rc.Get<GameObject>("timeContentTxt");
  20. self.noStatsTxt = rc.Get<GameObject>("noStatsTxt");
  21. self.nextTimeBtn = rc.Get<GameObject>("nextTimeBtn");
  22. self.nextTimeBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnNextTimeBtn(); });
  23. self.preTimeBtn = rc.Get<GameObject>("preTimeBtn");
  24. self.preTimeBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnPreTimeBtn(); });
  25. self.recodeBtn = rc.Get<GameObject>("recodeBtn");
  26. self.recodeBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnRecodeBtn(); });
  27. self.selPlayBtn = rc.Get<GameObject>("selPlayBtn");
  28. self.selPlayBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnSelPlayBtn(); });
  29. self.closeBtn = rc.Get<GameObject>("closeBtn");
  30. self.closeBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnCloseBtn(); });
  31. self.Init();
  32. }
  33. }
  34. private static void Init(this UIStatsComponent self)
  35. {
  36. self.playListObj.SetActive(false);
  37. self.noStatsTxt.SetActive(true);
  38. }
  39. public static async void OnNextTimeBtn(this UIStatsComponent self)
  40. {
  41. await SoundManager.Instance.PlaySound("clickbtnsound");
  42. }
  43. public static async void OnPreTimeBtn(this UIStatsComponent self)
  44. {
  45. await SoundManager.Instance.PlaySound("clickbtnsound");
  46. }
  47. public static async void OnRecodeBtn(this UIStatsComponent self)
  48. {
  49. await SoundManager.Instance.PlaySound("clickbtnsound");
  50. }
  51. public static async void OnSelPlayBtn(this UIStatsComponent self)
  52. {
  53. await SoundManager.Instance.PlaySound("clickbtnsound");
  54. }
  55. public static async void OnCloseBtn(this UIStatsComponent self)
  56. {
  57. await SoundManager.Instance.PlaySound("clickbtnsound");
  58. self.OnCloseAsync();
  59. }
  60. public static async void OnCloseAsync(this UIStatsComponent self)
  61. {
  62. await UIHelper.Remove(self.ClientScene(),UIType.UIStats);
  63. }
  64. }
  65. }