划船机其他细节

This commit is contained in:
CaiYanPeng 2021-10-22 16:21:00 +08:00
parent a4e17a56d0
commit eb21914fb7
8 changed files with 1949 additions and 1667 deletions

File diff suppressed because it is too large Load Diff

View File

@ -107,7 +107,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: adb30198aa32dd140b5750692dd48104, type: 3} m_Script: {fileID: 11500000, guid: adb30198aa32dd140b5750692dd48104, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
radius: 48 radius: 24
--- !u!225 &1578934454411558168 --- !u!225 &1578934454411558168
CanvasGroup: CanvasGroup:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -195,7 +195,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 78, y: 0} m_AnchoredPosition: {x: 20, y: 0}
m_SizeDelta: {x: 0, y: 36} m_SizeDelta: {x: 0, y: 36}
m_Pivot: {x: 0, y: 0.5} m_Pivot: {x: 0, y: 0.5}
--- !u!222 &5181308658082223272 --- !u!222 &5181308658082223272
@ -262,7 +262,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 0
--- !u!224 &2903393643563272319 --- !u!224 &2903393643563272319
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -277,9 +277,9 @@ RectTransform:
m_Father: {fileID: 1673166913076064936} m_Father: {fileID: 1673166913076064936}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 44, y: -48}
m_SizeDelta: {x: 48, y: 48} m_SizeDelta: {x: 48, y: 48}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &7027635956731480168 --- !u!222 &7027635956731480168

View File

@ -107,7 +107,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: adb30198aa32dd140b5750692dd48104, type: 3} m_Script: {fileID: 11500000, guid: adb30198aa32dd140b5750692dd48104, type: 3}
m_Name: m_Name:
m_EditorClassIdentifier: m_EditorClassIdentifier:
radius: 23 radius: 12
--- !u!225 &1578934454411558168 --- !u!225 &1578934454411558168
CanvasGroup: CanvasGroup:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -195,7 +195,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 54, y: 0} m_AnchoredPosition: {x: 20, y: 0}
m_SizeDelta: {x: 0, y: 19} m_SizeDelta: {x: 0, y: 19}
m_Pivot: {x: 0, y: 0.5} m_Pivot: {x: 0, y: 0.5}
--- !u!222 &5181308658082223272 --- !u!222 &5181308658082223272
@ -262,7 +262,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 0
--- !u!224 &2903393643563272319 --- !u!224 &2903393643563272319
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -277,9 +277,9 @@ RectTransform:
m_Father: {fileID: 1673166913076064936} m_Father: {fileID: 1673166913076064936}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 32, y: -24}
m_SizeDelta: {x: 24, y: 24} m_SizeDelta: {x: 24, y: 24}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &7027635956731480168 --- !u!222 &7027635956731480168

View File

