倒计时;三按钮弹窗
This commit is contained in:
1 parent
85e0a13f08
commit
b74c3b57b4
17 files changed
+2913
-1352
No files matched your search
@@ -0,0 +1,105 @@
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using DG.Tweening;
|
||||
using Assets.Scripts.UI.Control;
|
||||
using System;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class Confirm3 : PFUIPanel
|
||||
{
|
||||
private PFUIText _title;
|
||||
private PFUIText _content;
|
||||
private PfUIButton _1;
|
||||
private PfUIButton _2;
|
||||
private PfUIButton _3;
|
||||
private UnityAction _action1;
|
||||
private UnityAction _action2;
|
||||
private UnityAction _action3;
|
||||
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
var wrap = this.transform.Find("GameObject");
|
||||
_title = wrap.Find("Title").GetComponent<PFUIText>();
|
||||
_content = wrap.Find("Content").GetComponent<PFUIText>();
|
||||
|
||||
_1 = wrap.Find("Container/Save").GetComponent<PfUIButton>();
|
||||
_2 = wrap.Find("Container/Discard").GetComponent<PfUIButton>();
|
||||
_3 = wrap.Find("Container/Cancel").GetComponent<PfUIButton>();
|
||||
|
||||
UIManager.AddEvent(_1.gameObject, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
if(_action1 != null)
|
||||
{
|
||||
_action1();
|
||||
}
|
||||
});
|
||||
UIManager.AddEvent(_2.gameObject, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
if (_action2 != null)
|
||||
{
|
||||
_action2();
|
||||
}
|
||||
this.Close();
|
||||
});
|
||||
UIManager.AddEvent(_3.gameObject, EventTriggerType.PointerClick, (e) =>
|
||||
{
|
||||
if (_action3 != null)
|
||||
{
|
||||
_action3();
|
||||
}
|
||||
this.Close();
|
||||
});
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
protected override void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Set(string title, string content, UnityAction action1,UnityAction action2, UnityAction action3)
|
||||
{
|
||||
//if(text == null)
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
//text.text = txt;
|
||||
_title.Text = title;
|
||||
_content.Text = content;
|
||||
_action1 = action1;
|
||||
_action2 = action2;
|
||||
_action3 = action3;
|
||||
}
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Show()
|
||||
{
|
||||
var panel = this.transform.Find("Panel");
|
||||
var bg = panel.GetComponent<Image>();
|
||||
//bg.alphaHitTestMinimumThreshold
|
||||
|
||||
var color = bg.color;
|
||||
color.a = 0.6f;
|
||||
bg.color = color;
|
||||
base.Show();
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
var panel = this.transform.Find("Panel");
|
||||
var bg = panel.GetComponent<Image>();
|
||||
|
||||
bg.DOFade(0, 0.2f).OnComplete(() =>
|
||||
{
|
||||
this.gameObject.SetActive(false);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d1cc442a4153c84796605310af517e3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -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];
|
||||
//曲线
|
||||
|
||||
@@ -116,7 +116,10 @@ public class RouteItem : MonoBehaviour
|
||||
{
|
||||
UIManager.AddEvent(btnReRide.gameObject, EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
UIManager.ShowRowerPanel();
|
||||
UIManager.ShowConfirm("Re-Rowing", "Rowing again?", () =>
|
||||
{
|
||||
UIManager.ShowRowerPanel();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ public partial class RowerLargeDataFeed : MonoBehaviour, IComparer<DoubleVector2
|
||||
LoadWithoutDownSampling(start, end);
|
||||
else
|
||||
LoadWithDownSampling(start, end);
|
||||
graph.DataSource.MakeCurveCategorySmooth(Category);
|
||||
//graph.DataSource.MakeCurveCategorySmooth(Category);
|
||||
graph.DataSource.EndBatch();
|
||||
graph.HorizontalScrolling = pagePosition;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class RowerResult : PFUIPanel
|
||||
dataContent.Find("Table/AvgHR/Text").GetComponent<Text>().text
|
||||
= $"{_model.MaxHeartRate} BPM";
|
||||
dataContent.Find("Table/AvgRate/Text").GetComponent<Text>().text
|
||||
= $"{_model.MaxRate.ToString("#0")} W";
|
||||
= $"{_model.MaxRate.ToString("#0")} SPM";
|
||||
dataContent.Find("ChartPace/Avg/Value").GetComponent<Text>().text
|
||||
= $"{TimeSpan.FromSeconds(_model.AvgPace).ToString(@"mm\:ss")} /500M";
|
||||
dataContent.Find("ChartRate/Avg/Value").GetComponent<Text>().text
|
||||
@@ -85,7 +85,18 @@ public class RowerResult : PFUIPanel
|
||||
//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());
|
||||
chartPace.GetComponent<RowerLargeDataFeed>()
|
||||
.SetData(_model.ChartList.Select((x, i) => new DoubleVector2(i, ChartDateUtility.TimeSpanToValue(TimeSpan.FromMinutes(x.Pace)))).ToList());
|
||||
.SetData(_model.ChartList.Select((x, i) =>
|
||||
{
|
||||
if (x.Pace == 0)
|
||||
{
|
||||
return new DoubleVector2(i, ChartDateUtility.TimeSpanToValue(TimeSpan.FromHours(15))-2000);
|
||||
}
|
||||
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());
|
||||
chartHR.GetComponent<RowerLargeDataFeed>()
|
||||
|
||||
@@ -17,7 +17,9 @@ public class RowerWelldone : PFUIPanel
|
||||
{
|
||||
UIManager.AddEvent(transform.Find("BtnDefine").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
Close();
|
||||
UIManager.ShowHomePanel();
|
||||
UIManager.ShowUserInfoPanel();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user