StartRegistrationButtonHandler.cs 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using UnityEngine;
  2. using System.Collections;
  3. public class StartRegistrationButtonHandler : MonoBehaviour {
  4. public UILabel Label;
  5. public GameObject UIWarning;
  6. public MessageCodeCap UIMessage;
  7. public ScreenBase RegScreen;
  8. void Start()
  9. {
  10. UIWarning.SetActive(false);
  11. }
  12. void OnClick()
  13. {
  14. if (Label.text == string.Empty || Label.text == "Namn...")
  15. {
  16. UIWarning.SetActive(true);
  17. }
  18. else
  19. {
  20. ServerGiftManager.Instance.RegisterSantaName(Label.text, state =>
  21. {
  22. switch (state)
  23. {
  24. case ServerGiftManager.RegistrationStates.UpdateDone:
  25. transform.parent.GetComponent<ScreenBase>().Hide();
  26. LoginManager.Instance.ThirdEnter.SetActive(true);
  27. //RegScreen.Show();
  28. Debug.Log("new");
  29. //todo: handle - user info was updated (everything goes good)
  30. break;
  31. case ServerGiftManager.RegistrationStates.Old:
  32. Debug.Log("Old");
  33. //todo: handle - old user returns (everything goes good)
  34. break;
  35. case ServerGiftManager.RegistrationStates.SantaNameNotUnique:
  36. UIMessage.LabelMessage.text = "Tyvärr är namnet redan upptaget";
  37. UIMessage.GetComponent<ScreenBase>().Show();
  38. UIMessage.GetComponent<UIPanel>().alpha = 1;
  39. Debug.Log("SantaNameNotUnique");
  40. //todo: handle - user should guess another name for santa (no data was updated!)
  41. break;
  42. case ServerGiftManager.RegistrationStates.IdentificatorNotIsset:
  43. Debug.Log("IdentificatorNotIsset");
  44. //todo: handle - you must run base registration first! (no data was updated!)
  45. break;
  46. case ServerGiftManager.RegistrationStates.ContactsIsNotEnough:
  47. Debug.Log("ContactsIsNotEnough");
  48. //todo: handle - santaName or phone or e-mail is empty (no data was updated!)
  49. break;
  50. case ServerGiftManager.RegistrationStates.Error:
  51. UIMessage.LabelMessage.text = "Okänt fel";
  52. UIMessage.GetComponent<ScreenBase>().Show();
  53. Debug.Log("Error");
  54. //todo: handle - unknown error happens - maybe internet connection errors (no data was updated!)
  55. break;
  56. }
  57. });
  58. }
  59. }
  60. }