划船机保存前读秒

This commit is contained in:
CaiYanPeng 2021-10-25 16:13:04 +08:00
parent eb21914fb7
commit b9aa0131cc
5 changed files with 4348 additions and 4324 deletions

File diff suppressed because it is too large Load Diff

View File

@ -34,6 +34,7 @@ public class LoginControllerMobile : MonoBehaviour, INativeOnMobileWxLoginResp
private void Start() private void Start()
{ {
//Utils.showToast(null,"123",duration:10,showSeconds: true);
transform.Find("MobileInfo/BatteryText").GetComponent<Text>().text = transform.Find("MobileInfo/BatteryText").GetComponent<Text>().text =
$"{Math.Round(SystemInfo.batteryLevel * 100, 0)}%"; $"{Math.Round(SystemInfo.batteryLevel * 100, 0)}%";
transform.Find("MobileInfo/TimeText").GetComponent<Text>().text = transform.Find("MobileInfo/TimeText").GetComponent<Text>().text =

View File

@ -179,7 +179,7 @@ public class RowerHomeScript : PFUIPanel
#if !UNITY_EDITOR #if !UNITY_EDITOR
if (RowerData == null) if (RowerData == null)
{ {
Utils.showToast(null, "Please connect the device!"); Utils.showToast(null, "Please connect the device!", isLowest: true);
return; return;
} }
#endif #endif
@ -343,7 +343,7 @@ public class RowerHomeScript : PFUIPanel
{ {
if (seconds > 0) if (seconds > 0)
{ {
Utils.showToast(null, "Please end this training."); Utils.showToast(null, "Please end this training.", isLowest: true);
return; return;
} }
Disconnect(); Disconnect();
@ -357,18 +357,20 @@ public class RowerHomeScript : PFUIPanel
//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,1230,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) #if !UNITY_EDITOR
if (Rower == null)
{ {
HandleDiscardDirect(); HandleDiscardDirect();
return; return;
} }
#endif
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();
@ -387,16 +389,16 @@ public class RowerHomeScript : PFUIPanel
HandleSaveDirect(); HandleSaveDirect();
return; return;
} }
else if (stopSeconds == 86) else if (stopSeconds == 81)
{ {
Utils.showToast(null, "Record will be saved", duration: 5, stopFunc: () => stopSeconds < 6, isLowest: true); Utils.showToast(null, "Record will be saved", duration: 10, stopFunc: () => stopSeconds < 6, isLowest: true,showSeconds:true);
return; return;
} }
else if (stopSeconds >= 6) else if (stopSeconds >= 6)
{ {
if (stopSeconds == 6) if (stopSeconds == 6)
{ {
Utils.showToast(null, "Please keep rowing...", duration: 10, stopFunc: () => stopSeconds < 6, isLowest: true); Utils.showToast(null, "Please keep rowing...", duration: 60, 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 = "---";
@ -450,12 +452,14 @@ public class RowerHomeScript : PFUIPanel
void PaintPullCurve(ushort y) void PaintPullCurve(ushort y)
{ {
Debug.Log("收到拉力" + y); Debug.Log("收到拉力" + y);
#if !UNITY_EDITOR
if (!openTimer) if (!openTimer)
{ {
RowerData.PullChanged -= PaintPullCurveDelegate; RowerData.PullChanged -= PaintPullCurveDelegate;
return; return;
} }
if (y > 1200) y = 1200; #endif
//if (y > 1200) y = 1200;
//拉力条 //拉力条
var rate = ((float)y) * 2 / 1200; var rate = ((float)y) * 2 / 1200;
if (rate > 1) rate = 1f; if (rate > 1) rate = 1f;

View File

@ -36,23 +36,40 @@ public class Toast : MonoBehaviour
{ {
json.func = () => false; json.func = () => false;
} }
StartCoroutine(showToastCOR(json.text, json.duration,json.func)); StartCoroutine(showToastCOR(json.text, json.duration,json.func,json.showSeconds));
} }
private IEnumerator showToastCOR(string text, private IEnumerator showToastCOR(string text,
int duration, Func<bool> action) int duration, Func<bool> action,bool showSeconds)
{ {
gameObject.SetActive(true); gameObject.SetActive(true);
txt.text = text; if (showSeconds)
{
txt.text = text + $"({duration}s)";
}
else
{
txt.text = text;
}
//Fade in //Fade in
yield return fadeInAndOut(txt, true, 0.5f); yield return fadeInAndOut(txt, true, 0.5f);
//Wait for the duration //Wait for the duration
float counter = 0; float counter = 0,timer = 1f;
int seconds = 0;
while (counter < duration && !action.Invoke()) while (counter < duration && !action.Invoke())
{ {
counter += Time.deltaTime; counter += Time.deltaTime;
if (showSeconds)
{
timer -= Time.deltaTime;
if (timer < 0)
{
txt.text = text + $"({duration - (++seconds)}s)";
timer += 1f;
}
}
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, Func<bool> stopFunc = null, bool isLowest = false) public static void showToast(GameObject game, string text, int duration = 2, int type = 0, Func<bool> stopFunc = null, bool isLowest = false,bool showSeconds = false)
{ {
//type 0错误 1正确 //type 0错误 1正确
var parent = UIManager.Instance.ModalsPanel; var parent = UIManager.Instance.ModalsPanel;
@ -177,11 +177,13 @@ namespace Assets.Scripts
{ {
text = text, text = text,
duration = duration, duration = duration,
func = stopFunc func = stopFunc,
showSeconds = showSeconds
}); });
} }
public class ToastParams public class ToastParams
{ {
public bool showSeconds { get; set; }
public string text { get; set; } public string text { get; set; }
public int duration { get; set; } public int duration { get; set; }
public Func<bool> func { get; set; } public Func<bool> func { get; set; }