2021-09-13 18:21:43 +08:00
|
|
|
|
using Assets.Scenes.Ride.Scripts;
|
|
|
|
|
|
using Assets.Scripts;
|
2021-04-23 09:22:12 +08:00
|
|
|
|
using Assets.Scripts.Devices.Ant;
|
2021-06-10 17:46:43 +08:00
|
|
|
|
using Assets.Scripts.Scenes;
|
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-08-26 15:08:02 +08:00
|
|
|
|
using System;
|
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
|
|
|
|
|
2021-06-10 17:46:43 +08:00
|
|
|
|
public class MainController : BaseScene
|
2021-03-25 16:53:39 +08:00
|
|
|
|
{
|
2021-04-14 15:02:33 +08:00
|
|
|
|
[SerializeField]GameObject root;
|
2021-04-19 14:36:08 +08:00
|
|
|
|
private Text Version;
|
2021-06-10 17:46:43 +08:00
|
|
|
|
protected override void Awake()
|
2021-04-14 15:02:33 +08:00
|
|
|
|
{
|
2021-06-10 17:46:43 +08:00
|
|
|
|
base.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-08-24 17:50:14 +08:00
|
|
|
|
#if UNITY_ANDROID || UNITY_IOS
|
2021-08-25 14:32:49 +08:00
|
|
|
|
transform.GetComponent<CanvasScaler>().referenceResolution = new Vector2(844, 390);
|
2021-08-27 10:12:50 +08:00
|
|
|
|
//transform.Find("Panel").GetComponent<RectTransform>().sizeDelta = new Vector2(844, 390);
|
|
|
|
|
|
var rectTransform = transform.Find("Panel").GetComponent<RectTransform>();
|
|
|
|
|
|
rectTransform.anchorMin = Vector2.zero;
|
|
|
|
|
|
rectTransform.anchorMax = Vector2.one;
|
|
|
|
|
|
rectTransform.offsetMin = Vector2.zero;
|
|
|
|
|
|
rectTransform.offsetMax = Vector2.zero;
|
2021-09-01 16:14:45 +08:00
|
|
|
|
//var rect1 = transform.Find("GameObject").GetComponent<RectTransform>();
|
|
|
|
|
|
//rect1.anchorMin = Vector2.zero;
|
|
|
|
|
|
//rect1.anchorMax = Vector2.one;
|
|
|
|
|
|
//rect1.offsetMin = Vector2.zero;
|
|
|
|
|
|
//rect1.offsetMax = Vector2.zero;
|
2021-08-26 15:08:02 +08:00
|
|
|
|
//transform.Find("ModalPanel").GetComponent<RectTransform>().sizeDelta = new Vector2(844, 390);
|
2021-09-24 19:16:40 +08:00
|
|
|
|
#else
|
|
|
|
|
|
App.MainDeviceAdapter.StartScan();
|
2021-08-24 17:50:14 +08:00
|
|
|
|
#endif
|
2021-04-14 15:02:33 +08:00
|
|
|
|
|
2021-09-13 18:21:43 +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-09-23 18:14:53 +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-08-26 15:08:02 +08:00
|
|
|
|
transform.Find("MobileInfo/BatteryText").GetComponent<Text>().text =
|
|
|
|
|
|
$"{Math.Round(SystemInfo.batteryLevel * 100, 0)}%";
|
|
|
|
|
|
transform.Find("MobileInfo/TimeText").GetComponent<Text>().text =
|
|
|
|
|
|
DateTime.Now.ToString("HH:mm");
|
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-09-28 15:25:52 +08:00
|
|
|
|
if (!App.IsRowerMode.HasValue)
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.ShowRowerSelector();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (App.IsRowerMode == true)
|
2021-09-23 18:14:53 +08:00
|
|
|
|
{
|
|
|
|
|
|
UIManager.ShowRowerPanel();
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
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-09-15 10:45:11 +08:00
|
|
|
|
UIManager.ShowHomePanel();
|
2021-04-25 19:41:35 +08:00
|
|
|
|
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-07-23 18:07:12 +08:00
|
|
|
|
|
|
|
|
|
|
if (App.MainSceneParam["Name"] == "RaceHomePanel")
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.ShowRaceHomePanel();
|
|
|
|
|
|
}
|
2021-05-10 10:21:46 +08:00
|
|
|
|
App.MainSceneParam["Name"] = string.Empty;
|
2021-04-14 15:02:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2021-06-09 18:16:35 +08:00
|
|
|
|
UIManager.ShowHomePanel();
|
2021-04-14 15:02:33 +08:00
|
|
|
|
//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-09-23 18:14:53 +08:00
|
|
|
|
|
2021-09-03 15:12:01 +08:00
|
|
|
|
Task.Run(() => {
|
|
|
|
|
|
UIManager.UpdateJoinCompetition();//查询当前我参加的赛事
|
|
|
|
|
|
});
|
2021-03-25 16:53:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-06-10 17:46:43 +08:00
|
|
|
|
|
2021-07-23 18:07:12 +08:00
|
|
|
|
float t = 1f;
|
2021-09-13 18:21:43 +08:00
|
|
|
|
float scanTicks = 0;
|
2021-03-25 16:53:39 +08:00
|
|
|
|
// Update is called once per frame
|
|
|
|
|
|
void Update()
|
|
|
|
|
|
{
|
2021-09-23 18:14:53 +08:00
|
|
|
|
if (App.canvasWidth != transform.GetComponent<RectTransform>().sizeDelta.x)
|
|
|
|
|
|
{
|
|
|
|
|
|
App.canvasWidth = transform.GetComponent<RectTransform>().sizeDelta.x;
|
|
|
|
|
|
Debug.Log(App.canvasWidth);
|
|
|
|
|
|
}
|
|
|
|
|
|
//Debug.Log(transform.GetComponent<RectTransform>().sizeDelta.x);
|
2021-07-23 18:07:12 +08:00
|
|
|
|
t -= Time.deltaTime;
|
|
|
|
|
|
while (t <= 0)
|
|
|
|
|
|
{
|
2021-07-29 20:01:38 +08:00
|
|
|
|
App.CurrentScene = "Main";
|
2021-07-23 18:07:12 +08:00
|
|
|
|
UIManager.SendCompetitionStartMessage("Main");
|
|
|
|
|
|
t = 1;
|
2021-09-13 18:21:43 +08:00
|
|
|
|
scanTicks++;
|
|
|
|
|
|
if (scanTicks == 10)
|
|
|
|
|
|
{
|
2021-09-15 14:17:11 +08:00
|
|
|
|
//App.MainDeviceAdapter.StopScan();
|
|
|
|
|
|
//Debug.Log("StopScan");
|
2021-09-13 18:21:43 +08:00
|
|
|
|
}
|
2021-07-23 18:07:12 +08:00
|
|
|
|
}
|
2021-03-25 16:53:39 +08:00
|
|
|
|
}
|
2021-04-23 09:22:12 +08:00
|
|
|
|
|
|
|
|
|
|
private async Task Login()
|
|
|
|
|
|
{
|
|
|
|
|
|
var result = await ConfigHelper.userApi.Login("13115011550", "laozhong", "");
|
|
|
|
|
|
App.CurrentUser = result.data;
|
|
|
|
|
|
}
|
2021-03-25 16:53:39 +08:00
|
|
|
|
}
|