修改细节,修复bug

This commit is contained in:
Caiyanpeng committed 2022-04-01 18:07:16 +08:00
1 parent 06aefb93c4
commit 30e09c9c7a
15 files changed
+3566 -3347

No files matched your search

@@ -51,6 +51,12 @@ public class RowerHomeScript : PFUIPanel
protected override void OnDestroy()
{
Debug.Log("銷毀");
if (RowerCommonDataInstance != null)
{
RowerCommonDataInstance.PullChanged -= PaintPullCurve;
}
C2RowerData.EnableChanged -= ModeChanged;
FtmsRowerData.RowerResChanged -= ResChanged;
}
private IRowerDevice Rower
@@ -183,7 +189,7 @@ public class RowerHomeScript : PFUIPanel
var nav = transform.Find("MainNav-mobile").GetComponent<NewMainNav>();
var c1 = new NewMainNav.CustomButton(Resources.Load<Sprite>("Images/RowerNew/ICON_create_44"), () =>
{
//UIManager.ShowRowerWelldone("81A85D49-ACAA-C764-101A-02555E6AC81A");
//UIManager.ShowRowerWelldone("3026214f-e6e0-4297-8668-f7177dbaebe4");
//return;
if (checkRowing()) return;
if (C2RowerData.IsEnabled == true && C2RowerData.rowerType != null) return;
@@ -191,7 +197,7 @@ public class RowerHomeScript : PFUIPanel
{
rowerType = type;
HandleSelectType();
});
},rowerType);
}, false);
//var c2 = new NewMainNav.CustomButton(Resources.Load<Sprite>("Images/RowerNew/ICON_continue_44"), () =>
//{
@@ -212,21 +218,29 @@ public class RowerHomeScript : PFUIPanel
});
UIManager.AddEvent(transform.Find("Stopped/Confirm/BtnDrop").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
transform.Find("Stopped").gameObject.SetActive(false);
openTimer = false;
isPause = true;
if (C2RowerData.IsEnabled == true)
{
Utils.showToast(null, "Please press Menu to save.",int.MaxValue, stopFunc: () => C2RowerData.isReadyStatus, endCallback: Init);
}
else
{
Init();
}
Discard();
});
if (RowerCommonDataInstance != null)
{
RowerCommonDataInstance.PullChanged -= PaintPullCurve;
RowerCommonDataInstance.PullChanged += PaintPullCurve;
}
Init();
}
private void Discard()
{
transform.Find("Stopped").gameObject.SetActive(false);
openTimer = false;
isPause = true;
if (C2RowerData.IsEnabled == true)
{
Utils.showToast(null, @"Press ""Menu"" to save.", int.MaxValue, stopFunc: () => C2RowerData.isReadyStatus, endCallback: Init);
}
else
{
Init();
}
}
private void HandleSelectType()
{
@@ -290,7 +304,7 @@ public class RowerHomeScript : PFUIPanel
};
if (C2RowerData.IsEnabled == true)
{
Utils.showToast(null, "Please press Menu to save.",int.MaxValue, stopFunc: () => C2RowerData.isReadyStatus, endCallback: f);
Utils.showToast(null, @"Press ""Menu"" to save.", int.MaxValue, stopFunc: () => C2RowerData.isReadyStatus, endCallback: f);
}
else
{
@@ -364,6 +378,12 @@ public class RowerHomeScript : PFUIPanel
private void StartFunc()
{
//设定一个标准 如果满足条件不让他开始
if (C2RowerData.IsEnabled && RowerData != null && RowerData.ElapsedTime >= 5)
{
Utils.showToast(null, @"Press ""Menu"" to save.", stopFunc: () => RowerData.ElapsedTime < 5);
return;
}
if (!isPause)
{
startTime = UIManager.Now.GetDateTime();
@@ -409,10 +429,10 @@ public class RowerHomeScript : PFUIPanel
model.AvgPower = values.Average(x => x.power);
model.AvgRate = values.Average(x => x.rate);
model.AvgHeartRate = (int)values.Average(x => x.heartRate);
model.StrokeCount = (ushort)values.Max(x=>x.strokeCount);
model.TotalDistance = (ushort)values.Max(x => x.distance);
}
model.StrokeCount = RowerData.StrokeCount;
model.TotalTime = RowerData.ElapsedTime;
model.TotalDistance = RowerData.TotalDistance;
model.Type = rowerType.type == 0 ? (int?)null : rowerType.type;
model.TypeValue = rowerType.value == 0 ? (float?)null : rowerType.value;
model.ShadowIds = string.Join(",",GetComponent<RowerMultiModeScript>().shadowList.Select(x=>x.Nid));
@@ -523,9 +543,11 @@ public class RowerHomeScript : PFUIPanel
private void ModeChanged(object sender, EventArgs e)
{
print("增加服务"+RowerData.ResistanceLevel);
RowerCommonDataInstance.PullChanged -= PaintPullCurve;
RowerCommonDataInstance.PullChanged += PaintPullCurve;
if (RowerCommonDataInstance != null)
{
RowerCommonDataInstance.PullChanged -= PaintPullCurve;
RowerCommonDataInstance.PullChanged += PaintPullCurve;
}
slider.GetComponent<Slider>().interactable = !(bool)sender;
transform.Find("ResBar/BtnSub").GetComponent<Button>().interactable = !(bool)sender;
transform.Find("ResBar/BtnAdd").GetComponent<Button>().interactable = !(bool)sender;
@@ -534,13 +556,14 @@ public class RowerHomeScript : PFUIPanel
private void ResChanged(object sender, EventArgs e)
{
print("收到阻力" + sender);
if ((Convert.ToSingle(sender) > 50))
if ((Convert.ToSingle(sender) > 50) && slider)
{
slider.GetComponent<PFUISlider>().SetValue((Convert.ToSingle(sender) - 50) / 300f);
}
}
public bool checkRowing()
{
if (seconds > 0)
@@ -590,27 +613,18 @@ public class RowerHomeScript : PFUIPanel
var power = RowerData.InstantaneousPower;
var rate = RowerData.StrokeRate;
TempRowerCalc tmpdata = null;
//里程停止逻辑
if (totalDistance == RowerData.TotalDistance)
{
//判定一次停止
stopSeconds++;
}
else
else
{
stopSeconds = 0;
transform.Find("Stopped").gameObject.SetActive(false);
}
//if (stopSeconds >= 91)
//{
// Debug.Log("保存");
// HandleSaveDirect();
// return;
//}
//else if (stopSeconds == 81)
//{
// Utils.showToast(null, "Record will be saved!", duration: 10, stopFunc: () => stopSeconds < 6, isLowest: true,showSeconds:true);
// return;
//}
if (stopSeconds >= 2)
{
transform.Find("Stopped").gameObject.SetActive(true);
@@ -620,8 +634,8 @@ public class RowerHomeScript : PFUIPanel
//}
if (rowerType.type == 2)
{
var remainTime = rowerType.value - (seconds++);
if (remainTime == 0)
var remainTime = rowerType.value - (++seconds);
if (remainTime == 0)
{
records.Add($"{strokeCount},{RowerData.ElapsedTime},{distance},0,0,0,{RowerData.ResistanceLevel},{heartRate},{energy}");
tmpdata = new TempRowerCalc() { strokeCount = strokeCount, pace = 0, power = 0, rate = 0, heartRate = heartRate, distance = distance, energy = energy };
@@ -633,9 +647,9 @@ public class RowerHomeScript : PFUIPanel
TimeSpan.FromSeconds(remainTime).ToPFString();
bottom.Find("Time/Value").GetComponent<Text>().text = TimeSpan.FromSeconds(remainTime).ToPFString();
}
else
else
{
bottom.Find("Time/Value").GetComponent<Text>().text = TimeSpan.FromSeconds(seconds++).ToPFString();
bottom.Find("Time/Value").GetComponent<Text>().text = TimeSpan.FromSeconds(++seconds).ToPFString();
}
mid.Find("W/Value").GetComponent<Text>().text = "---";
//bottom.Find("W/AvgValue").GetComponent<Text>().text = "---";
@@ -650,7 +664,7 @@ public class RowerHomeScript : PFUIPanel
SendDataToRace(tmpdata);
return;
}
totalDistance = (uint)distance;
var pace = RowerData.InstantaneousPace;
@@ -697,7 +711,7 @@ public class RowerHomeScript : PFUIPanel
}
if (rowerType.type == 2)
{
var remainTime = rowerType.value - (seconds++);
var remainTime = rowerType.value - (++seconds);
bottom.Find("Time/Value").GetComponent<Text>().text = TimeSpan.FromSeconds(remainTime).ToPFString();
if (remainTime == 0)
{
@@ -711,12 +725,12 @@ public class RowerHomeScript : PFUIPanel
}
else
{
bottom.Find("Time/Value").GetComponent<Text>().text = TimeSpan.FromSeconds(seconds++).ToPFString();
bottom.Find("Time/Value").GetComponent<Text>().text = TimeSpan.FromSeconds(++seconds).ToPFString();
}
if (rowerType.type == 1)
{
var remainDistance = rowerType.value - totalDistance;
if (remainDistance < 0)
if (remainDistance <= 0)
{
bottom.Find("KM/Value").GetComponent<Text>().text = "0";
records.Add($"{strokeCount},{RowerData.ElapsedTime},{distance},{RowerData.InstantaneousPower},{RowerData.InstantaneousPace},{RowerData.StrokeRate},{RowerData.ResistanceLevel},{heartRate},{energy}");
@@ -732,10 +746,15 @@ public class RowerHomeScript : PFUIPanel
{
bottom.Find("KM/Value").GetComponent<Text>().text = totalDistance.ToString();
}
records.Add($"{strokeCount},{RowerData.ElapsedTime},{distance},{RowerData.InstantaneousPower},{RowerData.InstantaneousPace},{RowerData.StrokeRate},{RowerData.ResistanceLevel},{heartRate},{energy}");
tmpdata = new TempRowerCalc() { strokeCount = strokeCount, pace = pace, power = power, rate = rate, heartRate = heartRate, distance = distance, energy = energy };
values.Add(tmpdata);
SendDataToRace(tmpdata);
if (C2RowerData.IsEnabled == true && C2RowerData.isReadyStatus && values.Count()>10)
{
HandleSaveDirect();
}
//Debug.Log(1);
}
void SendDataToRace(TempRowerCalc tmpdata)
@@ -116,6 +116,10 @@ public class RowerMultiModeScript : MonoBehaviour
_distance = _list[currentSecond].Distance;
}
x.currentDistance = _distance;
if (x.isMine && rowerType.type == 1 && x.currentDistance > rowerType.value)
{
x.currentDistance = (int)rowerType.value;
}
});
}
userList = userList.OrderByDescending(x => x.currentDistance).ToList();
@@ -195,7 +199,14 @@ public class RowerMultiModeScript : MonoBehaviour
t.gameObject.SetActive(true);
TweenCallback callback = () =>
{
Utils.DisplayImageTempDict(t.Find("Left/Avatar").GetComponent<RawImage>(), data.Avatar, caches);
if (string.IsNullOrEmpty(data.Avatar))
{
t.Find("Left/Avatar").GetComponent<RawImage>().texture = null;
}
else
{
Utils.DisplayImageTempDict(t.Find("Left/Avatar").GetComponent<RawImage>(), data.Avatar, caches);
}
var _c = countryList.SingleOrDefault(x => x.country == data.Country);
if (_c != null)
{
@@ -287,12 +298,12 @@ public class RowerMultiModeScript : MonoBehaviour
{
diffWidth = 100 - ((int)rowerType.value - data.currentDistance);
}
if (data.isMine)
{
print("diff:" + diffWidth + ";"+ rowerType.type);
}
//if (data.isMine)
//{
// print("diff:" + diffWidth + ";"+ rowerType.type);
//}
if (diffWidth >= 0 && diffWidth <= 100)
{
{
var tWidth = (diffWidth / 100f) * width;
t.Find("Main/Boat").gameObject.SetActive(true);
//t.Find("Main/Boat").localPosition = new Vector3(25 + tWidth, t.Find("Main/Boat").localPosition.y, t.Find("Main/Boat").localPosition.z);
@@ -359,21 +370,27 @@ public class RowerMultiModeScript : MonoBehaviour
{
game.transform.Find("Content/Country").GetComponent<Image>().sprite = Resources.Load<Sprite>(_c.source);
}
int _d = 0, _p = 0;
if (currentSecond < 0 || item.list.Count == 0)
{
game.transform.Find("Content/Time").GetComponent<Text>().text = "0M";
game.transform.Find("Content/Power").GetComponent<Text>().text = "0W";
}
else if (currentSecond >= 0 && currentSecond < item.list.Count)
{
game.transform.Find("Content/Time").GetComponent<Text>().text = item.list[currentSecond].Distance.ToString("#0M");
game.transform.Find("Content/Power").GetComponent<Text>().text = item.list[currentSecond].Power.ToString("#0W");
_d = item.list[currentSecond].Distance;
_p = item.list[currentSecond].Power;
}
else
{
game.transform.Find("Content/Time").GetComponent<Text>().text = item.list[item.list.Count - 1].Distance.ToString("#0M");
game.transform.Find("Content/Power").GetComponent<Text>().text = item.list[item.list.Count - 1].Power.ToString("#0W");
_d = item.list[item.list.Count - 1].Distance;
_p = item.list[item.list.Count - 1].Power;
}
if (item.isMine && rowerType.type == 1 && _d > rowerType.value)
{
_d = (int)rowerType.value;
}
game.transform.Find("Content/Time").GetComponent<Text>().text = $"{_d}M";
game.transform.Find("Content/Power").GetComponent<Text>().text = $"{_p}W";
if (item.isMine)
{
game.transform.Find("Content/Time").GetComponent<Text>().color = Utils.HexToColorHtml("#f93086");
@@ -458,30 +475,56 @@ public class RowerMultiModeScript : MonoBehaviour
return;
}
var offset = pan.deltaTranslation;
if (scroll.localPosition.x >= 30 || scroll.localPosition.x <= -760) return;
scroll.localPosition += new Vector3(offset.x, 0, 0);
}
};
pan.gestureCompleteEvent += (r) =>
{
float x = 0;
foreach (Transform t in transform.Find("Rower/Dots"))
string selDot = "";
if (Color.Equals(transform.Find("Rower/Dots/d1").GetComponent<Image>().color, Utils.HexToColorHtml("#f93086")))
{
if (scroll.localPosition.x >= startPosition.x - ((730 * 1) / 10))
{
x = startPosition.x;
selDot = "d1";
}
else
{
print(491);
x = startPosition.x - 730;
selDot = "d2";
}
}
else
{
if (scroll.localPosition.x >= startPosition.x - ((730 * 9) / 10))
{
x = startPosition.x;
selDot = "d1";
}
else
{
x = startPosition.x - 730;
selDot = "d2";
}
}
foreach (Transform t in transform.Find("Rower/Dots"))
{
t.GetComponent<Image>().color = Utils.HexToColorHtml("#ffffff");
}
if (scroll.localPosition.x >= startPosition.x - (730 / 2))
{
x = startPosition.x;
transform.Find("Rower/Dots/d1").GetComponent<Image>().color = Utils.HexToColorHtml("#f93086");
}
else
{
x = startPosition.x - 730;
transform.Find("Rower/Dots/d2").GetComponent<Image>().color = Utils.HexToColorHtml("#f93086");
}
transform.Find($"Rower/Dots/{selDot}").GetComponent<Image>().color = Utils.HexToColorHtml("#f93086");
scroll.DOLocalMoveX(x, 0.5f);
PlayerPrefs.SetFloat("RowerMultiModeLocationX", x);
};
TouchKit.addGestureRecognizer(pan);
print("注册触摸事件");
}
private void OnDestroy()
{
TouchKit.removeAllGestureRecognizers();
}
//交换A,B索引的赛道
void ChangeTrace(int indexA, int indexB)
@@ -24,7 +24,7 @@ public class RowerTaskPanel : PFUIPanel
public float value { get; set; }
}
Transform selector, distance, time;
RowerType rowerType;
public RowerType rowerType;
public Action<RowerType> callBack { get; set; }
@@ -84,12 +84,18 @@ public class RowerTaskPanel : PFUIPanel
{
base.Show();
InitAll();
InitValue();
}
private void Go()
{
if (rowerType.type == 0 || rowerType.value == 0)
{
Utils.showToast(null, "请选择课程");
Utils.showToast(null, "Please select a course.", isOnly:true);
return;
}
if (rowerType.type == 1 && rowerType.value < 100)
{
Utils.showToast(null, "Minimum mileage is 100M.", isOnly: true);
return;
}
if (callBack != null)
@@ -129,7 +135,7 @@ public class RowerTaskPanel : PFUIPanel
}
if (float.TryParse(s, out float b))
{
if (b < 0 || b > 59)
if (b < 0 || b > 59)
{
Utils.showToast(null, "Please enter an integer between 0-59.");
time.Find("CustomizeS").GetComponent<InputField>().text = "";
@@ -151,6 +157,7 @@ public class RowerTaskPanel : PFUIPanel
btn.onClick.RemoveAllListeners();
btn.onClick.AddListener(() =>
{
InitAll();
rowerType.type = btn.transform.parent.name == "Distance" ? 1 : 2;
if (calcButton == null)
{
@@ -168,6 +175,16 @@ public class RowerTaskPanel : PFUIPanel
var input = item as PFUIInputField;
input.CustomSelect = () =>
{
string ignoreName = null;
if (input.name == "CustomizeMin")
{
ignoreName = "CustomizeS";
}
else if (input.name == "CustomizeS")
{
ignoreName = "CustomizeMin";
}
InitAll(ignoreName);
ClickDistanceBtn(null, btns);
rowerType.type = input.transform.parent.name == "Distance" ? 1 : 2;
SetTextColor(input.gameObject, true);
@@ -220,22 +237,68 @@ public class RowerTaskPanel : PFUIPanel
bg.GetComponent<Outline>().enabled = false;
}
}
private void InitAll()
public readonly Dictionary<int, List<double>> stdList = new Dictionary<int, List<double>>
{
{ 1,new List<double>() { 500,1000,2000,5000,10000 }},
{ 2,new List<double>() { 1800 }}
};
private void InitAll(string igName = null)
{
foreach (var item in formList)
{
if (item is Button)
{
SetButtonColor(item as Button, false);
var btn = item as Button;
if (btn.name == igName) continue;
SetButtonColor(btn, false);
}
else
{
var i = item as PFUIInputField;
if (i.name == igName) continue;
i.Text = "";
}
}
}
private void InitValue()
{
foreach (var item in formList)
{
if (item is Button)
{
var btn = item as Button;
var flag = (rowerType.type == 1 && string.Equals(rowerType.value.ToString(), btn.name.Replace("Btn", ""))) ||
(rowerType.type == 2 && rowerType.value == 1800 && btn.name == "Btn30");
SetButtonColor(btn, flag);
}
else
{
var i = item as PFUIInputField;
i.Text = "";
if (stdList.ContainsKey(rowerType.type) && !stdList[rowerType.type].Contains(rowerType.value))
{
if (rowerType.type == 1 && i.name == "Customize")
{
i.Text = rowerType.value.ToString();
}
else if (rowerType.type == 2)
{
var ts = TimeSpan.FromSeconds(rowerType.value);
if (i.name == "CustomizeMin")
{
i.Text = ts.Minutes.ToString();
}
else if (i.name == "CustomizeS")
{
i.Text = ts.Seconds.ToString();
}
}
}
}
}
}
private void ClickDistanceBtn(Button btn, IEnumerable<Button> list)
{
foreach (var item in list)
@@ -116,7 +116,7 @@ public class RowerWelldone : PFUIPanel
game.transform.Find("Content/Rank").GetComponent<Text>().text = (i + 1).ToString("00");
game.transform.Find("Content/NickName").GetComponent<Text>().text = item.NickName;
Utils.DisplayImageTempDict(game.transform.Find("Content/Avatar").GetComponent<RawImage>(), item.WxHeadImg, caches);
game.transform.Find("Content/Time").GetComponent<Text>().text = data.info.Type == 1 ? TimeSpan.FromSeconds(item.Time).ToString() : item.TotalDistance.ToString("#0M");
game.transform.Find("Content/Time").GetComponent<Text>().text = data.info.Type == 1 ? TimeSpan.FromSeconds(item.Time).ToString(@"hh\:mm\:ss") : item.TotalDistance.ToString("#0M");
game.transform.SetParent(rankContent);
game.transform.localScale = Vector3.one;
game.SetActive(true);