伴侣骑行
This commit is contained in:
1 parent
34cde86a28
commit
7744eec847
42 files changed
+18737
-13497
No files matched your search
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user