123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870 |
- using System;
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- using System.Linq;
- using Prime31;
- public class ServerGiftManager : MonoBehaviour {
- public enum RegistrationStates
- {
- New,
- Old,
- UpdateDone,
- SantaNameNotUnique,
- IdentificatorNotIsset,
- ContactsIsNotEnough,
- Error
- }
- public class GiftInfo
- {
- public static GiftInfo GetInfo()
- {
- return new GiftInfo(PlayerPrefs.GetString("GiftTokenInfo",""));
- }
- public static void Save(GiftInfo info)
- {
- PlayerPrefs.SetString("GiftTokenInfo",info.ToString());
- }
- public static void Consume()
- {
- PlayerPrefs.SetString("GiftTokenInfo", "");
- }
- public bool HasToken
- {
- get { return _lastTokenDate.Date == DateTime.Today && _token > 0; }
- }
- private DateTime _lastTokenDate;
- private int _token;
- public int Token
- {
- get
- {
- if (HasToken)
- {
- return _token;
- }
- return 0;
- }
- }
- public GiftInfo(string source)
- {
- _lastTokenDate = DateTime.MinValue;
- if (!String.IsNullOrEmpty(source))
- {
- var arr = source.Split(':');
- _lastTokenDate = DateTime.FromBinary(Int64.Parse(arr[0]));
- _token = Int32.Parse(arr[1]);
- }
- }
- public GiftInfo(int token)
- {
- _token = token;
- _lastTokenDate = DateTime.Now;
- }
- public override string ToString()
- {
- if (HasToken)
- {
- return String.Format("{0}:{1}",_lastTokenDate.Date.ToBinary(),_token);
- }
- return "";
- }
- }
- internal void SetAge(object text, Func<object, object> p)
- {
- throw new NotImplementedException();
- }
- public static string ID;
- private static string DeviceID
- {
- get
- {
- return (SystemInfo.deviceUniqueIdentifier + ID);
- }
- }
- public bool PhoneProvided;// { get; private set; }
- public bool SantaNameProvided;// { get; private set; }
- public bool EmailProvided;// { get; private set; }
- public static ServerGiftManager Instance {
- get
- {
- if (!_instance)
- {
- _instance = new GameObject("_serverGiftManager").AddComponent<ServerGiftManager>();
- DontDestroyOnLoad(_instance.gameObject);
- }
- return _instance;
- }
- }
- private static ServerGiftManager _instance;
- public int LevelServer;
- public int GiftNum;
- public int ScheduleID;
- void Awake ()
- {
- //for (int i = 0; i < 20; i++)
- //{
- // Debug.LogError(Guid.NewGuid().ToString());
- //}
- Debug.Log(PlayerPrefs.GetInt("GetCoupon"));
- Debug.Log(PlayerPrefs.GetString("NumberPhone"));
- //PlayerPrefs.DeleteAll();
- // PlayerPrefs.SetInt("GetCoupon", 0);
- //PlayerPrefs.SetString("NumberPhone", "");
- PlayerPrefs.Save();
- if (PlayerPrefs.GetInt("Level") == 0)
- {
- PlayerPrefs.SetInt("Level", 1);
- }
-
- //PlayerPrefs.SetInt("FirstEnter", 0);
- ID = "f77";
- if (_instance && _instance != this)
- {
- Destroy(gameObject);
- return;
- }
-
- }
- private static void TESTCALL()
- {
- ServerGiftManager.Instance.RequestTreeUpdate(meals =>
- {
- if (meals == -1)
- {
- //todo: server error, or wrong number filled
- }
- else
- {
- //todo: handle meals amount (everything goes good)
- }
- });
- ServerGiftManager.Instance.BaseRegistration((state, santaName) =>
- {
- switch (state)
- {
- case RegistrationStates.New:
- //todo: handle - user was registered from scratch (everything goes good)
- break;
- case RegistrationStates.Old:
- //todo: handle - old user returns (everything goes good)
- break;
- case RegistrationStates.Error:
- //todo: handle - unknown error happens - maybe internet connection errors (no data was updated!)
- break;
- }
- Debug.LogWarning(state + " " + santaName);
- });
- ServerGiftManager.Instance.FullRegistration("BestSanta", "+38 (063) 270-08-56", "m-snowy@mail.ru", state =>
- {
- switch (state)
- {
- case RegistrationStates.UpdateDone:
- //todo: handle - user info was updated (everything goes good)
- break;
- case RegistrationStates.Old:
- //todo: handle - old user returns (everything goes good)
- break;
- case RegistrationStates.SantaNameNotUnique:
- //todo: handle - user should guess another name for santa (no data was updated!)
- break;
- case RegistrationStates.IdentificatorNotIsset:
- //todo: handle - you must run base registration first! (no data was updated!)
- break;
- case RegistrationStates.ContactsIsNotEnough:
- //todo: handle - target field - santaName or phone or e-mail is empty (no data was updated!)
- break;
- case RegistrationStates.Error:
- //todo: handle - unknown error happens - maybe internet connection errors (no data was updated!)
- break;
- }
- Debug.LogWarning(state);
- });
- ServerGiftManager.Instance.GetGiftToken(info =>
- {
- if (info.HasToken)
- {
- //todo: handle - user achieve gift token - we can give coupon
- }
- else
- {
- //todo: handle - no token!
- }
- Debug.LogWarning(info.HasToken + " " + info.Token);
- });
- ServerGiftManager.Instance.ConsumeToken();
- //ServerGiftManager.Instance.SendCoupon((done, message,errorCode) =>
- //{
- // if (done)
- // {
- // //TODO coupon sent
- // }
- // else
- // {
- // switch (errorCode)
- // {
- // case 56:
- // //TODO handle error: deviceID is not registered
- // break;
- // case 57:
- // //TODO handle error: no deviceID
- // break;
- // case 58:
- // //TODO handle error: phone number does not provided
- // break;
- // case 59:
- // //TODO handle error: request error
- // break;
- // }
- // }
- //});
- }
- public void ConsumeToken()
- {
- GiftInfo.Consume();
- KHD.FlurryAnalyticsTest.Instance.CouponWon();
- }
- public void GetGiftToken(Action<GiftInfo> onDone)
- {
- //Debug.Log("GetGiftTokenRoutine");
- var info = GiftInfo.GetInfo();
- if (info.HasToken)
- {
- onDone(info);
- StartCoroutine(GetGiftTokenRoutine(info, onDone));
- }
- else
- {
- StartCoroutine(GetGiftTokenRoutine(info,onDone));
- }
- }
- static string remSkob(string input)
- {
- char[] arr = input.ToCharArray();
- char[] arr2 = new char[input.ToCharArray().Length];
- for (int i = 0; i < arr.Length; i++)
- {
- if (arr[i] == '{')
- {
-
- int k = i + 1;
- arr2[i] = '{';
- while (arr[k] != '}')
- {
- //arr[k] = '\0';
- arr2[k] = arr[k];
- k++;
- }
- arr2[k] = arr[k];
- }
- }
- string result = "";
- for (int i = 0; i < arr2.Length; i++)
- {
- if (arr2[i] != '\0')
- {
- result += arr2[i];
- }
- }
- return result;
- }
- private IEnumerator GetGiftTokenRoutine(GiftInfo def,Action<GiftInfo> onDone)
- {
- WWW www = new WWW("");
- var linq = "";
- if (InGameScriptCS.Instance.Level > 0 && InGameScriptCS.Instance.Level <= 3)
- {
- linq = string.Format("https://game.gamatic.com/app_runner_dk/RegScripts/GetGift.php?identificator={0}&lvl={1}", DeviceID, InGameScriptCS.Instance.Level);
- www = new WWW(linq);
-
- }
- else
- {
- linq = string.Format("https://game.gamatic.com/app_runner_dk/RegScripts/GetGift.php?id={0}", DeviceID);
- www = new WWW(linq);
-
- }
- Debug.LogError(linq);
- yield return www;
- var result = remSkob(www.text);
- if (!string.IsNullOrEmpty(www.error))
- {
- onDone(def);
- }
- else
- {
- string res = "";
- var response = (JsonObject)Json.decode(www.text);
- if (response == null)
- {
- res = result;
- }
- else
- {
-
- if (response != null)
- {
- res = response["response"] == null ? "" : response["response"].ToString().ToLower();
- }
- }
- try
- {
- if (res.Contains("giftNum"))
- {
- res = "available";
- }
- }
- catch (Exception e)
- {
- Debug.LogError(e);
- }
- Debug.Log(res);
- switch (res)
- {
- case "available":
- if (PlayerPrefs.GetInt("GetCoupon") == 0)
- {
- ScheduleID = Int32.Parse(((JsonObject)Json.decode(result))["ScheduleID"].ToString());
-
- PlayerPrefs.SetInt("ScheduleID", ScheduleID);
- PlayerPrefs.Save();
- var token = Int32.Parse(((JsonObject)Json.decode(result))["giftNum"].ToString());
- GiftNum = token;
- PlayerPrefs.SetInt("giftNum", token);
- PlayerPrefs.Save();
- var newInfo = new GiftInfo(token);
- GiftInfo.Save(newInfo);
- onDone(newInfo);
- Debug.LogError("token");
- }
- yield return new WaitForSeconds(0.1f);
- break;
- case "day count error":
- var newInf = new GiftInfo(0);
- GiftInfo.Save(newInf);
- InGameScriptCS.Instance.GetComponent<ElementsGeneratorCS>().GetGift = false;
- onDone(newInf);
- yield return new WaitForSeconds(0.1f);
- break;
- default:
- onDone(def);
- yield return new WaitForSeconds(0.1f);
- break;
- }
- if (response==null)
- {
- yield return new WaitForSeconds(0.1f);
- }
- else
- {
- if (response.ContainsKey("lvl"))
- {
- string lvl = response["lvl"] == null ? "" : response["lvl"].ToString();
- LevelServer = int.Parse(lvl);
- }
- }
-
- }
- }
- public void RequestTreeUpdate(Action<int> onDone)
- {
- StartCoroutine(RequestTreeUpdateRoutine(onDone));
- }
- private IEnumerator RequestTreeUpdateRoutine(Action<int> onDone)
- {
- var www = new WWW("https://game.gamatic.com/app_runner_dk/meals.json");
- yield return www;
- if (!string.IsNullOrEmpty(www.error))
- {
- onDone(-1);
- }
- else
- {
- var response = ((JsonObject)Json.decode(www.text))["meals"].ToString().ToLower();
- int result = 0;
- if (int.TryParse(response, out result))
- {
- onDone(result);
- }
- else
- {
- onDone(-1);
- }
- }
- }
- public void RequestWeeksUpdate(Action<string> onDone)
- {
- StartCoroutine(RequestWeekUpdateRoutine(onDone));
- }
- private IEnumerator RequestWeekUpdateRoutine(Action<string> onDone)
- {
- var www = new WWW("https://game.gamatic.com/app_runner_dk/week.json");
- yield return www;
- if (!string.IsNullOrEmpty(www.error))
- {
- onDone(www.error);
- }
- else
- {
- var response = www.text;
- int result = 0;
- if (!string.IsNullOrEmpty(www.text))
- {
- onDone(www.text);
- }
- else
- {
- onDone("Empty");
- }
- }
- }
- public void BaseRegistration(Action<RegistrationStates, string> onDone)
- {
- StartCoroutine(BaseRegistrationRoutine(onDone));
- }
- public IEnumerator BaseRegistrationRoutine(Action<RegistrationStates, string> onDone)
- {
- var www = new WWW(string.Format("https://game.gamatic.com/app_runner_dk/RegScripts/Register.php?identificator={0}", WWW.EscapeURL(DeviceID)));
- yield return www;
- if (!string.IsNullOrEmpty(www.error))
- {
- onDone(RegistrationStates.Error,"");
- }
- else
- {
- var response = (JsonObject)Json.decode(www.text);
- var answer = response["response"].ToString().ToLower();
- string santaName = response["name"] == null ? "" : response["name"].ToString();
- string setted = response["Isset"] == null ? "" : response["Isset"].ToString();
- SantaNameProvided = !string.IsNullOrEmpty(santaName);
- PhoneProvided = setted.Contains("P");
- EmailProvided = setted.Contains("M");
- switch (answer)
- {
- case "isset":
- onDone(RegistrationStates.Old, santaName);
- break;
- case "added":
- onDone(RegistrationStates.New, santaName);
- break;
- default:
- onDone(RegistrationStates.Error,"");
- break;
- }
- }
- }
- public void RegisterPhone(string phone, Action<RegistrationStates> onDone)
- {
- if (string.IsNullOrEmpty(phone))
- {
- onDone(RegistrationStates.ContactsIsNotEnough);
- return;
- }
- StartCoroutine(FullRegistrationRoutine("", phone.Trim(), "", onDone));
- }
- public void RegisterMail(string mail, Action<RegistrationStates> onDone)
- {
- if (string.IsNullOrEmpty(mail))
- {
- onDone(RegistrationStates.ContactsIsNotEnough);
- return;
- }
- StartCoroutine(FullRegistrationRoutine("", "", mail.Trim(), onDone));
- }
- public void RegisterSantaName(string santaName, Action<RegistrationStates> onDone)
- {
- if (string.IsNullOrEmpty(santaName))
- {
- onDone(RegistrationStates.ContactsIsNotEnough);
- return;
- }
- StartCoroutine(FullRegistrationRoutine(santaName.Trim(), "", "", onDone));
- }
- public void FullRegistration(string santaName, string phone, string email,Action<RegistrationStates> onDone)
- {
- if (string.IsNullOrEmpty(phone) || string.IsNullOrEmpty(email) || string.IsNullOrEmpty(santaName))
- {
- onDone(RegistrationStates.ContactsIsNotEnough);
- return;
- }
- StartCoroutine(FullRegistrationRoutine(santaName,phone,email,onDone));
- }
- protected IEnumerator FullRegistrationRoutine(string santaName, string phone, string email, Action<RegistrationStates> onDone)
- {
- var www = new WWW(string.Format("https://game.gamatic.com/app_runner_dk/RegScripts/Register.php?identificator={0}&name={1}&phone={2}&email={3}", WWW.EscapeURL(DeviceID), WWW.EscapeURL(santaName), WWW.EscapeURL(phone), WWW.EscapeURL(email)));
- yield return www;
- //Debug.Log(www.url);
- if (!string.IsNullOrEmpty(www.error))
- {
- onDone(RegistrationStates.Error);
- }
- else
- {
- var response = (JsonObject)Json.decode(www.text);
- var answer = response["response"].ToString().ToLower();
- if (string.IsNullOrEmpty(RegistrationManager.Instance.CurName))
- {
- SantaNameProvided = !string.IsNullOrEmpty(santaName);
- }
-
- string setted = response["Isset"] == null ? "" : response["Isset"].ToString();
- PhoneProvided = setted.Contains("P");
- EmailProvided = setted.Contains("M");
- switch (answer)
- {
- case "identificator not isset":
- onDone(RegistrationStates.IdentificatorNotIsset);
- break;
- case "update is succesfull":
- //Debug.Log((RegistrationManager.Instance == null) +" "+ santaName .ToString()+ " RegistrationManager.Instance is NULL!");
- if (RegistrationManager.Instance && !string.IsNullOrEmpty(santaName))
- {
- RegistrationManager.Instance.CurName = santaName;
- }
- else
- {
- Debug.Log("RegistrationManager.Instance is NULL!");
- }
-
- onDone(RegistrationStates.UpdateDone);
- break;
- case "isset":
- onDone(RegistrationStates.Old);
- break;
- case "namenotunique":
- onDone(RegistrationStates.SantaNameNotUnique);
- break;
- default:
- onDone(RegistrationStates.Error);
- break;
- }
- Debug.Log(answer);
- }
- }
- public void SetLevel(int lvl,Action<object> onDone)
- {
- if (lvl == 0)
- {
- return;
- }
- StartCoroutine(SendGetLevel(lvl, onDone));
- }
- private IEnumerator SendGetLevel(int lvl, Action<object> onDone)
- {
- var www = new WWW(string.Format("https://game.gamatic.com/app_runner_dk/RegScripts/GetGift.php?identificator={0}&lvl={1}", WWW.EscapeURL(DeviceID), WWW.EscapeURL(lvl.ToString())));
- yield return www;
- Debug.Log(www.url);
- if (!string.IsNullOrEmpty(www.error))
- {
- onDone(RegistrationStates.Error);
- }
- else
- {
-
- //var answer = response["result"].ToString().ToLower();
- //Debug.Log(answer);
- //if (string.IsNullOrEmpty(RegistrationManager.Instance.CurName))
- //{
- // SantaNameProvided = !string.IsNullOrEmpty(santaName);
- //}
- //string setted = response["Isset"] == null ? "" : response["Isset"].ToString();
- //PhoneProvided = setted.Contains("P");
- //EmailProvided = setted.Contains("M");
- //switch (answer)
- //{
- //}
- //Debug.Log(answer);
- }
- }
- public void GetLevel( Action<object> onDone)
- {
-
- StartCoroutine(SendGetLevel(onDone));
- }
- private IEnumerator SendGetLevel(Action<object> onDone)
- {
- var www = new WWW(string.Format("https://game.gamatic.com/app_runner_dk/RegScripts/GetGift.php?id={0}", WWW.EscapeURL(DeviceID)));
- yield return www;
- //Debug.Log(www.url);
- if (!string.IsNullOrEmpty(www.error))
- {
- //onDone(RegistrationStates.Error);
- }
- else
- {
- var response = (JsonObject)Json.decode(www.text);
- if (response.ContainsKey("lvl"))
- {
- string lvl = response["lvl"] == null ? "" : response["lvl"].ToString();
- //Debug.Log(lvl);
- if (!string.IsNullOrEmpty(lvl))
- {
- switch (lvl)
- {
- case "null":
- Debug.Log("null");
- break;
- }
- LevelServer = int.Parse(lvl);
- }
- else
- {
- LevelServer = 0;
- }
- }
- else
- {
- LevelServer = 0;
- }
- onDone(LevelServer);
-
- //Debug.Log(response);
- //var answer = response["result"].ToString().ToLower();
- //Debug.Log(answer);
- //if (string.IsNullOrEmpty(RegistrationManager.Instance.CurName))
- //{
- // SantaNameProvided = !string.IsNullOrEmpty(santaName);
- //}
- //string setted = response["Isset"] == null ? "" : response["Isset"].ToString();
- //PhoneProvided = setted.Contains("P");
- //EmailProvided = setted.Contains("M");
- //switch (answer)
- //{
-
- //}
- //Debug.Log(answer);
- }
- }
- public void SendInviteMailToserv(string email, Action<object> onDone)
- {
- if (string.IsNullOrEmpty(email))
- {
- onDone(RegistrationStates.ContactsIsNotEnough);
- return;
- }
- StartCoroutine(SendInviteMail(email, onDone));
- }
- private IEnumerator SendInviteMail(string email, Action<object> onDone)
- {
- var www = new WWW(string.Format("https://game.gamatic.com/app_runner_dk/RegScripts/SendInvite.php?uid={0}&Mail={1}", WWW.EscapeURL(DeviceID), WWW.EscapeURL(email)));
- yield return www;
- //Debug.Log(www.url);
- if (!string.IsNullOrEmpty(www.error))
- {
- onDone(RegistrationStates.Error);
- }
- else
- {
- var response = SimpleJSON.JSON.Parse(www.text)["Result"].ToString();
- onDone(response);
- Debug.Log(response);
- //var answer = response["result"].ToString().ToLower();
- //Debug.Log(answer);
- //if (string.IsNullOrEmpty(RegistrationManager.Instance.CurName))
- //{
- // SantaNameProvided = !string.IsNullOrEmpty(santaName);
- //}
- //string setted = response["Isset"] == null ? "" : response["Isset"].ToString();
- //PhoneProvided = setted.Contains("P");
- //EmailProvided = setted.Contains("M");
- //switch (answer)
- //{
- //}
- //Debug.Log(answer);
- }
- }
- public void SendCoupon(string phone,Action<bool, string, int> onDone)
- {
- Debug.Log( " phone " + phone + " " + WWW.EscapeURL(DeviceID));
- StartCoroutine(SendCouponRoutine(phone,onDone));
- }
-
- public void GetGiftActive(string giftId, Action onDone)
- {
- StartCoroutine(SendGetGiftOnRoad(giftId, onDone));
- }
- private IEnumerator SendGetGiftOnRoad(string giftId, Action onDone)
- {
- var www = new WWW(string.Format("https://game.gamatic.com/app_runner_is/RegScripts/GetGift.php?gift_id={0}", giftId));
- yield return www;
- Debug.Log(www.text);
- if (!string.IsNullOrEmpty(www.error))
- {
- //onDone(RegistrationStates.Error);
- Debug.LogError("error");
- }
- else
- {
- var response = (JsonObject)Json.decode(www.text);
- if (response.ContainsKey("success"))
- {
- Debug.LogError("success");
- }
- else if (response.ContainsKey("success"))
- {
- Debug.LogError("success");
- }
- onDone();
- }
- }
- protected IEnumerator SendCouponRoutine(string phone,Action<bool, string, int> onDone)
- {
-
- var linq = string.Format(
- "https://game.gamatic.com/CokeCaps/MIX/couponToken_V3d.php?identificator={0}&phone={1}&lvl={2}&ScheduleID={3}",
- WWW.EscapeURL(DeviceID), phone, LevelServer, PlayerPrefs.GetInt("ScheduleID"));
- Debug.LogError(linq);
- var www = new WWW(linq);
-
- yield return www;
- if (!string.IsNullOrEmpty(www.error))
- {
- onDone(false, www.error,100);
- }
- else
- {
- bool done = false;
- var result = remSkob(www.text);
- var answer = ((JsonObject)Json.decode(result));
- if (answer.ToString().Contains("issued"))
- {
- LoginManager.Instance.BackMessageCoupone.SetActive(true);
- LoginManager.Instance.CouponNumberWronge.Show();
-
- }
- else if (answer.ToString().Contains("successful"))
- {
- done = true;
- }
- else
- {
- if (answer.ToString().Contains("successful"))
- {
- done = answer["status"].ToString().Equals("done");
- }
-
- }
- int errorCode = answer.ContainsKey("errorCode") ? int.Parse(answer["errorCode"].ToString()) : 0;
- string message = answer.ContainsKey("errorCode")? answer["errorDesc"].ToString():"";
- //bool done = answer["status"].ToString().Equals("done");
- onDone(done, message, errorCode);
- }
- }
- public void GetAgeAction(Action<object> onDone)
- {
- StartCoroutine(GetAge(onDone));
- }
- protected IEnumerator GetAge(Action<object> onDone)
- {
- var www = new WWW(string.Format("https://game.gamatic.com/app_runner_dk/RequestCheck.php?GetAge={0}&uid={1}", 1, WWW.EscapeURL(DeviceID)));
- yield return www;
- if (!string.IsNullOrEmpty(www.error))
- {
- onDone(RegistrationStates.Error);
- }
- else
- {
- var response = www.text;
- if (response == 1.ToString())
- {
- LoginManager.Instance.Age = true;
- }
-
- onDone(response);
- }
- }
- public void SetAgeAction(Action<object> onDone)
- {
- Debug.Log(DeviceID);
- StartCoroutine(SetAge(onDone));
- }
- protected IEnumerator SetAge(Action<object> onDone)
- {
- var www = new WWW(string.Format("https://game.gamatic.com/app_runner_dk/RequestCheck.php?SetAge={0}&uid={1}", 1, WWW.EscapeURL(DeviceID)));
- yield return www;
- if (!string.IsNullOrEmpty(www.error))
- {
- onDone(RegistrationStates.Error);
- }
- else
- {
- var response = www.text;
- onDone(response);
- }
- }
- }
|