RegisterNameButtonHandler.cs 1.7 KB

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