移动动效和界面调整
This commit is contained in:
1 parent
11fdcff7c3
commit
9ac7c86ca6
12 files changed
+4926
-3498
No files matched your search
@@ -220,8 +220,13 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
nextSlopeDistance = sumDistance - totalDistance * 1000;
|
||||
currentSlopeDistance = totalDistance * 1000 - (sumDistance - pointList[index].Distance);
|
||||
//计算当前区间距离
|
||||
CurrentDistance = pointList[CurrentIndex].Grade;
|
||||
CurrentDistance = pointList[CurrentIndex].Distance;
|
||||
//计算上一个坡度
|
||||
PreElevation = pointList[preIndex].Elevation;
|
||||
PreSlope = pointList[preIndex].Grade;
|
||||
}
|
||||
public double PreElevation;
|
||||
public double PreSlope;
|
||||
//根据距离计算坐标
|
||||
Vector2d Along(double endDistance)
|
||||
{
|
||||
|
||||
@@ -24,6 +24,16 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
graph = GetComponent<GraphChartBase>();
|
||||
}
|
||||
|
||||
public bool isEnd(int index)
|
||||
{
|
||||
return index - start == 51;
|
||||
}
|
||||
|
||||
public bool isMid(int index)
|
||||
{
|
||||
return index - start == 26;
|
||||
}
|
||||
bool VerifySorted(List<DoubleVector2> data)
|
||||
{
|
||||
if (data == null)
|
||||
@@ -119,7 +129,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int start, end;
|
||||
void LoadPage(double pagePosition)
|
||||
{
|
||||
if (graph != null)
|
||||
@@ -128,7 +138,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
Debug.Log("Loading page :" + pagePosition);
|
||||
graph.DataSource.StartBatch(); // call start batch
|
||||
graph.DataSource.HorizontalViewOrigin = 0;
|
||||
int start, end;
|
||||
|
||||
findPointsForPage(pagePosition, out start, out end); // get the page edges
|
||||
graph.DataSource.ClearCategory("Player 2"); // clear the cateogry
|
||||
|
||||
@@ -174,14 +184,15 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public double pageStartThreshold;
|
||||
public double pageEndThreshold;
|
||||
public void Update()
|
||||
{
|
||||
if (graph != null)
|
||||
{
|
||||
//check the scrolling position of the graph. if we are past the view size , load a new page
|
||||
double pageStartThreshold = currentPagePosition - mCurrentPageSizeFactor;
|
||||
double pageEndThreshold = currentPagePosition + mCurrentPageSizeFactor - graph.DataSource.HorizontalViewSize;
|
||||
pageStartThreshold = currentPagePosition - mCurrentPageSizeFactor;
|
||||
pageEndThreshold = currentPagePosition + mCurrentPageSizeFactor - graph.DataSource.HorizontalViewSize;
|
||||
|
||||
if (graph.HorizontalScrolling < pageStartThreshold || graph.HorizontalScrolling > pageEndThreshold || currentZoom >= graph.DataSource.HorizontalViewSize * 2f)
|
||||
{
|
||||
|
||||
@@ -148,7 +148,6 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
}
|
||||
//异步请求mapbox画出当前路书路线图
|
||||
loadingController.DrawMapRoute(mapData);
|
||||
loadingController.AddProcess(10);
|
||||
}
|
||||
//加载人物和地图以及UI界面
|
||||
private void InitGameObject()
|
||||
@@ -173,6 +172,9 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
cyclingController = new SingleModel(route, selectParamModel);
|
||||
break;
|
||||
}
|
||||
//进入倒计时
|
||||
var singleUIManager = UIObject.GetComponent<SingleUIManager>();
|
||||
singleUIManager.StartRide(null);
|
||||
}
|
||||
|
||||
#region
|
||||
@@ -267,7 +269,9 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
cyclingController.recorderData.AntModelId = AntModelId;
|
||||
cyclingController.recorderData.ManufacturerId = ManufacturerId;
|
||||
cyclingController.recorderData.DeviceNumber = DeviceNumber;
|
||||
//cyclingController.recorderData.SaveData(cyclingModel, selectParamModel, imageFileName);
|
||||
#if !UNITY_EDITOR
|
||||
cyclingController.recorderData.SaveData(cyclingModel, selectParamModel, imageFileName);
|
||||
#endif
|
||||
//显示骑行结果
|
||||
resultPanel.SetActive(true);
|
||||
var rs = resultPanel.GetComponent<ResultPanelScript>();
|
||||
@@ -348,7 +352,7 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
var list = mapData.List.Select(c => (float)c.Elevation).ToArray();
|
||||
return list;
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
@@ -66,7 +66,13 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
public void DrawMapRoute(MapDataModel mapData)
|
||||
{
|
||||
var url = Helper.GetMapboxApiUrl(mapData.List);
|
||||
Utils.DisplayImage(StartCoroutine, mapRouteImage, url);
|
||||
Utils.DisplayImageAysnc(StartCoroutine, mapRouteImage, url, dowloadCallBack);
|
||||
mapRouteImage.gameObject.SetActive(false);
|
||||
}
|
||||
private void dowloadCallBack()
|
||||
{
|
||||
mapRouteImage.gameObject.SetActive(true);
|
||||
this.AddProcess(10);
|
||||
}
|
||||
//设定当前loading进度
|
||||
public void AddProcess(float v)
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
bicycleWeight = App.CurrentUser.BicycleWeight;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
power = Random.Range(1,200);//测试功率
|
||||
power = 2000;//测试功率
|
||||
#endif
|
||||
mainController.TrackResistance(currentSlope);//TODO
|
||||
speed = Helper.CalculateSpeed(elevation, currentSlope, power, weight, bicycleWeight);
|
||||
|
||||
@@ -162,14 +162,22 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
var list = mapApi.GetRouteRanking(App.RouteIdParam, "1", pageIndex, pageSize, seachName);
|
||||
totalPages = list.data.TotalPages;
|
||||
var data = list.data.list.Where(c => c.WeightKg >= _startValue && c.WeightKg <= _endValue).ToList();
|
||||
var data = list.data.list;//.Where(c => c.WeightKg >= _startValue && c.WeightKg <= _endValue).ToList();
|
||||
if (_startValue > 0)
|
||||
{
|
||||
data = data.Where(c => c.WeightKg >= _startValue).ToList();
|
||||
}
|
||||
if (_endValue > 0)
|
||||
{
|
||||
data = data.Where(c => c.WeightKg <= _endValue).ToList();
|
||||
}
|
||||
if (sort == 0)
|
||||
{
|
||||
data = data.OrderBy(c => c.WeightKg).ToList();
|
||||
data = data.OrderByDescending(c => c.WeightKg).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
data = data.OrderByDescending(c => c.WeightKg).ToList();
|
||||
data = data.OrderBy(c => c.WeightKg).ToList();
|
||||
}
|
||||
CreateGameObject(data);
|
||||
}
|
||||
@@ -191,6 +199,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
selectPlayerItemScript.SetRankingId(item.Id.ToString());
|
||||
selectPlayerItemScript.SetName(item.NickName);
|
||||
selectPlayerItemScript.SetTimer(item.TotalTime);
|
||||
selectPlayerItemScript.SetWeightKg(item.WeightKg.ToString());
|
||||
selectPlayerItemScript.SetHeadImage(item.WxHeadImg);
|
||||
selectPlayerItemScripts.Add(selectPlayerItemScript);
|
||||
UIManager.AddEvent(selectPlayerItemScript.GetButton().gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, OnSelectClick);
|
||||
|
||||
@@ -12,13 +12,15 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
private RawImage Head;
|
||||
private Text Name;
|
||||
private Text Timer;
|
||||
private Text WeightKg;
|
||||
private Button selectbutton;
|
||||
public bool isSelected;
|
||||
private void Awake()
|
||||
{
|
||||
Head = transform.Find("Head").GetComponent<RawImage>();
|
||||
Name = transform.Find("Name").GetComponent<Text>();
|
||||
Timer = transform.Find("Timer").GetComponent<Text>();
|
||||
|
||||
|
||||
|
||||
|
||||
selectbutton = transform.GetComponent<Button>();
|
||||
}
|
||||
private void Start()
|
||||
@@ -31,6 +33,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
public string GetName()
|
||||
{
|
||||
Name = transform.Find("Name").GetComponent<Text>();
|
||||
return Name.text;
|
||||
}
|
||||
public Texture GetImageTexture()
|
||||
@@ -47,14 +50,23 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
public void SetName(string name)
|
||||
{
|
||||
Name = transform.Find("Name").GetComponent<Text>();
|
||||
Name.text = name;
|
||||
}
|
||||
public void SetTimer(string timer)
|
||||
{
|
||||
Timer = transform.Find("Timer").GetComponent<Text>();
|
||||
Timer.text = timer;
|
||||
}
|
||||
|
||||
public void SetWeightKg(string value)
|
||||
{
|
||||
WeightKg = transform.Find("WeightKg").GetComponent<Text>();
|
||||
WeightKg.text = value+"W/KG";
|
||||
}
|
||||
public void SetHeadImage(string url)
|
||||
{
|
||||
Head = transform.Find("Head").GetComponent<RawImage>();
|
||||
Utils.DisplayImage(StartCoroutine, Head, url);
|
||||
var rect = ((RectTransform)Head.transform).rect;
|
||||
Material material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
public void SetName(string name)
|
||||
{
|
||||
Name.text = name;
|
||||
Name.color = new Color(1, 1, 1, 1);
|
||||
}
|
||||
public void SetRankingId(string id)
|
||||
{
|
||||
|
||||
@@ -81,6 +81,10 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
Image arrow;
|
||||
AbstractMap map;
|
||||
Transform t;
|
||||
GameObject alertPanel;
|
||||
Button alertBtn;
|
||||
Button alertCloseBtn;
|
||||
Text preSlopeText;
|
||||
void Awake()
|
||||
{
|
||||
#region 控件获取与事件绑定
|
||||
@@ -114,7 +118,14 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
img = transform.Find("Panel/GraphChart/Head").GetComponent<RawImage>();
|
||||
t = transform.Find("Panel/GraphChart/Button");
|
||||
miniMap = transform.Find("Panel/MiniMap").GetComponent<RawImage>();
|
||||
|
||||
|
||||
alertPanel = transform.Find("Panel/Alert").gameObject;
|
||||
alertBtn = transform.Find("Panel/Alert/SaveButton").GetComponent<Button>();
|
||||
alertCloseBtn = transform.Find("Panel/Alert/CloseButton").GetComponent<Button>();
|
||||
UIManager.AddEvent(alertBtn.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, AlertOk);
|
||||
UIManager.AddEvent(alertCloseBtn.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, AlertClose);
|
||||
|
||||
|
||||
selectPanel = transform.Find("Panel/SelectPanel").gameObject;
|
||||
selectPlayer = transform.Find("Panel/SelectPlayer").gameObject;
|
||||
reviewPanel = transform.Find("Panel/ReviewPanel").gameObject;
|
||||
@@ -133,6 +144,8 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
viewButton =transform.Find("Panel/ViewButton").GetComponent<Button>();
|
||||
altitudeGraph = transform.Find("Panel/TitlePanel/AltitudeGraph").GetComponent<RawImage>();
|
||||
|
||||
preSlopeText = transform.Find("Panel/PreSlopePanel/PreSlopeText").GetComponent<Text>();
|
||||
|
||||
target = transform.parent.Find("Target").gameObject;
|
||||
|
||||
UIManager.AddEvent(startBtn.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, StartRide);
|
||||
@@ -153,19 +166,6 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
UIManager.AddEvent(singleButton.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerExit, OnPointExit);
|
||||
UIManager.AddEvent(shadowButton.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerExit, OnPointExit);
|
||||
|
||||
|
||||
//startBtn.onClick.AddListener(StartRide);
|
||||
//simpleBtn.onClick.AddListener(ClearPanel);
|
||||
//pauseButton.onClick.AddListener(PauseRide);
|
||||
//settingButton.onClick.AddListener(ShowSettingPanel);
|
||||
//deviceButton.onClick.AddListener(ShowDevicePanel);
|
||||
//exitButton.onClick.AddListener(StopRide);
|
||||
//singleButton.onClick.AddListener(SingleRide);
|
||||
//shadowButton.onClick.AddListener(ShadowRide);
|
||||
//addButton.onClick.AddListener(ShowSelectPlayer);
|
||||
//saveButton.onClick.AddListener(SaveRide);
|
||||
//cancelQuitButton.onClick.AddListener(CancelQuit);
|
||||
//closeQuitButton.onClick.AddListener(CloseQuit);
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -241,6 +241,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
ditance.text = Math.Round(playerController.TotalDistance, 1).ToString("f1");
|
||||
heartRate.text = $"{Math.Round(playerController.HeartRate, 0)}";
|
||||
candance.text = $"{Math.Round(playerController.Cadance, 0)}";
|
||||
preSlopeText.text = $"{Math.Round(playerController.PreSlope, 1)}%";
|
||||
//倒计时
|
||||
if (count > 0)
|
||||
{
|
||||
@@ -282,6 +283,14 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
//控制照片移动
|
||||
((RectTransform)arrow.transform).position = Camera.main.WorldToScreenPoint(target.transform.position);
|
||||
if (playerController.Distance > 0 && mainController.isStart)
|
||||
{
|
||||
arrow.transform.Find("bg").gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
arrow.transform.Find("bg").gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,13 +316,24 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
selectPlayer.SetActive(true);
|
||||
}
|
||||
private void StartRide(BaseEventData baseEventData)
|
||||
public void AlertOk(BaseEventData baseEventData)
|
||||
{
|
||||
alertPanel.SetActive(false);
|
||||
UIManager.Show(UIManager.Instance.DevicePanel, transform.Find("Panel").GetComponent<PFUIPanel>());
|
||||
}
|
||||
public void AlertClose(BaseEventData baseEventData)
|
||||
{
|
||||
alertPanel.SetActive(false);
|
||||
}
|
||||
public void StartRide(BaseEventData baseEventData)
|
||||
{
|
||||
var antConnected = mainController.CheckAnt();//初始化ant+设备
|
||||
//if (!antConnected)
|
||||
//{
|
||||
// throw new Exception("请先连接设备");
|
||||
//}
|
||||
#if !UNITY_EDITOR
|
||||
if (!antConnected)
|
||||
{
|
||||
alertPanel.SetActive(true);
|
||||
}
|
||||
#endif
|
||||
//加个5秒钟倒计时
|
||||
count = 5;
|
||||
startBtn.gameObject.SetActive(false);
|
||||
@@ -514,7 +534,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
void MoveChartMarkPoint()
|
||||
{
|
||||
Vector3 prePosition = img.transform.position;
|
||||
int nextIndex = playerController.CurrentIndex;
|
||||
int nextIndex = playerController.CurrentIndex+1;
|
||||
double ditance = playerController.Distance;//当前移动距离
|
||||
double currentDistance = playerController.CurrentDistance;//当前区间距离
|
||||
var t = currentDistance != 0 ? ditance*1000 / currentDistance : 0;
|
||||
@@ -524,7 +544,14 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
|
||||
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)
|
||||
@@ -532,7 +559,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
// graph.HorizontalScrolling += 1;
|
||||
//}
|
||||
|
||||
#region 注释
|
||||
#region 注释
|
||||
//var dataPoints = elevationChart.series.list[0].dataPoints.OrderBy(c => c.x).ToList();
|
||||
//if (dataPoints.Count > 0)
|
||||
//{
|
||||
@@ -555,7 +582,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
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user