using UnityEngine; using System.Collections; public class GetCouponButtonHandler : MonoBehaviour { void OnClick() { //if(string.IsNullOrEmpty(PlayerPrefs.GetString("NumberPhone"))) { NGUIMenuScript.Instance.GetCoupon = true; LoginManager.Instance.CouponGetEnterNumber.Show(); } //else //{ // onDonePhone(); //} } private void onDonePhone() { ServerGiftManager.Instance.ConsumeToken(); ServerGiftManager.Instance.SendCoupon(PlayerPrefs.GetString("NumberPhone"), (done, message, errorCode) => { if (done) { //GetComponent().DeactivateButton(); //NGUIMenuScript.Instance.ShowMenu(NGUIMenuScript.NGUIMenus.SendCoupone); foreach (var b in LoginManager.Instance.ButtonsCoupon) { if (b.gameObject.activeSelf) { b.DeactivateButton(); } } PlayerPrefs.SetInt("CloseEnterNumber", 0); PlayerPrefs.SetInt("GetCoupon", 0); PlayerPrefs.SetInt("giftNum", 0); LoginManager.Instance.ScreenSendSmsMessages.Show(); if (NGUIMenuScript.Instance.CurStatePopup == NGUIMenuScript.StatesMenuForPopup.GameOver) { } else if (NGUIMenuScript.Instance.CurStatePopup == NGUIMenuScript.StatesMenuForPopup.Menu) { } else { LoginManager.Instance.OnClickOkLevelDone(); } Debug.LogWarning("SendCoupon"); switch (InGameScriptCS.Instance.Level) { case 1: KHD.FlurryAnalyticsTest.Instance.SendPhone(); break; case 2: KHD.FlurryAnalyticsTest.Instance.SendPhone(); break; case 3: KHD.FlurryAnalyticsTest.Instance.SendPhone(); break; case 0: switch (ServerGiftManager.Instance.LevelServer) { case 1: KHD.FlurryAnalyticsTest.Instance.SendPhone(); break; case 2: KHD.FlurryAnalyticsTest.Instance.SendPhone(); break; case 3: KHD.FlurryAnalyticsTest.Instance.SendPhone(); break; } break; } //TODO coupon sent } else { switch (message) { case "coupon is activated already": PlayerPrefs.SetInt("GetCoupon", 0); LoginManager.Instance.OnClickOkLevelDone(); Debug.Log("coupon is activated already"); break; } Debug.Log(errorCode); switch (errorCode) { case 56: Debug.LogError("//TODO handle error: deviceID is not registered"); //TODO handle error: deviceID is not registered break; case 57: Debug.LogError("//TODO handle error: no deviceID"); //TODO handle error: no deviceID break; case 58: Debug.LogError("//TODO handle error: phone number does not provided"); //TODO handle error: phone number does not provided break; case 59: Debug.LogError("//TODO handle error: no deviceID"); //TODO handle error: request error break; } } }); Debug.Log("onDonePhone"); PlayerPrefs.SetInt("Phone", 1); } }