2021-03-25 16:22:09 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.UI;
|
2021-03-28 18:17:15 +08:00
|
|
|
|
using XCharts;
|
|
|
|
|
|
using XUGL;
|
|
|
|
|
|
using System.Linq;
|
2021-03-29 20:32:30 +08:00
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using Mapbox.Unity.Map;
|
|
|
|
|
|
using DG.Tweening;
|
2021-03-30 17:15:16 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using Assets.Scenes.Ride.Scripts.Model;
|
2021-04-02 19:17:23 +08:00
|
|
|
|
using UnityEngine.SceneManagement;
|
2021-04-07 17:22:45 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using Assets.Cyp.Common;
|
2021-04-15 10:13:01 +08:00
|
|
|
|
using System.Threading.Tasks;
|
2021-03-25 16:22:09 +08:00
|
|
|
|
|
|
|
|
|
|
namespace Assets.Scenes.Ride.Scripts
|
|
|
|
|
|
{
|
|
|
|
|
|
|
2021-04-02 19:17:23 +08:00
|
|
|
|
public class SingleUIManager : MonoBehaviour
|
2021-03-25 16:22:09 +08:00
|
|
|
|
{
|
2021-03-30 17:15:16 +08:00
|
|
|
|
#region UI control
|
2021-04-15 10:13:01 +08:00
|
|
|
|
GameObject target;
|
2021-03-30 17:15:16 +08:00
|
|
|
|
GameObject rightPanel;//右边列表
|
|
|
|
|
|
GameObject leftPanel;//左边列表
|
2021-03-31 20:46:57 +08:00
|
|
|
|
GameObject nextSlopePanel;//下一个坡度面板
|
|
|
|
|
|
GameObject currentSlopePanel;//当前坡度面板
|
2021-04-15 10:13:01 +08:00
|
|
|
|
GameObject selectPanel;//骑行模式选择
|
|
|
|
|
|
GameObject selectPlayer;//伴侣骑行选择窗口
|
|
|
|
|
|
GameObject reviewPanel;
|
|
|
|
|
|
GameObject titlePanel;
|
|
|
|
|
|
GameObject quitPanel;//退出界面
|
|
|
|
|
|
|
2021-03-31 20:46:57 +08:00
|
|
|
|
Text nextSlopeText;//下一个坡度
|
|
|
|
|
|
Text nextSlopeDistanceText;//下一个坡度距离
|
|
|
|
|
|
Text currentSlopeText;//当前坡度
|
2021-04-15 10:13:01 +08:00
|
|
|
|
Text currentSlopeDistanceText;//当前坡度已骑行距离
|
|
|
|
|
|
Text currentSlopeToatalDistanceText;//当前坡度总距离
|
2021-03-30 17:15:16 +08:00
|
|
|
|
Text speedTxt;//当前速度
|
|
|
|
|
|
Text powerTxt;//功率
|
|
|
|
|
|
Text timerTxt;//计时器
|
2021-04-15 10:13:01 +08:00
|
|
|
|
Text ditance;//当前骑行距离
|
|
|
|
|
|
Text totalDistance;//当前骑行距离
|
|
|
|
|
|
Text candance;//踏频
|
|
|
|
|
|
Text heartRate;//心率
|
2021-03-30 17:15:16 +08:00
|
|
|
|
Text countDownTxt;//倒计时5s
|
2021-04-02 19:17:23 +08:00
|
|
|
|
Text mapName;//路书名称
|
2021-04-15 10:13:01 +08:00
|
|
|
|
Text fps;//fps
|
|
|
|
|
|
Text totalClimb;
|
|
|
|
|
|
|
|
|
|
|
|
Button startBtn;//开始按钮
|
|
|
|
|
|
Button simpleBtn;//进入简约模式按钮
|
|
|
|
|
|
Button pauseButton;//暂停按钮
|
|
|
|
|
|
Button settingButton;//设置那妞
|
|
|
|
|
|
Button deviceButton;//设备按钮
|
|
|
|
|
|
Button exitButton;//退出按钮
|
|
|
|
|
|
Button singleButton;//单人骑行按钮
|
|
|
|
|
|
Button shadowButton;//影子选手按钮
|
|
|
|
|
|
Button addButton;//添加伴侣骑行
|
|
|
|
|
|
Button saveButton;//退出panel保存按钮
|
|
|
|
|
|
Button cancelQuitButton;//退出panel取消按钮
|
|
|
|
|
|
Button closeQuitButton;//退出panel关闭按钮
|
|
|
|
|
|
|
|
|
|
|
|
LineChart elevationChart;//海拔图
|
|
|
|
|
|
RawImage img;//海拔图头像
|
2021-04-07 17:22:45 +08:00
|
|
|
|
|
2021-03-30 17:15:16 +08:00
|
|
|
|
#endregion
|
2021-03-28 18:17:15 +08:00
|
|
|
|
|
2021-03-30 17:15:16 +08:00
|
|
|
|
#region 控制器
|
|
|
|
|
|
|
2021-04-12 17:35:56 +08:00
|
|
|
|
public PlayerController playerController;//当前用户
|
|
|
|
|
|
public CyclingController mainController;//主控制器
|
2021-03-30 17:15:16 +08:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
2021-03-29 20:32:30 +08:00
|
|
|
|
|
2021-03-25 16:22:09 +08:00
|
|
|
|
private float timeRemaining = 1f;
|
|
|
|
|
|
private int count = 0;
|
2021-03-28 18:17:15 +08:00
|
|
|
|
|
|
|
|
|
|
void Awake()
|
|
|
|
|
|
{
|
2021-04-15 10:13:01 +08:00
|
|
|
|
#region 控件获取与事件绑定
|
|
|
|
|
|
fps = transform.Find("Panel/FPS").GetComponent<Text>();
|
2021-04-12 17:35:56 +08:00
|
|
|
|
leftPanel = transform.Find("Panel/ReviewPanel").gameObject;
|
|
|
|
|
|
rightPanel = transform.Find("Panel/NearPanel").gameObject;
|
|
|
|
|
|
startBtn = transform.Find("Panel/StartButton").GetComponent<Button>();
|
|
|
|
|
|
simpleBtn = transform.Find("Panel/SimpleButton").GetComponent<Button>();
|
|
|
|
|
|
ditance = transform.Find("Panel/CyclingComputerPanel/Distance").GetComponent<Text>();
|
2021-04-15 10:13:01 +08:00
|
|
|
|
titlePanel = transform.Find("Panel/TitlePanel").gameObject;
|
|
|
|
|
|
totalDistance = transform.Find("Panel/TitlePanel/TotalDistance").GetComponent<Text>();
|
2021-04-12 17:35:56 +08:00
|
|
|
|
candance = transform.Find("Panel/PowerPanel/Cadance").GetComponent<Text>();
|
|
|
|
|
|
heartRate = transform.Find("Panel/PowerPanel/Hrv").GetComponent<Text>();
|
|
|
|
|
|
nextSlopePanel = transform.Find("Panel/NextSlopePanel").gameObject;
|
|
|
|
|
|
currentSlopePanel = transform.Find("Panel/CurrentSlopePanel").gameObject;
|
2021-04-15 10:13:01 +08:00
|
|
|
|
nextSlopeText = transform.Find("Panel/NextSlopePanel/NextSlopeText").GetComponent<Text>();
|
|
|
|
|
|
nextSlopeDistanceText = transform.Find("Panel/NextSlopePanel/NextSlopeDistance").GetComponent<Text>();
|
|
|
|
|
|
currentSlopeText = transform.Find("Panel/CurrentSlopePanel/CurrentSlopeText").GetComponent<Text>();
|
|
|
|
|
|
currentSlopeDistanceText = transform.Find("Panel/CurrentSlopePanel/CurrentSlopeDistance").GetComponent<Text>();
|
|
|
|
|
|
currentSlopeToatalDistanceText = transform.Find("Panel/CurrentSlopePanel/TotalSlopeDistance").GetComponent<Text>();
|
|
|
|
|
|
speedTxt = transform.Find("Panel/CyclingComputerPanel/Speed").GetComponent<Text>();
|
|
|
|
|
|
powerTxt = transform.Find("Panel/PowerPanel/Power").GetComponent<Text>();
|
|
|
|
|
|
timerTxt = transform.Find("Panel/CyclingComputerPanel/Timer").GetComponent<Text>();
|
|
|
|
|
|
countDownTxt = transform.Find("Panel/CountDown").GetComponent<Text>();
|
|
|
|
|
|
mapName = transform.Find("Panel/TitlePanel/MapName").GetComponent<Text>();
|
|
|
|
|
|
totalClimb = transform.Find("Panel/CyclingComputerPanel/TotalClimb").GetComponent<Text>();
|
|
|
|
|
|
elevationChart = transform.Find("Panel/ElevationChart").GetComponent<LineChart>();
|
|
|
|
|
|
img = transform.Find("Panel/ElevationChart/HeadImage").GetComponent<RawImage>();
|
|
|
|
|
|
selectPanel = transform.Find("Panel/SelectPanel").gameObject;
|
|
|
|
|
|
selectPlayer = transform.Find("Panel/SelectPlayer").gameObject;
|
|
|
|
|
|
reviewPanel = transform.Find("Panel/ReviewPanel").gameObject;
|
|
|
|
|
|
quitPanel = transform.Find("Panel/QuitPanel").gameObject;
|
|
|
|
|
|
|
|
|
|
|
|
pauseButton = transform.Find("Panel/ToolBarPanel/StartOrPauseButton").GetComponent<Button>();
|
|
|
|
|
|
settingButton = transform.Find("Panel/ToolBarPanel/SettingButton").GetComponent<Button>();
|
|
|
|
|
|
deviceButton = transform.Find("Panel/ToolBarPanel/DeviceButton").GetComponent<Button>();
|
|
|
|
|
|
exitButton = transform.Find("Panel/ToolBarPanel/ExitButton").GetComponent<Button>();
|
|
|
|
|
|
singleButton = transform.Find("Panel/SelectPanel/SingleButton").GetComponent<Button>();
|
|
|
|
|
|
shadowButton = transform.Find("Panel/SelectPanel/ShadowButton").GetComponent<Button>();
|
|
|
|
|
|
addButton = transform.Find("Panel/ReviewPanel/SingleArea/AddButton").GetComponent<Button>();
|
|
|
|
|
|
saveButton = transform.Find("Panel/QuitPanel/SaveButton").GetComponent<Button>();
|
|
|
|
|
|
cancelQuitButton = transform.Find("Panel/QuitPanel/CancelButton").GetComponent<Button>();
|
|
|
|
|
|
closeQuitButton = transform.Find("Panel/QuitPanel/CloseButton").GetComponent<Button>();
|
2021-04-12 17:35:56 +08:00
|
|
|
|
|
2021-04-15 10:13:01 +08:00
|
|
|
|
target = transform.parent.Find("Target").gameObject;
|
2021-04-12 17:35:56 +08:00
|
|
|
|
|
2021-03-28 18:17:15 +08:00
|
|
|
|
startBtn.onClick.AddListener(StartRide);
|
2021-03-29 20:32:30 +08:00
|
|
|
|
simpleBtn.onClick.AddListener(ClearPanel);
|
2021-04-15 10:13:01 +08:00
|
|
|
|
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
|
2021-03-28 18:17:15 +08:00
|
|
|
|
}
|
2021-04-15 10:13:01 +08:00
|
|
|
|
|
2021-03-25 16:22:09 +08:00
|
|
|
|
void Start()
|
|
|
|
|
|
{
|
2021-04-02 19:17:23 +08:00
|
|
|
|
playerController = FindObjectOfType<PlayerController>();
|
|
|
|
|
|
mainController = FindObjectOfType<CyclingController>();
|
|
|
|
|
|
var route = mainController.GetRoute();
|
|
|
|
|
|
mapName.text = route.RouteInstance.Name;
|
2021-04-12 17:35:56 +08:00
|
|
|
|
totalDistance.text = Math.Round(mainController.GetMapData().TotalDistance, 2).ToString() + "KM";//总里程
|
2021-03-28 18:17:15 +08:00
|
|
|
|
RenderChart();
|
2021-04-07 17:22:45 +08:00
|
|
|
|
startIndex = playerController.CurrentIndex;
|
2021-03-25 16:22:09 +08:00
|
|
|
|
}
|
2021-03-31 20:46:57 +08:00
|
|
|
|
// Update is called once per frame
|
2021-04-02 19:17:23 +08:00
|
|
|
|
float tt = 1f;
|
2021-03-31 20:46:57 +08:00
|
|
|
|
void Update()
|
|
|
|
|
|
{
|
2021-04-02 19:17:23 +08:00
|
|
|
|
tt -= Time.deltaTime;
|
|
|
|
|
|
while (tt < 0) {
|
2021-04-15 10:13:01 +08:00
|
|
|
|
fps.text = (1 / Time.deltaTime).ToString();
|
2021-04-02 19:17:23 +08:00
|
|
|
|
tt = 1;
|
|
|
|
|
|
}
|
2021-03-31 20:46:57 +08:00
|
|
|
|
//获取当前选中玩家绑定当前UI
|
|
|
|
|
|
if (playerController != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
//绑定UI
|
|
|
|
|
|
speedTxt.text = $"{playerController.Speed}";
|
|
|
|
|
|
powerTxt.text = $"{playerController.Power}";
|
|
|
|
|
|
timerTxt.text = Helper.FormatTicks(playerController.TotalTicks);
|
|
|
|
|
|
ditance.text = Math.Round(playerController.TotalDistance, 2).ToString("f2")+"KM";
|
|
|
|
|
|
heartRate.text = $"{Math.Round(playerController.HeartRate, 0)}";
|
|
|
|
|
|
candance.text = $"{Math.Round(playerController.Cadance, 0)}";
|
|
|
|
|
|
//倒计时
|
|
|
|
|
|
if (count > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
timeRemaining -= Time.deltaTime;
|
|
|
|
|
|
if (timeRemaining <= 0)//定时器
|
|
|
|
|
|
{
|
|
|
|
|
|
count--;
|
|
|
|
|
|
if (count == 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
playerController.SetStart();
|
|
|
|
|
|
countDownTxt.gameObject.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
timeRemaining = 1.0f;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
countDownTxt.text = count.ToString();
|
|
|
|
|
|
//坡度相关数据
|
|
|
|
|
|
nextSlopeText.text = Math.Round(playerController.NextSlope, 1).ToString() + "%";
|
|
|
|
|
|
nextSlopeDistanceText.text ="-" + Math.Round(playerController.NextSlopeDistance, 0).ToString()+"M";
|
|
|
|
|
|
currentSlopeText.text = Math.Round(playerController.CurrentSlope, 1).ToString() + "%";
|
|
|
|
|
|
currentSlopeDistanceText.text = Math.Round(playerController.CurrentSlopeDistance, 0).ToString() + "M";
|
2021-04-15 10:13:01 +08:00
|
|
|
|
totalClimb.text = Math.Round(playerController.TotalClimb, 0).ToString();
|
2021-03-31 20:46:57 +08:00
|
|
|
|
//移动海拔图头像 TODO:移动所有人的头像
|
2021-04-07 17:22:45 +08:00
|
|
|
|
UpdateRealTimeChart();
|
|
|
|
|
|
//MoveChartMarkPoint();
|
2021-03-31 20:46:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-04-07 17:22:45 +08:00
|
|
|
|
private void LateUpdate()
|
2021-03-31 20:46:57 +08:00
|
|
|
|
{
|
2021-04-07 17:22:45 +08:00
|
|
|
|
if (target != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
target.transform.position = playerController.transform.position; //new Vector3((float)Math.Round(player.transform.position.x,1), 0, (float)Math.Round(player.transform.position.z,1));
|
2021-04-15 10:13:01 +08:00
|
|
|
|
//target.transform.rotation = playerController.transform.rotation;//new Quaternion(playerController.transform.rotation.x, playerController.transform.rotation.y +1f, playerController.transform.rotation.z, playerController.transform.rotation.w);
|
|
|
|
|
|
target.transform.eulerAngles = new Vector3(0, playerController.transform.eulerAngles.y + 180f, 0);
|
2021-04-07 17:22:45 +08:00
|
|
|
|
}
|
2021-03-31 20:46:57 +08:00
|
|
|
|
}
|
2021-04-15 10:13:01 +08:00
|
|
|
|
private void SingleRide()
|
|
|
|
|
|
{
|
|
|
|
|
|
selectPanel.SetActive(false);
|
|
|
|
|
|
mainController.cyclingModel = CyclingModel.Single;
|
|
|
|
|
|
//显示单人骑行列表
|
|
|
|
|
|
reviewPanel.SetActive(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
private void ShadowRide()
|
|
|
|
|
|
{
|
|
|
|
|
|
mainController.cyclingModel = CyclingModel.Review;
|
|
|
|
|
|
selectPanel.SetActive(false);
|
|
|
|
|
|
//显示影子选手骑行列表
|
|
|
|
|
|
selectPlayer.SetActive(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
private void ShowSelectPlayer()
|
|
|
|
|
|
{
|
|
|
|
|
|
selectPlayer.SetActive(true);
|
|
|
|
|
|
}
|
2021-03-25 16:22:09 +08:00
|
|
|
|
private void StartRide()
|
|
|
|
|
|
{
|
|
|
|
|
|
//加个5秒钟倒计时
|
|
|
|
|
|
count = 5;
|
|
|
|
|
|
startBtn.gameObject.SetActive(false);
|
|
|
|
|
|
countDownTxt.gameObject.SetActive(true);
|
|
|
|
|
|
countDownTxt.text = count.ToString();
|
2021-03-29 20:32:30 +08:00
|
|
|
|
}
|
2021-03-30 17:15:16 +08:00
|
|
|
|
//暂停游戏
|
|
|
|
|
|
private void PauseRide()
|
|
|
|
|
|
{
|
|
|
|
|
|
playerController.SetPause();
|
|
|
|
|
|
startBtn.gameObject.SetActive(true);
|
|
|
|
|
|
}
|
2021-04-15 10:13:01 +08:00
|
|
|
|
private void SaveRide()
|
|
|
|
|
|
{
|
|
|
|
|
|
playerController.Upload();
|
|
|
|
|
|
//SceneManager.LoadScene("MainScene");
|
|
|
|
|
|
quitPanel.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
private void CancelQuit()
|
|
|
|
|
|
{
|
|
|
|
|
|
quitPanel.SetActive(false);
|
|
|
|
|
|
SceneManager.LoadScene("MainScene");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void CloseQuit()
|
|
|
|
|
|
{
|
|
|
|
|
|
quitPanel.SetActive(false);
|
|
|
|
|
|
}
|
2021-03-30 17:15:16 +08:00
|
|
|
|
//结束游戏
|
|
|
|
|
|
private void StopRide()
|
|
|
|
|
|
{
|
2021-04-15 10:13:01 +08:00
|
|
|
|
quitPanel.SetActive(true);
|
2021-03-30 17:15:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
//显示设备连接
|
|
|
|
|
|
private void ShowDevicePanel()
|
|
|
|
|
|
{
|
2021-04-15 10:13:01 +08:00
|
|
|
|
UIManager.ShowCustom(UIManager.Instance.DevicePanel, transform.Find("Panel").gameObject);
|
2021-03-30 17:15:16 +08:00
|
|
|
|
}
|
|
|
|
|
|
//显示设置
|
|
|
|
|
|
private void ShowSettingPanel()
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
2021-03-29 20:32:30 +08:00
|
|
|
|
int isSimple = 1;
|
2021-04-15 10:13:01 +08:00
|
|
|
|
|
|
|
|
|
|
private bool clearLock = true;
|
|
|
|
|
|
private void ClearPanel()
|
2021-03-29 20:32:30 +08:00
|
|
|
|
{
|
2021-04-15 10:13:01 +08:00
|
|
|
|
if (clearLock)
|
|
|
|
|
|
{
|
|
|
|
|
|
clearLock = false;
|
|
|
|
|
|
leftPanel.transform.DOLocalMove(new Vector3(leftPanel.transform.localPosition.x + isSimple * -430f, leftPanel.transform.localPosition.y, leftPanel.transform.localPosition.z), 1);
|
|
|
|
|
|
titlePanel.transform.DOLocalMove(new Vector3(titlePanel.transform.localPosition.x, titlePanel.transform.localPosition.y + isSimple * 180f, titlePanel.transform.localPosition.z), 1);
|
|
|
|
|
|
rightPanel.transform.DOLocalMove(new Vector3(rightPanel.transform.localPosition.x + isSimple * 330f, rightPanel.transform.localPosition.y, rightPanel.transform.localPosition.z), 1).onComplete += () =>
|
|
|
|
|
|
{
|
|
|
|
|
|
clearLock = true;
|
|
|
|
|
|
isSimple *= -1;
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
2021-03-25 16:22:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-04-07 17:22:45 +08:00
|
|
|
|
private int maxCacheDataNumber = 100;//海拔图最大点数
|
|
|
|
|
|
private int totalCount;//路线实际点数
|
|
|
|
|
|
private int startIndex;//选中玩家起始索引
|
|
|
|
|
|
private int interval = 50;//选中玩家移动索引个数
|
|
|
|
|
|
private float[] elevationList;
|
2021-03-30 17:15:16 +08:00
|
|
|
|
//初始化海拔图
|
2021-03-28 18:17:15 +08:00
|
|
|
|
void RenderChart()
|
|
|
|
|
|
{
|
|
|
|
|
|
elevationChart.ClearData();
|
2021-04-07 17:22:45 +08:00
|
|
|
|
elevationList = mainController.GetLineChartData();
|
|
|
|
|
|
totalCount = elevationList.Length;
|
|
|
|
|
|
maxCacheDataNumber = Math.Min(totalCount, maxCacheDataNumber);
|
|
|
|
|
|
elevationChart.SetMaxCache(maxCacheDataNumber);
|
|
|
|
|
|
//for (int i = 0; i < maxCacheDataNumber; i++)
|
|
|
|
|
|
//{
|
|
|
|
|
|
// elevationChart.AddData(0, elevationList[i]);
|
|
|
|
|
|
//}
|
|
|
|
|
|
//elevationChart.RefreshChart();
|
|
|
|
|
|
|
|
|
|
|
|
var endIndex = playerController.CurrentIndex;
|
|
|
|
|
|
var s = endIndex / maxCacheDataNumber;
|
|
|
|
|
|
var v = endIndex % maxCacheDataNumber;
|
|
|
|
|
|
|
|
|
|
|
|
maxCacheDataNumber = Math.Min(totalCount-s* maxCacheDataNumber, maxCacheDataNumber);
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < maxCacheDataNumber; i++)
|
2021-03-28 18:17:15 +08:00
|
|
|
|
{
|
2021-04-07 17:22:45 +08:00
|
|
|
|
initCount++;
|
|
|
|
|
|
if (initCount > maxCacheDataNumber) break;
|
|
|
|
|
|
AddOneData(s * maxCacheDataNumber + v + i);
|
2021-03-28 18:17:15 +08:00
|
|
|
|
}
|
2021-04-07 17:22:45 +08:00
|
|
|
|
|
|
|
|
|
|
elevationChart.RefreshChart();
|
2021-04-12 17:35:56 +08:00
|
|
|
|
if (App.CurrentUser != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Utils.DisplayImage(StartCoroutine, img, App.CurrentUser.WxHeadImg);
|
|
|
|
|
|
}
|
2021-04-07 17:22:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
//长路线动态更新chart
|
|
|
|
|
|
private int initCount;
|
|
|
|
|
|
private float updateTime;
|
|
|
|
|
|
private int lastIndex;
|
|
|
|
|
|
private int chartAddNum;
|
|
|
|
|
|
void UpdateRealTimeChart()
|
|
|
|
|
|
{
|
|
|
|
|
|
var endIndex = playerController.CurrentIndex;
|
|
|
|
|
|
updateTime += Time.deltaTime;
|
|
|
|
|
|
if (updateTime >= 1)
|
|
|
|
|
|
{
|
|
|
|
|
|
int delta = endIndex - lastIndex;
|
|
|
|
|
|
if (delta >0 && initCount < totalCount)
|
|
|
|
|
|
{
|
|
|
|
|
|
lastIndex = endIndex;
|
|
|
|
|
|
AddOneData(initCount);
|
|
|
|
|
|
initCount++;
|
|
|
|
|
|
updateTime = 0;
|
|
|
|
|
|
chartAddNum++;
|
|
|
|
|
|
}
|
|
|
|
|
|
var v = (endIndex - chartAddNum) % maxCacheDataNumber;
|
|
|
|
|
|
MoveChartMarkPoint(v);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
void AddOneData(int index)
|
|
|
|
|
|
{
|
2021-04-15 10:13:01 +08:00
|
|
|
|
string category = index.ToString();
|
2021-04-07 17:22:45 +08:00
|
|
|
|
elevationChart.AddData(0, elevationList[index]);
|
2021-04-15 10:13:01 +08:00
|
|
|
|
//elevationChart.AddXAxisData(category);
|
2021-04-07 17:22:45 +08:00
|
|
|
|
//elevationChart.AddXAxisData(index.ToString(), index);
|
|
|
|
|
|
|
2021-03-28 18:17:15 +08:00
|
|
|
|
}
|
2021-03-29 20:32:30 +08:00
|
|
|
|
|
2021-04-07 17:22:45 +08:00
|
|
|
|
void MoveChartMarkPoint(int index)
|
2021-03-28 18:17:15 +08:00
|
|
|
|
{
|
2021-03-30 17:15:16 +08:00
|
|
|
|
var dataPoints = elevationChart.series.list[0].dataPoints.OrderBy(c=>c.x).ToList();
|
2021-03-29 20:32:30 +08:00
|
|
|
|
if (dataPoints.Count > 0)
|
|
|
|
|
|
{
|
2021-04-07 17:22:45 +08:00
|
|
|
|
var pinLoction = dataPoints[index];
|
|
|
|
|
|
pinLoction.y = img.transform.localPosition.y;
|
2021-03-29 20:32:30 +08:00
|
|
|
|
img.transform.localPosition = pinLoction;
|
|
|
|
|
|
}
|
2021-03-28 18:17:15 +08:00
|
|
|
|
}
|
2021-03-25 16:22:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|