Merge branch 'dev_lishuo' into dev
This commit is contained in:
commit
84e8b50bbf
@ -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
|
||||
|
||||
@ -11,9 +11,9 @@ GameObject:
|
||||
- component: {fileID: 1148602845821646045}
|
||||
- component: {fileID: 1148602845821646048}
|
||||
- component: {fileID: 1148602845821646051}
|
||||
- component: {fileID: 1148602845821646050}
|
||||
- component: {fileID: 6957187063806588864}
|
||||
m_Layer: 5
|
||||
m_Name: arrow
|
||||
m_Name: MiniArrow
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -65,8 +65,8 @@ MonoBehaviour:
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 0}
|
||||
m_Type: 0
|
||||
m_Sprite: {fileID: 21300000, guid: 8a1f5dd0a18144c498c99139fcfa3547, type: 3}
|
||||
m_Type: 1
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
@ -75,7 +75,7 @@ MonoBehaviour:
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!114 &1148602845821646050
|
||||
--- !u!114 &6957187063806588864
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
@ -84,7 +84,10 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 1148602845821646044}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: adb30198aa32dd140b5750692dd48104, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: 97bc2ebab6563400c95b036136d26ea6, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
radius: 4
|
||||
m_Inverse: 0
|
||||
m_MaskInteraction: 85
|
||||
m_UseStencil: 1
|
||||
m_RaycastFilter: 0
|
||||
|
||||
@ -198,7 +198,7 @@ RectTransform:
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 215, y: 48}
|
||||
m_SizeDelta: {x: 225, y: 48}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &8877223148509276859
|
||||
CanvasRenderer:
|
||||
|
||||
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)
|
||||
@ -162,8 +178,6 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
if (graph != null)
|
||||
{
|
||||
|
||||
Debug.Log("Loading page :" + pagePosition);
|
||||
graph.DataSource.StartBatch(); // call start batch
|
||||
graph.DataSource.HorizontalViewOrigin = 0;
|
||||
|
||||
|
||||
@ -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 = 1000; //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)
|
||||
|
||||
@ -45,11 +45,13 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
MapApi mapApi;
|
||||
Sprite down;
|
||||
Sprite up;
|
||||
Transform parent;
|
||||
private void Awake()
|
||||
{
|
||||
mapApi = new MapApi();
|
||||
cyclingController = FindObjectOfType<CyclingController>();
|
||||
//分页查询当前路数排行榜选手成绩列表
|
||||
parent = transform.Find("Panel/PlayerList/Scroll View/Viewport/Content");
|
||||
prefab = Resources.Load<GameObject>("UI/Prefab/Ride/SelectPlayerItem");
|
||||
down = Resources.Load<Sprite>("Images/DOWN");
|
||||
up = Resources.Load<Sprite>("Images/UP");
|
||||
@ -111,6 +113,14 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
OnEndDrag(null);
|
||||
}
|
||||
}
|
||||
if (Input.GetKeyDown(KeyCode.Return))
|
||||
{
|
||||
Search(null);
|
||||
}
|
||||
|
||||
bool enabled = gameObjects.Where(c => c.GetComponent<SeletedPlayerScript>().isUsed).Count() > 0;
|
||||
rideButton.enabled = enabled;
|
||||
rideButton.interactable = enabled;
|
||||
}
|
||||
private void StartvalueChanged(string input)
|
||||
{
|
||||
@ -190,14 +200,38 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
reviewPanel.SetActive(false);
|
||||
selectPanel.SetActive(true);
|
||||
nearPanel.SetActive(false);
|
||||
Reset();
|
||||
}
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
inputField.text = string.Empty;
|
||||
startValue.text = string.Empty;
|
||||
endValue.text = string.Empty;
|
||||
|
||||
pageIndex = 0;
|
||||
pageSize = 8;
|
||||
totalPages = 0;
|
||||
seachName = string.Empty;
|
||||
|
||||
_startValue = 0;
|
||||
_endValue = 0;
|
||||
|
||||
foreach (var item in gameObjects)
|
||||
{
|
||||
item.GetComponent<SeletedPlayerScript>().Reset();
|
||||
}
|
||||
parent.DestroyChildren();
|
||||
sort = 0;
|
||||
sortImage.sprite = down;
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
//CreateGameObject(cyclingController.mapRouteRankingList);
|
||||
Refresh();
|
||||
//Refresh();
|
||||
}
|
||||
|
||||
private void Refresh()
|
||||
public void Refresh()
|
||||
{
|
||||
var list = mapApi.GetShadowList(App.RouteIdParam, seachName, pageIndex, pageSize);
|
||||
totalPages = list.data.TotalPages;
|
||||
@ -222,7 +256,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
private void CreateGameObject(List<MapRouteRanking> list)
|
||||
{
|
||||
var parent = transform.Find("Panel/PlayerList/Scroll View/Viewport/Content");
|
||||
|
||||
int index = 0;
|
||||
foreach (var item in list)
|
||||
{
|
||||
|
||||
@ -103,6 +103,8 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
Image currentSlopeProcess;
|
||||
Text miniMapProcessText;
|
||||
|
||||
Slider cameraSlider;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
#region 控件获取与事件绑定
|
||||
@ -245,7 +247,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 +268,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 +277,26 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
cameraY = float.Parse(cameraArr[1]);
|
||||
cameraZ = float.Parse(cameraArr[2]);
|
||||
}
|
||||
//开发者视角调整
|
||||
cameraSlider = transform.Find("Panel/CameraSlider").GetComponent<Slider>();
|
||||
Text CameraText = transform.Find("Panel/CameraSlider/Text").GetComponent<Text>();
|
||||
string[] phoneList = new string[] { "18120141032", "15651831367", "13115011550", "15261826280" };
|
||||
if (phoneList.Contains(App.CurrentUser.Phone))
|
||||
{
|
||||
cameraSlider.gameObject.SetActive(true);
|
||||
cameraSlider.value = cameraY;
|
||||
CameraText.text = cameraY.ToString("f0");
|
||||
cameraSlider.onValueChanged.AddListener((f) =>
|
||||
{
|
||||
cameraY = f;
|
||||
CameraText.text = f.ToString("f0");
|
||||
});
|
||||
}
|
||||
//路书基本信息绑定
|
||||
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 +308,6 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
shadowButton.enabled = true;
|
||||
shadowButton.interactable = true;
|
||||
}
|
||||
|
||||
//标记3d的地图可以用
|
||||
if (!route.RouteInstance.Enable3D)
|
||||
{
|
||||
@ -328,7 +346,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
}
|
||||
Vector3 m = new Vector3(0.1f, 0.1f, 0.1f);
|
||||
|
||||
Vector3 CameraVector = Vector3.zero;
|
||||
//移动摄像头和箭头位置
|
||||
private void MoveCamera()
|
||||
{
|
||||
@ -345,7 +363,10 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
else
|
||||
{
|
||||
target.transform.eulerAngles = new Vector3(cameraX, cameraY, cameraZ);
|
||||
CameraVector.x = cameraX;
|
||||
CameraVector.y = cameraY;
|
||||
CameraVector.z = cameraZ;
|
||||
target.transform.eulerAngles = CameraVector;
|
||||
}
|
||||
//控制照片移动
|
||||
((RectTransform)arrow.transform).position = Camera.main.WorldToScreenPoint(target.transform.position);
|
||||
@ -371,7 +392,11 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
if (count == 0)
|
||||
{
|
||||
mainController.SetStart();
|
||||
countDownTxt.gameObject.SetActive(false);
|
||||
var canvasGroup = countDownTxt.transform.GetComponent<CanvasGroup>();
|
||||
canvasGroup.DOFade(0, 1).onComplete+=()=> {
|
||||
countDownTxt.gameObject.SetActive(false);
|
||||
canvasGroup.alpha = 1;
|
||||
};
|
||||
}
|
||||
if (count == 1 && mainController.cyclingModel == CyclingModel.Single)
|
||||
{
|
||||
@ -379,10 +404,12 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
//附近的人
|
||||
// nearByPanel.GetComponent<CanvasGroup>().DOFade(0, 1);
|
||||
}
|
||||
|
||||
countDownTxt.transform.DOPunchScale(new Vector3(1.2f, 1.2f, 1.2f),1,1,1);
|
||||
timeRemaining = 1.0f;
|
||||
}
|
||||
}
|
||||
countDownTxt.text = count.ToString();
|
||||
countDownTxt.text = count==0?"GO!": count.ToString();
|
||||
}
|
||||
private void BindDataSource()
|
||||
{
|
||||
@ -450,10 +477,10 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
private void ShadowRide(BaseEventData baseEventData)
|
||||
{
|
||||
//mainController.SetCyclingModel(CyclingModel.Review);
|
||||
selectPanel.SetActive(false);
|
||||
//显示影子选手骑行列表
|
||||
selectPlayer.SetActive(true);
|
||||
selectPlayer.GetComponent<SelectPlayerFactory>().Refresh();
|
||||
//显示附近的人列表
|
||||
nearByPanel.SetActive(true);
|
||||
}
|
||||
@ -581,11 +608,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 +625,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 +637,6 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
else
|
||||
{
|
||||
//var m = Screen.width / 1600D;
|
||||
var start = chartDataSourceScript.GetRealTimeStart();
|
||||
var end = chartDataSourceScript.GetRealTimeEnd();
|
||||
|
||||
|
||||
@ -5,6 +5,8 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.Net;
|
||||
using System.Globalization;
|
||||
using System.Threading;
|
||||
|
||||
public static class App
|
||||
{
|
||||
@ -50,6 +52,10 @@ public static class App
|
||||
|
||||
static App()
|
||||
{
|
||||
CultureInfo currentCulture = (CultureInfo)Thread.CurrentThread.CurrentCulture.Clone();
|
||||
currentCulture.NumberFormat.NumberDecimalSeparator = ".";
|
||||
Thread.CurrentThread.CurrentCulture = currentCulture;
|
||||
System.Globalization.CultureInfo.DefaultThreadCurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
|
||||
#if !UNITY_EDITOR
|
||||
// Host = "http://pf.juze.pro/";
|
||||
// UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21000);
|
||||
|
||||
@ -317,6 +317,51 @@ public class MapListController : PFUIPanel
|
||||
isEnd = false;
|
||||
GetList();
|
||||
}
|
||||
|
||||
public void ResetPanel()
|
||||
{
|
||||
if (searchInput != null)
|
||||
{
|
||||
//empty Data
|
||||
ftname = string.Empty;
|
||||
hands = new List<string>();
|
||||
var text = distanceOptions.GetComponent<Dropdown>().options[0].text;
|
||||
distance = MapFilterOptions.distanceDict[text];
|
||||
is3d = false;
|
||||
isFav = false;
|
||||
//empty ui
|
||||
searchInput.GetComponent<InputField>().text = string.Empty;
|
||||
var dDropdown = distanceOptions.GetComponent<Dropdown>();
|
||||
dDropdown.value = 0;
|
||||
|
||||
if (diffOptions != null)
|
||||
{
|
||||
foreach (Transform t in diffOptions)
|
||||
{
|
||||
var button = t.GetComponent<Button>();
|
||||
var image = t.GetComponent<Image>();
|
||||
var buttonText = t.Find("Text").GetComponent<Text>();
|
||||
ColorUtility.TryParseHtmlString("#23232D", out Color c);
|
||||
//ColorUtility.TryParseHtmlString("#F93086", out Color c);
|
||||
image.color = c;
|
||||
buttonText.color = new Color(1, 1, 1, 1);
|
||||
}
|
||||
}
|
||||
|
||||
var isfav = favContainer.Find("Gou").gameObject;
|
||||
isfav.SetActive(false);
|
||||
var is3dUI = tdContainer.Find("Gou").gameObject;
|
||||
is3dUI.SetActive(false);
|
||||
|
||||
if (sorts != null)
|
||||
{
|
||||
var drop = sorts.GetComponent<Dropdown>();
|
||||
drop.value = 0;
|
||||
}
|
||||
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
void ResetList()
|
||||
{
|
||||
distance = "";
|
||||
|
||||
@ -114,6 +114,13 @@ public class UserInfoController : PFUIPanel
|
||||
}
|
||||
|
||||
}
|
||||
public void Reset()
|
||||
{
|
||||
if (summaryPanel != null)
|
||||
{
|
||||
summaryPanel.Find("Panel").Find("RideResultList").GetComponent<ResultListController>().Reset();
|
||||
}
|
||||
}
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
@ -128,6 +128,17 @@ public class ResultListController : MonoBehaviour
|
||||
pageIndex[scrollIndex] = 0;
|
||||
GetList();
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
if (searchInput != null)
|
||||
{
|
||||
searchInput.GetComponent<InputField>().text = "";
|
||||
name = "";
|
||||
Load();
|
||||
StartScroll(1);
|
||||
}
|
||||
}
|
||||
Dictionary<int, bool> isEnd = new Dictionary<int, bool>
|
||||
{
|
||||
{0,false },{1,false }
|
||||
|
||||
@ -343,6 +343,7 @@ public class UIManager : MonoBehaviour
|
||||
|
||||
public static void ShowUserInfoPanel()
|
||||
{
|
||||
UIManager.Instance.UserInfoPanel.Reset();
|
||||
UIManager.Show(UIManager.Instance.UserInfoPanel, UIManager.Instance.MainPanel);
|
||||
}
|
||||
|
||||
@ -419,6 +420,7 @@ public class UIManager : MonoBehaviour
|
||||
{
|
||||
Debug.Log("清空");
|
||||
//App.propTextureCache["recordCache"].Clear();
|
||||
UIManager.Instance.MapListPanel.ResetPanel();
|
||||
UIManager.Show(UIManager.Instance.MapListPanel, UIManager.Instance.MainPanel);
|
||||
}
|
||||
public static void ShowMapDetailPanel(int id)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user