using UnityEngine; using System.Collections; public class StartRegistrationButtonHandler : MonoBehaviour { public UILabel Label; public GameObject UIWarning; public MessageCodeCap UIMessage; public ScreenBase RegScreen; void Start() { UIWarning.SetActive(false); } void OnClick() { if (Label.text == string.Empty || Label.text == "Namn...") { UIWarning.SetActive(true); } else { ServerGiftManager.Instance.RegisterSantaName(Label.text, state => { switch (state) { case ServerGiftManager.RegistrationStates.UpdateDone: transform.parent.GetComponent().Hide(); LoginManager.Instance.ThirdEnter.SetActive(true); //RegScreen.Show(); Debug.Log("new"); //todo: handle - user info was updated (everything goes good) break; case ServerGiftManager.RegistrationStates.Old: Debug.Log("Old"); //todo: handle - old user returns (everything goes good) break; case ServerGiftManager.RegistrationStates.SantaNameNotUnique: UIMessage.LabelMessage.text = "Tyvärr är namnet redan upptaget"; UIMessage.GetComponent().Show(); UIMessage.GetComponent().alpha = 1; Debug.Log("SantaNameNotUnique"); //todo: handle - user should guess another name for santa (no data was updated!) break; case ServerGiftManager.RegistrationStates.IdentificatorNotIsset: Debug.Log("IdentificatorNotIsset"); //todo: handle - you must run base registration first! (no data was updated!) break; case ServerGiftManager.RegistrationStates.ContactsIsNotEnough: Debug.Log("ContactsIsNotEnough"); //todo: handle - santaName or phone or e-mail is empty (no data was updated!) break; case ServerGiftManager.RegistrationStates.Error: UIMessage.LabelMessage.text = "Okänt fel"; UIMessage.GetComponent().Show(); Debug.Log("Error"); //todo: handle - unknown error happens - maybe internet connection errors (no data was updated!) break; } }); } } }