细节调整
This commit is contained in:
parent
bbc3deeef2
commit
02b8f97d83
@ -30,7 +30,7 @@ Transform:
|
||||
m_GameObject: {fileID: 3777003654129381334}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 3, y: 3, z: 3}
|
||||
m_LocalScale: {x: 15, y: 15, z: 15}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
@ -61,7 +61,7 @@ MeshRenderer:
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 2100000, guid: bdad3ccf6401a414188827874d8999aa, type: 2}
|
||||
- {fileID: 2100000, guid: 82096aab38f01cb40a1cbf8629a810ba, type: 2}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
|
||||
@ -108,9 +108,11 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
character: {fileID: 1056360222971152080}
|
||||
characterAnimator: {fileID: 0}
|
||||
isQuit: 0
|
||||
CurrentIndex: 0
|
||||
CurrentDistance: 0
|
||||
PreElevation: 0
|
||||
PreSlope: 0
|
||||
record: []
|
||||
_reviewItemScript: {fileID: 0}
|
||||
_playerController: {fileID: 0}
|
||||
LastTicks: 0
|
||||
tickOffset: 0
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -12,13 +12,13 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
public class ChartDataSourceScript:MonoBehaviour, IComparer<DoubleVector2>
|
||||
{
|
||||
public string Category = "Player 2";
|
||||
public int DownSampleToPoints = 100;
|
||||
List<DoubleVector2> mData = new List<DoubleVector2>(); // the data held by the chart
|
||||
public int DownSampleToPoints = 200;
|
||||
public List<DoubleVector2> mData = new List<DoubleVector2>(); // the data held by the chart
|
||||
double pageSize = 2f;
|
||||
double currentPagePosition = 0.0;
|
||||
double currentZoom = 0f;
|
||||
GraphChartBase graph;
|
||||
double mCurrentPageSizeFactor = double.NegativeInfinity;
|
||||
public double mCurrentPageSizeFactor = double.NegativeInfinity;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
|
||||
@ -63,8 +63,8 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
//获取路书信息
|
||||
mapApi = ConfigHelper.mapApi;
|
||||
routeId = App.RouteIdParam > 0? App.RouteIdParam : 2633;
|
||||
mapRoute = mapApi.GetById(routeId).data;
|
||||
miniMap = transform.Find("MiniMap").gameObject;//小地图
|
||||
//mapRoute = mapApi.GetById(routeId).data;
|
||||
//miniMap = transform.Find("MiniMap").gameObject;//小地图
|
||||
resultPanel = transform.Find("SingleUI/Panel/ResultPanel").gameObject;
|
||||
}
|
||||
|
||||
@ -75,7 +75,7 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
loadingController = FindObjectOfType<LoadingController>();
|
||||
loadingController.InjectController(this);
|
||||
//开始loading
|
||||
Init();
|
||||
StartCoroutine(Init());
|
||||
}
|
||||
|
||||
public void AddEvent(GameObject sender, EventTriggerType eventType,UnityAction<BaseEventData> unityAction)
|
||||
@ -92,14 +92,17 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
{
|
||||
return UIManager.Instance.loginRegOptions.GetCountryImageByName(name);
|
||||
}
|
||||
private void Init()
|
||||
private IEnumerator Init()
|
||||
{
|
||||
loadingController.Init(mapRoute);//初始化loading页面 10
|
||||
loadingController.AddProcess(10);
|
||||
MapUDPService.Init();//初始化TCP
|
||||
yield return new WaitForSeconds(1);
|
||||
mapRoute = mapApi.GetById(routeId).data;
|
||||
miniMap = transform.Find("MiniMap").gameObject;//小地图
|
||||
loadingController.Init(mapRoute);//初始化loading页面
|
||||
loadingController.AddProcess(10);
|
||||
InitData();//初始化数据
|
||||
InitGameObject();//初始化场景
|
||||
MapUDPService.Init();//初始化TCP
|
||||
loadingController.AddProcess(10);
|
||||
}
|
||||
//初始化数据
|
||||
private void InitData()
|
||||
@ -134,6 +137,8 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
App.routeResult = null;
|
||||
|
||||
#endregion
|
||||
//异步请求mapbox画出当前路书路线图
|
||||
loadingController.DrawMapRoute(mapData);
|
||||
//计算上次骑行距离调整地图中心点
|
||||
double endDistance = selectParamModel.EndDistance;
|
||||
coordiantes = Along(endDistance);
|
||||
@ -146,8 +151,6 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
loadingController.CreateRankingList(mapRouteRankingList);
|
||||
loadingController.AddProcess(10);
|
||||
}
|
||||
//异步请求mapbox画出当前路书路线图
|
||||
loadingController.DrawMapRoute(mapData);
|
||||
}
|
||||
//加载人物和地图以及UI界面
|
||||
private void InitGameObject()
|
||||
@ -269,14 +272,15 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
cyclingController.recorderData.AntModelId = AntModelId;
|
||||
cyclingController.recorderData.ManufacturerId = ManufacturerId;
|
||||
cyclingController.recorderData.DeviceNumber = DeviceNumber;
|
||||
#if !UNITY_EDITOR
|
||||
cyclingController.recorderData.SaveData(cyclingModel, selectParamModel, imageFileName);
|
||||
#endif
|
||||
//显示骑行结果
|
||||
resultPanel.SetActive(true);
|
||||
var rs = resultPanel.GetComponent<ResultPanelScript>();
|
||||
rs.InjectController(this);
|
||||
rs.SetDataSource(cyclingController.recorderData);
|
||||
#if !UNITY_EDITOR
|
||||
cyclingController.recorderData.SaveData(cyclingModel, selectParamModel, imageFileName);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
protected string CaptureCamera(Camera camera, Rect rect)
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
using UnityEngine;
|
||||
using Mapbox.Unity.Map;
|
||||
using DG.Tweening;
|
||||
using UnityEngine.UI;
|
||||
using Assets.Scripts.Apis;
|
||||
using System;
|
||||
@ -8,6 +9,7 @@ using Assets.Scripts.Apis.Models;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.SceneManagement;
|
||||
using System.Collections;
|
||||
|
||||
namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
@ -66,13 +68,50 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
public void DrawMapRoute(MapDataModel mapData)
|
||||
{
|
||||
var url = Helper.GetMapboxApiUrl(mapData.List);
|
||||
Utils.DisplayImageAysnc(StartCoroutine, mapRouteImage, url, dowloadCallBack);
|
||||
mapRouteImage.gameObject.SetActive(false);
|
||||
if (App.TextureCache.ContainsKey(url))
|
||||
{
|
||||
mapRouteImage.texture = App.TextureCache[url];
|
||||
var canvasGroup = mapRouteImage.GetComponent<CanvasGroup>();
|
||||
canvasGroup.DOFade(1, 1);
|
||||
this.AddProcess(10);
|
||||
}
|
||||
else
|
||||
{
|
||||
Utils.DisplayImageAysnc(StartCoroutine, mapRouteImage, url, dowloadCallBack);
|
||||
}
|
||||
}
|
||||
private void dowloadCallBack()
|
||||
|
||||
private void dowloadCallBack(string url)
|
||||
{
|
||||
mapRouteImage.gameObject.SetActive(true);
|
||||
this.AddProcess(10);
|
||||
if (!App.TextureCache.ContainsKey(url))
|
||||
{
|
||||
App.TextureCache.Add(url, mapRouteImage.texture);
|
||||
}
|
||||
else
|
||||
{
|
||||
App.TextureCache[url] = mapRouteImage.texture;
|
||||
}
|
||||
var canvasGroup = mapRouteImage.GetComponent<CanvasGroup>();
|
||||
canvasGroup.DOFade(1, 1);
|
||||
this.AddProcess(10);
|
||||
}
|
||||
float t = 1f;
|
||||
IEnumerator doCanvasGroup(CanvasGroup cp)
|
||||
{
|
||||
t -= Time.deltaTime;
|
||||
while (t<0)
|
||||
{
|
||||
if (1 != cp.alpha)
|
||||
{
|
||||
cp.alpha = Mathf.Lerp(cp.alpha, 1, alphaSpeed * Time.deltaTime);
|
||||
if (Mathf.Abs(1 - cp.alpha) <= 0.01f)
|
||||
{
|
||||
cp.alpha = 1;
|
||||
}
|
||||
yield return null;
|
||||
}
|
||||
t = 1;
|
||||
}
|
||||
}
|
||||
//设定当前loading进度
|
||||
public void AddProcess(float v)
|
||||
|
||||
@ -164,7 +164,8 @@ namespace Assets.Scenes.Ride.Scripts.Model
|
||||
Ticks = ticks,
|
||||
Mode = cyclingModel.ToString(),
|
||||
Param = Newtonsoft.Json.JsonConvert.SerializeObject(selectParam),
|
||||
GlobalCyclingId = 0
|
||||
GlobalCyclingId = 0,
|
||||
Source = "",
|
||||
};
|
||||
//var range = new MapSpeedRange().GetSpeedRange(RiderDatas, CurrentRoute.RouteInstance.Distance);
|
||||
interruptRecord.SpeedRange = null; //JsonConvert.SerializeObject(range);
|
||||
|
||||
@ -33,9 +33,9 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
weight = App.CurrentUser.Weight;
|
||||
bicycleWeight = App.CurrentUser.BicycleWeight;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
power = 2000;//测试功率
|
||||
#endif
|
||||
//#if UNITY_EDITOR
|
||||
power = 20000;//测试功率
|
||||
//#endif
|
||||
mainController.TrackResistance(currentSlope);//TODO
|
||||
speed = Helper.CalculateSpeed(elevation, currentSlope, power, weight, bicycleWeight);
|
||||
distance = mainController.UpdateDistance(speed);
|
||||
|
||||
@ -122,6 +122,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
//开始伴侣骑行的面板
|
||||
private void PreStart(BaseEventData baseEventData)
|
||||
{
|
||||
cyclingController.SetCyclingModel(CyclingModel.Review);
|
||||
transform.gameObject.SetActive(false);
|
||||
foreach (var item in gameObjects)
|
||||
{
|
||||
|
||||
@ -305,7 +305,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
private void ShadowRide(BaseEventData baseEventData)
|
||||
{
|
||||
mainController.SetCyclingModel(CyclingModel.Review);
|
||||
//mainController.SetCyclingModel(CyclingModel.Review);
|
||||
selectPanel.SetActive(false);
|
||||
//显示影子选手骑行列表
|
||||
selectPlayer.SetActive(true);
|
||||
@ -411,8 +411,8 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
clearLock = true;
|
||||
isSimple *= -1;
|
||||
simpleBtn.targetGraphic = simpleBtn.image;
|
||||
simpleBtn.image.sprite = isSimple == -1? Resources.Load<Sprite>("Images/Ride/full") : Resources.Load<Sprite>("Images/Ride/simple");
|
||||
simpleBtn.transform.GetComponent<Image>().sprite = isSimple == -1 ? Resources.Load<Sprite>("Images/Ride/full") : Resources.Load<Sprite>("Images/Ride/simple");
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -534,32 +534,61 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
void MoveChartMarkPoint()
|
||||
{
|
||||
Vector3 prePosition = img.transform.position;
|
||||
int nextIndex = playerController.CurrentIndex+1;
|
||||
int nextIndex = playerController.CurrentIndex;
|
||||
double ditance = playerController.Distance;//当前移动距离
|
||||
double currentDistance = playerController.CurrentDistance;//当前区间距离
|
||||
var t = currentDistance != 0 ? ditance*1000 / currentDistance : 0;
|
||||
var t = currentDistance != 0 ? ditance*1000 / currentDistance : 1;
|
||||
var n = graph.DataSource.GetPoint("Player 2", nextIndex);
|
||||
|
||||
graph.PointToWorldSpace(out Vector3 nextPosition, n.x, n.y, "Player 2");
|
||||
//var currentPos = Vector3.Lerp(prePosition, nextPosition, (float)t);
|
||||
if (mainController.isStart)
|
||||
{
|
||||
var ss = graph.GetComponentInChildren<ChartDataSourceScript>();
|
||||
if (ss.total <= ss.DownSampleToPoints)
|
||||
{
|
||||
img.transform.DOMove(new Vector3(nextPosition.x, nextPosition.y, 0), 0);
|
||||
}
|
||||
else
|
||||
{ //人 - 线(中点) - 人(ss.total - graph.HorizontalScrolling <100)
|
||||
//人物移动到中间的时候,线开始向左边平滑移动
|
||||
var mapData = mainController.GetMapData();
|
||||
//线移动
|
||||
var interval = ditance / mapData.TotalDistance * ss.total;
|
||||
|
||||
//线到头了开始移动人物
|
||||
var s = (ss.total - graph.HorizontalScrolling);
|
||||
img.transform.DOMove(new Vector3(nextPosition.x, nextPosition.y, 0), 1);
|
||||
//if (s < 200)
|
||||
//{
|
||||
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// graph.HorizontalScrolling = nextIndex + 1 - t;
|
||||
// img.transform.DOMove(new Vector3(prePosition.x, currentPos.y, 0), 1);
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// //人移动 当前中间的时候开始切换线移动
|
||||
// img.transform.DOMove(new Vector3(currentPos.x, currentPos.y, 0), 0);
|
||||
// //线快加载五年的时候
|
||||
//}
|
||||
|
||||
|
||||
//线即将加载完
|
||||
|
||||
|
||||
var currentPos = Vector3.Lerp(prePosition, nextPosition, (float)t);
|
||||
img.transform.DOMove(currentPos, 1);
|
||||
var ss = graph.GetComponentInChildren<ChartDataSourceScript>();
|
||||
var q = ss.pageStartThreshold;
|
||||
var p = ss.pageEndThreshold;
|
||||
var diff = currentPos.x - prePosition.x;
|
||||
var s = graph.ScrollableData;
|
||||
var sss = s.GetMaxValue(0, true);
|
||||
Debug.Log(sss);
|
||||
//graph.HorizontalScrolling += diff / graph.TotalWidth;
|
||||
//人物移动到中间的时候,线开始向左边平滑移动
|
||||
//int del = (int)Math.Round(graph.DataSource.HorizontalViewSize / 2, 0);
|
||||
//if (playerController.CurrentIndex % del == 0)
|
||||
//{
|
||||
// graph.HorizontalScrolling += 1;
|
||||
//}
|
||||
|
||||
#region 注释
|
||||
#region 注释
|
||||
//var dataPoints = elevationChart.series.list[0].dataPoints.OrderBy(c => c.x).ToList();
|
||||
//if (dataPoints.Count > 0)
|
||||
//{
|
||||
@ -582,7 +611,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
// //testButton.transform.DOLocalMove(new Vector3(pointMap[playerController.CurrentIndex - 1].x-Screen.width/2, pointMap[playerController.CurrentIndex - 1].y, 0),0.5f);
|
||||
// //pointMap.Remove(playerController.CurrentIndex - 1);
|
||||
//}
|
||||
#endregion
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,5 +105,6 @@ namespace Assets.Scripts.Apis.Models
|
||||
public string Param { get; set; }
|
||||
|
||||
public int GlobalCyclingId { get; set; }
|
||||
public string Source { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,14 +37,17 @@ public class MainController : MonoBehaviour
|
||||
//});
|
||||
if (App.MainSceneParam.ContainsKey("Name"))
|
||||
{
|
||||
if(App.MainSceneParam["Name"] == "MapListPanel")
|
||||
UIManager.PushHome();
|
||||
if (App.MainSceneParam["Name"] == "MapListPanel")
|
||||
{
|
||||
UIManager.ShowMapListPanel();
|
||||
App.MainSceneParam["Name"] = string.Empty;
|
||||
}
|
||||
|
||||
if (App.MainSceneParam["Name"] == "UserInfoPanel")
|
||||
{
|
||||
UIManager.ShowUserInfoPanel();
|
||||
App.MainSceneParam["Name"] = string.Empty;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@ -67,10 +67,34 @@ public class MapItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandler
|
||||
// //transform.localPosition.Set(transform.localPosition.x, localY.Value, transform.localPosition.z);
|
||||
// //transform.DOLocalMoveY(localY.Value, 0.5f);
|
||||
//});
|
||||
transform.GetComponent<Button>().onClick.AddListener(() =>
|
||||
|
||||
UIManager.AddEvent(transform.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, (Base) =>
|
||||
{
|
||||
UIManager.ShowMapDetailPanel(myMap.Id);
|
||||
App.RouteIdParam = myMap.Id;
|
||||
if (!App.MainSceneParam.ContainsKey("Name"))
|
||||
{
|
||||
App.MainSceneParam.Add("Name", "MapListPanel");
|
||||
}
|
||||
else
|
||||
{
|
||||
App.MainSceneParam["Name"] = "MapListPanel";
|
||||
}
|
||||
SceneManager.LoadScene("Ride");
|
||||
});
|
||||
//transform.GetComponent<Button>().onClick.AddListener(() =>
|
||||
//{
|
||||
// //UIManager.ShowMapDetailPanel(myMap.Id);
|
||||
// App.RouteIdParam = myMap.Id;
|
||||
// if (!App.MainSceneParam.ContainsKey("Name"))
|
||||
// {
|
||||
// App.MainSceneParam.Add("Name", "MapListPanel");
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// App.MainSceneParam["Name"]= "MapListPanel";
|
||||
// }
|
||||
// SceneManager.LoadScene("Ride");
|
||||
//});
|
||||
transform.Find("Name").GetComponent<Text>().text = myMap.Name;
|
||||
Utils.DisplayImage(StartCoroutine, transform.Find("MapTitleImg").GetComponent<RawImage>(), myMap.CoverImage);
|
||||
|
||||
|
||||
@ -57,10 +57,12 @@ public class RouteItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandle
|
||||
btnContinue = right.Find("BtnContinue");
|
||||
if (btnContinue)
|
||||
{
|
||||
bool enabled = result.ContinueCyclingParam != null;
|
||||
|
||||
//btnContinue.gameObject.SetActive(false);
|
||||
btnContinue.GetComponent<Button>().onClick.AddListener(GoContinue);
|
||||
btnContinue.GetComponent<Button>().interactable = !(result.Progress == 1.0);
|
||||
btnContinue.GetComponent<Button>().enabled = !(result.Progress == 1.0);
|
||||
btnContinue.GetComponent<Button>().interactable = enabled;
|
||||
btnContinue.GetComponent<Button>().enabled = enabled;
|
||||
}
|
||||
btnReRide = right.Find("BtnReRide");
|
||||
if (btnReRide)
|
||||
@ -114,8 +116,9 @@ public class RouteItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandle
|
||||
{
|
||||
if (f)
|
||||
{
|
||||
btnContinue.GetComponent<Image>().color =
|
||||
routeResult.Progress == 1? Utils.HexToColorHtml("#c8c8c880"): Utils.HexToColorHtml("#F93086");
|
||||
bool enabled = routeResult.ContinueCyclingParam == null;
|
||||
btnContinue.GetComponent<Image>().color =
|
||||
enabled ? Utils.HexToColorHtml("#c8c8c880"): Utils.HexToColorHtml("#F93086");
|
||||
btnReRide.GetComponent<Image>().color = Utils.HexToColorHtml("#F93086");
|
||||
btnDelete.GetComponent<Image>().color = Utils.HexToColorHtml("#353543");
|
||||
btnContinue.Find("Text").GetComponent<Text>().color = Utils.HexToColorHtml("#ffffff");
|
||||
|
||||
@ -130,6 +130,11 @@ public class UIManager : MonoBehaviour
|
||||
public static UIManager Instance;
|
||||
|
||||
private static Stack<PFUIPanel> stack;
|
||||
public static void PushHome()
|
||||
{
|
||||
stack.Clear();
|
||||
stack.Push(UIManager.Instance.HomePanel);
|
||||
}
|
||||
private void Awake()
|
||||
{
|
||||
UIManager.Instance = this;
|
||||
|
||||
@ -147,7 +147,7 @@ namespace Assets.Scripts
|
||||
startCoroutine(DownloadImage(img, url));
|
||||
}
|
||||
|
||||
public static void DisplayImageAysnc(StartCoroutine startCoroutine, RawImage img, string url,Action action)
|
||||
public static void DisplayImageAysnc(StartCoroutine startCoroutine, RawImage img, string url,Action<string> action)
|
||||
{
|
||||
startCoroutine(DownloadImageCallBack(img, url, action));
|
||||
}
|
||||
@ -170,7 +170,7 @@ namespace Assets.Scripts
|
||||
img.texture = ((DownloadHandlerTexture)request.downloadHandler).texture;
|
||||
}
|
||||
|
||||
static IEnumerator DownloadImageCallBack(RawImage img, string MediaUrl,Action action)
|
||||
static IEnumerator DownloadImageCallBack(RawImage img, string MediaUrl,Action<string> action)
|
||||
{
|
||||
UnityWebRequest request = UnityWebRequestTexture.GetTexture(MediaUrl);
|
||||
yield return request.SendWebRequest();
|
||||
@ -179,7 +179,7 @@ namespace Assets.Scripts
|
||||
else
|
||||
{
|
||||
img.texture = ((DownloadHandlerTexture)request.downloadHandler).texture;
|
||||
action.Invoke();
|
||||
action.Invoke(MediaUrl);
|
||||
}
|
||||
}
|
||||
/*显示网络图片*/
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user