Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using UnityEngine.SceneManagement;
- using System.Collections.Generic;
- using Newtonsoft.Json;
- using UnityEngine.UI;
- using System;
- using SmartLocalization;
- using System.Diagnostics;
- public class MainMenuController : MonoBehaviour {
- public UpperMenu upperMenu;
- public InputField adressText;
- public InputField typeText;
- public InputField descText;
- public InputField userText;
- public InputField dateText;
- public InputField debugText;
- public InputField pointsSmInputField;
- public InputField pointsInputField;
- public InputField sectorsInputField;
- public InputField speedInputField;
- public Text debugPathText;
- public Text dealer;
- public static MainMenuController Instance;
- public Dropdown typeDropdown;
- public MainMenuSettings settings;
- public GameObject SettingsDeviceBtn;
- public GameObject SettingsOpenLaucherPrompt;
- public PinPromptWindow PromptWindow;
- public GameObject DeviceSettingsWindow;
- public Text ErrorText;
- public GameObject ErrorBtn;
- public GameObject ErrorWindow;
- public Text shortSerialText;
- public Text longSerialText;
- private AndroidJavaObject gpsActivityJavaClass;
- private bool isDemo = false;
- public AsyncOperation _async;
- void Awake()
- {
- //PlayerPrefs.DeleteAll();
- Instance = this;
- if (PlayerPrefs.HasKey("lang"))
- {
- LanguageManager.Instance.ChangeLanguage(PlayerPrefs.GetString("lang"));
- }
- else
- {
- SmartCultureInfo deviceCulture = LanguageManager.Instance.GetDeviceCultureIfSupported();
- if (deviceCulture != null)
- {
- LanguageManager.Instance.ChangeLanguage(deviceCulture);
- }
- else
- {
- LanguageManager.Instance.ChangeLanguage("ru");
- }
- }
- if (PlayerPrefs.GetInt("metrics") == 0)
- {
- PlayerPrefs.SetInt("metrics", 8);
- }
- if (PlayerPrefs.GetInt("toggleCount") == 0)
- {
- PlayerPrefs.SetInt("toggleCount", 1);
- }
- if (PlayerPrefs.GetInt("om") == 0)
- {
- PlayerPrefs.SetInt("om", 30);
- }
- adressText.text = PlayerPrefs.GetString("address");
- typeText.text = PlayerPrefs.GetInt("typeDrop", 0).ToString();
- descText.text = PlayerPrefs.GetString("desc");
- userText.text = PlayerPrefs.GetString("userLbl");
- typeDropdown.options.Clear();
- typeDropdown.options.Add(new Dropdown.OptionData(LanguageManager.Instance.GetTextValue("Spraying")));
- typeDropdown.options.Add(new Dropdown.OptionData(LanguageManager.Instance.GetTextValue("Fertilizers")));
- typeDropdown.options.Add(new Dropdown.OptionData(LanguageManager.Instance.GetTextValue("Cultivation")));
- typeDropdown.options.Add(new Dropdown.OptionData(LanguageManager.Instance.GetTextValue("Harrowing")));
- typeDropdown.options.Add(new Dropdown.OptionData(LanguageManager.Instance.GetTextValue("Sowing")));
- typeDropdown.options.Add(new Dropdown.OptionData(LanguageManager.Instance.GetTextValue("Harvest")));
- typeDropdown.options.Add(new Dropdown.OptionData(LanguageManager.Instance.GetTextValue("Another")));
- typeDropdown.options.Add(new Dropdown.OptionData(LanguageManager.Instance.GetTextValue("Metering")));
- typeDropdown.options.Add(new Dropdown.OptionData(LanguageManager.Instance.GetTextValue("Air")));
- //typeDropdown.options.Add(new Dropdown.OptionData(LanguageManager.Instance.GetTextValue("Transport")));
- typeDropdown.options.Add(new Dropdown.OptionData(LanguageManager.Instance.GetTextValue("Plowing")));
- typeDropdown.options.Add(new Dropdown.OptionData(LanguageManager.Instance.GetTextValue("Loosening")));
- typeDropdown.value = PlayerPrefs.GetInt("typeDrop", 0);
- typeDropdown.RefreshShownValue();
- }
- public void Start()
- {
- #if UNITY_WSA_10_0 && !UNITY_EDITOR
- dateText.text = DateTime.Now.ToString();
- UnityBluetoothLibrary.UnityBluetooth.EnableBluetooth();
- #elif UNITY_ANDROID && !UNITY_EDITOR
- dateText.text = DateTime.Now.Date.ToShortDateString() + " " + DateTime.Now.ToShortTimeString();
- AndroidJNI.AttachCurrentThread();
- using (var javaUnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
- {
- using (var currentActivity = javaUnityPlayer.GetStatic<AndroidJavaObject>("currentActivity"))
- {
- gpsActivityJavaClass = new AndroidJavaObject("com.velestor.tractor.GPSTest", currentActivity);
- }
- }
- #endif
- SaveController.Instance.data = new SaveData();
- SaveController.Instance.saveName = "";
- debugPathText.text = System.IO.Path.Combine(Application.streamingAssetsPath, "test.db");
- pointsInputField.text = PlayerPrefs.GetFloat("startDevicedSquare").ToString();
- sectorsInputField.text = PlayerPrefs.GetInt("startDevicedSquareCount").ToString();
- speedInputField.text = PlayerPrefs.GetFloat("startDevicedSpeed").ToString();
- dealer.text = PlayerPrefs.GetString("delader");
- if(ConstConfig.isDemo)
- {
- PlayerPrefs.SetString("delader", LanguageManager.Instance.GetTextValue("OriginalDemo"));
- dealer.text = PlayerPrefs.GetString("delader");
- }
- Screen.sleepTimeout = SleepTimeout.NeverSleep;
- #if !UNITY_WSA_10_0 || UNITY_EDITOR
- _async = SceneManager.LoadSceneAsync("Main");
- _async.allowSceneActivation = false;
- #endif
- CheckLauncher();
- CheckOriginalDevice();
- }
- public void DeleteAllPrefs()
- {
- PlayerPrefs.DeleteAll();
- }
- public void ChangeTexts()
- {
- pointsInputField.text = PlayerPrefs.GetFloat("startDevicedSquare").ToString();
- sectorsInputField.text = PlayerPrefs.GetInt("startDevicedSquareCount").ToString();
- speedInputField.text = PlayerPrefs.GetFloat("startDevicedSpeed").ToString();
- if (PlayerPrefs.GetInt("Inner") == 1)
- {
- if(PlayerPrefs.GetInt("VelestorDevice") == 0)
- {
- PlayerPrefs.SetString("delader", LanguageManager.Instance.GetTextValue("Original"));
- }
- dealer.text = PlayerPrefs.GetString("delader");
- }
- else
- {
- dealer.text = PlayerPrefs.GetString("delader");
- }
- }
- public void CheckLauncher()
- {
- #if UNITY_ANDROID && !UNITY_EDITOR
- if (!gpsActivityJavaClass.CallStatic<bool>("isMyLauncherDefault"))
- {
- SettingsOpenLaucherPrompt.SetActive(true);
- SettingsDeviceBtn.SetActive(false);
- }
- if (gpsActivityJavaClass.CallStatic<bool>("isMyLauncherDefault"))
- {
- SettingsDeviceBtn.SetActive(true);
- SettingsOpenLaucherPrompt.SetActive(false);
- }
- #endif
- }
- public void CheckOriginalDevice()
- {
- if (PlayerPrefs.GetInt("VelestorDevice") == 0)
- {
- typeDropdown.interactable = false;
- }
- else
- {
- typeDropdown.interactable = true;
- }
- }
- public void OpenWLAN()
- {
- gpsActivityJavaClass.CallStatic<string>("OpenWifi");
- }
- public void OpenSim()
- {
- gpsActivityJavaClass.CallStatic<string>("OpenNetwork");
- }
- public void OpenSound()
- {
- gpsActivityJavaClass.CallStatic<string>("OpenSound");
- }
- private int _errorOpenDevice = 0;
- public void OpenDeviceSettings()
- {
- PromptWindow.Open((r) =>
- {
- if (r == PlayerPrefs.GetString("key"))
- {
- gpsActivityJavaClass.CallStatic<string>("OpenSettings");
- PromptWindow.gameObject.SetActive(false);
- }
- else
- {
- _errorOpenDevice++;
- PromptWindow.gameObject.SetActive(false);
- if (_errorOpenDevice >= 3)
- {
- ShowBLock();
- }
- }
- });
- }
- private void ShowBLock()
- {
- ErrorText.text = LanguageManager.Instance.GetTextValue("HelpBtnKey");
- ErrorBtn.SetActive(false);
- ErrorWindow.SetActive(true);
- StartCoroutine(CloseError());
- }
- private IEnumerator CloseError()
- {
- yield return new WaitForSeconds(600);
- ErrorWindow.SetActive(false);
- }
- public void OpenLaucherPrompt()
- {
- if (PlayerPrefs.GetInt("VelestorDevice") == 1)
- {
- gpsActivityJavaClass.CallStatic<string>("OpenLauncherPrompt");
- }
- else
- {
- StartCoroutine(MainMenuSettings.Instance.OpenCantOpenWindow());
- }
- }
- public void DeleteAll()
- {
- PlayerPrefs.DeleteAll();
- SceneManager.LoadScene("Menu");
- }
- public void SetDemoMode()
- {
- isDemo = true;
- }
- public void OnStartClicked()
- {
- if (upperMenu.isNewWork)
- {
- if (String.IsNullOrEmpty(adressText.text))
- {
- adressText.text = "-";
- }
- else
- {
- PlayerPrefs.SetString("address", adressText.text);
- }
- if (String.IsNullOrEmpty(typeText.text))
- {
- typeText.text = "-";
- }
- else
- {
- PlayerPrefs.SetString("type", typeText.text);
- }
- if (String.IsNullOrEmpty(descText.text))
- {
- descText.text = "-";
- }
- else
- {
- PlayerPrefs.SetString("desc", descText.text);
- }
- if (String.IsNullOrEmpty(userText.text))
- {
- userText.text = "-";
- }
- else
- {
- PlayerPrefs.SetString("userLbl", userText.text);
- }
- if (String.IsNullOrEmpty(adressText.text))
- {
- adressText.text = "-";
- }
- PlayerPrefs.SetInt("typeDrop", typeDropdown.value);
- typeText.text = typeDropdown.value.ToString();
- if (typeDropdown.value != 0)
- {
- PlayerPrefs.SetInt("toggleCount", 1);
- settings.toggleCount = 1;
- }
- SaveData data = new SaveData();
- data.positions = new List<Meshes>();
- data.curves = new List<CurvePoint>();
- data.date = dateText.text;
- data.adress = adressText.text;
- data.type = typeText.text;
- data.description = descText.text;
- data.user = userText.text;
- data.parallels = new List<Vector>();
- data.isAccelerator = SaveController.Instance.isDemo;
- data.isInner = ConstConfig.isInnerGPS;
- if (PlayerPrefs.GetInt("toggleCount" + typeText.text) != 0)
- {
- data.sections = PlayerPrefs.GetInt("toggleCount" + typeText.text);
- }
- else
- {
- data.sections = settings.toggleCount;
- PlayerPrefs.SetInt("toggleCount" + typeText.text, settings.toggleCount);
- }
- if (PlayerPrefs.GetInt("metrics" + typeText.text) != 0)
- {
- data.widthM = PlayerPrefs.GetInt("metrics" + typeText.text);
- }
- else
- {
- if (typeDropdown.value == 4)
- {
- data.widthM = 3;
- PlayerPrefs.SetInt("metrics" + typeText.text, data.widthM);
- }else if (typeDropdown.value == 8)
- {
- data.widthM = 40;
- PlayerPrefs.SetInt("metrics" + typeText.text, data.widthM);
- }
- else
- {
- data.widthM = settings.metrics;
- PlayerPrefs.SetInt("metrics" + typeText.text, data.widthM);
- }
- }
- if (PlayerPrefs.GetInt("sm" + typeText.text) != 0)
- {
- data.widthSM = PlayerPrefs.GetInt("sm" + typeText.text);
- }
- else
- {
- if (typeDropdown.value == 4)
- {
- data.widthSM =60;
- PlayerPrefs.SetInt("sm" + typeText.text, data.widthSM);
- }
- else
- {
- data.widthSM = settings.sm;
- PlayerPrefs.SetInt("sm" + typeText.text, data.widthSM);
- }
- }
- if (PlayerPrefs.GetInt("xOffset" + typeText.text) != 0)
- {
- data.xOffset = PlayerPrefs.GetInt("xOffset" + typeText.text);
- }
- else
- {
- data.xOffset = settings.xOffset;
- PlayerPrefs.SetInt("xOffset" + typeText.text, data.xOffset);
- }
- if (PlayerPrefs.GetInt("xSMOffset" + typeText.text) != 0)
- {
- data.xSMOffset = PlayerPrefs.GetInt("xSMOffset" + typeText.text);
- }
- else
- {
- data.xSMOffset = settings.xSMOffset;
- PlayerPrefs.SetInt("xSMOffset" + typeText.text, data.xSMOffset);
- }
- if (PlayerPrefs.GetInt("om" + typeText.text) != 0)
- {
- data.overlapM = PlayerPrefs.GetInt("om" + typeText.text);
- }
- else
- {
- data.overlapM = settings.om;
- PlayerPrefs.SetInt("om" + typeText.text, data.overlapM);
- }
- if (!string.IsNullOrEmpty(debugText.text))
- {
- data.debugFileName = debugText.text;
- }
- else
- {
- data.debugFileName = "-";
- }
- if (PlayerPrefs.GetInt("zOffset" + typeText.text) != 0)
- {
- data.zOffset = PlayerPrefs.GetInt("zOffset" + typeText.text);
- }
- else
- {
- if (typeDropdown.value != 8 && typeDropdown.value != 5)
- {
- if (PlayerPrefs.GetInt("VelestorDevice") == 1)
- {
- data.zOffset = 4;
- PlayerPrefs.SetInt("zOffset" + typeText.text, 4);
- }
- else
- {
- data.zOffset = 1;
- PlayerPrefs.SetInt("zOffset" + typeText.text, 1);
- }
- }
- else
- {
- data.zOffset = settings.zOffset;
- PlayerPrefs.SetInt("zOffset" + typeText.text, data.zOffset);
- }
- }
- if (PlayerPrefs.GetInt("zSMOffset" + typeText.text) != 0)
- {
- data.zSMOffset = PlayerPrefs.GetInt("zSMOffset" + typeText.text);
- }
- else
- {
- data.zSMOffset = settings.zSMOffset;
- PlayerPrefs.SetInt("zSMOffset" + typeText.text, data.zSMOffset);
- }
- data.isNewSave = true;
- data.isDeleted = "false";
- data.isSetCurves = "false";
- data.debugData = new DebugData();
- data.debugData.minSpeed = float.Parse(speedInputField.text);
- data.debugData.pointsDealey = float.Parse(pointsInputField.text);
- data.debugData.sectorDealey = int.Parse(sectorsInputField.text);
- if (typeDropdown.value == 8)
- {
- data.overlapM = 99;
- PlayerPrefs.SetInt("om" + typeText.text, 99);
- data.zOffset = 4;
- PlayerPrefs.SetInt("zOffset" + typeText.text, 4);
- }
- if (typeDropdown.value == 7)
- {
- data.overlapM = 30;
- PlayerPrefs.SetInt("om" + typeText.text, 30);
- data.zOffset = 1;
- PlayerPrefs.SetInt("zOffset" + typeText.text, 1);
- data.widthM = 2;
- PlayerPrefs.SetInt("metrics" + typeText.text, 2);
- }
- if (typeDropdown.value == 5)
- {
- data.overlapM = 99;
- PlayerPrefs.SetInt("om" + typeText.text, 30);
- data.zOffset = 1;
- PlayerPrefs.SetInt("zOffset" + typeText.text, 1);
- if (data.widthM < 4)
- {
- data.widthM = 4;
- PlayerPrefs.SetInt("metrics" + typeText.text, 4);
- }
- if (data.widthM > 11)
- {
- data.widthM = 11;
- PlayerPrefs.SetInt("metrics" + typeText.text, 11);
- }
- data.widthSM = 0;
- PlayerPrefs.SetInt("sm" + typeText.text, 0);
- }
- if (string.IsNullOrEmpty(data.saveIndex))
- {
- int i = PlayerPrefs.GetInt("saves");
- data.saveIndex = i.ToString();
- i++;
- PlayerPrefs.SetInt("saves", i);
- }
- SaveController.Instance.LoadData(data);
- #if !UNITY_WSA_10_0 || UNITY_EDITOR
- //
- _async.allowSceneActivation = true;
- #else
- SceneManager.LoadScene("Main");
- #endif
- }
- else
- {
- if (PlayerPrefs.GetInt("VelestorDevice") == 1)
- {
- SaveController.Instance.data.sections = settings.toggleCount;
- SaveController.Instance.data.widthM = settings.metrics;
- SaveController.Instance.data.widthSM = settings.sm;
- SaveController.Instance.data.xOffset = settings.xOffset;
- SaveController.Instance.data.xSMOffset = settings.xSMOffset;
- SaveController.Instance.data.overlapM = settings.om;
- SaveController.Instance.data.zOffset = settings.zOffset;
- SaveController.Instance.data.zSMOffset = settings.zSMOffset;
- if (SaveController.Instance.data.overlapM < 1)
- {
- SaveController.Instance.data.overlapM = 30;
- }
- if (SaveController.Instance.data.widthM == 0)
- {
- SaveController.Instance.data.widthM = 8;
- }
- if (SaveController.Instance.data.sections == 0)
- {
- SaveController.Instance.data.sections = 1;
- }
- if(PlayerPrefs.GetInt("Demo"+SaveController.Instance.data.saveIndex,0) == 1)
- {
- SaveController.Instance.data.isAccelerator = true;
- }
- SaveController.Instance.PrepareToStart();
- //SceneManager.LoadScene("Main");
- #if !UNITY_WSA_10_0 || UNITY_EDITOR
- //
- _async.allowSceneActivation = true;
- #else
- SceneManager.LoadScene("Main");
- #endif
- }
- else
- {
- StartCoroutine(MainMenuSettings.Instance.OpenCantOpenWindow());
- }
- }
- }
- public void StartSendInnerDevice()
- {
- StartCoroutine(SendInnerDevice(ActivateWindow.GenerateSerial(), "", "", ""));
- }
- public IEnumerator SendInnerDevice(string serial, string name, string pin, string mac)
- {
- string imei = SystemInfo.deviceUniqueIdentifier;
- string deviceModel = SystemInfo.deviceModel;
- PlayerPrefs.SetString("serial", ActivateWindow.GenerateSerial());
- #if !UNITY_EDITOR && UNITY_ANDROID
- AndroidJNI.AttachCurrentThread();
- using (var javaUnityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
- {
- using (var currentActivity = javaUnityPlayer.GetStatic<AndroidJavaObject>("currentActivity"))
- {
- gpsActivityJavaClass = new AndroidJavaObject("com.velestor.tractor.GPSTest", currentActivity);
- }
- }
- string Phone = gpsActivityJavaClass.CallStatic<string>("GetPhone");
- string[] phoneNumber = Phone.Split(new string[] { "|" }, System.StringSplitOptions.None);
- imei = phoneNumber[1];
- deviceModel = SystemInfo.deviceModel;
- #endif
- string url = "velestor." + ActivateWindow.URL_PREFIX + "/insertInnerDevice.php?serial=" + serial + "&name=" + deviceModel + "&pin=0000&mac=" + imei;
- url = url.Replace("\r\n", "%0A");
- url = url.Replace(" ", "%20");
- url = url.Replace(" ", "%20");
- url = url.Replace("#", "%23");
- url = url.Replace(":", "%3A");
- WWW www = new WWW("http://" + url);
- yield return www;
- ParseInnerGPS(www.text, www.url,www.error);
- if (!string.IsNullOrEmpty(www.error))
- {
- PromptDemoWindow.Instance.ShowInteretError();
- }
- else
- {
- if (string.IsNullOrEmpty(www.error) && www.text.StartsWith("OK"))
- {
- SaveController.Instance.isInnerGPS = true;
- ConstConfig.isInnerGPS = true;
- PromptDemoWindow.Instance.activateWindow.SetDemo();
- PlayerPrefs.SetInt("Active", 1);
- ConstConfig.isInnerGPS = true;
- PlayerPrefs.SetInt("Inner", 1);
- string[] s = www.text.Split(new char[] { '|' });
- PlayerPrefs.SetString("deviceId", s[1]);
- PlayerPrefs.SetInt("Active", 1);
- PlayerPrefs.SetString("mac", mac);
- PlayerPrefs.SetString("pin", pin);
- PlayerPrefs.SetString("device", name);
- PlayerPrefs.SetString("serial", s[1]);
- PlayerPrefs.SetString("key", pin);
- shortSerialText.text = "S/N: " + s[1];
- longSerialText.text = "S/N: " + s[1] + " PIN: 0000";
- //Invoke(StartGetDetails(),1);
- PlayerPrefs.SetFloat("startDevicedSquare", 1);
- PlayerPrefs.SetInt("startDevicedSquareCount", 1);
- PlayerPrefs.SetFloat("startDevicedSpeed", 1);
- CheckDevice();
- MainMenuController.Instance.ChangeTexts();
- //serialText.text = "S/N: " + PlayerPrefs.GetString("serial");
- UnityEngine.Debug.Log(PlayerPrefs.GetString("serial"));
- //yield return StartCoroutine(GetDetailsMore());
- PromptDemoWindow.Instance.gameObject.SetActive(false);
- DownloadController.Instance.StartSendAnalitic(s[1], "123", "test", "test", "test", "OK");
- CheckForBan.Instance.OnSuccessLogin();
- CheckOriginalDevice();
- }
- }
- }
- private void CheckDevice()
- {
- if (PlayerPrefs.GetString("serial").Length > 8)
- {
- PlayerPrefs.SetInt("VelestorDevice", 0);
- PlayerPrefs.SetString("delader", LanguageManager.Instance.GetTextValue("OriginalDemo"));
- MainMenuController.Instance.ChangeTexts();
- StartCoroutine(GetDetails());
- }
- else
- {
- PlayerPrefs.SetInt("VelestorDevice", 1);
- StartCoroutine(GetDetails());
- }
- MainMenuController.Instance.CheckOriginalDevice();
- }
- private string url = "http://velestor." + ActivateWindow.URL_PREFIX + "/";
- IEnumerator GetDetails()
- {
- WWW www = new WWW(url + "loxovnet.php?serial=" + PlayerPrefs.GetString("serial"));
- yield return www;
- ActivationModel model = JsonConvert.DeserializeObject<ActivationModel>(www.text);
- if (!string.IsNullOrEmpty(model.error))
- {
- }
- else
- {
- if (model.active == 0)
- {
- CheckModel(model);
- }
- else
- {
- CheckModel(model);
- PlayerPrefs.SetInt("Active", 1);
- PlayerPrefs.SetString("mac", model.mac);
- PlayerPrefs.SetString("pin", model.pin);
- PlayerPrefs.SetString("device", model.name);
- PlayerPrefs.SetString("deviceSpeed", model.deviceSpeed);
- PlayerPrefs.SetString("key", model.key);
- PlayerPrefs.SetFloat("startDevicedSquare", model.squareDelta);
- PlayerPrefs.SetInt("startDevicedSquareCount", model.squareCount);
- PlayerPrefs.SetFloat("startDevicedSpeed", model.minSpeed);
- if(PlayerPrefs.GetInt("VelestorDevice") == 1)
- PlayerPrefs.SetString("delader", model.dealer);
- MainMenuController.Instance.ChangeTexts();
- PlayerPrefs.SetString("info", model.text);
- PlayerPrefs.SetString("activationDate", model.date);
- PlayerPrefs.SetInt("control", model.control);
- PlayerPrefs.SetString("dealerContact", model.contact);
- PlayerPrefs.SetString("dealerEmail", model.email);
- PlayerPrefs.SetString("dealerAddress", model.address);
- PlayerPrefs.SetString("dealerTel", model.tel);
- CheckModel(model);
- #if UNITY_ANDROID || UNITY_WSA_10_0
- string[] parts = model.mac.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
- if (parts.Length < 6)
- {
- PlayerPrefs.SetInt("Inner", 1);
- SaveController.Instance.isInnerGPS = true;
- ConstConfig.isInnerGPS = true;
- }
- #endif
- CheckForBan.Instance.OnSuccessLogin();
- }
- }
- }
- private void CheckModel(ActivationModel model)
- {
- if(model != null)
- {
- UnityEngine.Debug.Log("Checked");
- }
- }
- private void ParseInnerGPS(string text, string url,string error = null)
- {
- UnityEngine.Debug.Log(text + " " + url);
- }
- public void StartGetLicense()
- {
- StartCoroutine(GetLicense());
- }
- public IEnumerator GetLicense()
- {
- string url = "velestor." + ActivateWindow.URL_PREFIX + "/getLicense.php";
- WWW www = new WWW("http://" + url);
- yield return www;
- if (string.IsNullOrEmpty(www.error))
- {
- ActivationModel model = JsonConvert.DeserializeObject<ActivationModel>(www.text);
- PlayerPrefs.SetString("info", model.text);
- UnityEngine.Debug.Log("License: " + model.text);
- }
- yield return null;
- }
- public void OnExitClicked()
- {
- if(ConstConfig.isDemo)
- {
- PlayerPrefs.DeleteAll();
- }
- #if UNITY_ANDROID && !UNITY_EDITOR
- if(gpsActivityJavaClass.CallStatic<bool>("isMyLauncherDefault"))
- {
- if(PlayerPrefs.GetInt("VelestorDevice") == 0)
- {
- gpsActivityJavaClass.CallStatic<string>("CloseApp");
- }else
- {
- gpsActivityJavaClass.CallStatic<string>("LockScreen");
- }
- }else
- {
- Application.Quit();
- }
- #elif UNITY_WSA_10_0 && !UNITY_EDITOR || UNITY_STANDALONE_WIN
- Application.Quit();
- #elif UNITY_STANDALONE_LINUX
- WinBluetoothController.Instance.SendShutdown();
- #endif
- #if UNITY_STANDALONE
- foreach (var process in Process.GetProcessesByName("VelestorBT"))
- {
- process.Kill();
- }
- #endif
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement