UILoginComponentSystem.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3. using static ET.GameSetting;
  4. namespace ET.Client
  5. {
  6. [FriendOf(typeof(UILoginComponent))]
  7. public static class UILoginComponentSystem
  8. {
  9. [ObjectSystem]
  10. public class UILoginComponentAwakeSystem : AwakeSystem<UILoginComponent>
  11. {
  12. protected override void Awake(UILoginComponent self, params object[] param)
  13. {
  14. ReferenceCollector rc = self.GetParent<UI>().GameObject.GetComponent<ReferenceCollector>();
  15. self.loginBtn = rc.Get<GameObject>("LoginBtn");
  16. self.getCodeBtn = rc.Get<GameObject>("GetCodeBtn");
  17. self.sureBtn = rc.Get<GameObject>("SureBtn");
  18. self.phoneBtn = rc.Get<GameObject>("PhoneBtn");
  19. self.wechatBtn = rc.Get<GameObject>("WechatBtn");
  20. self.closePhoneBtn = rc.Get<GameObject>("ClosePhoneBtn");
  21. self.loginBtn.GetComponent<Button>().onClick.AddListener(()=> { self.OnLogin(); });
  22. self.getCodeBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnGetCode(); });
  23. self.sureBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnSure(); });
  24. self.phoneBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnPhone(); });
  25. self.wechatBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnWechat(); });
  26. self.closePhoneBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnClosePhone(); });
  27. self.account = rc.Get<GameObject>("Account");
  28. self.password = rc.Get<GameObject>("Password");
  29. self.phoneObj = rc.Get<GameObject>("phoneObj");
  30. self.phoneObj.SetActive(false);
  31. self.testObj = rc.Get<GameObject>("TestObj");
  32. self.testObj.SetActive(false);
  33. self.inputIPObj = rc.Get<GameObject>("IPObj");
  34. self.inputPortObj = rc.Get<GameObject>("portObj");
  35. self.ipSureBtn = rc.Get<GameObject>("IpSureBtn");
  36. self.ipSureBtn.GetComponent<Button>().onClick.AddListener(() => { self.IpSureBtn(); });
  37. self.closeTestBtn = rc.Get<GameObject>("CloseTestBtn");
  38. self.closeTestBtn.GetComponent<Button>().onClick.AddListener(() => { self.CloseTestBtn(); });
  39. self.testBtn = rc.Get<GameObject>("TestBtn");
  40. self.testBtn.GetComponent<Button>().onClick.AddListener(() => { self.TestBtn(); });
  41. self.IDObj = rc.Get<GameObject>("IDObj");
  42. self.IDObj.SetActive(false);
  43. self.IDObjRITH = rc.Get<GameObject>("IDObjRITH");
  44. self.IDObjPASS = rc.Get<GameObject>("IDObjPASS");
  45. self.IDSureBtn = rc.Get<GameObject>("IDSureBtn");
  46. self.IDSureBtn.GetComponent<Button>().onClick.AddListener(() => { self.IDSureBtn(); });
  47. self.IDCloseBtn = rc.Get<GameObject>("IDCloseBtn");
  48. self.IDCloseBtn.GetComponent<Button>().onClick.AddListener(() => { self.IDCloseBtn(); });
  49. self.Init();
  50. }
  51. }
  52. private static void Init(this UILoginComponent self)
  53. {
  54. //每次登陆 重置声音
  55. GameSetting.Instance.SetFloat(MusicSets.Mute_BG, 1);
  56. GameSetting.Instance.SetFloat(MusicSets.Mute_Music, 1);
  57. GameUtil.Instance.SetSceneComponent(self.DomainScene());
  58. }
  59. public static async void OnLogin(this UILoginComponent self)
  60. {
  61. await SoundManager.Instance.PlaySound("clickbtnsound");
  62. // LoginHelper.Login(
  63. //self.DomainScene(),
  64. //self.account.GetComponent<InputField>().text,
  65. //self.password.GetComponent<InputField>().text).Coroutine();
  66. self.IDObj.SetActive(true);
  67. }
  68. public static void OnGetCode(this UILoginComponent self)
  69. {
  70. if (string.IsNullOrEmpty(self.account.GetComponent<InputField>().text))
  71. {
  72. Log.Error("输入手机号");
  73. return;
  74. }
  75. }
  76. public static async void OnSure(this UILoginComponent self)
  77. {
  78. await SoundManager.Instance.PlaySound("clickbtnsound");
  79. if (string.IsNullOrEmpty(self.password.GetComponent<InputField>().text))
  80. {
  81. Log.Error("输入验证码");
  82. return;
  83. }
  84. }
  85. public static async void OnPhone(this UILoginComponent self)
  86. {
  87. await SoundManager.Instance.PlaySound("clickbtnsound");
  88. self.phoneObj.SetActive(true);
  89. }
  90. public static async void OnWechat(this UILoginComponent self)
  91. {
  92. await SoundManager.Instance.PlaySound("clickbtnsound");
  93. }
  94. public static async void OnClosePhone(this UILoginComponent self)
  95. {
  96. await SoundManager.Instance.PlaySound("clickbtnsound");
  97. self.phoneObj.SetActive(false);
  98. }
  99. public static async void IpSureBtn(this UILoginComponent self)
  100. {
  101. await SoundManager.Instance.PlaySound("clickbtnsound");
  102. //测试输入IP
  103. LoginHelper.Login(
  104. self.DomainScene(),
  105. self.account.GetComponent<InputField>().text,
  106. self.password.GetComponent<InputField>().text,
  107. self.inputIPObj.GetComponent<InputField>().text,
  108. int.Parse(self.inputPortObj.GetComponent<InputField>().text)).Coroutine();
  109. }
  110. public static async void IDSureBtn(this UILoginComponent self)
  111. {
  112. await SoundManager.Instance.PlaySound("clickbtnsound");
  113. //测试输入IP
  114. LoginHelper.Login(
  115. self.DomainScene(),
  116. self.IDObjRITH.GetComponent<InputField>().text,
  117. self.IDObjPASS.GetComponent<InputField>().text).Coroutine();
  118. }
  119. public static async void IDCloseBtn(this UILoginComponent self)
  120. {
  121. await SoundManager.Instance.PlaySound("clickbtnsound");
  122. self.IDObjRITH.GetComponent<InputField>().text = "";
  123. self.IDObjPASS.GetComponent<InputField>().text = "";
  124. self.IDObj.SetActive(false);
  125. }
  126. public static void CloseTestBtn(this UILoginComponent self)
  127. {
  128. self.inputIPObj.GetComponent<InputField>().text = "";
  129. self.inputPortObj.GetComponent<InputField>().text = "";
  130. self.testObj.SetActive(false);
  131. }
  132. public static void TestBtn(this UILoginComponent self)
  133. {
  134. self.inputIPObj.GetComponent<InputField>().text = "";
  135. self.inputPortObj.GetComponent<InputField>().text = "";
  136. self.testObj.SetActive(true);
  137. }
  138. }
  139. }