//-------------------------------------------------------------------------------- // onClickForgotPassword //-------------------------------------------------------------------------------- public void onClickForgotPassword() { if (inputUsername != null && inputEmail != null) { if (LoomClient.validateName(inputUsername.text) || LoomClient.validateEmail(inputEmail.text) ) { string[] fields = new string[] { inputUsername.text, inputEmail.text }; TemporaryDisable(buttonForgot); LoomClient.ActionForgotPassword(fields, onCallbackForgotPassword); } else { FindObjectOfType <LC_UIPanelMessage>().Show(LoomClient.LANG_ERROR); } } else { Debug.LogWarning(LoomClient.LANG_EDITOR_MISSING + this.name); } }
//-------------------------------------------------------------------------------- // onClickChangePassword //-------------------------------------------------------------------------------- public void onClickChangePassword() { if (inputPasswordOld != null && inputPassword != null && inputPasswordRepeat != null) { if (LoomClient.validatePassword(inputPasswordOld.text) && LoomClient.validatePassword(inputPassword.text) && LoomClient.validatePassword(inputPasswordRepeat.text) && inputPasswordOld.text != inputPassword.text ) { string[] fields = new string[] { inputPasswordOld.text, inputPassword.text }; TemporaryDisable(buttonChange); LoomClient.ActionChangeAccountPassword(fields, onCallbackChangePassword); } else { FindObjectOfType <LC_UIPanelMessage>().Show(LoomClient.LANG_ERROR); } } else { Debug.LogWarning(LoomClient.LANG_EDITOR_MISSING + this.name); } }
//-------------------------------------------------------------------------------- // onClickLogin //-------------------------------------------------------------------------------- public void onClickLogin() { if (inputUsername != null && inputPassword != null ) { if (LoomClient.validateName(inputUsername.text) && LoomClient.validatePassword(inputPassword.text)) { string[] fields = new string[] { inputUsername.text, inputPassword.text, LoomClient.AppId }; TemporaryDisable(buttonLogin); LoomClient.ActionLogin(fields, onCallbackLogin); } else { FindObjectOfType <LC_UIPanelMessage>().Show(LoomClient.LANG_ERROR); } } else { Debug.LogWarning(LoomClient.LANG_EDITOR_MISSING + this.name); } }
// ------------------------------------------------------------------------------- // GetInstance (Singleton) // ------------------------------------------------------------------------------- public static LoomClient GetInstance() { if (!_instance) { GameObject client = new GameObject("LoomClient"); _instance = client.AddComponent <LoomClient>(); } return(_instance); }
//-------------------------------------------------------------------------------- // onCheckVersion //-------------------------------------------------------------------------------- private void onCheckVersion() { if (text != null) { LoomClient.ActionCheckVersion(new string[] { LoomClient.AppId, LoomClient.LOOM_VERSION }, onCallbackCheckVersion); } else { Debug.LogWarning(LoomClient.LANG_EDITOR_MISSING + this.name); } }
//-------------------------------------------------------------------------------- // onCallbackLogin //-------------------------------------------------------------------------------- private void onCallbackLogin(string[] result) { if (result[0] == "1") { LoomClient.Login(result); Hide(); } else { FindObjectOfType <LC_UIPanelMessage>().Show(LoomClient.LANG_LOGIN_FAIL); } }
//-------------------------------------------------------------------------------- // onClickLogout //-------------------------------------------------------------------------------- public void onClickLogout() { if (buttonLogout != null) { TemporaryDisable(buttonLogout); LoomClient.Logout(); } else { Debug.LogWarning(LoomClient.LANG_EDITOR_MISSING + this.name); } }
//-------------------------------------------------------------------------------- // onCallbackDeleteAccount //-------------------------------------------------------------------------------- private void onCallbackDeleteAccount(string[] result) { if (result[0] == "1") { Hide(); FindObjectOfType <LC_UIPanelMessage>().Show(LoomClient.LANG_DELETE_CONFIRM); LoomClient.Logout(); } else { FindObjectOfType <LC_UIPanelMessage>().Show(LoomClient.LANG_DELETE_FAIL); } }
//-------------------------------------------------------------------------------- // onClickSell //-------------------------------------------------------------------------------- public void onClickSell() { if (objectType == LoomClient.LOOM_ENUM_VIRTUAL_OBJ_TYPE.virtualCurrency) { string[] fields = new string[] { objectId.ToString(), sliderAmount.value.ToString() }; TemporaryDisable(buttonSell); LoomClient.ActionSellCurrency(fields, onCallbackSell); } else if (objectType == LoomClient.LOOM_ENUM_VIRTUAL_OBJ_TYPE.virtualGood) { } else if (objectType == LoomClient.LOOM_ENUM_VIRTUAL_OBJ_TYPE.virtualProperty) { } }
//-------------------------------------------------------------------------------- // OnInvokeRepeating //-------------------------------------------------------------------------------- public override void OnInvokeRepeating() { if (objectType == LoomClient.LOOM_ENUM_VIRTUAL_OBJ_TYPE.virtualCurrency) { LoomClient.ActionGetCurrencies(onCallbackGetCurrencies); } else if (objectType == LoomClient.LOOM_ENUM_VIRTUAL_OBJ_TYPE.virtualGood) { LoomClient.ActionGetGoods(onCallbackGetGoods); } else if (objectType == LoomClient.LOOM_ENUM_VIRTUAL_OBJ_TYPE.virtualProperty) { LoomClient.ActionGetProperties(onCallbackGetProperties); } else if (objectType == LoomClient.LOOM_ENUM_VIRTUAL_OBJ_TYPE.virtualEntity) { LoomClient.ActionGetEntities(onCallbackGetEntities); } }
//-------------------------------------------------------------------------------- // onClickDeleteAccount //-------------------------------------------------------------------------------- public void onClickDeleteAccount() { if (inputUsername != null && inputPassword != null) { if (LoomClient.validateName(inputUsername.text) && LoomClient.validatePassword(inputPassword.text) ) { string[] fields = new string[] { inputUsername.text, inputPassword.text }; TemporaryDisable(buttonDelete); LoomClient.ActionDeleteAccount(fields, onCallbackDeleteAccount); } } else { Debug.LogWarning(LoomClient.LANG_EDITOR_MISSING + this.name); } }
// ------------------------------------------------------------------------------- // resetClient // ------------------------------------------------------------------------------- private static void resetClient() { _instance = null; AccountOnline = false; }
//-------------------------------------------------------------------------------- // ActionForgotPassword //-------------------------------------------------------------------------------- public static void ActionForgotPassword(string[] fields, Action <string[]> callbackFunction) { LoomClient.SendData(1, 2, fields, callbackFunction); }
// =============================================================================== // UNITY RELATED FUNCTIONS // =============================================================================== // ------------------------------------------------------------------------------- // OnApplicationQuit // ------------------------------------------------------------------------------- void OnApplicationQuit() { LoomClient.Logout(); }
// ------------------------------------------------------------------------------- // Logout // ------------------------------------------------------------------------------- public static void Logout() { LoomClient.ActionLogout(onCallbackLogout); }
//-------------------------------------------------------------------------------- // ActionLogin //-------------------------------------------------------------------------------- public static void ActionLogin(string[] fields, Action <string[]> callbackFunction) { LoomClient.SendData(1, 3, fields, callbackFunction); }
//-------------------------------------------------------------------------------- // ActionRegisterAccount //-------------------------------------------------------------------------------- public static void ActionRegisterAccount(string[] fields, Action <string[]> callbackFunction) { LoomClient.SendData(1, 5, fields, callbackFunction); }
//-------------------------------------------------------------------------------- // onClickTabGoods //-------------------------------------------------------------------------------- public void onClickTabGoods() { objectType = LoomClient.LOOM_ENUM_VIRTUAL_OBJ_TYPE.virtualGood; LoomClient.ActionGetGoods(onCallbackGetGoods); }
//-------------------------------------------------------------------------------- // ActionDeleteAccount //-------------------------------------------------------------------------------- public static void ActionDeleteAccount(string[] fields, Action <string[]> callbackFunction) { LoomClient.SendData(2, 7, fields, callbackFunction); }
//-------------------------------------------------------------------------------- // ActionChangeAccountPassword //-------------------------------------------------------------------------------- public static void ActionChangeAccountPassword(string[] fields, Action <string[]> callbackFunction) { LoomClient.SendData(2, 6, fields, callbackFunction); }
//-------------------------------------------------------------------------------- // ActionResendConfirmation //-------------------------------------------------------------------------------- public static void ActionResendConfirmation(string[] fields, Action <string[]> callbackFunction) { LoomClient.SendData(1, 6, fields, callbackFunction); }
//-------------------------------------------------------------------------------- // ActionSellEntity //-------------------------------------------------------------------------------- public static void ActionSellEntity(string[] fields, Action <string[]> callbackFunction) { LoomClient.SendData(7, 2, fields, callbackFunction); }
// =============================================================================== // TAB BUTTON FUNCTIONS // =============================================================================== //-------------------------------------------------------------------------------- // onClickTabCurrencies //-------------------------------------------------------------------------------- public void onClickTabCurrencies() { objectType = LoomClient.LOOM_ENUM_VIRTUAL_OBJ_TYPE.virtualCurrency; LoomClient.ActionGetCurrencies(onCallbackGetCurrencies); }
//-------------------------------------------------------------------------------- // ActionLogout //-------------------------------------------------------------------------------- public static void ActionLogout(Action <string[]> callbackFunction) { LoomClient.SendData(1, 4, new string[] {}, callbackFunction, true); }
//-------------------------------------------------------------------------------- // onClickTabProperties //-------------------------------------------------------------------------------- public void onClickTabProperties() { objectType = LoomClient.LOOM_ENUM_VIRTUAL_OBJ_TYPE.virtualProperty; LoomClient.ActionGetProperties(onCallbackGetProperties); }
// ------------------------------------------------------------------------------- // SendData // ------------------------------------------------------------------------------- public static void SendData(int categoryId, int actionId, string[] fields, Action <string[]> callbackFunction, bool runSilent = false) { LoomClient instance = GetInstance(); instance.StartCoroutine(instance.WebRequestSend(categoryId, actionId, fields, callbackFunction, runSilent)); }
//================================================================================ // CLIENT //================================================================================ //-------------------------------------------------------------------------------- // ActionCheckVersion //-------------------------------------------------------------------------------- public static void ActionCheckVersion(string[] fields, Action <string[]> callbackFunction) { LoomClient.SendData(1, 0, fields, callbackFunction); }
//================================================================================ // ENTITIES //================================================================================ //-------------------------------------------------------------------------------- // ActionGetEntities //-------------------------------------------------------------------------------- public static void ActionGetEntities(Action <string[]> callbackFunction) { LoomClient.SendData(7, 0, new string[] {}, callbackFunction); }
//-------------------------------------------------------------------------------- // Show //-------------------------------------------------------------------------------- public override void OnChildEnable() { LoomClient.GetInstance(); text.text = LoomClient.LANG_CHECK_VERSION; onCheckVersion(); }
//-------------------------------------------------------------------------------- // ActionBuyProperty //-------------------------------------------------------------------------------- public static void ActionBuyProperty(string[] fields, Action <string[]> callbackFunction) { LoomClient.SendData(6, 1, fields, callbackFunction); }