继骑&重骑骑行结果页细节调整
This commit is contained in:
1 parent
018699c944
commit
afba150d91
34 files changed
+3601
-2379
No files matched your search
@@ -12,6 +12,7 @@ using UnityEngine.SceneManagement;
|
||||
using System.Collections.Generic;
|
||||
using Assets.Cyp.Common;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
@@ -74,11 +75,14 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
|
||||
private float timeRemaining = 1f;
|
||||
private int count = 0;
|
||||
|
||||
Image arrow;
|
||||
AbstractMap map;
|
||||
void Awake()
|
||||
{
|
||||
#region 控件获取与事件绑定
|
||||
fps = transform.Find("Panel/FPS").GetComponent<Text>();
|
||||
arrow = transform.Find("Panel/Arrow").GetComponent<Image>();
|
||||
map = transform.parent.Find("Map").GetComponent<AbstractMap>();
|
||||
leftPanel = transform.Find("Panel/ReviewPanel").gameObject;
|
||||
rightPanel = transform.Find("Panel/NearPanel").gameObject;
|
||||
startBtn = transform.Find("Panel/StartButton").GetComponent<Button>();
|
||||
@@ -121,18 +125,31 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
|
||||
target = transform.parent.Find("Target").gameObject;
|
||||
|
||||
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);
|
||||
UIManager.AddEvent(startBtn.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, StartRide);
|
||||
UIManager.AddEvent(simpleBtn.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, ClearPanel);
|
||||
UIManager.AddEvent(pauseButton.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, PauseRide);
|
||||
UIManager.AddEvent(settingButton.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, ShowSettingPanel);
|
||||
UIManager.AddEvent(deviceButton.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, ShowDevicePanel);
|
||||
UIManager.AddEvent(exitButton.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, StopRide);
|
||||
UIManager.AddEvent(singleButton.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, SingleRide);
|
||||
UIManager.AddEvent(shadowButton.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, ShadowRide);
|
||||
UIManager.AddEvent(addButton.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, ShowSelectPlayer);
|
||||
UIManager.AddEvent(saveButton.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, SaveRide);
|
||||
UIManager.AddEvent(cancelQuitButton.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, CancelQuit);
|
||||
UIManager.AddEvent(closeQuitButton.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, CloseQuit);
|
||||
|
||||
//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
|
||||
}
|
||||
|
||||
@@ -145,6 +162,22 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
totalDistance.text = Math.Round(mainController.GetMapData().TotalDistance, 2).ToString() + "KM";//总里程
|
||||
RenderChart();
|
||||
startIndex = playerController.CurrentIndex;
|
||||
//继续骑行如果有伴侣就自动进入伴侣骑行
|
||||
if (mainController.routeResult != null)
|
||||
{
|
||||
if (mainController.routeResult.Mode == CyclingModel.Review.ToString())
|
||||
{
|
||||
mainController.SetCyclingModel(CyclingModel.Review);
|
||||
selectPanel.SetActive(false);
|
||||
var reviewFactory = reviewPanel.transform.GetComponent<ReviewFactory>();
|
||||
reviewFactory.Refresh();
|
||||
}
|
||||
else if (mainController.routeResult.Mode == CyclingModel.Single.ToString())
|
||||
{
|
||||
mainController.SetCyclingModel(CyclingModel.Single);
|
||||
selectPanel.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Update is called once per frame
|
||||
float tt = 1f;
|
||||
@@ -153,6 +186,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
tt -= Time.deltaTime;
|
||||
while (tt < 0) {
|
||||
fps.text = (1 / Time.deltaTime).ToString();
|
||||
MoveChartMarkPoint();
|
||||
tt = 1;
|
||||
}
|
||||
//获取当前选中玩家绑定当前UI
|
||||
@@ -188,40 +222,45 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
currentSlopeDistanceText.text = Math.Round(playerController.CurrentSlopeDistance, 0).ToString() + "M";
|
||||
totalClimb.text = Math.Round(playerController.TotalClimb, 0).ToString();
|
||||
//移动海拔图头像 TODO:移动所有人的头像
|
||||
UpdateRealTimeChart();
|
||||
|
||||
//MoveChartMarkPoint();
|
||||
}
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
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));
|
||||
//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);
|
||||
//控制照片移动
|
||||
((RectTransform)arrow.transform).position = Camera.main.WorldToScreenPoint(target.transform.position);
|
||||
}
|
||||
}
|
||||
private void SingleRide()
|
||||
|
||||
private void SingleRide(BaseEventData baseEventData)
|
||||
{
|
||||
selectPanel.SetActive(false);
|
||||
mainController.cyclingModel = CyclingModel.Single;
|
||||
mainController.SetCyclingModel(CyclingModel.Single);
|
||||
//显示单人骑行列表
|
||||
reviewPanel.SetActive(true);
|
||||
}
|
||||
private void ShadowRide()
|
||||
private void ShadowRide(BaseEventData baseEventData)
|
||||
{
|
||||
mainController.cyclingModel = CyclingModel.Review;
|
||||
mainController.SetCyclingModel(CyclingModel.Review);
|
||||
selectPanel.SetActive(false);
|
||||
//显示影子选手骑行列表
|
||||
selectPlayer.SetActive(true);
|
||||
}
|
||||
private void ShowSelectPlayer()
|
||||
private void ShowSelectPlayer(BaseEventData baseEventData)
|
||||
{
|
||||
selectPlayer.SetActive(true);
|
||||
}
|
||||
private void StartRide()
|
||||
private void StartRide(BaseEventData baseEventData)
|
||||
{
|
||||
var antConnected = mainController.CheckAnt();//初始化ant+设备
|
||||
//if (!antConnected)
|
||||
//{
|
||||
// throw new Exception("请先连接设备");
|
||||
//}
|
||||
//加个5秒钟倒计时
|
||||
count = 5;
|
||||
startBtn.gameObject.SetActive(false);
|
||||
@@ -229,12 +268,12 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
countDownTxt.text = count.ToString();
|
||||
}
|
||||
//暂停游戏
|
||||
private void PauseRide()
|
||||
private void PauseRide(BaseEventData baseEventData)
|
||||
{
|
||||
playerController.SetPause();
|
||||
startBtn.gameObject.SetActive(true);
|
||||
}
|
||||
private void SaveRide()
|
||||
private void SaveRide(BaseEventData baseEventData)
|
||||
{
|
||||
playerController.SetPause();
|
||||
if (playerController.TotalTicks > 0 && !playerController.isQuit )
|
||||
@@ -244,18 +283,18 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
SceneManager.LoadScene("MainScene");
|
||||
}
|
||||
private void CancelQuit()
|
||||
private void CancelQuit(BaseEventData baseEventData)
|
||||
{
|
||||
quitPanel.SetActive(false);
|
||||
SceneManager.LoadScene("MainScene");
|
||||
}
|
||||
|
||||
private void CloseQuit()
|
||||
private void CloseQuit(BaseEventData baseEventData)
|
||||
{
|
||||
quitPanel.SetActive(false);
|
||||
}
|
||||
//结束游戏
|
||||
private void StopRide()
|
||||
private void StopRide(BaseEventData baseEventData)
|
||||
{
|
||||
if (playerController.TotalTicks > 0)
|
||||
{
|
||||
@@ -267,18 +306,18 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
}
|
||||
//显示设备连接
|
||||
private void ShowDevicePanel()
|
||||
private void ShowDevicePanel(BaseEventData baseEventData)
|
||||
{
|
||||
UIManager.Show(UIManager.Instance.DevicePanel, transform.Find("Panel").GetComponent<PFUIPanel>());
|
||||
}
|
||||
//显示设置
|
||||
private void ShowSettingPanel()
|
||||
private void ShowSettingPanel(BaseEventData baseEventData)
|
||||
{
|
||||
}
|
||||
int isSimple = 1;
|
||||
|
||||
private bool clearLock = true;
|
||||
private void ClearPanel()
|
||||
private void ClearPanel(BaseEventData baseEventData)
|
||||
{
|
||||
if (clearLock)
|
||||
{
|
||||
@@ -311,7 +350,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
// elevationChart.AddData(0, elevationList[i]);
|
||||
//}
|
||||
//elevationChart.RefreshChart();
|
||||
|
||||
ElevationToScreenPoint();
|
||||
var endIndex = playerController.CurrentIndex;
|
||||
var s = endIndex / maxCacheDataNumber;
|
||||
var v = endIndex % maxCacheDataNumber;
|
||||
@@ -324,7 +363,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
if (initCount > maxCacheDataNumber) break;
|
||||
AddOneData(s * maxCacheDataNumber + v + i);
|
||||
}
|
||||
|
||||
|
||||
elevationChart.RefreshChart();
|
||||
if (App.CurrentUser != null)
|
||||
{
|
||||
@@ -352,28 +391,59 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
chartAddNum++;
|
||||
}
|
||||
var v = (endIndex - chartAddNum) % maxCacheDataNumber;
|
||||
MoveChartMarkPoint(v);
|
||||
//MoveChartMarkPoint(v);
|
||||
App.CurrentUserHeadTexture = img.texture;
|
||||
}
|
||||
}
|
||||
void AddOneData(int index)
|
||||
{
|
||||
string category = index.ToString();
|
||||
|
||||
elevationChart.AddData(0, elevationList[index]);
|
||||
//elevationChart.AddXAxisData(category);
|
||||
//elevationChart.AddXAxisData(index.ToString(), index);
|
||||
|
||||
}
|
||||
|
||||
void MoveChartMarkPoint(int index)
|
||||
private Dictionary<int, Vector2> pointMap = new Dictionary<int, Vector2>();
|
||||
void ElevationToScreenPoint()
|
||||
{
|
||||
var dataPoints = elevationChart.series.list[0].dataPoints.OrderBy(c=>c.x).ToList();
|
||||
if (dataPoints.Count > 0)
|
||||
|
||||
var xUnit =(float) Math.Round(854f * (Screen.width/1600f) / elevationList.Length);//x单位
|
||||
var maxelev = (float)elevationList.Max();
|
||||
var yUnit =(float)Math.Round(46f * (Screen.height / 900f) / maxelev);//y单位
|
||||
var xoffset = 373f * (Screen.width / 1600f);
|
||||
var yoffset = 175f * (Screen.height / 900f);
|
||||
for (int i = 0; i < elevationList.Length; i++)
|
||||
{
|
||||
var pinLoction = dataPoints[index];
|
||||
pinLoction.y = img.transform.localPosition.y;
|
||||
img.transform.localPosition = pinLoction;
|
||||
var c = new Vector2(i*xUnit+ xoffset, elevationList[i]*yUnit + yoffset);
|
||||
pointMap.Add(i, c);
|
||||
}
|
||||
}
|
||||
public GameObject testButton;
|
||||
void MoveChartMarkPoint()
|
||||
{
|
||||
//var dataPoints = elevationChart.series.list[0].dataPoints.OrderBy(c => c.x).ToList();
|
||||
//if (dataPoints.Count > 0)
|
||||
//{
|
||||
// var pinLoction = dataPoints[index];
|
||||
// pinLoction.y = img.transform.localPosition.y;
|
||||
// img.transform.localPosition = pinLoction;
|
||||
//}
|
||||
|
||||
//if (pointMap.ContainsKey(playerController.CurrentIndex-1) )
|
||||
//{
|
||||
|
||||
|
||||
// Vector3 mousePos;
|
||||
// //testButton.transform.localPosition = new Vector3(pointMap[playerController.CurrentIndex - 1].x, pointMap[playerController.CurrentIndex - 1].y, 0);
|
||||
// //RectTransformUtility.ScreenPointToLocalPointInRectangle(transform.parent.GetComponent<RectTransform>(), new Vector3(pointMap[playerController.CurrentIndex - 1].x , pointMap[playerController.CurrentIndex - 1].y, 0), null, out mousePos);
|
||||
// ((RectTransform)testButton.transform).position = new Vector3(pointMap[playerController.CurrentIndex - 1].x, pointMap[playerController.CurrentIndex - 1].y, 0);
|
||||
// //testButton.transform.position = new Vector3( pointMap[index].x, 229f, 0);
|
||||
// //testButton.transform.position = new Vector3(pointMap[playerController.CurrentIndex-1].x, pointMap[playerController.CurrentIndex-1].y, 0);
|
||||
// //testButton.transform.DOMove(new Vector3(pointMap[playerController.CurrentIndex].x, pointMap[playerController.CurrentIndex].y,0),1).on;
|
||||
// //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);
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user