123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- using UnityEngine;
- using UnityEngine.UI;
- using static ET.GameSetting;
- namespace ET.Client
- {
- [FriendOf(typeof(UILoginComponent))]
- public static class UILoginComponentSystem
- {
- [ObjectSystem]
- public class UILoginComponentAwakeSystem : AwakeSystem<UILoginComponent>
- {
- protected override void Awake(UILoginComponent self, params object[] param)
- {
- ReferenceCollector rc = self.GetParent<UI>().GameObject.GetComponent<ReferenceCollector>();
- self.loginBtn = rc.Get<GameObject>("LoginBtn");
- self.getCodeBtn = rc.Get<GameObject>("GetCodeBtn");
- self.sureBtn = rc.Get<GameObject>("SureBtn");
- self.phoneBtn = rc.Get<GameObject>("PhoneBtn");
- self.wechatBtn = rc.Get<GameObject>("WechatBtn");
- self.closePhoneBtn = rc.Get<GameObject>("ClosePhoneBtn");
- self.loginBtn.GetComponent<Button>().onClick.AddListener(()=> { self.OnLogin(); });
- self.getCodeBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnGetCode(); });
- self.sureBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnSure(); });
- self.phoneBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnPhone(); });
- self.wechatBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnWechat(); });
- self.closePhoneBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnClosePhone(); });
- self.account = rc.Get<GameObject>("Account");
- self.password = rc.Get<GameObject>("Password");
- self.phoneObj = rc.Get<GameObject>("phoneObj");
- self.phoneObj.SetActive(false);
- self.testObj = rc.Get<GameObject>("TestObj");
- self.testObj.SetActive(false);
- self.inputIPObj = rc.Get<GameObject>("IPObj");
- self.inputPortObj = rc.Get<GameObject>("portObj");
- self.ipSureBtn = rc.Get<GameObject>("IpSureBtn");
- self.ipSureBtn.GetComponent<Button>().onClick.AddListener(() => { self.IpSureBtn(); });
- self.closeTestBtn = rc.Get<GameObject>("CloseTestBtn");
- self.closeTestBtn.GetComponent<Button>().onClick.AddListener(() => { self.CloseTestBtn(); });
- self.testBtn = rc.Get<GameObject>("TestBtn");
- self.testBtn.GetComponent<Button>().onClick.AddListener(() => { self.TestBtn(); });
- self.IDObj = rc.Get<GameObject>("IDObj");
- self.IDObj.SetActive(false);
- self.IDObjRITH = rc.Get<GameObject>("IDObjRITH");
- self.IDObjPASS = rc.Get<GameObject>("IDObjPASS");
- self.IDSureBtn = rc.Get<GameObject>("IDSureBtn");
- self.IDSureBtn.GetComponent<Button>().onClick.AddListener(() => { self.IDSureBtn(); });
- self.IDCloseBtn = rc.Get<GameObject>("IDCloseBtn");
- self.IDCloseBtn.GetComponent<Button>().onClick.AddListener(() => { self.IDCloseBtn(); });
- self.Init();
- }
- }
- private static void Init(this UILoginComponent self)
- {
- //每次登陆 重置声音
- GameSetting.Instance.SetFloat(MusicSets.Mute_BG, 1);
- GameSetting.Instance.SetFloat(MusicSets.Mute_Music, 1);
- GameUtil.Instance.SetSceneComponent(self.DomainScene());
- }
- public static async void OnLogin(this UILoginComponent self)
- {
- await SoundManager.Instance.PlaySound("clickbtnsound");
- // LoginHelper.Login(
- //self.DomainScene(),
- //self.account.GetComponent<InputField>().text,
- //self.password.GetComponent<InputField>().text).Coroutine();
- self.IDObj.SetActive(true);
- }
- public static void OnGetCode(this UILoginComponent self)
- {
- if (string.IsNullOrEmpty(self.account.GetComponent<InputField>().text))
- {
- Log.Error("输入手机号");
- return;
- }
- }
- public static async void OnSure(this UILoginComponent self)
- {
- await SoundManager.Instance.PlaySound("clickbtnsound");
- if (string.IsNullOrEmpty(self.password.GetComponent<InputField>().text))
- {
- Log.Error("输入验证码");
- return;
- }
- }
- public static async void OnPhone(this UILoginComponent self)
- {
- await SoundManager.Instance.PlaySound("clickbtnsound");
- self.phoneObj.SetActive(true);
- }
- public static async void OnWechat(this UILoginComponent self)
- {
- await SoundManager.Instance.PlaySound("clickbtnsound");
- }
- public static async void OnClosePhone(this UILoginComponent self)
- {
- await SoundManager.Instance.PlaySound("clickbtnsound");
- self.phoneObj.SetActive(false);
- }
- public static async void IpSureBtn(this UILoginComponent self)
- {
- await SoundManager.Instance.PlaySound("clickbtnsound");
- //测试输入IP
- LoginHelper.Login(
- self.DomainScene(),
- self.account.GetComponent<InputField>().text,
- self.password.GetComponent<InputField>().text,
- self.inputIPObj.GetComponent<InputField>().text,
- int.Parse(self.inputPortObj.GetComponent<InputField>().text)).Coroutine();
- }
- public static async void IDSureBtn(this UILoginComponent self)
- {
- await SoundManager.Instance.PlaySound("clickbtnsound");
- //测试输入IP
- LoginHelper.Login(
- self.DomainScene(),
- self.IDObjRITH.GetComponent<InputField>().text,
- self.IDObjPASS.GetComponent<InputField>().text).Coroutine();
- }
- public static async void IDCloseBtn(this UILoginComponent self)
- {
- await SoundManager.Instance.PlaySound("clickbtnsound");
- self.IDObjRITH.GetComponent<InputField>().text = "";
- self.IDObjPASS.GetComponent<InputField>().text = "";
- self.IDObj.SetActive(false);
- }
- public static void CloseTestBtn(this UILoginComponent self)
- {
- self.inputIPObj.GetComponent<InputField>().text = "";
- self.inputPortObj.GetComponent<InputField>().text = "";
- self.testObj.SetActive(false);
- }
-
- public static void TestBtn(this UILoginComponent self)
- {
- self.inputIPObj.GetComponent<InputField>().text = "";
- self.inputPortObj.GetComponent<InputField>().text = "";
- self.testObj.SetActive(true);
- }
- }
- }
|