适配c2;新版设计稿;对战切换手势;主逻辑接通;使用think的阻力值,修改影子模式船位置

This commit is contained in:
Caiyanpeng committed 2022-03-25 18:02:34 +08:00
1 parent e6f3e2ecfa
commit ab653b994f
82 files changed
+25241 -8988

No files matched your search

@@ -42,9 +42,9 @@ public class HomeController : PFUIPanel
#if UNITY_ANDROID || UNITY_IOS
var nav = transform.Find("MainNav-mobile").GetComponent<NewMainNav>();
nav.SetButtonActive(new List<int> { 1, 3, 4, 6 },null,new NewMainNav.CustomButton(Resources.Load<Sprite>("Images/Rower/划船"), () =>
nav.SetButtonActive(new List<int> { 1, 3, 4, 6 },null,new NewMainNav.CustomButton(Resources.Load<Sprite>("Images/RowerNew/ICON_mode_44"), () =>
{
UIManager.ShowRowerPanel();
UIManager.ShowRowerSelector();
}));
newNav = nav;
UIManager.AddEvent(transform.Find("TodayData/Datas/Distance").gameObject, EventTriggerType.PointerClick, b =>
+365 -109
View File
@@ -8,6 +8,7 @@ using Assets.Scripts.Devices.Ant.Interfaces;
using Assets.Scripts.Devices.Ble;
using Assets.Scripts.Devices.Ble.Characteristic;
using Assets.Scripts.Devices.Ble.Devices;
using Assets.Scripts.Devices.Ble.Interfaces;
using ChartAndGraph;
using System;
using System.Collections;
@@ -17,6 +18,7 @@ using System.Linq;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
using static RowerTaskPanel;
public class RowerHomeScript : PFUIPanel
{
@@ -26,6 +28,9 @@ public class RowerHomeScript : PFUIPanel
public ushort pace { get; set; }
public uint rate { get; set; }
public int heartRate { get; set; }
public int energy { get; set; }
public int distance { get; set; }
public int strokeCount { get; set; }
}
/// <summary>
/// 划船机数据
@@ -42,6 +47,7 @@ public class RowerHomeScript : PFUIPanel
return null;
}
}
protected override void OnDestroy()
{
Debug.Log("銷毀");
@@ -75,17 +81,17 @@ public class RowerHomeScript : PFUIPanel
}
}
GameObject btnStart;
Transform left, bottom;
Transform left, bottom, mid;
float timer = 1.0f;
EventHandler PaintPullCurveDelegate;
List<DoubleVector2> pullList = new List<DoubleVector2>();
Dictionary<object, Sprite> spriteDict;
public Dictionary<object, Sprite> spriteDict;
List<string> records;
List<TempRowerCalc> values;
DateTime startTime,createTime;
double Kj = 0;
int seconds = 0;
bool isPause = false;
public RowerType rowerType = null;
/// <summary>
/// 计算停止的秒数,如果超过5秒,除了累加值都变成--,这些值记录为0,提示用户如果超过90秒,将直接保存数据
/// 如果5-90秒有拉力,则继续滑行
@@ -93,20 +99,21 @@ public class RowerHomeScript : PFUIPanel
/// </summary>
int stopSeconds = 0;
uint totalDistance = 0;
Transform slider;
protected override void Start()
{
var nav = transform.Find("MainNav-mobile").GetComponent<NewMainNav>();
nav.SetButtonActive(new List<int> {1,4,6 }, null, new NewMainNav.CustomButton(Resources.Load<Sprite>("Images/Rower/骑行"), () =>
{
ReturnHome();
}));
var rect = transform.GetComponent<RectTransform>();
rect.offsetMax = Vector2.zero;
rect.offsetMin = Vector2.zero;
}
protected override void Awake()
{
rowerType = new RowerType();
spriteDict = new Dictionary<object, Sprite>()
{
{"Start",Resources.Load<Sprite>("Images/Rower/System_play")},
{"Untagged",Resources.Load<Sprite>("Images/Rower/System_pause")},
{"Start",Resources.Load<Sprite>("Images/RowerNew/ICON_continue_44") },
{"Untagged",Resources.Load<Sprite>("Images/RowerNew/ICON_pause_44")},
{0,Resources.Load<Sprite>("Images/Rower/序列帧/划船机0001") },
{1,Resources.Load<Sprite>("Images/Rower/序列帧/划船机0002") },
{2,Resources.Load<Sprite>("Images/Rower/序列帧/划船机0003") },
@@ -128,30 +135,107 @@ public class RowerHomeScript : PFUIPanel
//mainNav.ShowExit();
var btnHome = transform.Find("Other/BtnHome").gameObject;
UIManager.AddEvent(btnHome, UnityEngine.EventSystems.EventTriggerType.PointerClick, b => ReturnHome());
btnStart = transform.Find("Other1/BtnStart").gameObject;
UIManager.AddEvent(btnStart, UnityEngine.EventSystems.EventTriggerType.PointerClick, b => HandleStartOrPause());
left = transform.Find("Left");
bottom = transform.Find("Bottom");
PaintPullCurveDelegate = new EventHandler(PaintPullCurve);
transform.Find("PFUISlider").GetComponent<PFUISlider>().SetValueChanged(r =>
left = transform.Find("Rower/Modes/Scroll/M1/Left");
bottom = transform.Find("Rower/Bottom");
mid = transform.Find("Rower/Modes/Scroll/M1/Mid");
slider = transform.Find("ResBar/PFUISlider");
UIManager.AddEvent(transform.Find("ResBar/BtnAdd").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
var v = (ushort)(r * 65535);
if (RowerData != null)
{
slider.GetComponent<PFUISlider>().SetValue((RowerData.ResistanceLevel + 1 - 50) / 300f);
}
});
UIManager.AddEvent(transform.Find("ResBar/BtnSub").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
if (RowerData != null)
{
slider.GetComponent<PFUISlider>().SetValue((RowerData.ResistanceLevel - 1 - 50) / 300f);
}
});
slider.GetComponent<PFUISlider>().valueHandler = (a) => 50 + a * 300;
slider.GetComponent<PFUISlider>().SetValueChanged(r =>
{
var v = (ushort)Math.Round((r * 300));
print("设置阻力" + v);
if (Rower != null)
{
Rower.SetResistanceLevel(v);
//RowerData.
}
});
//transform.Find("Ready/DeviceStatus").gameObject.SetActive(!flag);
//transform.Find("Ready/DeviceStatusConnect").gameObject.SetActive(flag);
UIManager.AddEvent(transform.Find("Ready/DeviceStatus").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
if (checkRowing()) return;
UIManager.ShowRowerDevicePanel();
});
UIManager.AddEvent(transform.Find("Ready/DeviceStatusConnect").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
if (checkRowing()) return;
UIManager.ShowRowerDevicePanel();
});
//手机版tab
#if UNITY_ANDROID || UNITY_IOS
var nav = transform.Find("MainNav-mobile").GetComponent<NewMainNav>();
var c1 = new NewMainNav.CustomButton(Resources.Load<Sprite>("Images/RowerNew/ICON_create_44"), () =>
{
//UIManager.ShowRowerWelldone("81A85D49-ACAA-C764-101A-02555E6AC81A");
//return;
if (checkRowing()) return;
UIManager.ShowRowerTaskPanel(type=>
{
rowerType = type;
HandleSelectType();
});
}, false);
//var c2 = new NewMainNav.CustomButton(Resources.Load<Sprite>("Images/RowerNew/ICON_continue_44"), () =>
//{
// HandleStartOrPause();
//});
btnStart = transform.Find("MainNav-mobile/Custom2").gameObject;
var c3 = new NewMainNav.CustomButton(Resources.Load<Sprite>("Images/RowerNew/ICON_mode_44"), () =>
{
ReturnHome();
}, false);
nav.SetButtonActive(new List<int> { 3, 7 }, null, c1, null, c3);
newNav = nav;
#endif
UIManager.AddEvent(transform.Find("Stopped/Confirm/BtnSave").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
transform.Find("Stopped").gameObject.SetActive(false);
HandleSaveDirect();
});
UIManager.AddEvent(transform.Find("Stopped/Confirm/BtnDrop").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
transform.Find("Stopped").gameObject.SetActive(false);
Init();
});
Init();
}
private void HandleSelectType()
{
if (Rower != null)
{
Rower.Reset();
}
//RowerPanel/Rower/Bottom/Expected/Title
var dw = rowerType.type == 1 ? $"{rowerType.value}M" : $"{(rowerType.value / 60).ToString("#0.00")}Min";
bottom.Find("Expected/Title").GetComponent<Text>().text = $"EST\n/ {dw}";
Init();
//Utils.showToast(null, "请滑动划船机并开始", isLowest: true, type: 1);
}
public override void Show()
{
base.Show();
var mainNav = this.transform.Find("MainNav").GetComponent<MainNav>();
mainNav.ShowRowerTab();
//var mainNav = this.transform.Find("MainNav").GetComponent<MainNav>();
//mainNav.ShowRowerTab();
transform.MyDOFade();
Debug.Log("140,开始扫描");
App.MainDeviceAdapter.StartScan();
@@ -187,10 +271,16 @@ public class RowerHomeScript : PFUIPanel
Save();
Init();
}
private IRowerCommonData RowerCommonDataInstance => Rower != null ? (C2RowerData.IsEnabled == true ? (IRowerCommonData)Rower.c2RowerData : (IRowerCommonData)Rower.rowerData) : null;
private void HandleStartOrPause()
{
//UIManager.ShowRowerResult();
//return;
if (rowerType == null)
{
Utils.showToast(null, "Please select the course!", isLowest: true);
return;
}
if (btnStart.CompareTag("Start"))
{
#if !UNITY_EDITOR
@@ -202,23 +292,18 @@ public class RowerHomeScript : PFUIPanel
#endif
UIManager.ShowCountDownAnimation(() =>
{
if (RowerData != null)
#if !UNITY_EDITOR
if (RowerCommonDataInstance != null)
{
RowerData.PullChanged -= PaintPullCurveDelegate;
RowerData.PullChanged += PaintPullCurveDelegate;
RowerCommonDataInstance.PullChanged -= PaintPullCurve;
RowerCommonDataInstance.PullChanged += PaintPullCurve;
}
if (!isPause)
{
startTime = UIManager.Now.GetDateTime();
}
TimerTicks();
openTimer = true;
timer = 1.0f;
btnStart.GetComponent<Image>().sprite = spriteDict["Untagged"];
btnStart.tag = "Untagged";
#endif
StartFunc();
},
()=>
{
Debug.Log(222);
if (Rower != null && !isPause)
{
Rower.Reset();
@@ -251,6 +336,23 @@ public class RowerHomeScript : PFUIPanel
//StartCoroutine();
}
private void StartFunc()
{
if (!isPause)
{
startTime = UIManager.Now.GetDateTime();
}
if (!openTimer)
{
TimerTicks();
openTimer = true;
timer = 1.0f;
}
transform.Find("Ready").gameObject.SetActive(false);
btnStart.GetComponent<Image>().sprite = spriteDict["Untagged"];
btnStart.tag = "Untagged";
}
private void Save()
{
createTime = UIManager.Now.GetDateTime();
@@ -285,6 +387,8 @@ public class RowerHomeScript : PFUIPanel
model.StrokeCount = RowerData.StrokeCount;
model.TotalTime = RowerData.ElapsedTime;
model.TotalDistance = RowerData.TotalDistance;
model.Type = rowerType.type == 0 ? (int?)null : rowerType.type;
model.TypeValue = rowerType.value == 0 ? (float?)null : rowerType.value;
var path = PFConstants.RowerRecordFolder + "/" + model.Id;
Helper.CreateDirectoryIfNotExsit(path);
var files = new List<string>();
@@ -295,10 +399,12 @@ public class RowerHomeScript : PFUIPanel
{
var stream = new StreamWriter(fs);
stream.BaseStream.Seek(0, SeekOrigin.End);
foreach (var item in records)
{
stream.Write(item + "\r\n");
}
print("结果数" + records.Count);
stream.Write(string.Join("\r\n", records));
//foreach (var item in records)
//{
// stream.Write(item + "\r\n");
//}
stream.Flush();
stream.Close();
files.Add(fname);
@@ -309,12 +415,9 @@ public class RowerHomeScript : PFUIPanel
Helper.DelectDir(path);
Debug.Log(ex.Message);
}
UIManager.ShowRowerWelldone(model);
Disconnect();
Task.Run(()=>
{
var res = ConfigHelper.rowerApi.Add(model, files);
});
var res = ConfigHelper.rowerApi.Add(model, files);
UIManager.ShowRowerWelldone(model.Id);
//Disconnect();
}
private void Init()
@@ -327,6 +430,7 @@ public class RowerHomeScript : PFUIPanel
{
Rower.Reset();
}
GetComponent<RowerMultiModeScript>().GetShadowList(rowerType);
btnStart.tag = "Start";
btnStart.GetComponent<Image>().sprite = spriteDict["Start"];
left.Find("Rower").GetComponent<Image>().sprite = spriteDict[0];
@@ -335,18 +439,21 @@ public class RowerHomeScript : PFUIPanel
left.Find("Times/Value").GetComponent<Text>().text = "---";
left.Find("Calories/Value").GetComponent<Text>().text = "---";
pullList = new List<DoubleVector2>();
transform.Find("Mid/GraphChart").GetComponent<RowerGraphChartFeed>().SetData(pullList);
mid.Find("GraphChart").GetComponent<RowerGraphChartFeed>().SetData(pullList);
openTimer = false;
bottom.Find("Time/Value").GetComponent<Text>().text = "---";
bottom.Find("TrueTime/Value").GetComponent<Text>().text = "---";
//bottom.Find("TrueTime/Value").GetComponent<Text>().text = "---";
bottom.Find("KM/Value").GetComponent<Text>().text = "---";
bottom.Find("W/Value").GetComponent<Text>().text = "---";
bottom.Find("W/AvgValue").GetComponent<Text>().text = "---";
mid.Find("W/Value").GetComponent<Text>().text = "---";
//bottom.Find("W/AvgValue").GetComponent<Text>().text = "---";
bottom.Find("500/Value").GetComponent<Text>().text = "---";
bottom.Find("500/AvgValue").GetComponent<Text>().text = "---";
//bottom.Find("500/AvgValue").GetComponent<Text>().text = "---";
bottom.Find("MS/Value").GetComponent<Text>().text = "---";
bottom.Find("MS/AvgValue").GetComponent<Text>().text = "---";
//bottom.Find("MS/AvgValue").GetComponent<Text>().text = "---";
bottom.Find("BPM/Value").GetComponent<Text>().text = "---";
bottom.Find("Expected/Value").GetComponent<Text>().text = "---";
mid.Find("AvgForce/Value").GetComponent<Text>().text = "---";
mid.Find("PeakForce/Value").GetComponent<Text>().text = "---";
records = new List<string>();
values = new List<TempRowerCalc>();
Kj = 0;
@@ -355,42 +462,78 @@ public class RowerHomeScript : PFUIPanel
totalDistance = 0;
stopSeconds = 0;
isPause = false;
#if !UNITY_EDITOR
transform.Find("Ready").gameObject.SetActive(true);
#endif
C2RowerData.EnableChanged -= ModeChanged;
C2RowerData.EnableChanged += ModeChanged;
FtmsRowerData.RowerResChanged -= ResChanged;
FtmsRowerData.RowerResChanged += ResChanged;
}
private void ModeChanged(object sender, EventArgs e)
{
print("增加服务"+RowerData.ResistanceLevel);
RowerCommonDataInstance.PullChanged -= PaintPullCurve;
RowerCommonDataInstance.PullChanged += PaintPullCurve;
slider.GetComponent<Slider>().interactable = !(bool)sender;
transform.Find("ResBar/BtnSub").GetComponent<Button>().interactable = !(bool)sender;
transform.Find("ResBar/BtnAdd").GetComponent<Button>().interactable = !(bool)sender;
}
private void ResChanged(object sender, EventArgs e)
{
print("收到阻力" + sender);
slider.GetComponent<PFUISlider>().SetValue((Convert.ToSingle(sender) - 50) / 300f);
}
public bool checkRowing()
{
if (seconds > 0)
{
Utils.showToast(null, "Please end this training.", isLowest: true);
return true;
}
return false;
}
private void ReturnHome()
{
if (seconds > 0)
{
Utils.showToast(null, "Please end this training.", isLowest: true);
return;
}
if (checkRowing()) return;
Disconnect();
UIManager.ShowHomePanel();
UIManager.ShowRowerSelector();
}
// Update is called once per frame
bool openTimer = false;
double x = 0f;
//List<ushort> tempList = new List<ushort>()
//{
// 0,1230,4,500,12,13,16,0,0,0,20,30,40,50,60,500
//};
//int tempx = 0;
void TimerTicks()
#if UNITY_EDITOR
List<ushort> tempList = new List<ushort>()
{
//Debug.Log(123);
//PaintPullCurve(tempList[(tempx++) % tempList.Count]);
0,1230,4,500,12,13,16,0,0,0,20,30,40,50,60,500
};
int tempx = 0;
#endif
void TimerTicks()
{
#if UNITY_EDITOR
PaintPullCurve(tempList[(tempx++) % tempList.Count]);
#endif
#if !UNITY_EDITOR
if (Rower == null)
{
HandleDiscardDirect();
return;
}
#endif
if (RowerData == null) return;
#endif
var heartRate = HeartRate ?? 0;
bottom.Find("BPM/Value").GetComponent<Text>().text = heartRate.ToString();
var distance = (int)RowerData.TotalDistance;
var energy = RowerData.TotalEnergy;
var strokeCount = RowerData.StrokeCount;
TempRowerCalc tmpdata = null;
if (totalDistance == RowerData.TotalDistance)
{
//判定一次停止
@@ -399,51 +542,122 @@ public class RowerHomeScript : PFUIPanel
else
{
stopSeconds = 0;
transform.Find("Stopped").gameObject.SetActive(false);
}
if (stopSeconds >= 91)
//if (stopSeconds >= 91)
//{
// Debug.Log("保存");
// HandleSaveDirect();
// return;
//}
//else if (stopSeconds == 81)
//{
// Utils.showToast(null, "Record will be saved!", duration: 10, stopFunc: () => stopSeconds < 6, isLowest: true,showSeconds:true);
// return;
//}
if (stopSeconds >= 2)
{
Debug.Log("保存");
HandleSaveDirect();
return;
}
else if (stopSeconds == 81)
{
Utils.showToast(null, "Record will be saved!", duration: 10, stopFunc: () => stopSeconds < 6, isLowest: true,showSeconds:true);
return;
}
else if (stopSeconds >= 6)
{
if (stopSeconds == 6)
transform.Find("Stopped").gameObject.SetActive(true);
//if (stopSeconds == 6)
//{
// Utils.showToast(null, "Please keep rowing...", duration: 60, stopFunc: () => stopSeconds < 6, isLowest: true);
//}
if (rowerType.type == 2)
{
Utils.showToast(null, "Please keep rowing...", duration: 60, stopFunc: () => stopSeconds < 6, isLowest: true);
var remainTime = rowerType.value - (seconds++);
if (remainTime == 0)
{
HandleSaveDirect();
return;
}
bottom.Find("Time/Value").GetComponent<Text>().text = TimeSpan.FromSeconds(remainTime).ToString();
}
bottom.Find("Time/Value").GetComponent<Text>().text = TimeSpan.FromSeconds(seconds++).ToString();
bottom.Find("W/Value").GetComponent<Text>().text = "---";
bottom.Find("W/AvgValue").GetComponent<Text>().text = "---";
else
{
bottom.Find("Time/Value").GetComponent<Text>().text = TimeSpan.FromSeconds(seconds++).ToString();
}
mid.Find("W/Value").GetComponent<Text>().text = "---";
//bottom.Find("W/AvgValue").GetComponent<Text>().text = "---";
bottom.Find("500/Value").GetComponent<Text>().text = "---";
bottom.Find("500/AvgValue").GetComponent<Text>().text = "---";
//bottom.Find("500/AvgValue").GetComponent<Text>().text = "---";
bottom.Find("MS/Value").GetComponent<Text>().text = "---";
bottom.Find("MS/AvgValue").GetComponent<Text>().text = "---";
records.Add($"{RowerData.StrokeCount},{RowerData.ElapsedTime},{RowerData.TotalDistance},0,0,0,{RowerData.ResistanceLevel},{heartRate}");
values.Add(new TempRowerCalc() { pace = 0, power = 0, rate = 0, heartRate = heartRate });
//bottom.Find("MS/AvgValue").GetComponent<Text>().text = "---";
bottom.Find("Expected/Value").GetComponent<Text>().text = "---";
records.Add($"{strokeCount},{RowerData.ElapsedTime},{distance},0,0,0,{RowerData.ResistanceLevel},{heartRate},{energy}");
tmpdata = new TempRowerCalc() { strokeCount = strokeCount, pace = 0, power = 0, rate = 0, heartRate = heartRate, distance = distance, energy = energy };
values.Add(tmpdata);
SendDataToRace(tmpdata);
return;
}
totalDistance = RowerData.TotalDistance;
bottom.Find("Time/Value").GetComponent<Text>().text = TimeSpan.FromSeconds(seconds++).ToString();
bottom.Find("TrueTime/Value").GetComponent<Text>().text = TimeSpan.FromSeconds(RowerData.ElapsedTime).ToString();
bottom.Find("KM/Value").GetComponent<Text>().text = totalDistance.ToString();
var power = RowerData.InstantaneousPower;
bottom.Find("W/Value").GetComponent<Text>().text = power.ToString();
bottom.Find("W/AvgValue").GetComponent<Text>().text = RowerData.AveragePower.ToString();
totalDistance = (uint)distance;
var pace = RowerData.InstantaneousPace;
if (rowerType.type == 2)
{
var remainTime = rowerType.value - (seconds++);
if (remainTime == 0)
{
HandleSaveDirect();
return;
}
bottom.Find("Time/Value").GetComponent<Text>().text = TimeSpan.FromSeconds(remainTime).ToString();
}
else
{
bottom.Find("Time/Value").GetComponent<Text>().text = TimeSpan.FromSeconds(seconds++).ToString();
}
//bottom.Find("TrueTime/Value").GetComponent<Text>().text = TimeSpan.FromSeconds(RowerData.ElapsedTime).ToString();
if (rowerType.type == 1)
{
var remainDistance = rowerType.value - totalDistance;
if (remainDistance < 0)
{
HandleSaveDirect();
return;
}
bottom.Find("KM/Value").GetComponent<Text>().text = remainDistance.ToString();
}
else
{
bottom.Find("KM/Value").GetComponent<Text>().text = totalDistance.ToString();
}
if (pace != 0)
{
if (rowerType.type == 1)
{
//设置里程时 显示预估时间 当前时间+剩余里程/配速(转换)
var remainDistance = rowerType.value - totalDistance;
var time = values.Count + (remainDistance / (500f / pace));
bottom.Find("Expected/Value").GetComponent<Text>().text = TimeSpan.FromSeconds(time).ToString(@"hh\:mm\:ss");
}
else if (rowerType.type == 2)
{
var remainTime = rowerType.value - values.Count;
var dis = totalDistance + (remainTime * (500f / pace));
//设置时间时 显示预估里程 当前里程+剩余时间*配速
bottom.Find("Expected/Value").GetComponent<Text>().text = $"{dis.ToString("#0")}M";
}
else
{
//自由滑 显示30min里程 当前里程+剩余时间*配速
var remainTime = 30 * 60 - values.Count;
var dis = totalDistance + (remainTime * (500f / pace));
//设置时间时 显示预估里程 当前里程+剩余时间*配速
bottom.Find("Expected/Value").GetComponent<Text>().text = $"{dis.ToString("#0")}M";
}
}
//RowerPanel/Rower/Bottom/Expected/Value
var power = RowerData.InstantaneousPower;
mid.Find("W/Value").GetComponent<Text>().text = power.ToString();
//bottom.Find("W/AvgValue").GetComponent<Text>().text = RowerData.AveragePower.ToString();
bottom.Find("500/Value").GetComponent<Text>().text = TimeSpan.FromSeconds(pace).ToString(@"mm\:ss");
bottom.Find("500/AvgValue").GetComponent<Text>().text = TimeSpan.FromSeconds(RowerData.AveragePace).ToString(@"mm\:ss");
//bottom.Find("500/AvgValue").GetComponent<Text>().text = TimeSpan.FromSeconds(RowerData.AveragePace).ToString(@"mm\:ss");
var rate = RowerData.StrokeRate;
bottom.Find("MS/Value").GetComponent<Text>().text = rate.ToString();
bottom.Find("MS/AvgValue").GetComponent<Text>().text = RowerData.AverageStrokeRate.ToString();
var strokeCount = RowerData.StrokeCount;
//bottom.Find("MS/AvgValue").GetComponent<Text>().text = RowerData.AverageStrokeRate.ToString();
//if (ushort.TryParse(left.Find("Times/Value").GetComponent<Text>().text, out ushort originStroke))
//{
// if (strokeCount != originStroke)
@@ -452,28 +666,52 @@ public class RowerHomeScript : PFUIPanel
// }
//}
left.Find("Times/Value").GetComponent<Text>().text = strokeCount.ToString();
left.Find("Calories/Value").GetComponent<Text>().text = RowerData.TotalEnergy.ToString();
records.Add($"{RowerData.StrokeCount},{RowerData.ElapsedTime},{RowerData.TotalDistance},{RowerData.InstantaneousPower},{RowerData.InstantaneousPace},{RowerData.StrokeRate},{RowerData.ResistanceLevel},{heartRate}");
values.Add(new TempRowerCalc() { pace = pace, power = power, rate = rate,heartRate = heartRate });
left.Find("Calories/Value").GetComponent<Text>().text = energy.ToString();
mid.Find("AvgForce/Value").GetComponent<Text>().text = RowerCommonDataInstance.AverageDriveForce.ToString("#0");
mid.Find("PeakForce/Value").GetComponent<Text>().text = RowerCommonDataInstance.PeakDriveForce.ToString("#0");
records.Add($"{strokeCount},{RowerData.ElapsedTime},{distance},{RowerData.InstantaneousPower},{RowerData.InstantaneousPace},{RowerData.StrokeRate},{RowerData.ResistanceLevel},{heartRate},{energy}");
print(records.Count);
tmpdata = new TempRowerCalc() { strokeCount = strokeCount, pace = pace, power = power, rate = rate, heartRate = heartRate, distance = distance, energy = energy };
values.Add(tmpdata);
SendDataToRace(tmpdata);
//Debug.Log(1);
}
void SendDataToRace(TempRowerCalc tmpdata)
{
GetComponent<RowerMultiModeScript>().HandleTimeTick(new RowerChartModel
{
Pace = tmpdata.pace,
Power = tmpdata.power,
HeartRate = tmpdata.heartRate,
Rate = tmpdata.rate,
Distance = tmpdata.distance,
StrokeCount = tmpdata.strokeCount
});
}
void PaintPullCurve(object sender, EventArgs e)
{
var ftms = (FtmsRowerData)sender;
var ftms = (IRowerCommonData)sender;
//Debug.Log(ftms.PullValue);
PaintPullCurve(ftms.PullValue);
}
bool isPlay = false;
void PaintPullCurve(ushort y)
{
Debug.Log("收到拉力" + y);
Debug.Log("收到拉力" + y + ","+ DateTime.Now.Ticks);
#if !UNITY_EDITOR
if (!openTimer)
{
RowerData.PullChanged -= PaintPullCurveDelegate;
return;
if (y > 0)
{
//RowerCommonDataInstance.PullChanged -= PaintPullCurve;
//RowerCommonDataInstance.PullChanged += PaintPullCurve;
StartFunc();
}
else
{
return;
}
}
#endif
//if (y > 1200) y = 1200;
@@ -492,13 +730,13 @@ public class RowerHomeScript : PFUIPanel
isPlay = true;
x = 0;
pullList.Add(new DoubleVector2(x, y));
transform.Find("Mid/GraphChart").GetComponent<RowerGraphChartFeed>().SetData(pullList);
mid.Find("GraphChart").GetComponent<RowerGraphChartFeed>().SetData(pullList);
}
else if (pullList.Count > 1)
{
x += 0.1;
pullList.Add(new DoubleVector2(x, y));
transform.Find("Mid/GraphChart").GetComponent<RowerGraphChartFeed>().SetData(pullList);
mid.Find("GraphChart").GetComponent<RowerGraphChartFeed>().SetData(pullList);
pullList.Clear();
x = 0;
isPlay = true;
@@ -509,7 +747,7 @@ public class RowerHomeScript : PFUIPanel
//只有0并且两秒没拉,曲线消失
if (stopSeconds == 1)
{
transform.Find("Mid/GraphChart").GetComponent<RowerGraphChartFeed>().SetData(new List<DoubleVector2>());
mid.Find("GraphChart").GetComponent<RowerGraphChartFeed>().SetData(new List<DoubleVector2>());
}
}
}
@@ -523,8 +761,7 @@ public class RowerHomeScript : PFUIPanel
isPlay = false;
left.Find("Rower").GetComponent<RowerAnimation>().StartAnimation();
}
transform.Find("Mid/GraphChart").GetComponent<RowerGraphChartFeed>().SetData(pullList);
mid.Find("GraphChart").GetComponent<RowerGraphChartFeed>().SetData(pullList);
}
//Debug.Log($"{x},{y}");
//transform.Find("Mid/GraphChart").GetComponent<RowerGraphChartFeed>().SetData(pullList);
@@ -539,6 +776,7 @@ public class RowerHomeScript : PFUIPanel
// x += 0.1f;
//}
}
float staticTimer = 1f;
void Update()
{
if (openTimer)
@@ -550,5 +788,23 @@ public class RowerHomeScript : PFUIPanel
timer = 1f + timer;
}
}
staticTimer -= Time.deltaTime;
if (staticTimer <= 0)
{
HandleStatic();
staticTimer += 1f;
}
}
void HandleStatic()
{
if (transform.Find("Ready").gameObject.activeInHierarchy)
{
var flag = Rower != null && RowerData != null;
transform.Find("Ready/DeviceStatus").gameObject.SetActive(!flag);
transform.Find("Ready/Img").gameObject.SetActive(!flag);
transform.Find("Ready/Text").gameObject.SetActive(!flag);
transform.Find("Ready/DeviceStatusConnect").gameObject.SetActive(flag);
}
}
}