增加编号,loading页提示,延迟毫秒

This commit is contained in:
Caiyanpeng committed 2021-11-01 11:04:22 +08:00
1 parent b9aa0131cc
commit 558fb16160
62 files changed
+7533 -2804

No files matched your search

+1
View File
@@ -115,6 +115,7 @@ namespace Assets.Scripts.Apis
#else
defaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("Unity", ConfigHelper.AppVersion));
#endif
defaultRequestHeaders.Add("deviceUniqueIdentifier", SystemInfo.deviceUniqueIdentifier);
}
protected async Task<byte[]> GetUrlAsync(string url)
+4 -1
View File
@@ -10,6 +10,7 @@ using System.Threading;
using Assets.Scripts.Devices;
using Assets.Scripts;
using System;
using System.Threading.Tasks;
public static class App
{
@@ -97,6 +98,7 @@ public static class App
public readonly static bool isFullScreen = width / height > 1.8;
public static float canvasWidth { get; set; }
public static string WorkoutsUrl { get; internal set; }
public static long delayTime { get; set; }
static App()
{
@@ -116,6 +118,7 @@ public static class App
App._IsRowerMode = bool.Parse(isRower);
}
Screen.sleepTimeout = SleepTimeout.NeverSleep;
Debug.Log("117,"+ Utils.isUpdate("2.0.3","2.0.2"));
Debug.Log(SystemInfo.deviceUniqueIdentifier);
}
}
@@ -56,7 +56,8 @@ public class LoginControllerMobile : MonoBehaviour, INativeOnMobileWxLoginResp
var r = await ConfigHelper.userApi.GetVersions();
if (r.result)
{
#if UNITY_ANDROID
#if UNITY_ANDROID || UNITY_IOS
#if UNITY_ANDROID
var info = r.data.Value<JObject>("UnityApk");
Debug.Log(info.Value<string>("Version"));
if (Utils.isUpdate(App.AppVersion, info.Value<string>("Version")))
@@ -78,6 +79,7 @@ public class LoginControllerMobile : MonoBehaviour, INativeOnMobileWxLoginResp
}
#endif
App.WorkoutsUrl = info.Value<string>("Url");
#endif
}
//if (r.result)
//{
+26 -4
View File
@@ -113,6 +113,7 @@ public class LoginController : BaseScene
Dictionary<string, Selectable> formDict, signFormDict;
public string avatarName { get; private set; }
public Texture avatar;
// Start is called before the first frame update
void Start()
@@ -506,18 +507,39 @@ public class LoginController : BaseScene
}
async void Init()
{
Task.Run(() =>
{
System.Net.NetworkInformation.Ping ping = new System.Net.NetworkInformation.Ping();
System.Timers.Timer timer = new System.Timers.Timer();
timer.Interval = 1000;
timer.AutoReset = true;
timer.Elapsed += new ElapsedEventHandler((o, e) =>
{
var reply = ping.Send("47.97.84.8");
if (reply.Status == System.Net.NetworkInformation.IPStatus.Success)
{
#if UNITY_EDITOR
App.delayTime = new System.Random().Next(300);
#else
App.delayTime = reply.RoundtripTime;
#endif
}
else
{
App.delayTime = -1;
}
});
timer.Start();
});
Debug.Log(535);
UIManager.Instance.ModalsPanel = this.transform.Find("ModalPanel").GetComponent<PFUIPanel>();
userInfos = UIManager.Instance.userInfos;
App.DefaultRotateTexture = Utils.ReadTextureFromPlayerPrefs("rotateImage");
App.firstEnter = PlayerPrefs.GetInt("firstEnter");
PlayerPrefs.SetInt("firstEnter", 1);
var notifyId = PlayerPrefs.GetInt("notifyId");
//Task.Run(async () =>
//{
//});
var r = await ConfigHelper.userApi.GetNotify();
if (r.result)
{
#if !(UNITY_ANDROID || UNITY_IOS)
@@ -158,6 +158,36 @@ namespace Assets.Scenes.Ride.Scripts
UIManager.AddEvent(Apply, EventTriggerType.PointerClick, ApplyRace);
UIManager.AddEvent(CancelJoin, EventTriggerType.PointerClick, CancelReserve);
UIManager.AddEvent(Detail, EventTriggerType.PointerClick, GoDetail);
#if UNITY_STANDALONE_WIN
UIManager.RemoveEvent(distance.gameObject);
UIManager.RemoveEvent(slope.gameObject);
UIManager.RemoveEvent(elevaction.gameObject);
UIManager.AddEvent(distance.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerEnter, b =>
{
panel.transform.Find("DistanceTip").GetComponent<CanvasGroup>().DOFade(1, 0.5f);
});
UIManager.AddEvent(distance.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerExit, b =>
{
panel.transform.Find("DistanceTip").GetComponent<CanvasGroup>().DOFade(0, 0.5f);
});
UIManager.AddEvent(slope.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerEnter, b =>
{
panel.transform.Find("SlopeTip").GetComponent<CanvasGroup>().DOFade(1, 0.5f);
});
UIManager.AddEvent(slope.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerExit, b =>
{
panel.transform.Find("SlopeTip").GetComponent<CanvasGroup>().DOFade(0, 0.5f);
});
UIManager.AddEvent(elevaction.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerEnter, b =>
{
panel.transform.Find("ElevactionTip").GetComponent<CanvasGroup>().DOFade(1, 0.5f);
});
UIManager.AddEvent(elevaction.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerExit, b =>
{
panel.transform.Find("ElevactionTip").GetComponent<CanvasGroup>().DOFade(0, 0.5f);
});
#endif
}
private bool _canCancelApply = false;
@@ -197,7 +227,7 @@ namespace Assets.Scenes.Ride.Scripts
//路书描述
mapDescText.text = GetMaxString(competition.Dec, 400);
//线路编号
MapId.text = route.Id.ToString();
MapId.text = $"#{route.Id.ToString()}";
ReadMore.SetActive(!string.IsNullOrEmpty(competition.CompetitionPreviewUrl));
//主办方logo
@@ -176,20 +176,20 @@ namespace Assets.Scenes.Ride.Scripts
{
if (!rideNow.IsInteractable())
return;
var checkAnt = cyclingController.CheckAnt();
#if UNITY_EDITOR
checkAnt = true;
#endif
if (!checkAnt && !cyclingController.isWatch)
{
#if UNITY_IOS || UNITY_ANDROID
var alert = (GameObject)Instantiate(Resources.Load("UI/Prefab/Ride/Mobile/Alert"), panel.transform);
#else
var alert = (GameObject)Instantiate(Resources.Load("UI/Prefab/Ride/Alert"), panel.transform);
#endif
alert.SetActive(true);
}
else
//var checkAnt = cyclingController.CheckAnt();
//#if UNITY_EDITOR
// checkAnt = true;
//#endif
// if (!checkAnt && !cyclingController.isWatch)
// {
//#if UNITY_IOS || UNITY_ANDROID
// var alert = (GameObject)Instantiate(Resources.Load("UI/Prefab/Ride/Mobile/Alert"), panel.transform);
//#else
// var alert = (GameObject)Instantiate(Resources.Load("UI/Prefab/Ride/Alert"), panel.transform);
//#endif
// alert.SetActive(true);
// }
// else
{
cyclingController.InitTcp();
MapUDPService.SendGizpModel();
@@ -491,7 +491,25 @@ public class CyclingController : DeviceServiceMonoBase
public BaseUIManager singleUIManager;
public void GameStart()
{
singleUIManager.StartRide();
var check = CheckAnt();
if (check)
{
singleUIManager.StartRide();
transform.Find("UI/Panel(Clone)/ToolBarPanel/StartOrPauseButton").GetComponent<Button>().enabled = true;
}
else
{
transform.Find("UI/Panel(Clone)/ToolBarPanel/StartOrPauseButton").GetComponent<Button>().enabled = false;
Utils.showToast(null, "Please connect the device!", duration: int.MaxValue, isLowest: true
, stopFunc: () => !(!CheckAnt() && !isWatch)
, endCallback: () =>
{
UIManager.Instance.DevicePanel.Close();
singleUIManager.StartRide();
transform.Find("UI/Panel(Clone)/ToolBarPanel/StartOrPauseButton").GetComponent<Button>().enabled = true;
});
}
}
public void GoContinueRide()
@@ -5,6 +5,7 @@ using System;
using Assets.Scripts;
using Assets.Scripts.Apis.Models;
using System.Collections.Generic;
using DG.Tweening;
namespace Assets.Scenes.Ride.Scripts
{
@@ -51,6 +52,7 @@ namespace Assets.Scenes.Ride.Scripts
protected override void InitGameObject()
{
base.InitGameObject();
Debug.Log(55);
level = panel.transform.Find("level/Text").GetComponent<Text>();
rideNum = panel.transform.Find("RideNum").GetComponent<Text>();
uploadByUserName = panel.transform.Find("UploadByUserName").GetComponent<Text>();
@@ -60,6 +62,45 @@ namespace Assets.Scenes.Ride.Scripts
altitudeGraph = panel.transform.Find("AltitudeGraph").GetComponent<RawImage>();
mapRanking = panel.transform.Find("MapRanking");
mapId = panel.transform.Find("MapId").GetComponent<Text>();
#if UNITY_STANDALONE_WIN
UIManager.RemoveEvent(distance.gameObject);
UIManager.RemoveEvent(slope.gameObject);
UIManager.RemoveEvent(elevaction.gameObject);
UIManager.RemoveEvent(rideNum.gameObject);
UIManager.AddEvent(distance.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerEnter, b =>
{
panel.transform.Find("DistanceTip").GetComponent<CanvasGroup>().DOFade(1, 0.5f);
});
UIManager.AddEvent(distance.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerExit, b =>
{
panel.transform.Find("DistanceTip").GetComponent<CanvasGroup>().DOFade(0, 0.5f);
});
UIManager.AddEvent(slope.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerEnter, b =>
{
panel.transform.Find("SlopeTip").GetComponent<CanvasGroup>().DOFade(1, 0.5f);
});
UIManager.AddEvent(slope.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerExit, b =>
{
panel.transform.Find("SlopeTip").GetComponent<CanvasGroup>().DOFade(0, 0.5f);
});
UIManager.AddEvent(elevaction.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerEnter, b =>
{
panel.transform.Find("ElevactionTip").GetComponent<CanvasGroup>().DOFade(1, 0.5f);
});
UIManager.AddEvent(elevaction.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerExit, b =>
{
panel.transform.Find("ElevactionTip").GetComponent<CanvasGroup>().DOFade(0, 0.5f);
});
UIManager.AddEvent(rideNum.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerEnter, b =>
{
panel.transform.Find("RideTip").GetComponent<CanvasGroup>().DOFade(1, 0.5f);
});
UIManager.AddEvent(rideNum.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerExit, b =>
{
panel.transform.Find("RideTip").GetComponent<CanvasGroup>().DOFade(0, 0.5f);
});
#endif
}
protected override void InitGameObjectData()
{
@@ -77,7 +118,7 @@ namespace Assets.Scenes.Ride.Scripts
rideNum.text = route.TheHeat.ToString();
distance.text = route.Distance.ToString("f1") + "KM";
mapDescText.text = GetMaxString(route.Dec, 255);
mapId.text = route.Id.ToString();
mapId.text = $"#{route.Id.ToString()}";
var userList = ConfigHelper.mapApi.GetOnlineUserInfo(new int[] { route.UserId }).data;
if (userList.Count > 0)
{
@@ -1,4 +1,5 @@
using System.Collections;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
@@ -7,12 +8,48 @@ namespace Assets.Scenes.Ride.Scripts
{
public class VersionScript : MonoBehaviour
{
long _delayTime = 0;
Text appVersion;
void Start()
{
var appVersion = transform.GetComponent<Text>();
appVersion = transform.GetComponent<Text>();
if (appVersion != null)
{
appVersion.text = "V"+App.AppVersion;
appVersion.lineSpacing = 1;
appVersion.verticalOverflow = VerticalWrapMode.Overflow;
appVersion.alignment = TextAnchor.LowerRight;
appVersion.text = $"{"V" + App.AppVersion}";
}
}
private void Update()
{
if (_delayTime != App.delayTime && appVersion != null)
{
_delayTime = App.delayTime;
if (_delayTime != -1)
{
appVersion.text = $"<color={getColor(_delayTime)}>{_delayTime.ToString("0")}MS</color>\n{"V" + App.AppVersion}";
}
else
{
appVersion.text = "V" + App.AppVersion;
}
}
}
private string getColor(long a)
{
if (a > 0 && a <= 50)
{
return "#4FE944";
}
else if (a > 50 && a <= 100)
{
return "#E9BF44";
}
else
{
return "#EE2929";
}
}
}
+1 -1
View File
@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: f32005e7feffc344096558df74482afb
guid: 805aa640eb93e8e4e8da69ec52bcf9a1
folderAsset: yes
DefaultImporter:
externalObjects: {}
+1 -1
View File
@@ -227,7 +227,7 @@ namespace Assets.Scripts.UI.Control
break;
case Type.Image:
{
tooltips.SetActive(false);
//tooltips.SetActive(false);
}
break;
default:
+1 -1
View File
@@ -98,7 +98,7 @@ public class MapItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandler,
});
transform.Find("Name").GetComponent<Text>().text = myMap.Name;
transform.Find("IdContainer/Text").GetComponent<Text>().text = $"#{myMap.Id}";
transform.Find("Hot").gameObject.SetActive(myMap.IsFire);
var props = transform.Find("Props");
props.Find("DistanceText").GetComponent<Text>().text = $"{myMap.Distance.ToString(myMap.Distance>1000? "#0" : "#0.00")}KM";
@@ -79,6 +79,7 @@ public class RaceItemScript : MonoBehaviour, IPointerExitHandler, IPointerEnterH
= $"{mapCompetition.AverageGrade.ToString("#0.00")}%";
transform.Find("InfoContainer/StartTime/Text").GetComponent<Text>().text = mapCompetition.StartTime.ToLocalTime().ToString();
transform.Find("CountContainer/Text").GetComponent<Text>().text = mapCompetition.ApplyCount.ToString();
transform.Find("IdContainer/Text").GetComponent<Text>().text = $"#{mapCompetition.RouteId}";
SetStatus(mapCompetition);
#if !(UNITY_ANDROID || UNITY_IOS)
SetButtonGroup(mapCompetition);
@@ -233,6 +234,7 @@ public class RaceItemScript : MonoBehaviour, IPointerExitHandler, IPointerEnterH
transform.Find("GetReadyContainer").GetComponent<CanvasGroup>().DOFade(0, 0.5f);
transform.Find("GetReadyContainer-2").GetComponent<CanvasGroup>().DOFade(0, 0.5f);
transform.Find("InfoContainer").GetComponent<CanvasGroup>().DOFade(1, 0.2f);
transform.Find("IdContainer").GetComponent<CanvasGroup>().DOFade(1, 0.2f);
if (myType == ItemType.small)
{
transform.Find("DataContainer").GetComponent<CanvasGroup>().DOFade(0, 0.5f);
@@ -266,6 +268,7 @@ public class RaceItemScript : MonoBehaviour, IPointerExitHandler, IPointerEnterH
transform.Find("GetReadyContainer").GetComponent<CanvasGroup>().DOFade(1, 0.5f);
transform.Find("GetReadyContainer-2").GetComponent<CanvasGroup>().DOFade(1, 0.5f);
transform.Find("InfoContainer").GetComponent<CanvasGroup>().DOFade(0, 0.2f);
transform.Find("IdContainer").GetComponent<CanvasGroup>().DOFade(0, 0.2f);
if (myType == ItemType.small)
{
transform.Find("DataContainer").GetComponent<CanvasGroup>().DOFade(1, 0.5f);
+7 -4
View File
@@ -36,11 +36,11 @@ public class Toast : MonoBehaviour
{
json.func = () => false;
}
StartCoroutine(showToastCOR(json.text, json.duration,json.func,json.showSeconds));
StartCoroutine(showToastCOR(json.text, json.duration,json.func,json.showSeconds,json.endCallback));
}
private IEnumerator showToastCOR(string text,
int duration, Func<bool> action,bool showSeconds)
int duration, Func<bool> action,bool showSeconds,Action endCallback)
{
gameObject.SetActive(true);
@@ -72,10 +72,13 @@ public class Toast : MonoBehaviour
}
yield return null;
}
if (endCallback != null)
{
endCallback.Invoke();
}
//Fade out
yield return fadeInAndOut(txt, false, 0.5f);
gameObject.SetActive(false);
}
+5 -2
View File
@@ -143,11 +143,12 @@ namespace Assets.Scripts
_deviceDict = value;
}
}
public static void showToast(GameObject game, string text, int duration = 2, int type = 0, Func<bool> stopFunc = null, bool isLowest = false,bool showSeconds = false)
public static void showToast(GameObject game, string text, int duration = 2, int type = 0, Func<bool> stopFunc = null, bool isLowest = false,bool showSeconds = false,Action endCallback = null)
{
//type 0错误 1正确
var parent = UIManager.Instance.ModalsPanel;
if (parent == null) return;
if (!parent.gameObject.activeInHierarchy) parent.gameObject.SetActive(true);
var toast = parent.transform.Find("ToastContainer");
if (toast != null)
{
@@ -178,7 +179,8 @@ namespace Assets.Scripts
text = text,
duration = duration,
func = stopFunc,
showSeconds = showSeconds
showSeconds = showSeconds,
endCallback = endCallback
});
}
public class ToastParams
@@ -187,6 +189,7 @@ namespace Assets.Scripts
public string text { get; set; }
public int duration { get; set; }
public Func<bool> func { get; set; }
public Action endCallback { get; set; }
}
/*显示简略提示,需要拖Toast的预制件,且保证其他组件名字不是Toast,ToastContainer*/
public static void showLoading(this GameObject game)