@ -192,9 +192,11 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
var val = BitConverter.ToUInt16(data, pullB); var val = BitConverter.ToUInt16(data, pullB);
list.Add(val); list.Add(val);
PullValue = val; PullValue = val;
} }
Debug.Log("拉力:" + string.Join(",",list));
} }
Debug.Log("原始数据:" + string.Join(",", data)); //Debug.Log("原始数据:" + string.Join(",", data));
} }
public void Reset() public void Reset()
{ {

View File

@ -34,7 +34,7 @@ public class RowerHomeScript : PFUIPanel
{ {
get get
{ {
var device = App.MainDeviceAdapter.GetDevices().FirstOrDefault(d => (d.State == DeviceState.Connected || d.State == DeviceState.Connecting) && d.Sensor == SensorType.Rower); var device = App.MainDeviceAdapter.GetDevices().FirstOrDefault(d => (d.State == DeviceState.Connected) && d.Sensor == SensorType.Rower);
if (device != null) if (device != null)
{ {
return ((IRowerDevice)device).rowerData; return ((IRowerDevice)device).rowerData;
@ -152,14 +152,19 @@ public class RowerHomeScript : PFUIPanel
} }
App.MainDeviceAdapter.StopScan(); App.MainDeviceAdapter.StopScan();
} }
void HandleDiscardDirect()
{
openTimer = false;
isPause = true;
Debug.Log(RowerData);
btnStart.GetComponent<Image>().sprite = spriteDict["Start"];
btnStart.tag = "Start";
Init();
}
void HandleSaveDirect() void HandleSaveDirect()
{ {
openTimer = false; openTimer = false;
isPause = true; isPause = true;
if (RowerData != null)
{
RowerData.PullChanged -= PaintPullCurveDelegate;
}
btnStart.GetComponent<Image>().sprite = spriteDict["Start"]; btnStart.GetComponent<Image>().sprite = spriteDict["Start"];
btnStart.tag = "Start"; btnStart.tag = "Start";
Save(); Save();
@ -182,11 +187,11 @@ public class RowerHomeScript : PFUIPanel
{ {
if (RowerData != null) if (RowerData != null)
{ {
RowerData.PullChanged -= PaintPullCurveDelegate;
RowerData.PullChanged += PaintPullCurveDelegate; RowerData.PullChanged += PaintPullCurveDelegate;
} }
if (!isPause) if (!isPause)
{ {
startTime = UIManager.Now.GetDateTime(); startTime = UIManager.Now.GetDateTime();
} }
TimerTicks(); TimerTicks();
@ -207,10 +212,6 @@ public class RowerHomeScript : PFUIPanel
{ {
openTimer = false; openTimer = false;
isPause = true; isPause = true;
if (RowerData != null)
{
RowerData.PullChanged -= PaintPullCurveDelegate;
}
btnStart.GetComponent<Image>().sprite = spriteDict["Start"]; btnStart.GetComponent<Image>().sprite = spriteDict["Start"];
btnStart.tag = "Start"; btnStart.tag = "Start";
UIManager.ShowConfirm3("Quit", "Do you want to keep the record?", UIManager.ShowConfirm3("Quit", "Do you want to keep the record?",
@ -303,7 +304,6 @@ public class RowerHomeScript : PFUIPanel
{ {
if (RowerData != null) if (RowerData != null)
{ {
RowerData.PullChanged -= PaintPullCurveDelegate;
RowerData.Reset(); RowerData.Reset();
} }
if (Rower != null) if (Rower != null)
@ -321,6 +321,7 @@ public class RowerHomeScript : PFUIPanel
transform.Find("Mid/GraphChart").GetComponent<RowerGraphChartFeed>().SetData(pullList); transform.Find("Mid/GraphChart").GetComponent<RowerGraphChartFeed>().SetData(pullList);
openTimer = false; openTimer = false;
bottom.Find("Time/Value").GetComponent<Text>().text = "---"; bottom.Find("Time/Value").GetComponent<Text>().text = "---";
bottom.Find("TrueTime/Value").GetComponent<Text>().text = "---";
bottom.Find("KM/Value").GetComponent<Text>().text = "---"; bottom.Find("KM/Value").GetComponent<Text>().text = "---";
bottom.Find("W/Value").GetComponent<Text>().text = "---"; bottom.Find("W/Value").GetComponent<Text>().text = "---";
bottom.Find("W/AvgValue").GetComponent<Text>().text = "---"; bottom.Find("W/AvgValue").GetComponent<Text>().text = "---";
@ -354,15 +355,20 @@ public class RowerHomeScript : PFUIPanel
double x = 0f; double x = 0f;
List<ushort> tempList = new List<ushort>() //List<ushort> tempList = new List<ushort>()
{ //{
0,1,4,500,12,13,16,0,0,0,20,30,40,50,60,500 // 0,1,4,500,12,13,16,0,0,0,20,30,40,50,60,500
}; //};
int tempx = 0; //int tempx = 0;
void TimerTicks() void TimerTicks()
{ {
//Debug.Log(123); //Debug.Log(123);
PaintPullCurve(tempList[(tempx++) % tempList.Count]); //PaintPullCurve(tempList[(tempx++) % tempList.Count]);
if (Rower == null)
{
HandleDiscardDirect();
return;
}
if (RowerData == null) return; if (RowerData == null) return;
var heartRate = HeartRate ?? 0; var heartRate = HeartRate ?? 0;
bottom.Find("BPM/Value").GetComponent<Text>().text = heartRate.ToString(); bottom.Find("BPM/Value").GetComponent<Text>().text = heartRate.ToString();
@ -381,19 +387,24 @@ public class RowerHomeScript : PFUIPanel
HandleSaveDirect(); HandleSaveDirect();
return; return;
} }
else if (stopSeconds == 86)
{
Utils.showToast(null, "Record will be saved", duration: 5, stopFunc: () => stopSeconds < 6, isLowest: true);
return;
}
else if (stopSeconds >= 6) else if (stopSeconds >= 6)
{ {
if (stopSeconds == 6) if (stopSeconds == 6)
{ {
Utils.showToast(null, "Please keep rowing...",duration:5); Utils.showToast(null, "Please keep rowing...", duration: 10, stopFunc: () => stopSeconds < 6, isLowest: true);
} }
bottom.Find("Time/Value").GetComponent<Text>().text = TimeSpan.FromSeconds(seconds++).ToString(); bottom.Find("Time/Value").GetComponent<Text>().text = TimeSpan.FromSeconds(seconds++).ToString();
bottom.Find("W/Value").GetComponent<Text>().text = "--"; bottom.Find("W/Value").GetComponent<Text>().text = "---";
bottom.Find("W/AvgValue").GetComponent<Text>().text = "--"; bottom.Find("W/AvgValue").GetComponent<Text>().text = "---";
bottom.Find("500/Value").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/Value").GetComponent<Text>().text = "---";
bottom.Find("MS/AvgValue").GetComponent<Text>().text = "--"; bottom.Find("MS/AvgValue").GetComponent<Text>().text = "---";
records.Add($"{RowerData.StrokeCount},{RowerData.ElapsedTime},{RowerData.TotalDistance},0,0,0,{RowerData.ResistanceLevel},{heartRate}"); 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 }); values.Add(new TempRowerCalc() { pace = 0, power = 0, rate = 0, heartRate = heartRate });
return; return;
@ -402,6 +413,7 @@ public class RowerHomeScript : PFUIPanel
totalDistance = RowerData.TotalDistance; totalDistance = RowerData.TotalDistance;
bottom.Find("Time/Value").GetComponent<Text>().text = TimeSpan.FromSeconds(seconds++).ToString(); 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(); bottom.Find("KM/Value").GetComponent<Text>().text = totalDistance.ToString();
var power = RowerData.InstantaneousPower; var power = RowerData.InstantaneousPower;
bottom.Find("W/Value").GetComponent<Text>().text = power.ToString(); bottom.Find("W/Value").GetComponent<Text>().text = power.ToString();
@ -437,6 +449,12 @@ public class RowerHomeScript : PFUIPanel
bool isPlay = false; bool isPlay = false;
void PaintPullCurve(ushort y) void PaintPullCurve(ushort y)
{ {
Debug.Log("收到拉力" + y);
if (!openTimer)
{
RowerData.PullChanged -= PaintPullCurveDelegate;
return;
}
if (y > 1200) y = 1200; if (y > 1200) y = 1200;
//拉力条 //拉力条
var rate = ((float)y) * 2 / 1200; var rate = ((float)y) * 2 / 1200;
@ -465,10 +483,14 @@ public class RowerHomeScript : PFUIPanel
isPlay = true; isPlay = true;
pullList.Add(new DoubleVector2(x, y)); pullList.Add(new DoubleVector2(x, y));
} }
//else else
//{ {
// transform.Find("Mid/GraphChart").GetComponent<RowerGraphChartFeed>().SetData(new List<DoubleVector2> ()); //只有0并且两秒没拉曲线消失
//} if (stopSeconds == 1)
{
transform.Find("Mid/GraphChart").GetComponent<RowerGraphChartFeed>().SetData(new List<DoubleVector2>());
}
}
} }
else else
{ {

View File

@ -1,5 +1,6 @@
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
@ -28,15 +29,18 @@ public class Toast : MonoBehaviour
[SerializeField] GameObject toast; [SerializeField] GameObject toast;
[SerializeField] Text txt; [SerializeField] Text txt;
public void showToast(string json) public void showToast(Assets.Scripts.Utils.ToastParams json)
{ {
JObject JO = (JObject)JsonConvert.DeserializeObject(json);
gameObject.SetActive(true); gameObject.SetActive(true);
StartCoroutine(showToastCOR(JO.Value<string>("text"), JO.Value<int>("duration"))); if (json.func == null)
{
json.func = () => false;
}
StartCoroutine(showToastCOR(json.text, json.duration,json.func));
} }
private IEnumerator showToastCOR(string text, private IEnumerator showToastCOR(string text,
int duration) int duration, Func<bool> action)
{ {
gameObject.SetActive(true); gameObject.SetActive(true);
@ -46,7 +50,7 @@ public class Toast : MonoBehaviour
//Wait for the duration //Wait for the duration
float counter = 0; float counter = 0;
while (counter < duration) while (counter < duration && !action.Invoke())
{ {
counter += Time.deltaTime; counter += Time.deltaTime;
yield return null; yield return null;

View File

@ -143,7 +143,7 @@ namespace Assets.Scripts
_deviceDict = value; _deviceDict = value;
} }
} }
public static void showToast(GameObject game,string text,int duration = 2,int type = 0) public static void showToast(GameObject game, string text, int duration = 2, int type = 0, Func<bool> stopFunc = null, bool isLowest = false)
{ {
//type 0错误 1正确 //type 0错误 1正确
var parent = UIManager.Instance.ModalsPanel; var parent = UIManager.Instance.ModalsPanel;
@ -163,13 +163,28 @@ namespace Assets.Scripts
newToast.transform.parent = parent.transform; newToast.transform.parent = parent.transform;
toast = newToast.transform; toast = newToast.transform;
var toastStyle = toastDict[type].Split('|'); var toastStyle = toastDict[type].Split('|');
if (isLowest)
{
toast.SetAsFirstSibling();
}
else
{
toast.SetAsLastSibling();
}
toast.Find("Image").GetComponent<Image>().sprite = Resources.Load<Sprite>(toastStyle[0]); toast.Find("Image").GetComponent<Image>().sprite = Resources.Load<Sprite>(toastStyle[0]);
toast.GetComponent<Image>().color = HexToColorHtml(toastStyle[1]); toast.GetComponent<Image>().color = HexToColorHtml(toastStyle[1]);
toast.GetComponent<Toast>().showToast(JsonConvert.SerializeObject(new toast.GetComponent<Toast>().showToast(new ToastParams
{ {
text, text = text,
duration duration = duration,
})); func = stopFunc
});
}
public class ToastParams
{
public string text { get; set; }
public int duration { get; set; }
public Func<bool> func { get; set; }
} }
/*显示简略提示需要拖Toast的预制件且保证其他组件名字不是Toast,ToastContainer*/ /*显示简略提示需要拖Toast的预制件且保证其他组件名字不是Toast,ToastContainer*/
public static void showLoading(this GameObject game) public static void showLoading(this GameObject game)

View File

@ -38,6 +38,7 @@ GraphicsSettings:
- {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 16000, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 16001, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0} - {fileID: 17000, guid: 0000000000000000f000000000000000, type: 0}
- {fileID: 16003, guid: 0000000000000000f000000000000000, type: 0}
m_PreloadedShaders: [] m_PreloadedShaders: []
m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000, m_SpritesDefaultMaterial: {fileID: 10754, guid: 0000000000000000f000000000000000,
type: 0} type: 0}