2021-09-13 18:21:43 +08:00
|
|
|
|
using Assets.Scenes.Ride.Scripts;
|
2021-12-07 16:44:36 +08:00
|
|
|
|
using Assets.Scenes.Ride.Scripts.Model;
|
2021-09-13 18:21:43 +08:00
|
|
|
|
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-12-14 18:10:58 +08:00
|
|
|
|
using DG.Tweening;
|
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-12-15 18:18:12 +08:00
|
|
|
|
using System.Linq;
|
2021-04-23 09:22:12 +08:00
|
|
|
|
using System.Threading.Tasks;
|
2021-03-25 16:53:39 +08:00
|
|
|
|
using UnityEngine;
|
2021-12-07 16:44:36 +08:00
|
|
|
|
using UnityEngine.SceneManagement;
|
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-12-17 18:28:02 +08:00
|
|
|
|
Debug.Log("执行25");
|
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-12-14 18:10:58 +08:00
|
|
|
|
msg = transform.Find("GameObject/Message").GetComponent<CanvasGroup>();
|
2021-12-15 18:18:12 +08:00
|
|
|
|
InitialMessage();
|
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-12-30 16:51:04 +08:00
|
|
|
|
transform.Find("GameObject/Version").gameObject.SetActive(false);
|
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
|
2021-11-04 13:24:40 +08:00
|
|
|
|
var modalRect = transform.Find("ModalPanel").GetComponent<RectTransform>();
|
|
|
|
|
|
modalRect.anchorMin = new Vector2(0.5f, 0.5f);
|
|
|
|
|
|
modalRect.anchorMax = new Vector2(0.5f, 0.5f);
|
|
|
|
|
|
modalRect.offsetMin = Vector2.zero;
|
|
|
|
|
|
modalRect.offsetMax = Vector2.zero;
|
|
|
|
|
|
modalRect.sizeDelta = new Vector2(1600, 900);
|
2021-09-24 19:16:40 +08:00
|
|
|
|
App.MainDeviceAdapter.StartScan();
|
2021-08-24 17:50:14 +08:00
|
|
|
|
#endif
|
2021-12-15 18:18:12 +08:00
|
|
|
|
EventQueueSystem.AddListener<LinkedMessageEvent>(LinkedMessageHandler);
|
2021-12-16 16:00:14 +08:00
|
|
|
|
App.isHomeChanged -= OnIsHomeChanged;
|
|
|
|
|
|
App.isHomeChanged += OnIsHomeChanged;
|
2021-12-15 18:18:12 +08:00
|
|
|
|
}
|
2021-12-16 16:00:14 +08:00
|
|
|
|
#region 显示消息有关
|
|
|
|
|
|
//切换页面后
|
|
|
|
|
|
private void OnIsHomeChanged(object sender, EventArgs e)
|
|
|
|
|
|
{
|
2021-12-31 11:23:16 +08:00
|
|
|
|
//DOTween.KillAll();
|
2021-12-16 16:54:31 +08:00
|
|
|
|
FinishMessage(sender);
|
2021-12-16 16:00:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-12-27 09:39:07 +08:00
|
|
|
|
List<CanvasGroup> msgs;
|
2021-12-15 18:18:12 +08:00
|
|
|
|
Vector3 msgLocation;
|
|
|
|
|
|
int msgIndex = 0;
|
2021-12-16 16:00:14 +08:00
|
|
|
|
CanvasGroup rightMessage;
|
2021-12-15 18:18:12 +08:00
|
|
|
|
private void InitialMessage()
|
|
|
|
|
|
{
|
2021-12-16 16:54:31 +08:00
|
|
|
|
#if UNITY_STANDALONE_WIN
|
2021-12-15 18:18:12 +08:00
|
|
|
|
msgLocation = 1 * msg.transform.localPosition;
|
|
|
|
|
|
var msg2 = Instantiate<CanvasGroup>(msg);
|
|
|
|
|
|
var msg3 = Instantiate<CanvasGroup>(msg);
|
|
|
|
|
|
msg2.transform.SetParent(msg.transform.parent);
|
|
|
|
|
|
msg3.transform.SetParent(msg.transform.parent);
|
|
|
|
|
|
msg2.transform.localPosition = 1 * msgLocation;
|
|
|
|
|
|
msg2.transform.localScale = Vector3.one;
|
|
|
|
|
|
msg2.alpha = 0;
|
|
|
|
|
|
msg3.transform.localPosition = 1 * msgLocation;
|
|
|
|
|
|
msg3.transform.localScale = Vector3.one;
|
|
|
|
|
|
msg3.alpha = 0;
|
2021-12-27 09:39:07 +08:00
|
|
|
|
msgs = List<CanvasGroup> { msg, msg2, msg3 };
|
2021-12-16 16:00:14 +08:00
|
|
|
|
rightMessage = transform.Find("GameObject/MessageRight").GetComponent<CanvasGroup>();
|
2021-12-16 16:54:31 +08:00
|
|
|
|
#else
|
2022-01-07 15:11:40 +08:00
|
|
|
|
msgLocation = new Vector3(168, 37-46, 0);
|
2021-12-16 16:54:31 +08:00
|
|
|
|
var go = transform.Find("GameObject");
|
|
|
|
|
|
go.GetComponent<RectTransform>().anchorMin = Vector2.zero;
|
|
|
|
|
|
go.GetComponent<RectTransform>().anchorMax = Vector2.one;
|
|
|
|
|
|
go.GetComponent<RectTransform>().offsetMax = Vector2.zero;
|
|
|
|
|
|
go.GetComponent<RectTransform>().offsetMin = Vector2.zero;
|
|
|
|
|
|
DestroyImmediate(transform.Find("GameObject/Message").gameObject);
|
|
|
|
|
|
DestroyImmediate(transform.Find("GameObject/MessageRight").gameObject);
|
|
|
|
|
|
var m = Resources.Load<GameObject>("UI/Prefab/NewRoute/Mobile/Message");
|
|
|
|
|
|
rightMessage = Instantiate<GameObject>(m).GetComponent<CanvasGroup>();
|
2021-12-16 16:00:14 +08:00
|
|
|
|
|
2021-12-16 16:54:31 +08:00
|
|
|
|
rightMessage.transform.SetParent(go);
|
|
|
|
|
|
rightMessage.transform.localScale = Vector3.one;
|
2021-12-27 09:39:07 +08:00
|
|
|
|
rightMessage.transform.localPosition = 1 * msgLocation;
|
2021-12-31 11:23:16 +08:00
|
|
|
|
rightMessage.alpha = 0;
|
2021-12-27 09:39:07 +08:00
|
|
|
|
msgs = new List<CanvasGroup> { rightMessage };
|
2022-01-07 15:11:40 +08:00
|
|
|
|
for (int i = 0; i < 4; i++)
|
2021-12-27 09:39:07 +08:00
|
|
|
|
{
|
|
|
|
|
|
var tmpm = Instantiate<CanvasGroup>(rightMessage);
|
|
|
|
|
|
tmpm.transform.SetParent(rightMessage.transform.parent);
|
|
|
|
|
|
tmpm.transform.localPosition = 1 * msgLocation;
|
|
|
|
|
|
tmpm.transform.localScale = Vector3.one;
|
|
|
|
|
|
tmpm.alpha = 0;
|
|
|
|
|
|
msgs.Add(tmpm);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-12-16 16:54:31 +08:00
|
|
|
|
Debug.Log(rightMessage.GetComponent<RectTransform>().localPosition);
|
|
|
|
|
|
//rightMessage.transform.SetParent(transform.Find("GameObject"));
|
2021-12-16 16:00:14 +08:00
|
|
|
|
#endif
|
2021-12-15 18:18:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void LinkedMessageHandler(LinkedMessageEvent e)
|
|
|
|
|
|
{
|
|
|
|
|
|
//msg.transform.Find("Content")
|
|
|
|
|
|
emptyt = 0;
|
2021-12-16 16:00:14 +08:00
|
|
|
|
#if UNITY_STANDALONE_WIN
|
2021-12-15 18:18:12 +08:00
|
|
|
|
Debug.Log(e.content);
|
2021-12-16 16:00:14 +08:00
|
|
|
|
if (App.currentPageIsHome)
|
|
|
|
|
|
{
|
|
|
|
|
|
DoMessage(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
DoMessageRight(e);
|
|
|
|
|
|
}
|
|
|
|
|
|
#else
|
2021-12-31 11:23:16 +08:00
|
|
|
|
if (App.currentPageIsHome)
|
2021-12-16 16:54:31 +08:00
|
|
|
|
{
|
2021-12-27 09:39:07 +08:00
|
|
|
|
DoMessage6(e);
|
2021-12-16 16:54:31 +08:00
|
|
|
|
}
|
2021-12-16 16:00:14 +08:00
|
|
|
|
#endif
|
|
|
|
|
|
}
|
|
|
|
|
|
private void DoMessageRight(LinkedMessageEvent e)
|
|
|
|
|
|
{
|
|
|
|
|
|
SetMessage(rightMessage, e);
|
2021-12-16 16:54:31 +08:00
|
|
|
|
rightMessage.DOFade(1, 0.5f).onComplete = () => Invoke("fade0", 0.8f);
|
2021-12-15 18:18:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
private void DoMessage(LinkedMessageEvent e)
|
|
|
|
|
|
{
|
2021-12-16 16:00:14 +08:00
|
|
|
|
|
2021-12-15 18:18:12 +08:00
|
|
|
|
var selectIndex = msgIndex % 3;
|
2021-12-16 16:00:14 +08:00
|
|
|
|
var m = msgs[selectIndex];
|
2021-12-15 18:18:12 +08:00
|
|
|
|
if (msgIndex >= 3) //
|
|
|
|
|
|
{
|
|
|
|
|
|
//msgIndex = 0;
|
|
|
|
|
|
m.DOFade(0, 0.5f).onComplete = ()=>
|
|
|
|
|
|
{
|
|
|
|
|
|
SetMessage(m, e);
|
|
|
|
|
|
m.transform.localPosition = new Vector3(msgLocation.x, msgLocation.y - 54 * 2, msgLocation.z);
|
|
|
|
|
|
m.DOFade(1, 0.5f);
|
|
|
|
|
|
foreach (var item in msgs.Where((x, i) => i != selectIndex))
|
|
|
|
|
|
{
|
|
|
|
|
|
item.transform.DOLocalMoveY(item.transform.localPosition.y + 54, 0.5f);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
SetMessage(m, e);
|
|
|
|
|
|
m.transform.localPosition = new Vector3(msgLocation.x, msgLocation.y - 54 * (msgIndex % 3), msgLocation.z);
|
|
|
|
|
|
m.DOFade(1, 0.5f);
|
|
|
|
|
|
}
|
|
|
|
|
|
msgIndex++;
|
|
|
|
|
|
}
|
2021-12-27 09:39:07 +08:00
|
|
|
|
private void DoMessage6(LinkedMessageEvent e)
|
|
|
|
|
|
{
|
2022-01-07 15:11:40 +08:00
|
|
|
|
var selectIndex = msgIndex % 5;
|
2021-12-27 09:39:07 +08:00
|
|
|
|
var m = msgs[selectIndex];
|
2022-01-07 15:11:40 +08:00
|
|
|
|
if (msgIndex >= 5) //
|
2021-12-27 09:39:07 +08:00
|
|
|
|
{
|
|
|
|
|
|
//msgIndex = 0;
|
2021-12-31 11:23:16 +08:00
|
|
|
|
Sequence se = DOTween.Sequence();
|
2021-12-30 16:51:04 +08:00
|
|
|
|
//m.transform.DOLocalMoveY(m.transform.localPosition.y - 38, 0.5f);
|
|
|
|
|
|
foreach (var item in msgs)
|
|
|
|
|
|
{
|
2021-12-31 11:23:16 +08:00
|
|
|
|
se.Join(item.transform.DOLocalMoveY(item.transform.localPosition.y - 38, 0.5f));
|
2021-12-30 16:51:04 +08:00
|
|
|
|
}
|
2021-12-31 11:23:16 +08:00
|
|
|
|
se.Join(m.DOFade(0, 0.5f));
|
|
|
|
|
|
se.Play().onComplete = () =>
|
2021-12-27 09:39:07 +08:00
|
|
|
|
{
|
|
|
|
|
|
SetMessage(m, e);
|
|
|
|
|
|
m.transform.localPosition = 1 * msgLocation;
|
|
|
|
|
|
m.DOFade(1, 0.5f);
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.Log(191);
|
|
|
|
|
|
SetMessage(m, e);
|
2021-12-31 11:23:16 +08:00
|
|
|
|
Sequence se = DOTween.Sequence();
|
2021-12-27 09:39:07 +08:00
|
|
|
|
for (int i = 0; i < msgIndex; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
var rect = msgs[i].GetComponent<RectTransform>();
|
2021-12-31 11:23:16 +08:00
|
|
|
|
se.Join(rect.DOLocalMoveY(rect.localPosition.y - 38, 0.5f));
|
2021-12-27 09:39:07 +08:00
|
|
|
|
}
|
2021-12-31 11:23:16 +08:00
|
|
|
|
se.Join(m.DOFade(1, 0.5f));
|
|
|
|
|
|
se.Play();
|
2021-12-27 09:39:07 +08:00
|
|
|
|
}
|
2021-12-30 16:51:04 +08:00
|
|
|
|
m.transform.SetAsLastSibling();
|
2021-12-27 09:39:07 +08:00
|
|
|
|
msgIndex++;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-12-16 16:54:31 +08:00
|
|
|
|
void FinishMessage(object sender)
|
2021-12-16 16:00:14 +08:00
|
|
|
|
{
|
2021-12-16 16:54:31 +08:00
|
|
|
|
#if UNITY_STANDALONE_WIN
|
|
|
|
|
|
if ((bool)sender)
|
2021-12-16 16:00:14 +08:00
|
|
|
|
{
|
2021-12-16 16:54:31 +08:00
|
|
|
|
FinishMessageRight();
|
2021-12-16 16:00:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
2021-12-16 16:54:31 +08:00
|
|
|
|
{
|
|
|
|
|
|
FinishMessageLeft();
|
|
|
|
|
|
}
|
|
|
|
|
|
#else
|
2021-12-31 11:23:16 +08:00
|
|
|
|
|
2021-12-16 16:54:31 +08:00
|
|
|
|
if (!(bool)sender)
|
2021-12-16 16:00:14 +08:00
|
|
|
|
{
|
2021-12-30 16:51:04 +08:00
|
|
|
|
//FinishMessage6();
|
2021-12-31 11:23:16 +08:00
|
|
|
|
//DOTween.CompleteAll(true);
|
|
|
|
|
|
DOTween.CompleteAll(true);
|
|
|
|
|
|
transform.Find("GameObject").gameObject.SetActive(false);
|
2021-12-30 16:51:04 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2021-12-31 11:23:16 +08:00
|
|
|
|
transform.Find("GameObject").gameObject.SetActive(true);
|
2021-12-16 16:00:14 +08:00
|
|
|
|
}
|
2021-12-16 16:54:31 +08:00
|
|
|
|
#endif
|
2021-12-16 16:00:14 +08:00
|
|
|
|
}
|
|
|
|
|
|
void FinishMessageLeft()
|
2021-12-15 18:18:12 +08:00
|
|
|
|
{
|
2021-12-20 14:44:48 +08:00
|
|
|
|
#if UNITY_STANDALONE_WIN
|
2021-12-15 18:18:12 +08:00
|
|
|
|
msgIndex = 0;
|
2021-12-17 18:28:02 +08:00
|
|
|
|
if (msgs != null)
|
2021-12-15 18:18:12 +08:00
|
|
|
|
{
|
2021-12-17 18:28:02 +08:00
|
|
|
|
foreach (var item in msgs)
|
|
|
|
|
|
{
|
|
|
|
|
|
item.DOFade(0, 0.3f);
|
|
|
|
|
|
}
|
2021-12-15 18:18:12 +08:00
|
|
|
|
}
|
2021-12-20 14:44:48 +08:00
|
|
|
|
#endif
|
2021-12-15 18:18:12 +08:00
|
|
|
|
}
|
2021-12-16 16:00:14 +08:00
|
|
|
|
|
|
|
|
|
|
void FinishMessageRight()
|
|
|
|
|
|
{
|
|
|
|
|
|
msgIndex = 0;
|
|
|
|
|
|
rightMessage.DOFade(0, 0.3f);
|
|
|
|
|
|
}
|
2021-12-27 09:39:07 +08:00
|
|
|
|
void FinishMessage6()
|
|
|
|
|
|
{
|
|
|
|
|
|
msgIndex = 0;
|
|
|
|
|
|
foreach (var m in msgs)
|
|
|
|
|
|
{
|
|
|
|
|
|
m.alpha = 0;
|
|
|
|
|
|
m.GetComponent<RectTransform>().localPosition = 1 * msgLocation;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-12-15 18:18:12 +08:00
|
|
|
|
private void SetMessage(CanvasGroup m,LinkedMessageEvent e)
|
|
|
|
|
|
{
|
2021-12-29 14:23:37 +08:00
|
|
|
|
m.GetComponent<Button>().onClick.RemoveAllListeners();
|
|
|
|
|
|
m.GetComponent<Button>().onClick.AddListener(()=>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (e.routeId > 0)
|
|
|
|
|
|
{
|
2022-01-07 11:05:32 +08:00
|
|
|
|
var res = ConfigHelper.mapApi.GetById(e.routeId);
|
|
|
|
|
|
if (res.result)
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.ShowStartRideModal(res.data);
|
|
|
|
|
|
}
|
|
|
|
|
|
//UIManager.ShowConfirm(App.GetLocalString("RIDE NOW"), App.GetLocalLanguage() == "zh"? $"<color=#fff>是否要加入</color><color=#f93086>{e.routeName}</color><color=#fff>骑行?</color>" :$"<color=#fff>Join</color> <color=#f93086>{e.routeName}</color><color=#fff>?</color>", () =>
|
|
|
|
|
|
// {
|
|
|
|
|
|
// App.RouteIdParam = e.routeId;
|
|
|
|
|
|
// SceneManager.LoadScene("Ride");
|
|
|
|
|
|
// });
|
2021-12-29 14:23:37 +08:00
|
|
|
|
}
|
|
|
|
|
|
//Debug.Log(e.routeId);
|
|
|
|
|
|
});
|
2021-12-15 18:18:12 +08:00
|
|
|
|
m.transform.Find("Avatar").GetComponent<RawImage>().texture = null;
|
|
|
|
|
|
Utils.DisplayHead(m.transform.Find("Avatar").GetComponent<RawImage>(), e.avatar);
|
|
|
|
|
|
m.transform.Find("Nickname").GetComponent<Text>().text = e.nickname;
|
2021-12-30 16:51:04 +08:00
|
|
|
|
var txt = m.transform.Find("TextContainer/Content").GetComponent<RectTransform>();
|
|
|
|
|
|
txt.GetComponent<Text>().text = e.content;
|
|
|
|
|
|
LayoutRebuilder.ForceRebuildLayoutImmediate(txt);
|
|
|
|
|
|
Debug.Log(e.content + txt.sizeDelta.x);
|
2021-12-31 11:23:16 +08:00
|
|
|
|
m.GetComponent<HomeMessageController>().Initial();
|
2021-12-30 16:51:04 +08:00
|
|
|
|
m.GetComponent<HomeMessageController>().textWidth = txt.sizeDelta.x;
|
2021-09-13 18:21:43 +08:00
|
|
|
|
}
|
2021-12-16 16:00:14 +08:00
|
|
|
|
CanvasGroup msg;
|
|
|
|
|
|
void fade0()
|
|
|
|
|
|
{
|
|
|
|
|
|
rightMessage.DOFade(0, 0.5f);
|
|
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
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-12-17 11:24:24 +08:00
|
|
|
|
//#if UNITY_ANDROID || UNITY_IOS
|
|
|
|
|
|
// if (!App.IsRowerMode.HasValue)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// UIManager.ShowRowerSelector();
|
|
|
|
|
|
// return;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// if (App.IsRowerMode == true)
|
|
|
|
|
|
// {
|
|
|
|
|
|
// UIManager.ShowRowerPanel();
|
|
|
|
|
|
// return;
|
|
|
|
|
|
// }
|
|
|
|
|
|
//#endif
|
|
|
|
|
|
LastRide();//检查本地异常中断的骑行并弹窗提示继续
|
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-12-15 11:08:18 +08:00
|
|
|
|
UIManager.ShowNewRouteOverviewPanel();
|
2021-04-25 19:41:35 +08:00
|
|
|
|
if (App.MainSceneParam["Name"] == "MapListPanel")
|
2021-04-14 15:02:33 +08:00
|
|
|
|
{
|
|
|
|
|
|
UIManager.ShowMapListPanel();
|
|
|
|
|
|
}
|
2021-12-15 11:08:18 +08:00
|
|
|
|
if (App.MainSceneParam["Name"] == "NewRouteDetail" && App.currentArea != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.ShowNewRouteDetailPanel(App.currentArea);
|
|
|
|
|
|
}
|
2021-04-23 09:37:41 +08:00
|
|
|
|
if (App.MainSceneParam["Name"] == "UserInfoPanel")
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.ShowUserInfoPanel();
|
2022-01-07 10:34:16 +08:00
|
|
|
|
#if UNITY_ANDROID || UNITY_IOS
|
|
|
|
|
|
UIManager.ShowResultListPanel();
|
|
|
|
|
|
#endif
|
2021-04-23 09:37:41 +08:00
|
|
|
|
}
|
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-12-07 14:37:08 +08:00
|
|
|
|
//UIManager.ShowNewRouteOverviewPanel();
|
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-11-23 16:27:35 +08:00
|
|
|
|
|
|
|
|
|
|
UIManager.UpdateJoinCompetition();//查询当前我参加的赛事
|
2021-03-25 16:53:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2022-01-05 17:40:12 +08:00
|
|
|
|
|
2021-12-15 18:18:12 +08:00
|
|
|
|
float emptyt = 0;//用于无消息计时
|
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
|
2021-11-09 11:37:10 +08:00
|
|
|
|
protected override void Update()
|
2021-03-25 16:53:39 +08:00
|
|
|
|
{
|
2021-11-09 11:37:10 +08:00
|
|
|
|
base.Update();
|
2021-12-15 13:24:26 +08:00
|
|
|
|
|
2021-09-23 18:14:53 +08:00
|
|
|
|
if (App.canvasWidth != transform.GetComponent<RectTransform>().sizeDelta.x)
|
|
|
|
|
|
{
|
|
|
|
|
|
App.canvasWidth = transform.GetComponent<RectTransform>().sizeDelta.x;
|
2021-12-15 13:24:26 +08:00
|
|
|
|
//Debug.Log(App.canvasWidth);
|
2021-09-23 18:14:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
//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++;
|
2021-12-15 18:18:12 +08:00
|
|
|
|
emptyt++;
|
|
|
|
|
|
if (emptyt >= 10)
|
|
|
|
|
|
{
|
|
|
|
|
|
emptyt = 0;
|
2021-12-16 18:43:26 +08:00
|
|
|
|
if (App.currentPageIsHome)
|
|
|
|
|
|
{
|
|
|
|
|
|
FinishMessageLeft();
|
|
|
|
|
|
}
|
2021-12-15 18:18:12 +08:00
|
|
|
|
}
|
2021-09-13 18:21:43 +08:00
|
|
|
|
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-12-15 13:24:26 +08:00
|
|
|
|
MapUDPService.Send(0, App.CurrentUser.Id, new double[]{ 0d,0d}, competitionId: 0);
|
|
|
|
|
|
//发送消息
|
|
|
|
|
|
|
2021-12-21 10:10:05 +08:00
|
|
|
|
var list = MapUDPService.GetAllOnlineUserList();
|
2021-12-24 18:33:58 +08:00
|
|
|
|
var lang = App.GetLocalLanguage();
|
2021-12-20 14:44:48 +08:00
|
|
|
|
foreach (var item in list)
|
2021-12-15 13:24:26 +08:00
|
|
|
|
{
|
2022-01-06 10:58:52 +08:00
|
|
|
|
if (item.Point != null && item.Point.Length > 0 && item.Point[0] == -1d)
|
|
|
|
|
|
{
|
|
|
|
|
|
var message = lang == "zh" ? $"{item.Name}进入了 运动地球" : "entered PowerFun";
|
2022-01-07 15:11:40 +08:00
|
|
|
|
EventQueueSystem.QueueEventOnce(new LinkedMessageEvent(-1, message, item.HeadImage, item.Name, item.RouteName), $"{item.Id}{item.LastActiveTime}{item.Point}");
|
2022-01-06 10:58:52 +08:00
|
|
|
|
}
|
2021-12-15 13:24:26 +08:00
|
|
|
|
if (item.RouteId > 0)
|
|
|
|
|
|
{
|
2021-12-15 18:18:12 +08:00
|
|
|
|
var message = "";
|
2022-01-06 10:58:52 +08:00
|
|
|
|
if (item.TotalTicks == 0 && item.PreDistance == 0)
|
2021-12-15 18:18:12 +08:00
|
|
|
|
{
|
2021-12-30 16:51:04 +08:00
|
|
|
|
message = lang=="zh"?$"发起了对<color=#f93086>{item.RouteName}</color>的挑战!" : $"started riding <color=#f93086>{item.RouteName}</color>!";
|
2021-12-15 18:18:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
if (item.IsCompleted)
|
|
|
|
|
|
{
|
2021-12-30 16:51:04 +08:00
|
|
|
|
message = lang == "zh" ? $"完成了<color=#f93086>{item.RouteName}</color>的挑战!" : $"completed <color=#f93086>{item.RouteName}</color> ride!";
|
2021-12-15 18:18:12 +08:00
|
|
|
|
}
|
2021-12-20 14:44:48 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(message))
|
2021-12-15 18:18:12 +08:00
|
|
|
|
{
|
2021-12-30 16:51:04 +08:00
|
|
|
|
EventQueueSystem.QueueEventOnce(new LinkedMessageEvent(item.RouteId, message, item.HeadImage, item.Name,item.RouteName), $"{item.RouteId}{item.Name}");
|
2021-12-15 18:18:12 +08:00
|
|
|
|
}
|
2021-12-15 13:24:26 +08:00
|
|
|
|
}
|
2021-12-24 18:33:58 +08:00
|
|
|
|
//距离50
|
|
|
|
|
|
if (item.EndDistance >= 50)
|
2021-12-15 13:24:26 +08:00
|
|
|
|
{
|
2022-01-07 18:22:22 +08:00
|
|
|
|
var message = lang == "zh" ? $"在<color=#f93086>{item.RouteName}</color>中骑行里程达到<color=#e3d427>{"50KM"}</color>!" : $"riding distance reaches <color=#e3d427>{"50KM"}</color> in <color=#f93086>${item.RouteName}</color>!";
|
2021-12-30 16:51:04 +08:00
|
|
|
|
EventQueueSystem.QueueEventOnce(new LinkedMessageEvent(item.RouteId, message, item.HeadImage, item.Name, item.RouteName), $"{item.RouteId}{item.Name}50KM");
|
2021-12-15 13:24:26 +08:00
|
|
|
|
}
|
2021-12-24 18:33:58 +08:00
|
|
|
|
//距离100
|
|
|
|
|
|
if (item.EndDistance >= 100)
|
2021-12-15 13:24:26 +08:00
|
|
|
|
{
|
2022-01-07 18:22:22 +08:00
|
|
|
|
var message = lang == "zh" ? $"在<color=#f93086>{item.RouteName}</color>中骑行里程达到<color=#e3d427>{"100KM"}</color>!" : $"riding distance reaches <color=#e3d427>{"100KM"}</color> in <color=#f93086>${item.RouteName}</color>!";
|
2021-12-30 16:51:04 +08:00
|
|
|
|
EventQueueSystem.QueueEventOnce(new LinkedMessageEvent(item.RouteId, message, item.HeadImage, item.Name, item.RouteName), $"{item.RouteId}{item.Name}100KM");
|
2021-12-24 18:33:58 +08:00
|
|
|
|
}
|
2022-01-06 10:58:52 +08:00
|
|
|
|
////速度35
|
|
|
|
|
|
//if (item.Speed >= 35)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// var message = lang == "zh" ? $"骑行速度突破<color=#e3d427>{Math.Round(item.Speed, 2)}KM/H</color>!" : $"riding speed reaches <color=#e3d427>{Math.Round(item.Speed, 2)}KM/H</color>!";
|
|
|
|
|
|
// EventQueueSystem.QueueEventOnce(new LinkedMessageEvent(item.RouteId, message, item.HeadImage, item.Name, item.RouteName), $"{item.RouteId}{item.Name}35KM/H");
|
|
|
|
|
|
//}
|
2021-12-24 18:33:58 +08:00
|
|
|
|
//速度50
|
|
|
|
|
|
if (item.Speed >= 50)
|
|
|
|
|
|
{
|
2022-01-07 18:22:22 +08:00
|
|
|
|
var message = lang == "zh" ? $"在<color=#f93086>{item.RouteName}</color>中骑行速度达到<color=#e3d427>{Math.Round(item.Speed,2)}KM/H</color>!" : $"riding speed reaches <color=#e3d427>{Math.Round(item.Speed, 2)}KM/H</color> in <color=#f93086>${item.RouteName}</color>!";
|
2021-12-30 16:51:04 +08:00
|
|
|
|
EventQueueSystem.QueueEventOnce(new LinkedMessageEvent(item.RouteId, message, item.HeadImage, item.Name, item.RouteName), $"{item.RouteId}{item.Name}50KM/H");
|
2021-12-15 13:24:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
//功体比
|
2022-01-06 10:58:52 +08:00
|
|
|
|
if (item.WeightKg >= 4)
|
2021-12-15 13:24:26 +08:00
|
|
|
|
{
|
2022-01-07 18:22:22 +08:00
|
|
|
|
var message = lang == "zh" ? $"在<color=#f93086>{item.RouteName}</color>中功体比达到<color=#e3d427>{Math.Round(item.WeightKg, 2)}w/kg</color>!" : $" riding PWR reaches <color=#e3d427>{Math.Round(item.WeightKg, 2)}w/kg</color> in <color=#f93086>${item.RouteName}</color>!";
|
2021-12-30 16:51:04 +08:00
|
|
|
|
EventQueueSystem.QueueEventOnce(new LinkedMessageEvent(item.RouteId, message, item.HeadImage, item.Name, item.RouteName), $"{item.RouteId}{item.Name}3WeightKg");
|
2021-12-15 13:24:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-07-23 18:07:12 +08:00
|
|
|
|
}
|
2022-01-05 17:40:12 +08:00
|
|
|
|
|
2021-12-14 18:10:58 +08:00
|
|
|
|
}
|
2021-12-15 18:18:12 +08:00
|
|
|
|
|
2021-12-16 16:00:14 +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-12-07 16:44:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 检查上次异常中断的骑行
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void LastRide()
|
|
|
|
|
|
{
|
|
|
|
|
|
var tempFileList = System.IO.Directory.GetFiles(PFConstants.MapWorkoutRecordTempFolder);
|
|
|
|
|
|
if (tempFileList.Length > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
var tempFile = tempFileList[0];
|
|
|
|
|
|
var content = System.IO.File.ReadAllText(tempFile);
|
|
|
|
|
|
if (!string.IsNullOrEmpty(content))
|
|
|
|
|
|
{
|
|
|
|
|
|
var tempRecordData = Newtonsoft.Json.JsonConvert.DeserializeObject<TempRecordData>(content);
|
|
|
|
|
|
App.tempRecordData = tempRecordData;
|
2021-12-16 16:53:38 +08:00
|
|
|
|
|
2021-12-29 17:05:07 +08:00
|
|
|
|
UIManager.ShowConfirm(App.GetLocalString("Reconnect"), App.GetLocalString("Did you want to reconnect the trip that was interrupted abnormally?"), () => {
|
|
|
|
|
|
App.RouteIdParam = App.tempRecordData.RouteId;
|
|
|
|
|
|
App.CompetionId = App.tempRecordData.CompetitionId;
|
|
|
|
|
|
SceneManager.LoadScene("Ride");
|
|
|
|
|
|
},2,()=> {
|
2021-12-17 11:10:17 +08:00
|
|
|
|
Helper.DelectDir(PFConstants.MapWorkoutRecordTempFolder);
|
|
|
|
|
|
App.tempRecordData = null;
|
|
|
|
|
|
});
|
2021-12-07 16:44:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-12-16 16:00:14 +08:00
|
|
|
|
private void OnDestroy()
|
|
|
|
|
|
{
|
2021-12-21 10:10:05 +08:00
|
|
|
|
EventQueueSystem.RemoveListener<LinkedMessageEvent>(LinkedMessageHandler);
|
2021-12-16 16:00:14 +08:00
|
|
|
|
App.isHomeChanged -= OnIsHomeChanged;
|
|
|
|
|
|
}
|
2021-03-25 16:53:39 +08:00
|
|
|
|
}
|