void loadInfo() { WelcomePanel.SetActive(true); LoginPanel.SetActive(false); RegisterPanel.SetActive(false); MainPanel.SetActive(false); Loading.SetActive(true); var form = new WWWForm(); //here you create a new form connection form.AddField("token", PlayerPrefs.GetString("sid")); form.AddField("appid", APPID); form.AddField("sign", md5(PlayerPrefs.GetString("sid") + APPSERECT)); //send ObservableWWW.Post("http://tapp.vn/charge/code/authen_mini.html", form).TakeUntilDestroy(this).Subscribe( x => { Debug.Log(x); JSONObject obj = new JSONObject(x); UName.text = obj["data"]["username"].str; FloatingButton.SetActive(true); Loading.SetActive(false); //GameController.GetComponent<Done_GameController>().enabled = true; gameObject.SetActive(false); }, // onSuccess ex => { MobileNativeMessage msg = new MobileNativeMessage("TAPP.vn", "Có lỗi xảy ra"); }// onError ); }
public void BuyNonConsumable(string id) { if (UM_InAppPurchaseManager.Instance.IsProductPurchased(id)) { MobileNativeMessage msg = new MobileNativeMessage("Already purchased", "You already purchased this item"); // GameData.SetRemoveAds(true); return; } UM_InAppPurchaseManager.Instance.Purchase(id); }
public void OnGetCoinButtonClick() { SoundsManager.instance.PlayMenuButtonSound(); if (Advertisement.IsReady()) { UnityRewardAds.instance.ShowRewardedAd(HandleShowResult); GetCoinButton.interactable = false; } else { MobileNativeMessage msg = new MobileNativeMessage("Error", "To use this feature please enable your internet connection"); } }
void OnGUI() { UpdateToStartPos(); GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "Native Pop Ups", style); StartY += YLableStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Rate PopUp with events")) { MobileNativeRateUs ratePopUp = new MobileNativeRateUs("Like this game?", "Please rate to support future updates!"); ratePopUp.SetAppleId(appleId); ratePopUp.SetAndroidAppUrl(androidAppUrl); ratePopUp.OnComplete += OnRatePopUpClose; ratePopUp.Start(); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Dialog PopUp")) { MobileNativeDialog dialog = new MobileNativeDialog("Dialog Titile", "Dialog message"); dialog.OnComplete += OnDialogClose; Invoke("Dismiss", 2.0f); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Message PopUp")) { MobileNativeMessage msg = new MobileNativeMessage("Message Titile", "Message message"); msg.OnComplete += OnMessageClose; } StartY += YButtonStep; StartX = XStartPos; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Show Prealoder")) { MNP.ShowPreloader("Title", "Message"); Invoke("OnPreloaderTimeOut", 3f); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Hide Prealoder")) { MNP.HidePreloader(); } }
void OnGUI() { UpdateToStartPos(); GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "Native Pop Ups", style); StartY+= YLableStep; if(GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Rate PopUp with events")) { MobileNativeRateUs ratePopUp = new MobileNativeRateUs("Like this game?", "Please rate to support future updates!"); ratePopUp.SetAppleId(appleId); ratePopUp.SetAndroidAppUrl(apdroidAppUrl); ratePopUp.OnComplete += OnRatePopUpClose; ratePopUp.Start(); } StartX += XButtonStep; if(GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Dialog PopUp")) { MobileNativeDialog dialog = new MobileNativeDialog("Dialog Titile", "Dialog message"); dialog.OnComplete += OnDialogClose; } StartX += XButtonStep; if(GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Message PopUp")) { MobileNativeMessage msg = new MobileNativeMessage("Message Titile", "Message message"); msg.OnComplete += OnMessageClose; } StartY += YButtonStep; StartX = XStartPos; if(GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Show Prealoder")) { MNP.ShowPreloader("Title", "Message"); Invoke("OnPreloaderTimeOut", 3f); } StartX += XButtonStep; if(GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Hide Prealoder")) { MNP.HidePreloader(); } }
public void OnOneMoreChanceButtonClick() { SoundsManager.instance.PlayMenuButtonSound(); if (Advertisement.IsReady()) { UnityRewardAds.instance.ShowRewardedAd(HandleShowResult); GameManager.instance.gameState = GameManager.GameState.game; GameManager.instance.oneMoreChanceUsed = true; GameManager.instance.StartGame(false, false); Deactivate(); } else { MobileNativeMessage msg = new MobileNativeMessage("Error", "To use this feature please enable your internet connection"); } }
IEnumerator rutinaObtenerImagen() { //Debug.Log ("La corrutina inicia: " + image); Debug.Log ("La corrutina inicia... "); //yield return image; yield return new WaitForEndOfFrame (); //Debug.Log ("Imagen obtenida!!!!" + image); //Texture2D tex = new Texture2D ( image.Width, image.Height); //image.CopyToTexture (tex); //tex.Apply (); //de acuerdo con la documentacion de Unity esta puede ser una operacion de procescamiento intensiva //Debug.Log ("Ya se ha copiado la textura!!!"); /* //iniciando pruebas: Sprite test = new Sprite (); test = Sprite.Create (tex, new Rect (0, 0, tex.width, tex.height), new Vector2 (0f, 0f)); textura_prueba.GetComponent<UnityEngine.UI.Image> ().sprite = test; Debug.Log ("Antes de obtener el renderer!!!"); Material mater = GetComponent<Renderer> ().material; Texture2D textur = mater.mainTexture as Texture2D; Debug.Log ("Despues de obtener el renderer"); //terminando pruebas */ //Texture2D txt_girada = FlipTexture (tex); //Texture2D txt_horiz = FlipTextureHoriz (txt_girada); int ancho = Screen.width; int alto = Screen.height; Texture2D txt_girada = new Texture2D (ancho, alto, TextureFormat.RGB24, false); txt_girada.ReadPixels (new Rect (0, 0, ancho, alto), 0, 0); txt_girada.Apply (); byte[] bytes = txt_girada.EncodeToPNG(); //byte[] bytes = tex.EncodeToPNG(); Destroy( txt_girada ); //Mostrando el cuadro de feedback en la interfaz para que el estudiante no regrese hacia atras //mientras se esta enviando la imagen: if (feedback_obj != null && texto_feedback != null) { feedback_obj.GetComponent<UnityEngine.UI.Image> ().enabled = true; texto_feedback.GetComponent<UnityEngine.UI.Text> ().enabled = true; } //definiendo el nombre de la imagen con base en el codigo de estudiante y en el tipo de img: string nombre_imagen = this.codigo_estudiante + "_" + tipo_img + ".png"; // Create a Web Form WWWForm form = new WWWForm(); form.AddField("frameCount", Time.frameCount.ToString()); form.AddField("cod_estud", this.codigo_estudiante); form.AddField("tipo_img", this.tipo_img); //adjuntando los datos binarios para enviar la imagen (el nombre se ha definido anteriormente) form.AddBinaryData("fileimage", bytes, nombre_imagen, "image/png"); Debug.Log ("Se va a enviar el formulario !!"); // Upload to a cgi script WWW w = new WWW(this.url_servidor + "uploadimage.php", form); yield return w; if (!string.IsNullOrEmpty(w.error)) { //ocultando el cuadro del feedback porque ya se ha terminado la transferencia de la imagen: if (feedback_obj != null && texto_feedback != null) { feedback_obj.GetComponent<UnityEngine.UI.Image> ().enabled = false; texto_feedback.GetComponent<UnityEngine.UI.Text> ().enabled = false; } AppManager.manager.can_return_from_take_photo = true; //mostrando el feedback de ERROR en el envio del archivo: MobileNativeMessage mensaje_confirm = new MobileNativeMessage("Error","No se ha podido enviar la foto. Porfavor verifica que estas conectado a internet y que la conexion es buena. Informa al profesor de este problema.","Aceptar"); Debug.Log ("ERROR EN LA TRANSFERENCIA AL SERVIDOR" + w.error); } else { //ocultando el cuadro del feedback: if (feedback_obj != null && texto_feedback != null) { feedback_obj.GetComponent<UnityEngine.UI.Image> ().enabled = false; texto_feedback.GetComponent<UnityEngine.UI.Text> ().enabled = false; } AppManager.manager.can_return_from_take_photo = true; //mostrando el feedback de EXITO en el envio del archivo: MobileNativeMessage mensaje_confirm = new MobileNativeMessage("Datos enviados","La foto se ha enviado correctamente.","Aceptar"); Debug.Log ("Transferencia satisfactoria!!! --> " + w.text); } //cierra else //aqui se notifica al AppManager que ya se ha completado la actividad de tomar la foto //esto se hace invocando al metodo delegado ResultPhotoActivity enviando como parametros //la interfaz que solicito la accion y el tipo de imagen que se estaba tomando: this.ResultPhotoActivity (interface_coming_from, tipo_img); }
public void onRestorePurchases() { UM_InAppPurchaseManager.instance.RestorePurchases(); MobileNativeMessage msg = new MobileNativeMessage("Restoring Purchases", "Racing Manager will now check to see if you previously unlocked the game and will restore your purchases if any are found"); }
public void LoginAsGuest() { var epochStart = new System.DateTime(1970, 1, 1, 8, 0, 0, System.DateTimeKind.Utc); string time = (System.DateTime.UtcNow - epochStart).TotalSeconds.ToString(); var form = new WWWForm(); //here you create a new form connection form.AddField("type", "guess"); form.AddField("platform", "android"); form.AddField("username", "ad" + time); form.AddField("password", ""); form.AddField("appid", APPID); form.AddField("time", time); form.AddField("sign", md5(time + APPID + APPSERECT)); Loading.SetActive(true); //send ObservableWWW.Post(URLLOGIN, form).Subscribe( x => { Debug.Log(x); JSONObject obj = new JSONObject(x); PlayerPrefs.SetString("sid", (obj["token"].str)); loadInfo(); Loading.SetActive(false); }, // onSuccess ex => { MobileNativeMessage msg = new MobileNativeMessage("TAPP.vn", ex.ToString()); }// onError ); }
public void Login() { double CurrentTimestamp = (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0)).TotalSeconds; int timestamp = Mathf.RoundToInt((float)CurrentTimestamp); var form = new WWWForm(); //here you create a new form connection form.AddField("type", "login"); form.AddField("platform", "android"); form.AddField("username", usernameInput.text); form.AddField("password", passwordInput.text); form.AddField("appid", APPID); form.AddField("time", timestamp.ToString()); form.AddField("sign", md5(timestamp.ToString() + APPID + APPSERECT)); //send Loading.SetActive(true); ObservableWWW.Post(URLLOGIN, form).Subscribe( x => { Debug.Log(x); JSONObject obj = new JSONObject(x); if (obj["status"].i <= 0) { MobileNativeMessage msg = new MobileNativeMessage("TAPP.vn", "Thông tin đăng nhập không đúng"); } else { PlayerPrefs.SetString("sid", (obj["token"].str)); PlayerPrefs.SetString("uid", (obj["userid"].str)); loadInfo(); } Loading.SetActive(false); }, // onSuccess ex => Debug.LogException(ex) // onError ); }
public void game4() { MobileNativeMessage msg = new MobileNativeMessage("Info", "Coming soon!"); }
/// <summary> /// Notifies the login succeed. /// This method is called through a delegate method from the ControllerLoginUser /// </summary> /// <param name="logged">If set to <c>true</c> logged.</param> public void NotifyLoginSucceed(bool logged) { if (logged) { //Se inicia el proceso de inicializacion del archivo de datos que se almacena en la tablet: Debug.Log ("El archivo de datos del estudiante NO existe y se van a definir los datos por defecto:"); user_logged = true; DestroyImmediate (login_user_interface_instance); Debug.Log("El codigo de estudiante que se va a registrar es: " + codigo_estudiante); //asignando valores por defecto porque el archivo no existe: //evaluation_mode_enabled = false; //cambiando valor para pruebas de desarrollo evaluation_mode_enabled = true; //este valor originalmente debe ser false //Asignando valor por defecto para el estado de organizacion de las fases en el modo evaluacion: eval_mode_phases_organized = false; //Asignando valor por defecto para el estado de organizacion de los pasos de la FASE 1: eval_mode_phase1_steps_organized = false; //Asignando valor por defecto para el estado de organizacion de los pasos de la FASE 2: eval_mode_phase2_steps_organized = false; //el usuario ahora esta logueado: user_logged = true; //NOTA: El codigo del estudiante se asigna directamente desde ControllerLoginUser!! //inicializando los valores para las fases MODO GUIADO: phase_one_enable = true; phase_two_enable = false; phase_three_enable = false; phase_four_enable = false; phase_five_enable = false; phase_six_enable = false; //inicializando los valores para las fases MODO EVALUACION: phase_one_enable_eval_mode = true; phase_two_enable_eval_mode = false; phase_three_enable_eval_mode = false; phase_four_enable_eval_mode = false; phase_five_enable_eval_mode = false; phase_six_enable_eval_mode = false; //NOTA IMPORTANTE: Si el archivo de datos no existe, entonces se dejan por defecto los vectores //steps_phase_one_completed[] con la inicializacion en 0 que se hace desde el InitManager() //creando el archivo y guardando los datos por defecto: SaveDataForStudent (); //metodo que muestra el mensaje de inicio de sesion exitoso MobileNativeMessage mensaje_confirm = new MobileNativeMessage("Login Correcto","Has iniciado sesion correctamente","Aceptar"); //en modo compacto desde aca se redirecciona a la interfaz del challenge porque ha sido previamente eliminada //cuando se carga la interfaz del modo login: if(compact_mode){ GoToChallengeInterface (); } } else user_logged = false; }
/// <summary> /// Restarts the guided mode. /// This method is called mainly from the ConfigurationInterface from the SelectionOfMode interface /// in order to restart the guided mode /// </summary> public void RestartGuidedMode() { this.phase_one_enable = true; this.phase_two_enable = false; this.phase_three_enable = false; this.phase_four_enable = false; this.phase_five_enable = false; this.phase_six_enable = false; //reiniciando el vector que controla los pasos de la FASE 1: steps_phase_one_completed = new StepOfProcess[6]; for (int i = 0; i<steps_phase_one_completed.Length; i++) { steps_phase_one_completed [i] = new StepOfProcess (false, false,false,true,true); } //OJO Aqui hay que inicializar los pasos especificos donde SI hay actividad de tomar fotos: //debido a que en la fase 1 paso 6 hay una actividad de tomar fotos, entonces se reinicializa esa actividad en false: steps_phase_one_completed [5].take_photo_ficha_tecnica = false; steps_phase_one_completed [5].take_photo_ficha_seguridad = false; //reiniciando el vector que controla los pasos de la FASE 2: Debug.Log ("AppManager: Re-inicializando StepsOfProcess FASE 2 e inicializando..."); steps_phase_two_completed = new StepOfProcess[8]; for (int j = 0; j<steps_phase_two_completed.Length; j++) { steps_phase_two_completed[j] = new StepOfProcess(false,false,false,true,true); //se inicializa un vector con todas las actividades en false menos la ultima: tomar fotos (porque hay algunos pasos que no tienen esta actividad) } //se procede a guardar los datos en el dispositivo: SaveDataForStudent (); //Se notifica como registro de navegacion que el estudiante ha reiniciado el modo guiado: string fecha = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); NavigationControllerObject.navigation.RegistrarReinicioDeModo (this.codigo_estudiante, fecha, "RRMG", "0", "-1", "guiado"); //Notificando mendiante mensaje que se ha reiniciado el modo guiado: MobileNativeMessage mensaje_confirm = new MobileNativeMessage("Modo Guiado reiniciado","El Modo Guiado se ha reiniciado correctamente","Aceptar"); }
/// <summary> /// Restarts the evaluation mode. /// This method is maintly called from the ConfigurationInterface from the SelectionOfMode interface /// </summary> public void RestartEvaluationMode() { this.evaluation_mode_enabled = true; //estado de organizacion de las fases del proceso: this.eval_mode_phases_organized = false; //estado de organizacion de los pasos de la FASE 1: this.eval_mode_phase1_steps_organized = false; //estado de organizacion de los pasos de la FASE 2: this.eval_mode_phase2_steps_organized = false; //reiniciando los pasos del MODO EVALUACION de la FASE1: steps_p_one_eval_completed = new StepOfProcessEvalMode[6]; for (int i = 0; i<steps_p_one_eval_completed.Length; i++) { steps_p_one_eval_completed [i] = new StepOfProcessEvalMode (false, false); } //reiniciando los pasos del MODO EVALUACION de la FASE2: steps_p_two_eval_completed = new StepOfProcessEvalMode[8]; for (int i = 0; i<steps_p_two_eval_completed.Length; i++) { steps_p_two_eval_completed [i] = new StepOfProcessEvalMode (false, false); } //se procede a guardar los datos en el dispositivo: SaveDataForStudent (); //Se notifica como registro de navegacion que el estudiante ha reiniciado el modo guiado: string fecha = System.DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); NavigationControllerObject.navigation.RegistrarReinicioDeModo (this.codigo_estudiante, fecha, "RRME", "0", "-1", "eval"); //Notificando mendiante mensaje que se ha reiniciado el modo evaluativo: MobileNativeMessage mensaje_confirm = new MobileNativeMessage("Modo Evaluativo reiniciado","El Modo Evaluativo se ha reiniciado correctamente","Aceptar"); }