Loading页面渐隐

This commit is contained in:
lishuo 2021-04-16 11:23:18 +08:00
parent 10c82703f4
commit 018699c944
8 changed files with 3778 additions and 3473 deletions

File diff suppressed because it is too large Load Diff

View File

@ -32,7 +32,7 @@ public class CyclingController : DeviceServiceMonoBase
private MapApi mapApi;
private Route mapRoute;
#endregion
GameObject loadingcanvas;
void Awake()
{
cyclingModel = CyclingModel.Single;
@ -42,8 +42,8 @@ public class CyclingController : DeviceServiceMonoBase
RouteId = App.RouteIdParam > 0? App.RouteIdParam : 376;
//var result = GetTestData();
MapDataModel result = mapApi.GetData(RouteId);
//player = transform.Find("Player").gameObject;
//loadingcanvas = transform.Find("LoadingCanvas").gameObject;
var antConnected = CheckAnt();//初始化ant+设备
//if (!antConnected)
@ -52,7 +52,6 @@ public class CyclingController : DeviceServiceMonoBase
//}
//StartCoroutine(requset());
var param = mapApi.GetById(RouteId);
mapRoute = GetNewInstace(RouteId);//获取一个路书所有的数据
MapUDPService.Init();
@ -75,16 +74,6 @@ public class CyclingController : DeviceServiceMonoBase
// CyclingModel = new ReviewModel(Route, param);
//cyclingModel.OpenCyclingWindow();
// break;
//case Model.CyclingModel.Competition:
// CyclingModel = new CompetitionModel(Route, param);
// //cyclingModel.OpenCyclingWindow();
// break;
//case Model.CyclingModel.GlobalCycling:
// CyclingModel = new GlobalCyclingModel(Route, param);
// break;
//default:
// break;
}
if (result != null )//&& mapRoute != null)
@ -114,15 +103,10 @@ public class CyclingController : DeviceServiceMonoBase
{
//加载人物和地图以及UI界面
map.gameObject.SetActive(true);
//player.SetActive(true);
player.SetActive(true);
UIObject.SetActive(true);
}
private void Update()
{
}
#region
/// <summary>
/// 当前骑行数据的记录器

View File

