2021-04-23 09:22:12 +08:00
|
|
|
|
using Assets.Scripts;
|
|
|
|
|
|
using Assets.Scripts.Devices.Ant;
|
2021-04-30 18:03:34 +08:00
|
|
|
|
using Assets.Scripts.UI.Prefab.Device;
|
2021-04-23 09:22:12 +08:00
|
|
|
|
using Mapbox.Examples;
|
2021-04-14 15:02:33 +08:00
|
|
|
|
using System.Collections;
|
2021-03-25 16:53:39 +08:00
|
|
|
|
using System.Collections.Generic;
|
2021-04-23 09:22:12 +08:00
|
|
|
|
using System.Threading.Tasks;
|
2021-03-25 16:53:39 +08:00
|
|
|
|
using UnityEngine;
|
2021-04-19 14:36:08 +08:00
|
|
|
|
using UnityEngine.UI;
|
2021-03-25 16:53:39 +08:00
|
|
|
|
|
|
|
|
|
|
public class MainController : MonoBehaviour
|
|
|
|
|
|
{
|
2021-04-14 15:02:33 +08:00
|
|
|
|
[SerializeField]GameObject root;
|
2021-04-19 14:36:08 +08:00
|
|
|
|
private Text Version;
|
2021-04-14 15:02:33 +08:00
|
|
|
|
private void Awake()
|
|
|
|
|
|
{
|
2021-04-19 18:16:56 +08:00
|
|
|
|
Version = this.transform.Find("GameObject").Find("Version").GetComponent<Text>();
|
2021-04-23 09:22:12 +08:00
|
|
|
|
Version.text = "V"+App.AppVersion;
|
2021-05-08 11:09:03 +08:00
|
|
|
|
DeviceCache.Init(PFConstants.DeviceCacheFolder);
|
2021-06-08 10:30:26 +08:00
|
|
|
|
Loom.Initialize();
|
2021-05-19 14:38:48 +08:00
|
|
|
|
//AntConnector.Instance((device2) => {
|
|
|
|
|
|
// if (device2.State == DeviceState.Disconnected)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// //Debug.Log($"探索到新的设备{ device2.DeviceNumber }");
|
|
|
|
|
|
// //自动连接
|
|
|
|
|
|
// if (DeviceCache.Exist(device2))
|
|
|
|
|
|
// {
|
|
|
|
|
|
// Debug.Log("自动连接" + device2.DeviceNumber);
|
|
|
|
|
|
// device2.Connect();
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
//}, Debug.Log);
|
|
|
|
|
|
App.MainDeviceAdapter.StartScan();
|
2021-04-30 18:03:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Debug.Log(Application.dataPath);
|
2021-04-14 15:02:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-03-25 16:53:39 +08:00
|
|
|
|
// Start is called before the first frame update
|
2021-04-23 09:22:12 +08:00
|
|
|
|
async void Start()
|
2021-03-25 16:53:39 +08:00
|
|
|
|
{
|
2021-04-14 15:02:33 +08:00
|
|
|
|
UIManager.Instance.Root = root;
|
2021-04-09 09:44:06 +08:00
|
|
|
|
UIManager.Instance.MainPanel = this.transform.Find("Panel").GetComponent<PFUIPanel>();
|
|
|
|
|
|
UIManager.Instance.ModalsPanel = this.transform.Find("ModalPanel").GetComponent<PFUIPanel>();
|
2021-05-06 16:02:37 +08:00
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
|
if (App.CurrentUser == null) //App.CurrentUser == null
|
2021-04-23 09:22:12 +08:00
|
|
|
|
{
|
|
|
|
|
|
await Login();
|
|
|
|
|
|
}
|
2021-05-06 16:02:37 +08:00
|
|
|
|
#endif
|
2021-03-25 16:53:39 +08:00
|
|
|
|
//MainMenu.transform.Find("Home").GetComponent<Button>().onClick.AddListener(() =>
|
|
|
|
|
|
//{
|
|
|
|
|
|
// UIManager.ShowHomePanel();
|
|
|
|
|
|
//});
|
2021-05-10 10:21:46 +08:00
|
|
|
|
if (App.MainSceneParam.ContainsKey("Name") && !string.IsNullOrEmpty(App.MainSceneParam["Name"]))
|
2021-04-14 15:02:33 +08:00
|
|
|
|
{
|
2021-04-25 19:41:35 +08:00
|
|
|
|
UIManager.PushHome();
|
|
|
|
|
|
if (App.MainSceneParam["Name"] == "MapListPanel")
|
2021-04-14 15:02:33 +08:00
|
|
|
|
{
|
|
|
|
|
|
UIManager.ShowMapListPanel();
|
|
|
|
|
|
}
|
2021-04-23 09:37:41 +08:00
|
|
|
|
|
|
|
|
|
|
if (App.MainSceneParam["Name"] == "UserInfoPanel")
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.ShowUserInfoPanel();
|
|
|
|
|
|
}
|
2021-05-10 10:21:46 +08:00
|
|
|
|
App.MainSceneParam["Name"] = string.Empty;
|
2021-04-14 15:02:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.ShowHomePanel();
|
|
|
|
|
|
//UIManager.ShowUserInfoPanel();
|
|
|
|
|
|
//UIManager.ShowEditUserPanel();
|
|
|
|
|
|
//UIManager.ShowBigMapPanel();
|
2021-04-27 19:47:02 +08:00
|
|
|
|
//UIManager.ShowEarthPanel();
|
2021-04-14 15:02:33 +08:00
|
|
|
|
}
|
2021-03-25 16:53:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
|
void Update()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2021-04-23 09:22:12 +08:00
|
|
|
|
|
|
|
|
|
|
private async Task Login()
|
|
|
|
|
|
{
|
|
|
|
|
|
var result = await ConfigHelper.userApi.Login("13115011550", "laozhong", "");
|
|
|
|
|
|
App.CurrentUser = result.data;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnApplicationQuit()
|
|
|
|
|
|
{
|
2021-05-19 14:38:48 +08:00
|
|
|
|
App.MainDeviceAdapter.Dispose();
|
2021-04-23 09:22:12 +08:00
|
|
|
|
}
|
2021-03-25 16:53:39 +08:00
|
|
|
|
}
|