修改细节

This commit is contained in:
Caiyanpeng committed 2021-09-28 20:35:16 +08:00
1 parent b74c3b57b4
commit 8d8fd59a80
26 files changed
+6379 -5567

No files matched your search

+2
View File
@@ -62,6 +62,7 @@ public class MainController : BaseScene
//{
// UIManager.ShowHomePanel();
//});
#if UNITY_ANDROID || UNITY_IOS
if (!App.IsRowerMode.HasValue)
{
UIManager.ShowRowerSelector();
@@ -72,6 +73,7 @@ public class MainController : BaseScene
UIManager.ShowRowerPanel();
return;
}
#endif
if (App.MainSceneParam.ContainsKey("Name") && !string.IsNullOrEmpty(App.MainSceneParam["Name"]))
{
UIManager.ShowHomePanel();
@@ -145,10 +145,18 @@ public class RowerHomeScript : PFUIPanel
}
else
{
openTimer = false;
isPause = true;
if (RowerData != null)
{
RowerData.PullChanged -= PaintPullCurveDelegate;
}
btnStart.GetComponent<Image>().sprite = spriteDict["Start"];
btnStart.tag = "Start";
UIManager.ShowConfirm3("Quit", "Do you want to keep the record?",
() =>
{
UIManager.CloseConfirm();
UIManager.CloseConfirm3();
Save();
Init();
},
@@ -158,11 +166,7 @@ public class RowerHomeScript : PFUIPanel
},
()=>
{
openTimer = false;
isPause = true;
RowerData.PullChanged -= PaintPullCurveDelegate;
btnStart.GetComponent<Image>().sprite = spriteDict["Start"];
btnStart.tag = "Start";
});
}
Debug.Log(RowerData);
@@ -189,11 +193,14 @@ public class RowerHomeScript : PFUIPanel
if (values.Count > 0)
{
model.MaxPower = values.Max(x => x.power);
model.MaxPace = values.Where(x => x.pace > 0).Min(x => x.pace);
if (values.Count(x => x.pace > 0) > 0)
{
model.MaxPace = values.Where(x => x.pace > 0).Min(x => x.pace);
model.AvgPace = values.Where(x => x.pace > 0).Average(x => x.pace);
}
model.MaxRate = values.Max(x => x.rate);
model.MaxHeartRate = values.Max(x => x.heartRate);
model.AvgPower = values.Average(x => x.power);
model.AvgPace = values.Where(x => x.pace > 0).Average(x => x.pace);
model.AvgRate = values.Average(x => x.rate);
model.AvgHeartRate = (int)values.Average(x => x.heartRate);
}
@@ -296,7 +303,15 @@ public class RowerHomeScript : PFUIPanel
bottom.Find("MS/AvgValue").GetComponent<Text>().text = RowerData.AverageStrokeRate.ToString();
var heartRate = HeartRate ?? 0;
bottom.Find("BPM/Value").GetComponent<Text>().text = heartRate.ToString();
left.Find("Times/Value").GetComponent<Text>().text = RowerData.StrokeCount.ToString();
var strokeCount = RowerData.StrokeCount;
if (ushort.TryParse(left.Find("Times/Value").GetComponent<Text>().text, out ushort originStroke))
{
if (strokeCount != originStroke)
{
left.Find("Rower").GetComponent<RowerAnimation>().StartAnimation();
}
}
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 });
@@ -319,7 +334,7 @@ public class RowerHomeScript : PFUIPanel
left.Find("LeftImage/Value").GetComponent<Image>().fillAmount = rate;
left.Find("RightImage/Value").GetComponent<Image>().fillAmount = rate;
//动画
left.Find("Rower").GetComponent<Image>().sprite = spriteDict[y / 67];
//left.Find("Rower").GetComponent<Image>().sprite = spriteDict[y / 67];
//曲线
if (y == 0)
{
@@ -8,12 +8,12 @@ public class RowerAnimation : PFUIPanel
{
List<Sprite> sprites;
Image image;
public bool isFinish = false;
protected override void Awake()
{
base.Awake();
sprites = new List<Sprite>();
for (int i = 1; i < 26; i++)
for (int i = 1; i <= 30; i++)
{
sprites.Add(Resources.Load<Sprite>($"Images/Rower/序列帧/划船机{i.ToString("0000")}"));
}
@@ -40,19 +40,16 @@ public class RowerAnimation : PFUIPanel
public void StartAnimation()
{
index = 0;
isFinish = false;
StartCoroutine(Animation());
}
IEnumerator Animation()
{
for (; ; )
yield return new WaitForEndOfFrame();
for (int i = 0; i < 30; i++)
{
if (index % 25 == 0)
{
index = 0;
}
image.sprite = sprites[index];
index++;
image.sprite = sprites[i];
yield return new WaitForSeconds(0.08f);
}
}
@@ -190,8 +190,8 @@ public class RowerDeviceView : MonoBehaviour
sprite0 = Resources.Load<Sprite>("Images/Devices/Heart Rate_1");
sprite1 = Resources.Load<Sprite>("Images/Devices/Heart Rate_1");
sprite3 = Resources.Load<Sprite>("Images/Devices/Heart Rate_4");
powerUnit.text = "BPM";
powerValue.text = "";
powerUnit.text = "";
}
else if (SensorType == SensorType.Trainer)
{
@@ -0,0 +1,143 @@
#define Graph_And_Chart_PRO
using ChartAndGraph;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public partial class RowerHoverText : MonoBehaviour
{
public Text TextPrefab;
public int FontSize = 5;
public Vector3 TextOffset = new Vector3();
int fractionDigits = 0;
AnyChart mChart;
List<Text> mItems = new List<Text>();
List<CharItemEffectController> mRemoved = new List<CharItemEffectController>();
partial void HoverStart();
void Start ()
{
var graph = GetComponent<GraphChart>();
var labels = GetComponent<ItemLabels>();
if (labels != null)
fractionDigits = labels.FractionDigits;
else
fractionDigits = 2;
if (graph != null)
{
mChart = graph;
graph.PointHovered.AddListener(GraphHover);
graph.NonHovered.AddListener(NonHover);
return;
}
var bar = GetComponent<CanvasBarChart>();
if (bar != null)
{
mChart = bar;
bar.BarHovered.AddListener(BarHover);
bar.NonHovered.AddListener(NonHover);
return;
}
HoverStart();
}
void NonHover()
{
for (int i = 0; i < mItems.Count; i++)
{
RemoveText(mItems[i]);
}
mItems.Clear();
}
void Update()
{
mRemoved.RemoveAll(x =>
{
if(!x.enabled)
{
ChartCommon.SafeDestroy(x.gameObject);
return true;
}
return false;
});
}
IEnumerator SelectText(Text text)
{
yield return new WaitForEndOfFrame();
if (text != null)
{
ChartItemEvents e = text.GetComponent<ChartItemEvents>();
if (e != null)
{
e.OnMouseHover.Invoke(e.gameObject);
}
}
}
void RemoveText(Text text)
{
if (text != null)
{
ChartItemEvents e = text.GetComponent<ChartItemEvents>();
CharItemEffectController control = text.GetComponent<CharItemEffectController>();
if (e != null && control != null)
{
e.OnMouseLeave.Invoke(e.gameObject);
mRemoved.Add(control);
}
else
{
ChartCommon.SafeDestroy(text);
}
}
}
void PopText(string data,Vector3 position,bool worldPositionStays)
{
var canvas = GetComponentInParent<Canvas>();
if (canvas == null || TextPrefab == null)
return;
NonHover();
GameObject obj =(GameObject) GameObject.Instantiate(TextPrefab.gameObject, position + TextOffset, Quaternion.identity);
var text = obj.GetComponent<Text>();
text.maskable = false;
text.text = data;
text.fontSize = FontSize;
obj.transform.SetParent(transform, false);
if (worldPositionStays)
obj.transform.position = position + TextOffset;
else
obj.transform.localPosition = position + TextOffset;
Vector3 local = obj.transform.localPosition;
local.z = 0f;
obj.transform.localPosition = local;
mItems.Add(text);
StartCoroutine(SelectText(text));
}
void BarHover(BarChart.BarEventArgs args)
{
String data = ChartAdancedSettings.Instance.FormatFractionDigits(fractionDigits, args.Value);
PopText(data, args.TopPosition,true);
}
void GraphHover(GraphChartBase.GraphEventArgs args)
{
var graph = mChart as GraphChart;
var point = graph.DataSource.GetPoint(args.Category, args.Index);
Vector3 position;
if(graph.PointToWorldSpace(out position, point.x, point.y, args.Category))
PopText($"({args.XString},{args.YString})", position, true);
else
PopText($"({args.XString},{args.YString})", args.Position,false);
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: edce4d82bd7a8544982946c6318de49b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -9,7 +9,7 @@ public partial class RowerLargeDataFeed : MonoBehaviour, IComparer<DoubleVector2
{
public string Category = "Player 1";
public int DownSampleToPoints = 100;
List<DoubleVector2> mData = new List<DoubleVector2>(); // the data held by the chart
public List<DoubleVector2> mData = new List<DoubleVector2>(); // the data held by the chart
double pageSize = 2f;
double currentPagePosition = 0.0;
double currentZoom = 0f;
@@ -228,7 +228,9 @@ public partial class RowerLargeDataFeed : MonoBehaviour, IComparer<DoubleVector2
graph.DataSource.HorizontalViewOrigin = 0;
int start, end;
findPointsForPage(pagePosition, out start, out end); // get the page edges
graph.DataSource.ClearAndMakeBezierCurve(Category); // clear the cateogry
graph.DataSource.ClearCategory(Category); // clear the cateogry
graph.DataSource.HorizontalViewSize = 500 > mData.Count ? mData.Count : 500;
if (DownSampleToPoints <= 0)
LoadWithoutDownSampling(start, end);
+13 -8
View File
@@ -55,16 +55,16 @@ public class RowerResult : PFUIPanel
dataContent.Find("TitleContent/Device").GetComponent<Text>().text
= $"<color=#5c5c6e>Rowing equipment :</color> {_model.ManufacturerName}";
dataContent.Find("Table/AvgPower/Text").GetComponent<Text>().text
= $"{_model.AvgPower.ToString("#0")} W";
= $"{TimeSpan.FromSeconds(_model.AvgPace).ToString(@"mm\:ss")} /500M";
dataContent.Find("Table/AvgHR/Text").GetComponent<Text>().text
= $"{_model.AvgHeartRate} BPM";
dataContent.Find("Table/AvgRate/Text").GetComponent<Text>().text
= $"{_model.AvgRate.ToString("#0")} W";
dataContent.Find("Table/MaxPower/Text").GetComponent<Text>().text
= $"{_model.MaxPower.ToString("#0")} W";
dataContent.Find("Table/AvgHR/Text").GetComponent<Text>().text
= $"{TimeSpan.FromSeconds(_model.MaxPace).ToString(@"mm\:ss")} /500M";
dataContent.Find("Table/MaxHR/Text").GetComponent<Text>().text
= $"{_model.MaxHeartRate} BPM";
dataContent.Find("Table/AvgRate/Text").GetComponent<Text>().text
dataContent.Find("Table/MaxRate/Text").GetComponent<Text>().text
= $"{_model.MaxRate.ToString("#0")} SPM";
dataContent.Find("ChartPace/Avg/Value").GetComponent<Text>().text
= $"{TimeSpan.FromSeconds(_model.AvgPace).ToString(@"mm\:ss")} /500M";
@@ -84,18 +84,23 @@ public class RowerResult : PFUIPanel
= _model.StrokeCount.ToString();
//var b = _model.ChartList.Select((x, i) => new DoubleVector2(i, ChartDateUtility.TimeSpanToValue(TimeSpan.FromMinutes(x.Pace + UnityEngine.Random.value * 300)))).ToList();
//Debug.Log(_model.ChartList.Select((x, i) => new DoubleVector2(i, ChartDateUtility.TimeSpanToValue(TimeSpan.FromMinutes(x.Pace + UnityEngine.Random.value * 300)))).ToList());
//var a = new List<DoubleVector2>();
//for (int i = 0; i < 20000; i++)
//{
// a.Add(new DoubleVector2(i, UnityEngine.Random.value * 200));
//}
chartPace.GetComponent<RowerLargeDataFeed>()
.SetData(_model.ChartList.Select((x, i) =>
.SetData(_model.ChartList.Select((x, i) =>
{
if (x.Pace == 0)
{
return new DoubleVector2(i, ChartDateUtility.TimeSpanToValue(TimeSpan.FromHours(15))-2000);
return new DoubleVector2(i, ChartDateUtility.TimeSpanToValue(TimeSpan.FromHours(15)) - 2000);
}
else
else
{
return new DoubleVector2(i, ChartDateUtility.TimeSpanToValue(TimeSpan.FromMinutes(x.Pace)));
}
}).ToList());
chartRate.GetComponent<RowerLargeDataFeed>()
.SetData(_model.ChartList.Select((x, i) => new DoubleVector2(i, x.Rate)).ToList());
+9
View File
@@ -201,6 +201,15 @@ public class UIManager : MonoBehaviour
UIManager.Show(UIManager.Instance.DownloadWorkoutsModal, null, true);
//UIManager.Show(UIManager.Instance.RaceListPanel, UIManager.Instance.MainPanel);
}
public static void CloseConfirm3()
{
if (UIManager.Instance.confirm3 != null)
{
UIManager.Instance.confirm3.Close();
}
}
/*比赛列表*/
/*划船机页面*/
//自由滑