@ -9,6 +9,18 @@ namespace Assets.Scenes.Ride.Scripts
{
public class DeviceServiceMonoBase: MonoBehaviour
{
public void TrackResistance(double grade)
{
//if (!ConfigHelper.IsNeedContectedToDevice)
//{
// return;
//}
var device = (_device as FitDevice);
if (device != null)
{
device.SetTrackResistance(grade);
}
}
#region
/// <summary>
/// 更新速度(KM/H)

View File

@ -0,0 +1,118 @@
using UnityEngine;
using Mapbox.Unity.Map;
using UnityEngine.UI;
using Assets.Scripts.Apis;
using System;
using Assets.Scripts;
namespace Assets.Scenes.Ride.Scripts
{
//[ExecuteInEditMode]
public class LoadingController : MonoBehaviour
{
Text mapName;
AbstractMap _map;
Text level;
Text distance;
Text elevaction;
Text slope;
Text rideNum;
Text uploadByUserName;
RawImage head;
RawImage country;
MapApi mapApi;
GameObject panel;
CanvasGroup canvasGroup;
private void Start()
{
int routeId = App.RouteIdParam;
mapApi = new MapApi();
panel = transform.Find("Panel").gameObject;
mapName = transform.Find("Panel/MapName").GetComponent<Text>();
level = transform.Find("Panel/level/Text").GetComponent<Text>();
elevaction = transform.Find("Panel/Elevaction").GetComponent<Text>();
slope = transform.Find("Panel/Slope").GetComponent<Text>();
rideNum = transform.Find("Panel/RideNum").GetComponent<Text>();
uploadByUserName = transform.Find("Panel/UploadByUserName").GetComponent<Text>();
country = transform.Find("Panel/UploadByCountry").GetComponent<RawImage>();
head = transform.Find("Panel/UploadByHead").GetComponent<RawImage>();
var root = transform.parent;
_map = root.Find("Map").GetComponent<AbstractMap>();
canvasGroup = transform.GetComponent<CanvasGroup>();
if (routeId > 0)
{
var map = mapApi.GetById(routeId);
var route = map.data;
mapName.text = route.Name;
level.text = route.Hard;
elevaction.text = route.EleDifference.ToString("g0");
slope.text = Math.Round(route.AverageGrade,2).ToString() + "%";
rideNum.text = route.TheHeat.ToString();
var userList = mapApi.GetOnlineUserInfo(new int[] { route.UserId }).data;
if (userList.Count > 0)
{
uploadByUserName.text = userList[0].Name;
var countryUrl = App.Host + $"User/GetCountryImg?userid={userList[0].Id}";
Utils.DisplayImage(StartCoroutine, head, userList[0].HeadImage);
Utils.DisplayImage(StartCoroutine, country, countryUrl);
}
_map.OnInitialized += _map_OnInitialized;
_map.OnEditorPreviewEnabled += OnEditorPreviewEnabled;
_map.OnEditorPreviewDisabled += OnEditorPreviewDisabled;
}
}
void _map_OnInitialized()
{
var visualizer = _map.MapVisualizer;
visualizer.OnMapVisualizerStateChanged += (s) =>
{
if (s == ModuleState.Finished)
{
canvasGroup.blocksRaycasts = false;
depressFlag = true;
}
};
}
void OnEditorPreviewEnabled()
{
transform.gameObject.SetActive(false);
}
void OnEditorPreviewDisabled()
{
transform.gameObject.SetActive(true);
}
public float targetAlpha = 0f;
public float alphaSpeed = 2.0f;
private bool depressFlag = false;
void Update()
{
if (canvasGroup == null)
{
return;
}
if (targetAlpha != canvasGroup.alpha && depressFlag)
{
canvasGroup.alpha = Mathf.Lerp(canvasGroup.alpha, targetAlpha, alphaSpeed * Time.deltaTime);
if (Mathf.Abs(targetAlpha - canvasGroup.alpha) <= 0.01f)
{
canvasGroup.alpha = targetAlpha;
}
if (canvasGroup.alpha == 0)
{
transform.gameObject.SetActive(false);
}
}
}
}
}

View File

@ -1,102 +0,0 @@
using UnityEngine;
using Mapbox.Unity.Map;
using UnityEngine.UI;
namespace Assets.Scenes.Ride.Scripts
{
//[ExecuteInEditMode]
public class LoadingPanelController : MonoBehaviour
{
[SerializeField]
Text _text;
[SerializeField]
AnimationCurve _curve;
Text mapName;
AbstractMap _map;
Text level;
Text distance;
Text elevaction;
Text slope;
Text rideNum;
Text uploadByUserName;
private void Start()
{
var root = transform.parent.parent.parent;
_map = root.Find("Map").GetComponent<AbstractMap>();
var cyclingController = root.GetComponent<CyclingController>();
mapName = transform.Find("MapName").GetComponent<Text>();
level = transform.Find("level/Text").GetComponent<Text>();
elevaction = transform.Find("Elevaction").GetComponent<Text>();
slope = transform.Find("Slope").GetComponent<Text>();
rideNum = transform.Find("RideNum").GetComponent<Text>();
uploadByUserName = transform.Find("UploadByUserName").GetComponent<Text>();
var mapdata = cyclingController.GetMapData();
var route = cyclingController.GetRoute();
mapName.text = route.RouteInstance.Name;
level.text = route.RouteInstance.Hard;
elevaction.text = route.RouteInstance.EleDifference.ToString("g0");
slope.text = route.RouteInstance.AverageGrade.ToString() + "%";
rideNum.text = route.RouteInstance.TheHeat.ToString();
uploadByUserName.text = route.RouteInstance.UserId.ToString();
_map.OnInitialized += _map_OnInitialized;
_map.OnTileFinished += _map_OnTileFinished;
_map.OnEditorPreviewEnabled += OnEditorPreviewEnabled;
_map.OnEditorPreviewDisabled += OnEditorPreviewDisabled;
_map.OnUpdated += _map_OnUpdated;
}
private void _map_OnUpdated()
{
//Debug.Log("_map_OnUpdated");
}
private void _map_OnTileFinished(global::Mapbox.Unity.MeshGeneration.Data.UnityTile obj)
{
//transform.gameObject.SetActive(false);
Debug.Log("_map_OnTileFinished");
}
void _map_OnInitialized()
{
var visualizer = _map.MapVisualizer;
_text.text = "LOADING";
visualizer.OnMapVisualizerStateChanged += (s) =>
{
if (this == null)
return;
if (s == ModuleState.Finished)
{
transform.gameObject.SetActive(false);
}
else if (s == ModuleState.Working)
{
}
};
}
void OnEditorPreviewEnabled()
{
transform.gameObject.SetActive(false);
}
void OnEditorPreviewDisabled()
{
transform.gameObject.SetActive(true);
}
void Update()
{
var t = _curve.Evaluate(Time.time);
_text.color = Color.Lerp(Color.clear, Color.white, t);
}
}
}

View File

@ -32,9 +32,10 @@ namespace Assets.Scenes.Ride.Scripts
weight = App.CurrentUser.Weight;
bicycleWeight = App.CurrentUser.BicycleWeight;
Debug.Log(power);
//#if UNITY_EDITOR
// power = 2000;//测试功率
//#endif
#if UNITY_EDITOR
power = 2000;//测试功率
#endif
mainController.TrackResistance(currentSlope);
speed = Helper.CalculateSpeed(elevation, currentSlope, power, weight, bicycleWeight);
distance = mainController.UpdateDistance(speed);
totalDistance += distance;

View File

@ -183,7 +183,7 @@ namespace Assets.Scenes.Ride.Scripts
lineRender.SetVertexCount(dat.Count);
lineRender.SetPositions(feat.Points[0].ToArray());
lineRender.loop = false;
//lineRender.numCapVertices = 90;
lineRender.numCapVertices = 90;
float alpha = 1.0f;
//Gradient gradient = new Gradient();
//gradient.SetKeys(