using System; using System.Collections; using System.Collections.Generic; using System.IO; using System.Linq; using UnityEngine; using UnityEngine.Networking; public class ReadingFile : MonoBehaviour { public enum UserType { Admin = 1, Teacher = 2, Demo = 3, MyRobotStudent = 4, ZoeStudent = 5, } public static List StudentUsers = new List() { UserType.ZoeStudent, UserType.MyRobotStudent }; public static List AllClassesUsers = new List() { UserType.Admin, UserType.Teacher}; public bool developing, iplocal; public UserType userType = UserType.Demo; public static string idmatricula, senha, iploc, banco, idUnit, route; public static int micro = 0; string path = ""; public static ReadingFile instance; private string GetAndroidID() { if (Application.platform == RuntimePlatform.Android) { using (AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) using (AndroidJavaObject currentActivity = unityPlayer.GetStatic("currentActivity")) using (AndroidJavaObject contentResolver = currentActivity.Call("getContentResolver")) using (AndroidJavaClass secureSettings = new AndroidJavaClass("android.provider.Settings$Secure")) { return secureSettings.CallStatic("getString", contentResolver, "android_id"); } } return "Unsupported Platform"; } private void Awake() { instance = this; } public bool canGo = false; private async void Start() { canGo = false; path = Application.persistentDataPath.Replace(Application.productName, "RobotIngles"); var loginData = await RobotData.GetRobotLogin(); if (loginData != null) { banco = loginData.db; idmatricula = loginData.idusers.ToString(); senha = loginData.password; iploc = "18.228.91.135"; idUnit = loginData.idunits.ToString(); micro = loginData.micro; userType = (UserType)loginData.idusertype; //iploc = ""; if (iplocal) { route = "http://localhost:3337"; } else { route = "https://zoe.myrobotlab.com.br"; } canGo = true; } else { } } #region Micro public int CheckMicro() { return micro; } public void UpdateMicro(int newMic) { string thisPath = path + "micro.txt"; if (File.Exists(thisPath)) { File.Delete(thisPath); } File.WriteAllText(thisPath, newMic.ToString()); } #endregion public static Texture2D LoadPNG(string filePath) { Texture2D tex = null; byte[] fileData; if (File.Exists(filePath)) { fileData = File.ReadAllBytes(filePath); tex = new Texture2D(2, 2); tex.LoadImage(fileData); } return tex; } }