Loading页面渐隐
This commit is contained in:
parent
10c82703f4
commit
018699c944
File diff suppressed because it is too large
Load Diff
@ -32,7 +32,7 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
private MapApi mapApi;
|
private MapApi mapApi;
|
||||||
private Route mapRoute;
|
private Route mapRoute;
|
||||||
#endregion
|
#endregion
|
||||||
|
GameObject loadingcanvas;
|
||||||
void Awake()
|
void Awake()
|
||||||
{
|
{
|
||||||
cyclingModel = CyclingModel.Single;
|
cyclingModel = CyclingModel.Single;
|
||||||
@ -42,8 +42,8 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
RouteId = App.RouteIdParam > 0? App.RouteIdParam : 376;
|
RouteId = App.RouteIdParam > 0? App.RouteIdParam : 376;
|
||||||
//var result = GetTestData();
|
//var result = GetTestData();
|
||||||
MapDataModel result = mapApi.GetData(RouteId);
|
MapDataModel result = mapApi.GetData(RouteId);
|
||||||
|
//player = transform.Find("Player").gameObject;
|
||||||
|
//loadingcanvas = transform.Find("LoadingCanvas").gameObject;
|
||||||
var antConnected = CheckAnt();//初始化ant+设备
|
var antConnected = CheckAnt();//初始化ant+设备
|
||||||
|
|
||||||
//if (!antConnected)
|
//if (!antConnected)
|
||||||
@ -52,7 +52,6 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
//}
|
//}
|
||||||
//StartCoroutine(requset());
|
//StartCoroutine(requset());
|
||||||
|
|
||||||
|
|
||||||
var param = mapApi.GetById(RouteId);
|
var param = mapApi.GetById(RouteId);
|
||||||
mapRoute = GetNewInstace(RouteId);//获取一个路书所有的数据
|
mapRoute = GetNewInstace(RouteId);//获取一个路书所有的数据
|
||||||
MapUDPService.Init();
|
MapUDPService.Init();
|
||||||
@ -75,16 +74,6 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
// CyclingModel = new ReviewModel(Route, param);
|
// CyclingModel = new ReviewModel(Route, param);
|
||||||
//cyclingModel.OpenCyclingWindow();
|
//cyclingModel.OpenCyclingWindow();
|
||||||
// break;
|
// 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)
|
if (result != null )//&& mapRoute != null)
|
||||||
@ -114,15 +103,10 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
{
|
{
|
||||||
//加载人物和地图以及UI界面
|
//加载人物和地图以及UI界面
|
||||||
map.gameObject.SetActive(true);
|
map.gameObject.SetActive(true);
|
||||||
//player.SetActive(true);
|
player.SetActive(true);
|
||||||
UIObject.SetActive(true);
|
UIObject.SetActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Update()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#region 数据处理
|
#region 数据处理
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前骑行数据的记录器
|
/// 当前骑行数据的记录器
|
||||||
|
|||||||
@ -9,6 +9,18 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
{
|
{
|
||||||
public class DeviceServiceMonoBase: MonoBehaviour
|
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 获取设备数据
|
#region 获取设备数据
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新速度(KM/H)
|
/// 更新速度(KM/H)
|
||||||
|
|||||||
118
Assets/Scenes/Ride/Scripts/LoadingController.cs
Normal file
118
Assets/Scenes/Ride/Scripts/LoadingController.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -32,9 +32,10 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
weight = App.CurrentUser.Weight;
|
weight = App.CurrentUser.Weight;
|
||||||
bicycleWeight = App.CurrentUser.BicycleWeight;
|
bicycleWeight = App.CurrentUser.BicycleWeight;
|
||||||
Debug.Log(power);
|
Debug.Log(power);
|
||||||
//#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
// power = 2000;//测试功率
|
power = 2000;//测试功率
|
||||||
//#endif
|
#endif
|
||||||
|
mainController.TrackResistance(currentSlope);
|
||||||
speed = Helper.CalculateSpeed(elevation, currentSlope, power, weight, bicycleWeight);
|
speed = Helper.CalculateSpeed(elevation, currentSlope, power, weight, bicycleWeight);
|
||||||
distance = mainController.UpdateDistance(speed);
|
distance = mainController.UpdateDistance(speed);
|
||||||
totalDistance += distance;
|
totalDistance += distance;
|
||||||
|
|||||||
@ -183,7 +183,7 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
lineRender.SetVertexCount(dat.Count);
|
lineRender.SetVertexCount(dat.Count);
|
||||||
lineRender.SetPositions(feat.Points[0].ToArray());
|
lineRender.SetPositions(feat.Points[0].ToArray());
|
||||||
lineRender.loop = false;
|
lineRender.loop = false;
|
||||||
//lineRender.numCapVertices = 90;
|
lineRender.numCapVertices = 90;
|
||||||
float alpha = 1.0f;
|
float alpha = 1.0f;
|
||||||
//Gradient gradient = new Gradient();
|
//Gradient gradient = new Gradient();
|
||||||
//gradient.SetKeys(
|
//gradient.SetKeys(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user