伴侣骑行
This commit is contained in:
1 parent
34cde86a28
commit
7744eec847
42 files changed
+18737
-13497
No files matched your search
@@ -11,6 +11,7 @@ using Assets.Scenes.Ride.Scripts.Model;
|
||||
using UnityEngine.SceneManagement;
|
||||
using System.Collections.Generic;
|
||||
using Assets.Cyp.Common;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
@@ -18,50 +19,50 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
public class SingleUIManager : MonoBehaviour
|
||||
{
|
||||
#region UI control
|
||||
Text Fps;//fps
|
||||
Button startBtn;//开始按钮
|
||||
Button simpleBtn;//进入简约模式按钮
|
||||
GameObject target;
|
||||
GameObject rightPanel;//右边列表
|
||||
GameObject leftPanel;//左边列表
|
||||
GameObject nextSlopePanel;//下一个坡度面板
|
||||
GameObject currentSlopePanel;//当前坡度面板
|
||||
GameObject selectPanel;//骑行模式选择
|
||||
GameObject selectPlayer;//伴侣骑行选择窗口
|
||||
GameObject reviewPanel;
|
||||
GameObject titlePanel;
|
||||
GameObject quitPanel;//退出界面
|
||||
|
||||
Text nextSlopeText;//下一个坡度
|
||||
Text nextSlopeDistanceText;//下一个坡度距离
|
||||
Text currentSlopeText;//当前坡度
|
||||
Text currentSlopeDistanceText;//当前坡度已骑行距离
|
||||
Text currentSlopeToatalDistanceText;//当前坡度总距离
|
||||
Text speedTxt;//当前速度
|
||||
Text powerTxt;//功率
|
||||
Text timerTxt;//计时器
|
||||
Text ditance;//当前骑行距离
|
||||
Text totalDistance;//当前骑行距离
|
||||
Text candance;//踏频
|
||||
Text heartRate;//心率
|
||||
GameObject rightPanel;//右边列表
|
||||
GameObject leftPanel;//左边列表
|
||||
|
||||
GameObject nextSlopePanel;//下一个坡度面板
|
||||
|
||||
GameObject currentSlopePanel;//当前坡度面板
|
||||
[SerializeField]
|
||||
Text nextSlopeText;//下一个坡度
|
||||
[SerializeField]
|
||||
Text nextSlopeDistanceText;//下一个坡度距离
|
||||
[SerializeField]
|
||||
Text currentSlopeText;//当前坡度
|
||||
[SerializeField]
|
||||
Text currentSlopeDistanceText;//当前坡度距离
|
||||
[SerializeField]
|
||||
Text speedTxt;//当前速度
|
||||
[SerializeField]
|
||||
Text powerTxt;//功率
|
||||
[SerializeField]
|
||||
Text timerTxt;//计时器
|
||||
[SerializeField]
|
||||
Text countDownTxt;//倒计时5s
|
||||
[SerializeField]
|
||||
Text mapName;//路书名称
|
||||
[SerializeField] LineChart elevationChart;//海拔图
|
||||
[SerializeField] RawImage img;//当前用户头像
|
||||
[SerializeField]
|
||||
Button StartOrPauseButton;//暂停按钮
|
||||
[SerializeField]
|
||||
Button SettingButton;//设置那妞
|
||||
[SerializeField]
|
||||
Button DeviceButton;//设备按钮
|
||||
[SerializeField]
|
||||
Button ExitButton;//退出按钮
|
||||
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;//海拔图头像
|
||||
|
||||
[SerializeField]
|
||||
GameObject target;//开始按钮
|
||||
#endregion
|
||||
|
||||
#region 控制器
|
||||
@@ -76,26 +77,65 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
|
||||
void Awake()
|
||||
{
|
||||
Fps = transform.Find("Panel/FPS").GetComponent<Text>();
|
||||
#region 控件获取与事件绑定
|
||||
fps = transform.Find("Panel/FPS").GetComponent<Text>();
|
||||
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>();
|
||||
totalDistance = transform.Find("Panel/TotalDistancePanel/TotalDistance").GetComponent<Text>();
|
||||
titlePanel = transform.Find("Panel/TitlePanel").gameObject;
|
||||
totalDistance = transform.Find("Panel/TitlePanel/TotalDistance").GetComponent<Text>();
|
||||
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;
|
||||
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>();
|
||||
|
||||
target = transform.parent.Find("Target").gameObject;
|
||||
|
||||
startBtn.onClick.AddListener(StartRide);
|
||||
simpleBtn.onClick.AddListener(ClearPanel);
|
||||
StartOrPauseButton.onClick.AddListener(PauseRide);
|
||||
SettingButton.onClick.AddListener(ShowSettingPanel);
|
||||
DeviceButton.onClick.AddListener(ShowDevicePanel);
|
||||
ExitButton.onClick.AddListener(StopRide);
|
||||
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
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
playerController = FindObjectOfType<PlayerController>();
|
||||
@@ -112,7 +152,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
tt -= Time.deltaTime;
|
||||
while (tt < 0) {
|
||||
Fps.text = (1 / Time.deltaTime).ToString();
|
||||
fps.text = (1 / Time.deltaTime).ToString();
|
||||
tt = 1;
|
||||
}
|
||||
//获取当前选中玩家绑定当前UI
|
||||
@@ -146,6 +186,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
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";
|
||||
totalClimb.text = Math.Round(playerController.TotalClimb, 0).ToString();
|
||||
//移动海拔图头像 TODO:移动所有人的头像
|
||||
UpdateRealTimeChart();
|
||||
//MoveChartMarkPoint();
|
||||
@@ -157,10 +198,28 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
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 = new Quaternion(playerController.transform.rotation.x, playerController.transform.rotation.y + 180, playerController.transform.rotation.z, playerController.transform.rotation.w);
|
||||
//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);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
private void StartRide()
|
||||
{
|
||||
//加个5秒钟倒计时
|
||||
@@ -175,30 +234,52 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
playerController.SetPause();
|
||||
startBtn.gameObject.SetActive(true);
|
||||
}
|
||||
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);
|
||||
}
|
||||
//结束游戏
|
||||
private void StopRide()
|
||||
{
|
||||
//TODO:主动保存或者舍弃保存
|
||||
//切换到路数列表
|
||||
SceneManager.LoadScene("MainScene");
|
||||
|
||||
quitPanel.SetActive(true);
|
||||
}
|
||||
//显示设备连接
|
||||
private void ShowDevicePanel()
|
||||
{
|
||||
UIManager.Show(UIManager.Instance.DevicePanel, transform.Find("Panel").gameObject);
|
||||
UIManager.ShowCustom(UIManager.Instance.DevicePanel, transform.Find("Panel").gameObject);
|
||||
}
|
||||
//显示设置
|
||||
private void ShowSettingPanel()
|
||||
{
|
||||
}
|
||||
int isSimple = 1;
|
||||
//TODO:简约模式
|
||||
private void ClearPanel()
|
||||
|
||||
private bool clearLock = true;
|
||||
private void ClearPanel()
|
||||
{
|
||||
leftPanel.transform.DOLocalMove(new Vector3(leftPanel.transform.localPosition.x + isSimple * -430f, leftPanel.transform.localPosition.y, leftPanel.transform.localPosition.z), 1);
|
||||
rightPanel.transform.DOLocalMove(new Vector3(rightPanel.transform.localPosition.x + isSimple * 330f, rightPanel.transform.localPosition.y, rightPanel.transform.localPosition.z), 1);
|
||||
isSimple *= -1;
|
||||
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;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private int maxCacheDataNumber = 100;//海拔图最大点数
|
||||
@@ -265,7 +346,9 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
void AddOneData(int index)
|
||||
{
|
||||
string category = index.ToString();
|
||||
elevationChart.AddData(0, elevationList[index]);
|
||||
//elevationChart.AddXAxisData(category);
|
||||
//elevationChart.AddXAxisData(index.ToString(), index);
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user