倒计时;三按钮弹窗

This commit is contained in:
Caiyanpeng committed 2021-09-28 17:51:58 +08:00
1 parent 85e0a13f08
commit b74c3b57b4
17 files changed
+2913 -1352

No files matched your search

@@ -65,6 +65,8 @@ public class RowerHomeScript : PFUIPanel
List<TempRowerCalc> values;
DateTime startTime,createTime;
double Kj = 0;
int seconds = 0;
bool isPause = false;
protected override void Awake()
{
spriteDict = new Dictionary<object, Sprite>()
@@ -117,33 +119,51 @@ public class RowerHomeScript : PFUIPanel
//return;
if (btnStart.CompareTag("Start"))
{
#if !UNITY_EDITOR
if (RowerData == null)
{
Utils.showToast(null, "Please connect the device!");
return;
}
if (RowerData != null)
#endif
UIManager.ShowCountDownAnimation(() =>
{
RowerData.PullChanged += PaintPullCurveDelegate;
}
btnStart.GetComponent<Image>().sprite = spriteDict["Untagged"];
startTime = UIManager.Now.GetDateTime();
TimerTicks();
openTimer = true;
timer = 1.0f;
btnStart.tag = "Untagged";
if (RowerData != null)
{
RowerData.PullChanged += PaintPullCurveDelegate;
}
if (!isPause)
{
startTime = UIManager.Now.GetDateTime();
}
TimerTicks();
openTimer = true;
timer = 1.0f;
btnStart.GetComponent<Image>().sprite = spriteDict["Untagged"];
btnStart.tag = "Untagged";
});
}
else
{
UIManager.ShowConfirm("Quit", "Do you want to keep the record?", () =>
{
UIManager.CloseConfirm();
Save();
Init();
},cancel:()=>
{
Init();
});
UIManager.ShowConfirm3("Quit", "Do you want to keep the record?",
() =>
{
UIManager.CloseConfirm();
Save();
Init();
},
()=>
{
Init();
},
()=>
{
openTimer = false;
isPause = true;
RowerData.PullChanged -= PaintPullCurveDelegate;
btnStart.GetComponent<Image>().sprite = spriteDict["Start"];
btnStart.tag = "Start";
});
}
Debug.Log(RowerData);
//StartCoroutine();
@@ -169,11 +189,11 @@ public class RowerHomeScript : PFUIPanel
if (values.Count > 0)
{
model.MaxPower = values.Max(x => x.power);
model.MaxPace = values.Min(x => x.pace);
model.MaxPace = values.Where(x => x.pace > 0).Min(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.Average(x => x.pace);
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);
}
@@ -241,6 +261,8 @@ public class RowerHomeScript : PFUIPanel
values = new List<TempRowerCalc>();
Kj = 0;
x = 0;
seconds = 0;
isPause = false;
}
private void ReturnHome()
{
@@ -261,7 +283,7 @@ public class RowerHomeScript : PFUIPanel
//PaintPullCurve(tempList[(tempx++) % tempList.Count]);
if (RowerData == null) return;
bottom.Find("Time/Value").GetComponent<Text>().text = TimeSpan.FromSeconds(RowerData.ElapsedTime).ToString();
bottom.Find("Time/Value").GetComponent<Text>().text = TimeSpan.FromSeconds(seconds++).ToString();
bottom.Find("KM/Value").GetComponent<Text>().text = RowerData.TotalDistance.ToString();
var power = RowerData.InstantaneousPower;
bottom.Find("W/Value").GetComponent<Text>().text = power.ToString();
@@ -292,8 +314,10 @@ public class RowerHomeScript : PFUIPanel
{
if (y > 1000) y = 1000;
//拉力条
left.Find("LeftImage/Value").GetComponent<Image>().fillAmount = ((float)y) / 1000;
left.Find("RightImage/Value").GetComponent<Image>().fillAmount = ((float)y) / 1000;
var rate = ((float)y) * 2 / 1000;
if (rate > 1) rate = 1;
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];
//曲线