1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- using UnityEngine;
- using System.Collections;
- public class RenameButtonHandler : MonoBehaviour {
- public UILabel Label;
- public MessageCodeCap UIMessage;
-
- //public GameObject UIWarning;
- void Start()
- {
- //UIWarning.SetActive(false);
- }
- void OnClick()
- {
- if (Label.text == string.Empty || Label.text == "Nytt namm...")
- {
- //UIMessage.LabelMessage.text = "Felaktigt namn. Försök igen.";
- // UIMessage.GetComponent<ScreenBase>().Show();
- NGUIMenuScript.Instance.ShowMenu(NGUIMenuScript.NGUIMenus.Menu);
- NGUITools.SetActive(this.transform.parent.gameObject, false);
- }
- else
- {
- ServerGiftManager.Instance.RegisterSantaName(Label.text, state =>
- {
- switch (state)
- {
- case ServerGiftManager.RegistrationStates.UpdateDone:
- NGUIMenuScript.Instance.ShowMenu(NGUIMenuScript.NGUIMenus.Menu);
- NGUITools.SetActive(this.transform.parent.gameObject, false);
- Debug.Log("UpdateDone");
- Label.text = "Nytt namm...";
- //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<ScreenBase>().Show();
- Label.text = "Nytt namm...";
- Debug.Log("SantaNameNotUnique");
- //todo: handle - user should guess another name for santa (no data was updated!)
- break;
- case ServerGiftManager.RegistrationStates.IdentificatorNotIsset:
- Debug.Log("IdentificatorNotIsset");
- Label.text = "Nytt namm...";
- //todo: handle - you must run base registration first! (no data was updated!)
- break;
- case ServerGiftManager.RegistrationStates.ContactsIsNotEnough:
- Debug.Log("ContactsIsNotEnough");
- Label.text = "Nytt namm...";
- //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<ScreenBase>().Show();
- Label.text = "Nytt namm...";
- //todo: handle - unknown error happens - maybe internet connection errors (no data was updated!)
- break;
- }
-
- Debug.LogWarning(state);
- });
- }
- }
- }
|