EnterPhoneButton.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using UnityEngine;
  2. using System.Collections;
  3. public class EnterPhoneButton : MonoBehaviour {
  4. public UIInput Telephone;
  5. public CheckBoxConditionsHandler CheckBoxConditionsHandler;
  6. public UIButton Ok;
  7. // Use this for initialization
  8. void Start()
  9. {
  10. Ok.onClick.Add(new EventDelegate(ClickOk));
  11. }
  12. void OnEnable()
  13. {
  14. Telephone.text = "Telefonnummer...";
  15. }
  16. private bool DoneMail;
  17. private bool DonePhone;
  18. private void ClickOk()
  19. {
  20. if (ChekingTelephone(Telephone.text))
  21. {
  22. Debug.Log("Telephone success");
  23. }
  24. else
  25. {
  26. LoginManager.Instance.WrongNumberPhone.Show();
  27. GetComponent<ScreenBase>().Hide();
  28. }
  29. if (CheckBoxConditionsHandler.Check)
  30. {
  31. Debug.Log("Check success");
  32. }
  33. if (ChekingTelephone(Telephone.text) && CheckBoxConditionsHandler.Check)
  34. {
  35. ServerGiftManager.Instance.RegisterPhone(Telephone.text, states => onDonePhone());
  36. NGUIMenuScript.Instance.CurStatePopup = NGUIMenuScript.StatesMenuForPopup.Popup;
  37. NGUIMenuScript.Instance.ShowMenu(NGUIMenuScript.NGUIMenus.LeaderBoardNew);
  38. NGUIMenuScript.Instance.CloseMenu(NGUIMenuScript.NGUIMenus.GameOver);
  39. }
  40. }
  41. private void onDonePhone()
  42. {
  43. Debug.Log("onDonePhone");
  44. PlayerPrefs.SetInt("Phone", 1);
  45. DonePhone = true;
  46. }
  47. private void onDoneMail()
  48. {
  49. Debug.Log("onDonePhone");
  50. PlayerPrefs.SetInt("Mail", 1);
  51. DoneMail = true;
  52. }
  53. bool ChekingTelephone(string telephone)
  54. {
  55. RegexUtilities util = new RegexUtilities();
  56. return util.IsValidPhone(telephone);
  57. }
  58. }