继续骑行海图初始位置,地图属性调整
This commit is contained in:
parent
724e43f392
commit
3757ae6e6c
@ -112,8 +112,8 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 1}
|
||||
m_AnchorMax: {x: 0.5, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: -65}
|
||||
m_SizeDelta: {x: 92, y: 50}
|
||||
m_AnchoredPosition: {x: -0.0000038146973, y: -65}
|
||||
m_SizeDelta: {x: 163.5351, y: 50}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &2030232658984377928
|
||||
CanvasRenderer:
|
||||
@ -155,7 +155,7 @@ MonoBehaviour:
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: Warn
|
||||
m_Text: Warning
|
||||
--- !u!1 &2030232659281999545
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,7 @@
|
||||
using Assets.Scenes.Ride.Scripts.Model.CyclingModels;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using ChartAndGraph;
|
||||
using DG.Tweening;
|
||||
using GeoJSON.Net.Geometry;
|
||||
using Mapbox.Unity.Map;
|
||||
using Mapbox.Utils;
|
||||
@ -11,6 +13,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using TurfCS;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
@ -76,7 +79,14 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
public Vector2d Currentlatlong { get => currentlatlong; }
|
||||
#endregion
|
||||
|
||||
#region UI对象
|
||||
|
||||
//UI对象
|
||||
protected GameObject headPanel;
|
||||
protected GraphChartBase graph;
|
||||
protected ChartDataSourceScript chartDataSourceScript;
|
||||
|
||||
#endregion
|
||||
void Start()
|
||||
{
|
||||
Init();
|
||||
@ -102,6 +112,11 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
mainController = transform.parent.GetComponent<CyclingController>();
|
||||
map = transform.parent.Find("Map").GetComponent<AbstractMap>();
|
||||
mapData = mainController.GetMapData();//获取路书信息
|
||||
|
||||
//获取海拔图UI对象
|
||||
var graphObject = transform.parent.Find("SingleUI/Panel/GraphChart");
|
||||
chartDataSourceScript = graphObject.GetComponent<ChartDataSourceScript>();
|
||||
graph = graphObject.GetComponent<GraphChartBase>();
|
||||
}
|
||||
|
||||
protected virtual void Excute()
|
||||
@ -119,9 +134,12 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
//骑行中
|
||||
protected virtual void Run()
|
||||
{
|
||||
if (mapData == null)
|
||||
return;
|
||||
ComputeNextSlope();//计算下一个坡度相关数据
|
||||
MoveGraphHead();//移动海拔图头像
|
||||
//人物动画控制
|
||||
if (characterAnimator != null && mapData != null)
|
||||
if (characterAnimator != null)
|
||||
{
|
||||
characterAnimator.SetFloat("Speed", (float)speed);
|
||||
characterAnimator.SetFloat("Slope", (float)currentSlope);
|
||||
@ -286,5 +304,14 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region UI行为
|
||||
|
||||
protected virtual void MoveGraphHead()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,6 +44,22 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
return index - graph.HorizontalScrolling >= graph.DataSource.HorizontalViewSize / 2;
|
||||
}
|
||||
|
||||
public void InitHorizontalScrolling(int index)
|
||||
{
|
||||
var halfView = graph.DataSource.HorizontalViewSize / 2;
|
||||
if (index >= halfView)
|
||||
{
|
||||
if (index + halfView >= mData.Count)
|
||||
{
|
||||
graph.HorizontalScrolling = mData.Count - graph.DataSource.HorizontalViewSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
graph.HorizontalScrolling = index - halfView;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool VerifySorted(List<DoubleVector2> data)
|
||||
{
|
||||
if (data == null)
|
||||
|
||||
@ -243,6 +243,9 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
Quaternion neededRotation = Quaternion.LookRotation(s - e);
|
||||
player.transform.rotation = Quaternion.Euler(0, neededRotation.eulerAngles.y, 0);
|
||||
playerController.currentRotation = neededRotation;
|
||||
//初始化海拔图头像位置
|
||||
var index = GetCurrentIndex(recorderData.EndDistance);
|
||||
playerController.InitGraph(index);
|
||||
}
|
||||
SingleUIManager singleUIManager;
|
||||
public void AutoStart()
|
||||
@ -284,6 +287,7 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
var currentUser = currentOnlineUserList.Where(c => c.UserId == item.UserId).FirstOrDefault();
|
||||
var onlineDistance = onlineRider.EndDistance - onlineRider.PreDistance;
|
||||
var onlineTotalDistance = onlineRider.EndDistance;
|
||||
var index = GetCurrentIndex(onlineTotalDistance);
|
||||
|
||||
if (currentUser == null)
|
||||
{
|
||||
@ -294,7 +298,8 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
otherList.Add(onlinePlayerController);
|
||||
|
||||
onlinePlayerController.UserId = onlineRider.UserId;
|
||||
onlinePlayerController.SetDataSource(onlineTotalDistance, onlineDistance, onlineRider.NickName, onlineRider.WeightKg);
|
||||
|
||||
onlinePlayerController.SetDataSource(onlineTotalDistance, onlineDistance, onlineRider.NickName, onlineRider.WeightKg, index);
|
||||
onlinePlayerController.SetHead(onlineRider.WxHeadImg);
|
||||
//小地图人物
|
||||
GameObject miniPlayer = (GameObject)Instantiate(miniMapPlayerPrefab, transform);
|
||||
@ -304,11 +309,10 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
if(messageIndex > 0)
|
||||
EventQueueSystem.QueueEvent(new JoinMessageEvent(onlineRider.NickName, onlineRider.WxHeadImg));
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
currentUser.SetDataSource(onlineTotalDistance, onlineDistance, onlineRider.NickName, onlineRider.WeightKg);
|
||||
currentUser.SetDataSource(onlineTotalDistance, onlineDistance, onlineRider.NickName, onlineRider.WeightKg, index);
|
||||
}
|
||||
}
|
||||
if(onlineRiders.Count > 0)
|
||||
@ -539,6 +543,25 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
{
|
||||
return coordiantes;
|
||||
}
|
||||
|
||||
public int GetCurrentIndex(double endDistance)
|
||||
{
|
||||
int index = 0;
|
||||
var pointList = mapData.List;
|
||||
double sumDistance = 0;
|
||||
|
||||
for (int i = 0; i < pointList.Count; i++)
|
||||
{
|
||||
sumDistance += pointList[i].Distance;
|
||||
if (endDistance * 1000 <= sumDistance)
|
||||
{
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
index = endDistance >= mapData.TotalDistance ? index + 1 : index;
|
||||
return index;
|
||||
}
|
||||
public Vector2d Along(double endDistance)
|
||||
{
|
||||
if (mapData != null)
|
||||
|
||||
@ -14,15 +14,10 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
public PlayerController _playerController;
|
||||
RawImage head;
|
||||
GameObject headPanel;
|
||||
|
||||
Image arrowImage;
|
||||
GameObject infoPanel;
|
||||
Transform uiObject;
|
||||
|
||||
GraphChartBase graph;
|
||||
ChartDataSourceScript chartDataSourceScript;
|
||||
|
||||
string nickName;
|
||||
string weightKgStr;
|
||||
|
||||
@ -31,15 +26,10 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
base.Init();
|
||||
currentlatlong = mainController.GetCenterCoordinate();
|
||||
_playerController = FindObjectOfType<PlayerController>();
|
||||
graph = transform.parent.Find("SingleUI/Panel/GraphChart").GetComponent<GraphChartBase>();
|
||||
chartDataSourceScript = transform.parent.Find("SingleUI/Panel/GraphChart").GetComponent<ChartDataSourceScript>();
|
||||
|
||||
//创建UI
|
||||
uiObject = transform.parent.Find("SingleUI/Panel/ArrowList");
|
||||
arrowImage = Instantiate(Resources.Load<Image>("UI/Prefab/Ride/ReviewArrow"), uiObject);
|
||||
arrowImage.color = new Color(0.1529412f, 0.8745098f, 0.8901961f);
|
||||
|
||||
|
||||
}
|
||||
public override bool GetStart()
|
||||
{
|
||||
@ -50,80 +40,23 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
currentlatlong = mainController.Along(totalDistance);//下一个坐标
|
||||
|
||||
diff = Math.Round((totalDistance - _playerController.TotalDistance) * 1000, 0);
|
||||
|
||||
MoveHead(graph.transform);
|
||||
}
|
||||
double diff = 0;
|
||||
public void SetDataSource(double _totalDistance, double _distance,string Name,double weightKg)
|
||||
public void SetDataSource(double _totalDistance, double _distance,string Name,double weightKg,int index=0)
|
||||
{
|
||||
totalDistance = _totalDistance;
|
||||
distance = _distance;
|
||||
speed = distance*3600;
|
||||
nickName = Name;
|
||||
weightKgStr = weightKg.ToString("f2") + "W/KG";
|
||||
CurrentIndex = index;
|
||||
}
|
||||
|
||||
public int GetCurrentIndex(double endistance,MapDataModel mapDataModel)
|
||||
{
|
||||
var pointList = mapDataModel.List;
|
||||
int onIndex = 0;
|
||||
var sumDistance = 0D;
|
||||
for (int i = 0; i < pointList.Count; i++)
|
||||
{
|
||||
sumDistance += pointList[i].Distance;
|
||||
if (endistance * 1000 <= sumDistance)
|
||||
{
|
||||
onIndex = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (endistance > mapDataModel.TotalDistance)
|
||||
{
|
||||
onIndex = pointList.Count-2;
|
||||
}
|
||||
return onIndex;
|
||||
}
|
||||
|
||||
private string headUrl;
|
||||
public void SetHead(string url )
|
||||
{
|
||||
headUrl = url;
|
||||
}
|
||||
public void MoveHead(Transform parent)
|
||||
{
|
||||
var itemIndex = chartDataSourceScript.GetViewIndex(GetCurrentIndex(TotalDistance, mainController.GetMapData()))+1;
|
||||
var m = graph.DataSource.GetPoint("Player 2", itemIndex);
|
||||
Debug.Log(itemIndex.ToString() + "=" + TotalDistance.ToString());
|
||||
graph.PointToWorldSpace(out Vector3 itemPosition, m.x, m.y, "Player 2");
|
||||
itemPosition.x -= 12f;
|
||||
itemPosition.y += 5f;
|
||||
|
||||
if (headPanel == null)
|
||||
{
|
||||
headPanel = Instantiate(Resources.Load<GameObject>("UI/Prefab/Ride/OnlineHeadPanel"));
|
||||
headPanel.transform.SetParent(parent);
|
||||
headPanel.transform.localScale = new Vector3(0.8f, 0.8f, 0.8f);
|
||||
headPanel.transform.position = itemPosition;
|
||||
}
|
||||
else
|
||||
{
|
||||
headPanel.transform.DOMove(new Vector3(itemPosition.x, itemPosition.y, 0), 1);
|
||||
}
|
||||
if (head == null)
|
||||
{
|
||||
head = headPanel.GetComponentInChildren<RawImage>();
|
||||
if (!string.IsNullOrEmpty(headUrl))
|
||||
{
|
||||
Utils.DisplayImage(head, headUrl, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
headPanel.transform.Find("DefaultHead").gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void ShowInfoPanel(Vector3 playerScreenPos)
|
||||
{
|
||||
@ -157,13 +90,10 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
|
||||
public void RemoveSelf()
|
||||
{
|
||||
//headPanel?.SetActive(false);
|
||||
arrowImage.gameObject?.Destroy();
|
||||
headPanel?.Destroy();
|
||||
infoPanel?.Destroy();
|
||||
transform.gameObject.Destroy();
|
||||
//infoPanel?.SetActive(false);
|
||||
//transform.DestroyChildren();
|
||||
}
|
||||
|
||||
protected override void AfterExcute()
|
||||
@ -215,5 +145,40 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
lineRender.numCapVertices = 10;
|
||||
lineRender.numCornerVertices = 10;
|
||||
}
|
||||
|
||||
protected override void MoveGraphHead()
|
||||
{
|
||||
var itemIndex = chartDataSourceScript.GetViewIndex(CurrentIndex);
|
||||
var m = graph.DataSource.GetPoint("Player 2", itemIndex);
|
||||
|
||||
graph.PointToWorldSpace(out Vector3 itemPosition, m.x, m.y, "Player 2");
|
||||
itemPosition.x -= 12f;
|
||||
itemPosition.y += 5f;
|
||||
|
||||
if (headPanel == null)
|
||||
{
|
||||
headPanel = Instantiate(Resources.Load<GameObject>("UI/Prefab/Ride/OnlineHeadPanel"));
|
||||
headPanel.transform.SetParent(graph.transform);
|
||||
headPanel.transform.localScale = new Vector3(0.8f, 0.8f, 0.8f);
|
||||
headPanel.transform.position = itemPosition;
|
||||
}
|
||||
else
|
||||
{
|
||||
headPanel.transform.DOMove(new Vector3(itemPosition.x, itemPosition.y, 0), 1);
|
||||
}
|
||||
|
||||
if (head == null)
|
||||
{
|
||||
head = headPanel.GetComponentInChildren<RawImage>();
|
||||
if (!string.IsNullOrEmpty(headUrl))
|
||||
{
|
||||
Utils.DisplayImage(head, headUrl, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
headPanel.transform.Find("DefaultHead").gameObject.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -8,24 +8,24 @@ using UnityEngine.UI;
|
||||
namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
public class OtherPlayerController : AbstractPlayer
|
||||
{
|
||||
{
|
||||
public string[] record { set; get; }
|
||||
public ReviewItemScript _reviewItemScript;
|
||||
public PlayerController _playerController;
|
||||
RawImage head;
|
||||
GameObject headPanel;
|
||||
GameObject infoPanel;
|
||||
|
||||
public int tickOffset = 0;
|
||||
Image arrowImage;
|
||||
GameObject reviewInfoPanel;
|
||||
Transform uiObject;
|
||||
|
||||
|
||||
string nickName;
|
||||
string weightKgStr;
|
||||
|
||||
public double Weight { get; set; }
|
||||
public double BikeWeight { get; set; }
|
||||
|
||||
//UI
|
||||
RawImage head;
|
||||
GameObject infoPanel;
|
||||
Image arrowImage;
|
||||
Transform uiObject;
|
||||
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
@ -37,7 +37,6 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
|
||||
double diff = 0;
|
||||
|
||||
protected override void Compute()
|
||||
{
|
||||
if (tickOffset + ticks < record.Length)
|
||||
@ -45,7 +44,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
var data = TargetData.Read(record[tickOffset + ticks - 1]);
|
||||
power = data._Power;
|
||||
speed = data._Speed;
|
||||
distance = data._Speed/3600;
|
||||
distance = data._Speed / 3600;
|
||||
totalDistance = data._Distance;
|
||||
}
|
||||
else
|
||||
@ -57,30 +56,15 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
totalDistance = data._Distance;
|
||||
}
|
||||
currentlatlong = mainController.Along(totalDistance);//下一个坐标
|
||||
diff = Math.Round((totalDistance - _playerController.TotalDistance) *1000, 0);
|
||||
diff = Math.Round((totalDistance - _playerController.TotalDistance) * 1000, 0);
|
||||
_reviewItemScript.SetDistance(diff);
|
||||
|
||||
|
||||
}
|
||||
public void SetController(ReviewItemScript reviewItemScript)
|
||||
{
|
||||
_reviewItemScript = reviewItemScript;
|
||||
nickName = _reviewItemScript.GetName();
|
||||
}
|
||||
public void MoveHead(Transform parent,Vector3 nextPosition)
|
||||
{
|
||||
if (headPanel == null)
|
||||
{
|
||||
headPanel = Instantiate(Resources.Load<GameObject>("UI/Prefab/Ride/HeadPanel"));
|
||||
headPanel.transform.parent = parent;
|
||||
headPanel.transform.localScale = new Vector3(0.8f, 0.8f, 0.8f);
|
||||
}
|
||||
if (head == null)
|
||||
{
|
||||
head = headPanel.GetComponentInChildren<RawImage>();
|
||||
head.texture = _reviewItemScript.GetHead();
|
||||
}
|
||||
headPanel.transform.DOMove(new Vector3(nextPosition.x, nextPosition.y, 0), 1);
|
||||
}
|
||||
|
||||
public void ShowInfoPanel(Vector3 playerScreenPos)
|
||||
{
|
||||
@ -103,11 +87,11 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
var infoDistance = infoPanel.transform.Find("Distance").GetComponent<Text>();
|
||||
if (_playerController != null)
|
||||
{
|
||||
infoDistance.text = diff >0? $"+{diff}M" : $"{diff}M";
|
||||
infoDistance.text = diff > 0 ? $"+{diff}M" : $"{diff}M";
|
||||
}
|
||||
var infoWKG = infoPanel.transform.Find("WKG").GetComponent<Text>();
|
||||
if (Weight + BikeWeight != 0) {
|
||||
weightKgStr = (power / (Weight + BikeWeight)).ToString("f2")+"W/KG";
|
||||
weightKgStr = (power / (Weight + BikeWeight)).ToString("f2") + "W/KG";
|
||||
infoWKG.text = weightKgStr;
|
||||
}
|
||||
|
||||
@ -162,7 +146,29 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
IsShowInfo = false;
|
||||
infoPanel?.Destroy();
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void MoveGraphHead()
|
||||
{
|
||||
var itemIndex = chartDataSourceScript.GetViewIndex(CurrentIndex);
|
||||
var m = graph.DataSource.GetPoint("Player 2", itemIndex);
|
||||
graph.PointToWorldSpace(out Vector3 itemPosition, m.x, m.y, "Player 2");
|
||||
itemPosition.x -= 12f;
|
||||
itemPosition.y += 5f;
|
||||
|
||||
if (headPanel == null)
|
||||
{
|
||||
headPanel = Instantiate(Resources.Load<GameObject>("UI/Prefab/Ride/HeadPanel"));
|
||||
headPanel.transform.SetParent(graph.transform);
|
||||
headPanel.transform.localScale = new Vector3(0.8f, 0.8f, 0.8f);
|
||||
}
|
||||
if (head == null)
|
||||
{
|
||||
head = headPanel.GetComponentInChildren<RawImage>();
|
||||
head.texture = _reviewItemScript.GetHead();
|
||||
}
|
||||
headPanel.transform.DOMove(new Vector3(itemPosition.x, itemPosition.y, 0), 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5,6 +5,8 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Assets.Scenes.Ride.Scripts.Model.RiderModels;
|
||||
using System;
|
||||
using ChartAndGraph;
|
||||
using DG.Tweening;
|
||||
|
||||
namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
@ -34,6 +36,8 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
trail.motionVectorGenerationMode = MotionVectorGenerationMode.ForceNoMotion;
|
||||
trail.receiveShadows = false;
|
||||
trail.rayTracingMode = UnityEngine.Experimental.Rendering.RayTracingMode.Off;
|
||||
|
||||
headPanel = transform.parent.Find("SingleUI/Panel/GraphChart/HeadPanel").gameObject;
|
||||
}
|
||||
TargetData targetData;
|
||||
/// <summary>
|
||||
@ -50,10 +54,10 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
cadance = mainController.UpdateCadence();
|
||||
weight = App.CurrentUser.Weight;
|
||||
bicycleWeight = App.CurrentUser.BicycleWeight;
|
||||
#if UNITY_EDITOR
|
||||
//#if UNITY_EDITOR
|
||||
System.Random rd = new System.Random();
|
||||
power = rd.Next(150, 300);//测试功率
|
||||
#endif
|
||||
power = 5000; //rd.Next(150, 300);//测试功率
|
||||
//#endif
|
||||
mainController.TrackResistance(currentSlope * App.rideSetting.sensitivity / 100);
|
||||
}
|
||||
catch (Exception)
|
||||
@ -127,5 +131,36 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
mainController.Save(TotalDistance);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public void InitGraph(int index)
|
||||
{
|
||||
chartDataSourceScript.InitHorizontalScrolling(index);
|
||||
}
|
||||
//移动海拔图头像
|
||||
protected override void MoveGraphHead()
|
||||
{
|
||||
Vector3 oldPos = headPanel.transform.position;
|
||||
int nextIndex = CurrentIndex;
|
||||
var viewIndex = chartDataSourceScript.GetViewIndex(nextIndex);
|
||||
|
||||
var n = graph.DataSource.GetPoint("Player 2", viewIndex);
|
||||
graph.PointToWorldSpace(out Vector3 nextPosition, n.x, n.y, "Player 2");
|
||||
nextPosition.x -= 14f;
|
||||
nextPosition.y += 5f;
|
||||
//人物移动 停止条件 到中间且线未加载完
|
||||
if ( GetStart() && chartDataSourceScript.ReachMid(viewIndex) && !chartDataSourceScript.ReachEnd())
|
||||
{
|
||||
var currentDistance = CurrentDistance;
|
||||
var distance = Distance;
|
||||
var offset = currentDistance > 0 ? distance * 1000 / currentDistance : 1;
|
||||
graph.HorizontalScrolling += offset;
|
||||
headPanel.transform.DOMove(new Vector3(oldPos.x, nextPosition.y, 0), 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
headPanel.transform.DOMove(new Vector3(nextPosition.x, nextPosition.y, 0), 1);
|
||||
}
|
||||
headPanel.transform.SetSiblingIndex(999);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,14 +90,6 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
|
||||
private void Cancel(BaseEventData baseEventData)
|
||||
{
|
||||
if (App.MainSceneParam.ContainsKey("Name"))
|
||||
{
|
||||
App.MainSceneParam["Name"] = "MapListPanel";
|
||||
}
|
||||
else
|
||||
{
|
||||
App.MainSceneParam.Add("Name", "MapListPanel");
|
||||
}
|
||||
SceneManager.LoadScene("MainScene");
|
||||
}
|
||||
public void SetDataSource(RecorderDataModel record)
|
||||
|
||||
@ -245,7 +245,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
time -= Time.deltaTime;
|
||||
while (time < 0) {
|
||||
MoveChartMarkPoint();
|
||||
MoveElevationImage();
|
||||
BindDataSource();
|
||||
fps.text = (1 / Time.deltaTime).ToString();
|
||||
time = 1;
|
||||
@ -266,7 +266,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
player = transform.parent.Find("Player");
|
||||
var route = mainController.GetRoute();
|
||||
routeInstance = route.RouteInstance;
|
||||
mapName.text = routeInstance.Name;
|
||||
//初始化3d视角
|
||||
var camera = routeInstance.Camera;
|
||||
if (!string.IsNullOrEmpty(camera))
|
||||
{
|
||||
@ -275,9 +275,11 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
cameraY = float.Parse(cameraArr[1]);
|
||||
cameraZ = float.Parse(cameraArr[2]);
|
||||
}
|
||||
//路书基本信息绑定
|
||||
mapName.text = routeInstance.Name;
|
||||
totalDistance.text = Math.Round(mainController.GetMapData().TotalDistance, 1).ToString() + "KM";//总里程
|
||||
Utils.DisplayImage(altitudeGraph, route.RouteInstance.AltitudeGraph);//渲染海拔图
|
||||
|
||||
//影子骑行按钮控制
|
||||
if (mainController.mapRouteRankingList == null || mainController.mapRouteRankingList.Count == 0)
|
||||
{
|
||||
shadowButton.image.sprite = Resources.Load<Sprite>("Images/Ride/Shadow Mode_no");
|
||||
@ -289,7 +291,6 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
shadowButton.enabled = true;
|
||||
shadowButton.interactable = true;
|
||||
}
|
||||
|
||||
//标记3d的地图可以用
|
||||
if (!route.RouteInstance.Enable3D)
|
||||
{
|
||||
@ -450,7 +451,6 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
private void ShadowRide(BaseEventData baseEventData)
|
||||
{
|
||||
//mainController.SetCyclingModel(CyclingModel.Review);
|
||||
selectPanel.SetActive(false);
|
||||
//显示影子选手骑行列表
|
||||
selectPlayer.SetActive(true);
|
||||
@ -581,11 +581,11 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
var one = mapData.List.Where(c => c.Distance == 0).Count();
|
||||
foreach (var item in mapData.List)
|
||||
{
|
||||
x += item.Distance;
|
||||
if (!dataSource.ContainsKey(x))
|
||||
{
|
||||
dataSource.Add(x, item.Elevation);
|
||||
}
|
||||
x += item.Distance;
|
||||
dd.Add(item.Elevation);
|
||||
}
|
||||
chartDataSourceScript = transform.Find("Panel/GraphChart").GetComponent<ChartDataSourceScript>();
|
||||
@ -598,64 +598,6 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
}
|
||||
|
||||
void MoveChartMarkPoint()
|
||||
{
|
||||
//if (mainController.isStart)
|
||||
{
|
||||
MoverCurrentUserHead();
|
||||
MoveOtherHeads();
|
||||
MoveElevationImage();
|
||||
}
|
||||
}
|
||||
//移动当前用户头像
|
||||
private void MoverCurrentUserHead()
|
||||
{
|
||||
Vector3 prePos = headPanel.transform.position;
|
||||
int nextIndex = playerController.CurrentIndex + 1;
|
||||
var viewIndex = chartDataSourceScript.GetViewIndex(nextIndex);
|
||||
if (!mainController.isStart && !mainController.isPause && !mainController.isQuit ||(mainController.isStart && playerController.TotalDistance == 0))//未开始未暂停未结束
|
||||
{
|
||||
viewIndex = 0;
|
||||
}
|
||||
|
||||
var n = graph.DataSource.GetPoint("Player 2", viewIndex);
|
||||
graph.PointToWorldSpace(out Vector3 nextPosition, n.x, n.y, "Player 2");
|
||||
nextPosition.x -= 14f;
|
||||
nextPosition.y += 5f;
|
||||
//人物移动 停止条件 到中间且线未加载完
|
||||
if (chartDataSourceScript.ReachMid(viewIndex) && !chartDataSourceScript.ReachEnd())
|
||||
{
|
||||
var currentDistance = playerController.CurrentDistance;
|
||||
var distance = playerController.Distance;
|
||||
var offset = currentDistance > 0 ? distance * 1000 / currentDistance : 1;
|
||||
graph.HorizontalScrolling += offset;
|
||||
headPanel.transform.DOMove(new Vector3(prePos.x, nextPosition.y, 0), 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
headPanel.transform.DOMove(new Vector3(nextPosition.x , nextPosition.y, 0), 1);
|
||||
}
|
||||
headPanel.transform.SetSiblingIndex(999);
|
||||
}
|
||||
//移动其他骑手头像
|
||||
private void MoveOtherHeads()
|
||||
{
|
||||
var others = FindObjectsOfType<OtherPlayerController>();
|
||||
foreach (var item in others)
|
||||
{
|
||||
var itemIndex = chartDataSourceScript.GetViewIndex(item.CurrentIndex) + 1;
|
||||
if (!mainController.isStart && !mainController.isPause && !mainController.isQuit || (mainController.isStart && item.TotalDistance == 0))//未开始未暂停未结束
|
||||
{
|
||||
itemIndex = 0;
|
||||
}
|
||||
var m = graph.DataSource.GetPoint("Player 2", itemIndex);
|
||||
graph.PointToWorldSpace(out Vector3 itemPosition, m.x, m.y, "Player 2");
|
||||
itemPosition.x -= 12f;
|
||||
itemPosition.y += 5f;
|
||||
item.MoveHead(graph.transform, itemPosition);
|
||||
}
|
||||
|
||||
}
|
||||
//移动总海拔图范围
|
||||
private void MoveElevationImage()
|
||||
{
|
||||
@ -668,7 +610,6 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
else
|
||||
{
|
||||
//var m = Screen.width / 1600D;
|
||||
var start = chartDataSourceScript.GetRealTimeStart();
|
||||
var end = chartDataSourceScript.GetRealTimeEnd();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user