2021-04-01 11:01:29 +08:00
|
|
|
|
using UnityEngine;
|
2021-03-23 16:07:31 +08:00
|
|
|
|
using Assets.Scripts.Apis.Models;
|
2021-03-25 16:22:09 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using Assets.Scripts.Apis;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Collections.Generic;
|
2021-03-28 18:17:15 +08:00
|
|
|
|
using System.Globalization;
|
2021-03-30 17:15:16 +08:00
|
|
|
|
using Assets.Scenes.Ride.Scripts.Model;
|
|
|
|
|
|
using System.IO;
|
2021-03-22 19:20:51 +08:00
|
|
|
|
|
2021-03-23 16:07:31 +08:00
|
|
|
|
namespace Assets.Scenes.Ride.Scripts
|
2021-03-22 19:20:51 +08:00
|
|
|
|
{
|
2021-04-01 11:01:29 +08:00
|
|
|
|
public class PlayerController : AbstractPlayer
|
2021-03-22 19:20:51 +08:00
|
|
|
|
{
|
2021-03-30 17:15:16 +08:00
|
|
|
|
#region 骑行逻辑
|
2021-03-25 16:22:09 +08:00
|
|
|
|
|
2021-04-01 11:01:29 +08:00
|
|
|
|
protected override void Init()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Init();
|
|
|
|
|
|
}
|
2021-04-02 19:17:23 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 计算数据,父类会在此方法后处理动画
|
|
|
|
|
|
/// </summary>
|
2021-04-01 11:01:29 +08:00
|
|
|
|
protected override void Compute()
|
|
|
|
|
|
{
|
|
|
|
|
|
//计算数据
|
2021-04-02 19:17:23 +08:00
|
|
|
|
//speed = mainController.UpDateSpeed();
|
|
|
|
|
|
heartRate = mainController.UpDateHeart()??0;
|
|
|
|
|
|
power = mainController.UpdatePower();
|
|
|
|
|
|
cadance = mainController.UpdateCadence();
|
|
|
|
|
|
|
|
|
|
|
|
power = 2000;//测试功率
|
|
|
|
|
|
|
2021-04-01 11:01:29 +08:00
|
|
|
|
speed = Helper.CalculateSpeed(elevation, currentSlope, power, weight, bicycleWeight);
|
2021-04-02 19:17:23 +08:00
|
|
|
|
distance = mainController.UpdateDistance(speed);
|
2021-04-01 11:01:29 +08:00
|
|
|
|
totalDistance += distance;
|
2021-04-02 19:17:23 +08:00
|
|
|
|
//记录骑行数据
|
2021-04-07 17:22:45 +08:00
|
|
|
|
#if UNITY_EDITOR
|
2021-04-02 19:17:23 +08:00
|
|
|
|
var recorderData = cyclingExcutor.recorderData;
|
|
|
|
|
|
recorderData.RiderDatas.Add(new TargetData
|
|
|
|
|
|
{
|
|
|
|
|
|
Ticks = ticks,
|
|
|
|
|
|
_Power = power,
|
|
|
|
|
|
_Speed = speed,
|
|
|
|
|
|
_Distance = totalDistance> mapData.TotalDistance? mapData.TotalDistance: totalDistance,
|
|
|
|
|
|
_Cadence = cadance,
|
|
|
|
|
|
_HeartRate = heartRate,
|
|
|
|
|
|
_Lat = nextlatlong.x,
|
|
|
|
|
|
_Lon = nextlatlong.y
|
|
|
|
|
|
});
|
|
|
|
|
|
#endif
|
2021-04-07 17:22:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
//上传数据
|
|
|
|
|
|
protected override void Upload()
|
2021-04-01 11:01:29 +08:00
|
|
|
|
{
|
2021-04-07 17:22:45 +08:00
|
|
|
|
#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));
|
2021-04-02 19:17:23 +08:00
|
|
|
|
cyclingExcutor.recorderData.IsCompleted = totalDistance == mapData.TotalDistance;
|
|
|
|
|
|
cyclingExcutor.recorderData.EndDistance = totalDistance;
|
2021-04-07 17:22:45 +08:00
|
|
|
|
cyclingExcutor.recorderData.SaveData(cyclingExcutor.Mode,null, imageFileName);
|
2021-04-02 19:17:23 +08:00
|
|
|
|
#endif
|
2021-03-25 16:22:09 +08:00
|
|
|
|
}
|
2021-04-02 19:17:23 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|