RenameButtonHandler.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using UnityEngine;
  2. using System.Collections;
  3. public class RenameButtonHandler : MonoBehaviour {
  4. public UILabel Label;
  5. public MessageCodeCap UIMessage;
  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 == "Nytt namm...")
  14. {
  15. //UIMessage.LabelMessage.text = "Felaktigt namn. Försök igen.";
  16. // UIMessage.GetComponent<ScreenBase>().Show();
  17. NGUIMenuScript.Instance.ShowMenu(NGUIMenuScript.NGUIMenus.Menu);
  18. NGUITools.SetActive(this.transform.parent.gameObject, false);
  19. }
  20. else
  21. {
  22. ServerGiftManager.Instance.RegisterSantaName(Label.text, state =>
  23. {
  24. switch (state)
  25. {
  26. case ServerGiftManager.RegistrationStates.UpdateDone:
  27. NGUIMenuScript.Instance.ShowMenu(NGUIMenuScript.NGUIMenus.Menu);
  28. NGUITools.SetActive(this.transform.parent.gameObject, false);
  29. Debug.Log("UpdateDone");
  30. Label.text = "Nytt namm...";
  31. //todo: handle - user info was updated (everything goes good)
  32. break;
  33. case ServerGiftManager.RegistrationStates.Old:
  34. Debug.Log("Old");
  35. //todo: handle - old user returns (everything goes good)
  36. break;
  37. case ServerGiftManager.RegistrationStates.SantaNameNotUnique:
  38. UIMessage.LabelMessage.text = "Tyvärr är namnet redan upptaget";
  39. UIMessage.GetComponent<ScreenBase>().Show();
  40. Label.text = "Nytt namm...";
  41. Debug.Log("SantaNameNotUnique");
  42. //todo: handle - user should guess another name for santa (no data was updated!)
  43. break;
  44. case ServerGiftManager.RegistrationStates.IdentificatorNotIsset:
  45. Debug.Log("IdentificatorNotIsset");
  46. Label.text = "Nytt namm...";
  47. //todo: handle - you must run base registration first! (no data was updated!)
  48. break;
  49. case ServerGiftManager.RegistrationStates.ContactsIsNotEnough:
  50. Debug.Log("ContactsIsNotEnough");
  51. Label.text = "Nytt namm...";
  52. //todo: handle - santaName or phone or e-mail is empty (no data was updated!)
  53. break;
  54. case ServerGiftManager.RegistrationStates.Error:
  55. UIMessage.LabelMessage.text = "Okänt fel";
  56. UIMessage.GetComponent<ScreenBase>().Show();
  57. Label.text = "Nytt namm...";
  58. //todo: handle - unknown error happens - maybe internet connection errors (no data was updated!)
  59. break;
  60. }
  61. Debug.LogWarning(state);
  62. });
  63. }
  64. }
  65. }