伴侣骑行
This commit is contained in:
1 parent
34cde86a28
commit
7744eec847
42 files changed
+18737
-13497
No files matched your search
+16640
-13298
File diff suppressed because it is too large.
Load diff
@@ -21,7 +21,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
GameObject character;
|
||||
[SerializeField]
|
||||
Animator characterAnimator;
|
||||
[SerializeField]
|
||||
|
||||
AbstractMap map;
|
||||
//AbstractMap map;
|
||||
|
||||
@@ -55,7 +55,9 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
protected double distance;
|
||||
protected double currentSlopeDistance;
|
||||
protected double lastEndDistance;
|
||||
protected double totalClimb;
|
||||
|
||||
public double TotalClimb { get => totalClimb; }
|
||||
public int UserId { get => userId; }
|
||||
public bool IsStart { get => isStart; }
|
||||
public double Speed { get => speed; }
|
||||
@@ -78,18 +80,21 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
public void SetStart()
|
||||
{
|
||||
isStart = true;
|
||||
mainController.isStart = true;
|
||||
startTime = DateTime.Now;
|
||||
}
|
||||
//继续骑行
|
||||
public void SetContinue()
|
||||
{
|
||||
isStart = true;
|
||||
mainController.isStart = true;
|
||||
}
|
||||
//暂停骑行
|
||||
public void SetPause()
|
||||
{
|
||||
isStart = false;
|
||||
characterAnimator.SetBool("IsRide", false);
|
||||
mainController.isStart = false;
|
||||
//characterAnimator.SetBool("IsRide", false);
|
||||
}
|
||||
//退出或者完成骑行
|
||||
public void SetQuit()
|
||||
@@ -108,10 +113,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
Excute();
|
||||
}
|
||||
private void FixedUpdate()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#region 骑行逻辑
|
||||
//初始化骑行数据
|
||||
protected CyclingController mainController;
|
||||
@@ -120,10 +122,11 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
characterAnimator = GetComponentInChildren<Animator>();
|
||||
mainController = transform.parent.GetComponent<CyclingController>();
|
||||
//map = FindObjectOfType<AbstractMap>();
|
||||
map = transform.parent.Find("Map").GetComponent<AbstractMap>();
|
||||
mapData = mainController.GetMapData();//获取路书信息
|
||||
nextlatlong = new Vector2d(mapData.List[0].Point[0], mapData.List[0].Point[1]);//初始化人物位置 TODO加上之前骑行距离
|
||||
cyclingExcutor = mainController.cyclingController;
|
||||
isStart = mainController.isStart;
|
||||
}
|
||||
|
||||
protected virtual void Excute()
|
||||
@@ -141,11 +144,17 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
ComputeNextSlope();//计算下一个坡度相关数据
|
||||
SendTcp();
|
||||
if (isStart)
|
||||
if (mainController.isStart)
|
||||
{
|
||||
ticks++;
|
||||
//计算累计爬升
|
||||
var diff = mapData.List[CurrentIndex].Elevation - elevation;
|
||||
if (diff > 0)
|
||||
{
|
||||
totalClimb += diff;
|
||||
}
|
||||
Compute();//接受蓝牙设备数据计算
|
||||
characterAnimator.SetBool("IsRide", false);//初始化动画状态
|
||||
//characterAnimator.SetBool("IsRide", false);//初始化动画状态
|
||||
if (totalDistance <= mapData.TotalDistance)
|
||||
{
|
||||
//数据处理
|
||||
@@ -157,7 +166,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
//动画控制
|
||||
if (distance > 0)
|
||||
{
|
||||
characterAnimator.SetBool("IsRide", true);//开始移动动画
|
||||
//characterAnimator.SetBool("IsRide", true);//开始移动动画
|
||||
|
||||
StartCoroutine(MoveTo());//移动
|
||||
//transform.localPosition = nextPos;
|
||||
@@ -166,7 +175,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
else
|
||||
{
|
||||
totalDistance = mapData.TotalDistance;
|
||||
characterAnimator.SetBool("ReachEnd", true);//到达终点
|
||||
//characterAnimator.SetBool("ReachEnd", true);//到达终点
|
||||
//Task.Run(() => { });//异步上传数据
|
||||
Upload();
|
||||
isStart = false;
|
||||
@@ -187,7 +196,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
//totalDistance += distance;
|
||||
}
|
||||
//当前用户调用来上传骑行记录
|
||||
protected virtual void Upload()
|
||||
public virtual void Upload()
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
@@ -226,12 +235,12 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
}
|
||||
|
||||
public int CurrentIndex;
|
||||
private int index;
|
||||
//当前距离所在的海拔/坡度/距离 下一个点的坡度以及剩余距离
|
||||
void ComputeNextSlope()
|
||||
{
|
||||
double sumDistance = 0;
|
||||
var pointList = mapData.List;
|
||||
int index = 0;
|
||||
for (int i = 0; i < pointList.Count; i++)
|
||||
{
|
||||
sumDistance += pointList[i].Distance;
|
||||
|
||||
@@ -17,15 +17,16 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
public AbstractMap map;
|
||||
public GameObject player;
|
||||
public GameObject UIObject;
|
||||
public SelectParamModel selectParamModel;
|
||||
|
||||
#region 参数
|
||||
private MapDataModel mapData;//当前路书数据
|
||||
private double[] coordiantes;//当前地图中心
|
||||
private int currentUserId;//当前选中的用户id
|
||||
private bool isStart;//当前游戏是否开始
|
||||
public bool isStart;//当前游戏是否开始
|
||||
private DateTime startTime;//开始时间
|
||||
private bool initComplete;
|
||||
private CyclingModel cyclingModel;//当前骑行模式
|
||||
|
||||
public CyclingModel cyclingModel;//当前骑行模式
|
||||
public BaseCycling cyclingController { get; set; }
|
||||
private int RouteId;
|
||||
private MapApi mapApi;
|
||||
@@ -34,8 +35,8 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
|
||||
void Awake()
|
||||
{
|
||||
initComplete = false;
|
||||
cyclingModel = CyclingModel.Single;
|
||||
InitParam();
|
||||
//获取路书信息
|
||||
mapApi = new MapApi();
|
||||
RouteId = App.RouteIdParam > 0? App.RouteIdParam : 376;
|
||||
@@ -61,19 +62,19 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
cyclingController = new SingleModel(mapRoute);
|
||||
//cyclingModel.OpenCyclingWindow();
|
||||
break;
|
||||
//case CyclingModel.Online:
|
||||
// CyclingModel = new OnlineModel(Route, param);
|
||||
// //cyclingModel.OpenCyclingWindow();
|
||||
// break;
|
||||
//case CyclingModel.Review:
|
||||
// if (param.RankingsId.Count == 0)
|
||||
// {
|
||||
// UIHelper.ShowError(View.GetLang("MapboxController.PSelectARider"));//请选择骑行人
|
||||
// return;
|
||||
// }
|
||||
// CyclingModel = new ReviewModel(Route, param);
|
||||
// //cyclingModel.OpenCyclingWindow();
|
||||
// break;
|
||||
//case CyclingModel.Online:
|
||||
// CyclingModel = new OnlineModel(Route, param);
|
||||
// cyclingModel.OpenCyclingWindow();
|
||||
// break;
|
||||
//case CyclingModel.Review:
|
||||
// if (selectParamModel.RankingsId.Count == 0)
|
||||
// {
|
||||
// //TODO:弹窗请选择跟随骑行的人
|
||||
// return;
|
||||
// }
|
||||
// CyclingModel = new ReviewModel(Route, param);
|
||||
//cyclingModel.OpenCyclingWindow();
|
||||
// break;
|
||||
//case Model.CyclingModel.Competition:
|
||||
// CyclingModel = new CompetitionModel(Route, param);
|
||||
// //cyclingModel.OpenCyclingWindow();
|
||||
@@ -90,7 +91,6 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
{
|
||||
mapData = result;
|
||||
coordiantes = result.List[0].Point;//TODO计算当前用户所处的位置
|
||||
initComplete = true;
|
||||
Init();
|
||||
}
|
||||
else
|
||||
@@ -98,11 +98,18 @@ public class CyclingController : DeviceServiceMonoBase
|
||||
throw new System.Exception("fail to get route data");
|
||||
}
|
||||
}
|
||||
|
||||
private void InitParam()
|
||||
{
|
||||
selectParamModel = new SelectParamModel();
|
||||
selectParamModel.RouteId = App.RouteIdParam;
|
||||
selectParamModel.RankingsId = new List<string>();
|
||||
}
|
||||
private void Init()
|
||||
{
|
||||
//加载人物和地图以及UI界面
|
||||
map.gameObject.SetActive(true);
|
||||
player.SetActive(true);
|
||||
//player.SetActive(true);
|
||||
UIObject.SetActive(true);
|
||||
}
|
||||
|
||||
|
||||
@@ -137,14 +137,15 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
var lineRender = _mipMapRoute.AddComponent<LineRenderer>();
|
||||
lineRender.material = new Material(Shader.Find("Sprites/Default"));
|
||||
var dat = feat.Points[0];
|
||||
lineRender.endColor = Color.blue;
|
||||
lineRender.startColor = Color.blue;
|
||||
lineRender.endColor = Color.white;
|
||||
lineRender.startColor = Color.white;
|
||||
//设置宽度
|
||||
lineRender.startWidth = 0.6f;
|
||||
lineRender.endWidth = 0.6f;
|
||||
lineRender.startWidth = 1f;
|
||||
lineRender.endWidth = 1f;
|
||||
lineRender.positionCount = dat.Count;
|
||||
lineRender.SetPositions(feat.Points[0].ToArray());
|
||||
lineRender.numCornerVertices = 90;
|
||||
lineRender.numCornerVertices = 0;
|
||||
lineRender.loop = false;
|
||||
_mipMapRoute.layer = 9;
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -23,12 +23,20 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
_map.OnTileFinished += _map_OnTileFinished;
|
||||
_map.OnEditorPreviewEnabled += OnEditorPreviewEnabled;
|
||||
_map.OnEditorPreviewDisabled += OnEditorPreviewDisabled;
|
||||
_map.OnUpdated += _map_OnUpdated;
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void _map_OnUpdated()
|
||||
{
|
||||
//Debug.Log("_map_OnUpdated");
|
||||
}
|
||||
|
||||
private void _map_OnTileFinished(global::Mapbox.Unity.MeshGeneration.Data.UnityTile obj)
|
||||
{
|
||||
transform.gameObject.SetActive(false);
|
||||
Debug.Log("_map_OnTileFinished");
|
||||
}
|
||||
|
||||
void _map_OnInitialized()
|
||||
@@ -41,10 +49,9 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
|
||||
if (this == null)
|
||||
return;
|
||||
|
||||
if (s == ModuleState.Finished)
|
||||
{
|
||||
transform.gameObject.SetActive(false);
|
||||
//transform.gameObject.SetActive(false);
|
||||
}
|
||||
else if (s == ModuleState.Working)
|
||||
{
|
||||
@@ -59,12 +66,14 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
|
||||
void OnEditorPreviewEnabled()
|
||||
{
|
||||
transform.gameObject.SetActive(false);
|
||||
//transform.gameObject.SetActive(false);
|
||||
Debug.Log("OnEditorPreviewEnabled");
|
||||
}
|
||||
|
||||
void OnEditorPreviewDisabled()
|
||||
{
|
||||
transform.gameObject.SetActive(true);
|
||||
//transform.gameObject.SetActive(true);
|
||||
Debug.Log("OnEditorPreviewDisabled");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
using Mapbox.Unity.Map;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
public class MiniMapPlayerController: MonoBehaviour
|
||||
{
|
||||
private AbstractPlayer _player;
|
||||
private AbstractMap _map;
|
||||
private void Awake()
|
||||
{
|
||||
_map = transform.parent.Find("MiniMap").GetComponent<AbstractMap>();
|
||||
}
|
||||
public void SetController(AbstractPlayer player)
|
||||
{
|
||||
_player = player;
|
||||
}
|
||||
float t = 1f;
|
||||
private void Update()
|
||||
{
|
||||
t -= Time.deltaTime;
|
||||
while (t < 0)
|
||||
{
|
||||
if (_player != null)
|
||||
{
|
||||
transform.localPosition = _map.GeoToWorldPosition(_player.Nextlatlong);
|
||||
}
|
||||
t = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e19a9a72e39c8da4489a110f68ff2dc1
|
||||
guid: 287bd44099b0d56478ff1fe696796816
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
+1
-7
@@ -1,18 +1,13 @@
|
||||
using Assets.Scenes.Ride.Scripts.Model;
|
||||
using Assets.Scripts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Assertions;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
public class NearListFactory : MonoBehaviour
|
||||
public class NearByFactory : MonoBehaviour
|
||||
{
|
||||
PlayerController playerController;
|
||||
private GameObject nearByItem;
|
||||
@@ -33,7 +28,6 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
playerController = FindObjectOfType<PlayerController>();
|
||||
nearByItem = Resources.Load<GameObject>("UI/Prefab/Ride/NearbyItem");
|
||||
nearByMajorItem = Resources.Load<GameObject>("UI/Prefab/Ride/NearbyMajorItem");
|
||||
Assert.IsNotNull(nearByItem);
|
||||
scroll = transform.parent.parent.gameObject;
|
||||
if (scroll != null)
|
||||
{
|
||||
File renamed without changes.
@@ -1,21 +1,40 @@
|
||||
using System;
|
||||
using Assets.Scenes.Ride.Scripts.Model;
|
||||
using System;
|
||||
|
||||
namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
public class OtherPlayerController : AbstractPlayer
|
||||
{
|
||||
public string[] record;
|
||||
public ReviewItemScript _reviewItemScript;
|
||||
public PlayerController _playerController;
|
||||
protected override void Init()
|
||||
{
|
||||
base.Init();
|
||||
SetStart();//自动开始
|
||||
}
|
||||
|
||||
protected override void Compute()
|
||||
{
|
||||
power = 900;//功率
|
||||
speed = Helper.CalculateSpeed(elevation, currentSlope, power, weight, bicycleWeight);
|
||||
distance = Math.Round(speed / 3600, 6);
|
||||
totalDistance += distance;
|
||||
if (ticks < record.Length)
|
||||
{
|
||||
var data = TargetData.Read(record[ticks-1]);
|
||||
distance = data._Speed/3600;
|
||||
totalDistance = data._Distance;
|
||||
}
|
||||
else
|
||||
{
|
||||
var data = TargetData.Read(record[record.Length - 1]);
|
||||
distance = data._Speed / 3600;
|
||||
totalDistance = data._Distance;
|
||||
}
|
||||
var diff = Math.Round(totalDistance - _playerController.TotalDistance, 3) * 1000;
|
||||
_reviewItemScript.SetDistance(diff);
|
||||
}
|
||||
public void SetController(ReviewItemScript reviewItemScript, PlayerController playerController)
|
||||
{
|
||||
_reviewItemScript = reviewItemScript;
|
||||
_playerController = playerController;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -29,14 +29,16 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
heartRate = mainController.UpDateHeart()??0;
|
||||
power = mainController.UpdatePower();
|
||||
cadance = mainController.UpdateCadence();
|
||||
#if UNITY_EDITOR
|
||||
weight = App.CurrentUser.Weight;
|
||||
bicycleWeight = App.CurrentUser.BicycleWeight;
|
||||
|
||||
power = 2000;//测试功率
|
||||
#endif
|
||||
|
||||
speed = Helper.CalculateSpeed(elevation, currentSlope, power, weight, bicycleWeight);
|
||||
distance = mainController.UpdateDistance(speed);
|
||||
totalDistance += distance;
|
||||
//记录骑行数据
|
||||
#if UNITY_EDITOR
|
||||
|
||||
var recorderData = cyclingExcutor.recorderData;
|
||||
targetData = new TargetData
|
||||
{
|
||||
@@ -50,21 +52,21 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
_Lon = nextlatlong.y
|
||||
};
|
||||
recorderData.RiderDatas.Add(targetData);
|
||||
#endif
|
||||
|
||||
}
|
||||
protected override void SendTcp()
|
||||
{
|
||||
mainController.cyclingController.Run(null);
|
||||
}
|
||||
//上传数据
|
||||
protected override void Upload()
|
||||
public override void Upload()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
|
||||
string imageFileName = base.CaptureCamera(Camera.main, new Rect(Screen.width * 0f, Screen.height * 0f, Screen.width * 0.5f, Screen.height * 0.5f));
|
||||
cyclingExcutor.recorderData.IsCompleted = totalDistance == mapData.TotalDistance;
|
||||
cyclingExcutor.recorderData.EndDistance = totalDistance;
|
||||
cyclingExcutor.recorderData.SaveData(cyclingExcutor.Mode,null, imageFileName);
|
||||
#endif
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Assertions;
|
||||
|
||||
namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
public class NearByItemFactory : MonoBehaviour
|
||||
{
|
||||
private GameObject nearByItem;
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
nearByItem = Resources.Load<GameObject>("UI/Prefab/Ride/NearbyItem");
|
||||
Assert.IsNotNull(nearByItem);
|
||||
}
|
||||
float t = 1;
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
t -= Time.deltaTime;
|
||||
while (t < 0)
|
||||
{
|
||||
//var nearList = MapUDPService.GetNearRiderData(1, 20, new double[] { playerController.Nextlatlong.x, playerController.Nextlatlong.y });
|
||||
//Debug.Log(nearList.Count());
|
||||
GameObject newObj; // Create GameObject instance
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
// Create new instances of our prefab until we've created as many as we specified
|
||||
newObj = (GameObject)Instantiate(nearByItem, transform);
|
||||
var nearByItemscript = newObj.GetComponent<NearByItemScript>();
|
||||
nearByItemscript.setName("");
|
||||
nearByItemscript.setRatio("");
|
||||
nearByItemscript.setSpeed("");
|
||||
nearByItemscript.setHead("");
|
||||
t = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
using Assets.Scenes.Ride.Scripts.Model;
|
||||
|
||||
public class PubCommData
|
||||
{
|
||||
public static t_user CurrentUser;
|
||||
|
||||
public static int PlanId;//当前训练id
|
||||
|
||||
public static string sp = "";
|
||||
|
||||
public static string po = "";
|
||||
|
||||
public static string SearchKeyword = "";
|
||||
|
||||
/// <summary>
|
||||
/// lat lng
|
||||
/// </summary>
|
||||
public static double[] location;
|
||||
/// <summary>
|
||||
/// 当前位置
|
||||
/// </summary>
|
||||
public static string Address;
|
||||
|
||||
public static double routeDistance;
|
||||
/// <summary>
|
||||
/// en,zh-CN
|
||||
/// </summary>
|
||||
public static string Lauguage = "";
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
using Assets.Scenes.Ride.Scripts.Model;
|
||||
using Assets.Scripts.Apis;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
public class ReviewFactory : MonoBehaviour
|
||||
{
|
||||
private CyclingController cyclingController;
|
||||
private GameObject singleArea;
|
||||
private GameObject reviewScrollView;
|
||||
private GameObject reviewItem;
|
||||
private GameObject content;
|
||||
private GameObject otherPlayer;
|
||||
private GameObject miniMapPlayer;
|
||||
|
||||
private MapApi mapApi;
|
||||
private PlayerController playerController;
|
||||
private List<ReviewItemScript> reviewList ;
|
||||
private List<OtherPlayerController> otherList;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
reviewList = new List<ReviewItemScript>();
|
||||
otherList = new List<OtherPlayerController>();
|
||||
cyclingController = FindObjectOfType<CyclingController>();
|
||||
singleArea = transform.Find("SingleArea").gameObject;
|
||||
|
||||
reviewScrollView = transform.Find("ReviewArea").gameObject;
|
||||
content = transform.Find("ReviewArea/ReviewScrollView/Viewport/Content").gameObject;
|
||||
reviewItem = Resources.Load<GameObject>("UI/Prefab/Ride/ReviewItem");
|
||||
otherPlayer = Resources.Load<GameObject>("UI/Prefab/Ride/ReviewPlayer");
|
||||
miniMapPlayer = Resources.Load<GameObject>("UI/Prefab/Ride/MiniMapPlayer");
|
||||
playerController = FindObjectOfType<PlayerController>();
|
||||
mapApi = new MapApi();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
public void Refresh()
|
||||
{
|
||||
var mode = cyclingController.cyclingModel;
|
||||
switch (mode)
|
||||
{
|
||||
case Model.CyclingModel.Single:
|
||||
singleArea.SetActive(true);
|
||||
break;
|
||||
case Model.CyclingModel.Online:
|
||||
break;
|
||||
case Model.CyclingModel.Review:
|
||||
InitReview();
|
||||
break;
|
||||
case Model.CyclingModel.Competition:
|
||||
break;
|
||||
case Model.CyclingModel.GlobalCycling:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
float t = 1;
|
||||
private void Update()
|
||||
{
|
||||
t -= Time.deltaTime;
|
||||
while (t < 0)
|
||||
{
|
||||
ReviewRanking();
|
||||
t = 1;
|
||||
}
|
||||
}
|
||||
|
||||
private void ReviewRanking()
|
||||
{
|
||||
var sortList = reviewList.OrderByDescending(c => c.GetDistance()).ToList();
|
||||
for (int i = 0; i < sortList.Count; i++)
|
||||
{
|
||||
var item = sortList[i].gameObject.transform;
|
||||
item.SetSiblingIndex(i);
|
||||
}
|
||||
}
|
||||
private void InitReview()
|
||||
{
|
||||
reviewScrollView.SetActive(true);
|
||||
var rankingList = mapApi.GetRecordFileFromServer(cyclingController.selectParamModel.RankingsId);
|
||||
foreach (var item in rankingList)
|
||||
{
|
||||
GameObject newObj = (GameObject)Instantiate(reviewItem, content.transform);
|
||||
|
||||
var reviewItemScript = newObj.GetComponent<ReviewItemScript>();
|
||||
reviewItemScript.SetHead(item.WxHeadImg);
|
||||
reviewItemScript.SetName(item.NickName);
|
||||
reviewItemScript.SetDistance(0D);
|
||||
reviewList.Add(reviewItemScript);
|
||||
GameObject otherPlayerObj = (GameObject)Instantiate(otherPlayer, transform.parent.parent.parent);
|
||||
var otherPlayerController = otherPlayerObj.GetComponent<OtherPlayerController>();
|
||||
otherList.Add(otherPlayerController);
|
||||
otherPlayerController.record = item.record;
|
||||
otherPlayerController.SetController(reviewItemScript, playerController);
|
||||
GameObject miniPlayer = (GameObject)Instantiate(miniMapPlayer, transform.parent.parent.parent);
|
||||
var miniController = miniPlayer.GetComponent<MiniMapPlayerController>();
|
||||
miniController.SetController(otherPlayerController);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cbaab6daec5ce6243ae09ccf27489dae
|
||||
guid: 8a2fc04fdcd84754fa144586013907eb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -0,0 +1,55 @@
|
||||
using Assets.Scripts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
public class ReviewItemScript : MonoBehaviour
|
||||
{
|
||||
private RawImage Head;
|
||||
private Text Name;
|
||||
private Text Distance;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Head = transform.Find("Head").GetComponent<RawImage>();
|
||||
Name = transform.Find("Name").GetComponent<Text>();
|
||||
Distance = transform.Find("Distance").GetComponent<Text>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
|
||||
}
|
||||
public void SetName(string name)
|
||||
{
|
||||
Name.text = name;
|
||||
}
|
||||
|
||||
public void SetHead(string url)
|
||||
{
|
||||
Utils.DisplayImage(StartCoroutine,Head,url);
|
||||
var rect = ((RectTransform)Head.transform).rect;
|
||||
Material material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
||||
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height, 0));
|
||||
Head.material = material;
|
||||
}
|
||||
|
||||
public void SetDistance(double distance)
|
||||
{
|
||||
_distance = distance;
|
||||
var prefix = distance > 0 ? "+" : "";
|
||||
Distance.text = prefix + distance.ToString() + "M";
|
||||
}
|
||||
private double _distance;
|
||||
public double GetDistance()
|
||||
{
|
||||
return _distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0767437c87622348a0b98bbc0c7dc51
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -179,7 +179,7 @@ namespace Assets.Scenes.Ride.Scripts
|
||||
lineRender.endColor = c;
|
||||
lineRender.startColor = c;
|
||||
//设置宽度
|
||||
lineRender.SetWidth(0.2f, 0.2f);
|
||||
lineRender.SetWidth(0.5f, 0.5f);
|
||||
lineRender.SetVertexCount(dat.Count);
|
||||
lineRender.SetPositions(feat.Points[0].ToArray());
|
||||
lineRender.loop = false;
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
using Assets.Scenes.Ride.Scripts.Model;
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
public class SelectPlayerFactory : MonoBehaviour
|
||||
{
|
||||
GameObject prefab;
|
||||
GameObject scroll;
|
||||
Transform content;
|
||||
Button rideButton;
|
||||
Button cancelButton;
|
||||
Button closeButton;
|
||||
Button searchButton;
|
||||
GameObject reviewPanel;
|
||||
InputField inputField;
|
||||
private int pageIndex = 0;
|
||||
private int pageSize = 8;
|
||||
private int totalPages = 0;
|
||||
private string seachName = string.Empty;
|
||||
CyclingController cyclingController;
|
||||
public List<GameObject> gameObjects = new List<GameObject>();
|
||||
List<SelectPlayerItemScript> selectPlayerItemScripts = new List<SelectPlayerItemScript>();
|
||||
MapApi mapApi;
|
||||
private void Awake()
|
||||
{
|
||||
mapApi = new MapApi();
|
||||
cyclingController = FindObjectOfType<CyclingController>();
|
||||
//分页查询当前路数排行榜选手成绩列表
|
||||
prefab = Resources.Load<GameObject>("UI/Prefab/Ride/SelectPlayerItem");
|
||||
scroll = transform.Find("Panel/PlayerList/Scroll View").gameObject;
|
||||
content = transform.Find("Panel/PlayerList/Scroll View/Viewport/Content");
|
||||
rideButton = transform.Find("Panel/RideButton").GetComponent<Button>();
|
||||
cancelButton = transform.Find("Panel/CancelButton").GetComponent<Button>();
|
||||
closeButton = transform.Find("Panel/Close").GetComponent<Button>();
|
||||
searchButton = transform.Find("Panel/SearchButton").GetComponent<Button>();
|
||||
inputField = transform.Find("Panel/InputField").GetComponent<InputField>();
|
||||
reviewPanel = transform.parent.Find("ReviewPanel").gameObject;
|
||||
|
||||
inputField.onValueChanged.AddListener(InputTextChanged);
|
||||
rideButton.onClick.AddListener(PreStart);
|
||||
cancelButton.onClick.AddListener(Cancel);
|
||||
closeButton.onClick.AddListener(Cancel);
|
||||
searchButton.onClick.AddListener(Search);
|
||||
UIManager.AddEvent(scroll, UnityEngine.EventSystems.EventTriggerType.EndDrag, OnEndDrag);
|
||||
|
||||
gameObjects.Add(transform.Find("Panel/Player1").gameObject);
|
||||
gameObjects.Add(transform.Find("Panel/Player2").gameObject);
|
||||
gameObjects.Add(transform.Find("Panel/Player3").gameObject);
|
||||
gameObjects.Add(transform.Find("Panel/Player4").gameObject);
|
||||
gameObjects.Add(transform.Find("Panel/Player5").gameObject);
|
||||
}
|
||||
|
||||
private void InputTextChanged(string input)
|
||||
{
|
||||
seachName = input;
|
||||
}
|
||||
private void Search()
|
||||
{
|
||||
Utils.DestroyChildren(content);
|
||||
Refresh();
|
||||
}
|
||||
//开始伴侣骑行的面板
|
||||
private void PreStart()
|
||||
{
|
||||
transform.gameObject.SetActive(false);
|
||||
foreach (var item in gameObjects)
|
||||
{
|
||||
var seletedPlayerScript = item.GetComponent<SeletedPlayerScript>();
|
||||
if (seletedPlayerScript.isUsed)
|
||||
{
|
||||
cyclingController.selectParamModel.RankingsId.Add(seletedPlayerScript.GetRankingId());
|
||||
}
|
||||
}
|
||||
cyclingController.cyclingModel = CyclingModel.Review;
|
||||
if (!reviewPanel.activeSelf)
|
||||
{
|
||||
reviewPanel.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
reviewPanel.GetComponent<ReviewFactory>().Refresh();
|
||||
}
|
||||
reviewPanel.transform.Find("ReviewArea").gameObject.SetActive(true);
|
||||
reviewPanel.transform.Find("SingleArea").gameObject.SetActive(false);
|
||||
|
||||
}
|
||||
//取消和关闭都进入单人骑行界面
|
||||
private void Cancel()
|
||||
{
|
||||
cyclingController.cyclingModel = CyclingModel.Single;
|
||||
transform.gameObject.SetActive(false);
|
||||
reviewPanel.SetActive(true);
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
Refresh();
|
||||
}
|
||||
|
||||
private void Refresh()
|
||||
{
|
||||
|
||||
var list = mapApi.GetRouteRanking(App.RouteIdParam, "1", pageIndex, pageSize, seachName);
|
||||
totalPages = list.data.TotalPages;
|
||||
var parent = transform.Find("Panel/PlayerList/Scroll View/Viewport/Content");
|
||||
foreach (var item in list.data.list)
|
||||
{
|
||||
GameObject newObj = (GameObject)Instantiate(prefab, parent);
|
||||
var selectPlayerItemScript = newObj.GetComponent<SelectPlayerItemScript>();
|
||||
selectPlayerItemScript.SetRankingId(item.Id.ToString());
|
||||
selectPlayerItemScript.SetName(item.NickName);
|
||||
selectPlayerItemScript.SetTimer(item.TotalTime);
|
||||
selectPlayerItemScript.SetHeadImage(item.WxHeadImg);
|
||||
selectPlayerItemScripts.Add(selectPlayerItemScript);
|
||||
UIManager.AddEvent(selectPlayerItemScript.GetButton().gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, OnSelectClick);
|
||||
}
|
||||
}
|
||||
private void OnSelectClick(BaseEventData baseEventData)
|
||||
{
|
||||
var selectPlayerItemScript = baseEventData.selectedObject.GetComponent<SelectPlayerItemScript>();
|
||||
foreach (var item in gameObjects)
|
||||
{
|
||||
var seletedPlayerScript = item.GetComponent<SeletedPlayerScript>();
|
||||
if (!seletedPlayerScript.isUsed && !selectPlayerItemScript.isSelected)
|
||||
{
|
||||
seletedPlayerScript.SetHead(selectPlayerItemScript.GetImageTexture(), true);
|
||||
seletedPlayerScript.SetName(selectPlayerItemScript.GetName());
|
||||
seletedPlayerScript.SetRankingId(selectPlayerItemScript.GetRankingId());
|
||||
UIManager.AddEvent(seletedPlayerScript.GetButton().gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, OnCloseClick);
|
||||
selectPlayerItemScript.isSelected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
private void OnCloseClick(BaseEventData baseEventData)
|
||||
{
|
||||
var seletedPlayerScript = baseEventData.selectedObject.transform.parent.GetComponent<SeletedPlayerScript>();
|
||||
var seletPlayerItemScript = selectPlayerItemScripts.Where(c => c.GetRankingId() == seletedPlayerScript.GetRankingId()).FirstOrDefault();
|
||||
if (seletPlayerItemScript != null)
|
||||
{
|
||||
seletPlayerItemScript.isSelected = false;
|
||||
}
|
||||
seletedPlayerScript.Reset();
|
||||
}
|
||||
private void OnEndDrag(BaseEventData arg0)
|
||||
{
|
||||
var scrollrect = scroll.GetComponent<ScrollRect>();
|
||||
if (scrollrect.verticalNormalizedPosition <= 0)
|
||||
{
|
||||
if (pageIndex < totalPages )
|
||||
{
|
||||
pageIndex++;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
if (scrollrect.verticalNormalizedPosition >= 1)
|
||||
{
|
||||
if (pageIndex >0)
|
||||
{
|
||||
pageIndex--;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d02ff009326642f4c8b9e7f603c50939
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,65 @@
|
||||
using Assets.Cyp.Common;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
public class SelectPlayerItemScript:MonoBehaviour
|
||||
{
|
||||
private string Id ;
|
||||
private RawImage Head;
|
||||
private Text Name;
|
||||
private Text Timer;
|
||||
private Button selectbutton;
|
||||
public bool isSelected;
|
||||
private void Awake()
|
||||
{
|
||||
Head = transform.Find("Head").GetComponent<RawImage>();
|
||||
Name = transform.Find("Name").GetComponent<Text>();
|
||||
Timer = transform.Find("Timer").GetComponent<Text>();
|
||||
selectbutton = transform.GetComponent<Button>();
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
|
||||
}
|
||||
public string GetRankingId()
|
||||
{
|
||||
return Id;
|
||||
}
|
||||
public string GetName()
|
||||
{
|
||||
return Name.text;
|
||||
}
|
||||
public Texture GetImageTexture()
|
||||
{
|
||||
return Head.texture;
|
||||
}
|
||||
public Button GetButton()
|
||||
{
|
||||
return selectbutton;
|
||||
}
|
||||
public void SetRankingId(string id)
|
||||
{
|
||||
Id = id;
|
||||
}
|
||||
public void SetName(string name)
|
||||
{
|
||||
Name.text = name;
|
||||
}
|
||||
public void SetTimer(string timer)
|
||||
{
|
||||
Timer.text = timer;
|
||||
}
|
||||
public void SetHeadImage(string url)
|
||||
{
|
||||
Utils.DisplayImage(StartCoroutine, Head, url);
|
||||
var rect = ((RectTransform)Head.transform).rect;
|
||||
Material material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
||||
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height, 0));
|
||||
Head.material = material;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1a77881c6394b0947b40b398dcdcc7db
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scenes.Ride.Scripts
|
||||
{
|
||||
public class SeletedPlayerScript :MonoBehaviour
|
||||
{
|
||||
private RawImage Head;
|
||||
private Button Close;
|
||||
private Text Name;
|
||||
private string RankingId;
|
||||
public bool isUsed = false;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Head = transform.GetComponent<RawImage>();
|
||||
Name = transform.Find("Name").GetComponent<Text>();
|
||||
Close = transform.Find("CloseButton").GetComponent<Button>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
|
||||
}
|
||||
public Button GetButton()
|
||||
{
|
||||
return Close;
|
||||
}
|
||||
public string GetRankingId()
|
||||
{
|
||||
return RankingId;
|
||||
}
|
||||
public void SetName(string name)
|
||||
{
|
||||
Name.text = name;
|
||||
}
|
||||
public void SetRankingId(string id)
|
||||
{
|
||||
RankingId = id;
|
||||
}
|
||||
public void Reset()
|
||||
{
|
||||
Close.gameObject.SetActive(false);
|
||||
isUsed = false;
|
||||
Name.text = "New Shadow";
|
||||
var defaultexture = Resources.Load<Sprite>("Images/New Account").texture;
|
||||
Head.texture = defaultexture;
|
||||
RankingId = string.Empty;
|
||||
}
|
||||
public void SetHead(Texture texture, bool select)
|
||||
{
|
||||
Close.gameObject.SetActive(select);
|
||||
isUsed = select;
|
||||
Head.texture = texture;
|
||||
var rect = ((RectTransform)Head.transform).rect;
|
||||
Material material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
||||
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height, 0));
|
||||
Head.material = material;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5d999af905983b4b9b61199c4ece030
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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