修改细节,修复bug

This commit is contained in:
CaiYanPeng 2022-03-31 18:30:07 +08:00
parent 06aefb93c4
commit 30e09c9c7a
15 changed files with 3566 additions and 3347 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,79 @@
%YAML 1.1 %YAML 1.1
%TAG !u! tag:unity3d.com,2011: %TAG !u! tag:unity3d.com,2011:
--- !u!1 &512581023253864657
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 3352968575790546772}
- component: {fileID: 5194161964235640498}
- component: {fileID: 1144697767514498682}
m_Layer: 5
m_Name: Panel
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!224 &3352968575790546772
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 512581023253864657}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 6182801171780224340}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: -245}
m_SizeDelta: {x: 205, y: 38}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &5194161964235640498
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 512581023253864657}
m_CullTransparentMesh: 0
--- !u!114 &1144697767514498682
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 512581023253864657}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 0.392}
m_RaycastTarget: 1
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!1 &676752742128862401 --- !u!1 &676752742128862401
GameObject: GameObject:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -138,7 +212,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 167, y: -226} m_AnchoredPosition: {x: 194.5, y: -226}
m_SizeDelta: {x: 1, y: 38} m_SizeDelta: {x: 1, y: 38}
m_Pivot: {x: 0, y: 1} m_Pivot: {x: 0, y: 1}
--- !u!222 &6083926578620374178 --- !u!222 &6083926578620374178
@ -526,6 +600,7 @@ RectTransform:
- {fileID: 5297867286345066477} - {fileID: 5297867286345066477}
- {fileID: 7238412377813769565} - {fileID: 7238412377813769565}
- {fileID: 9197141820760920897} - {fileID: 9197141820760920897}
- {fileID: 3352968575790546772}
m_Father: {fileID: 6445869985133304203} m_Father: {fileID: 6445869985133304203}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -2601,7 +2676,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0 m_HorizontalOverflow: 0
m_VerticalOverflow: 0 m_VerticalOverflow: 0
m_LineSpacing: 1 m_LineSpacing: 1
m_Text: Start Free Mode m_Text: Just Row
--- !u!114 &7238412377813769538 --- !u!114 &7238412377813769538
MonoBehaviour: MonoBehaviour:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -2653,8 +2728,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 20, y: -226} m_AnchoredPosition: {x: 92.5, y: -226}
m_SizeDelta: {x: 139, y: 38} m_SizeDelta: {x: 94, y: 38}
m_Pivot: {x: 0, y: 1} m_Pivot: {x: 0, y: 1}
--- !u!114 &7238412377813769543 --- !u!114 &7238412377813769543
MonoBehaviour: MonoBehaviour:
@ -3260,7 +3335,7 @@ PrefabInstance:
- target: {fileID: 3150550772099312288, guid: 6b94e789d6585a04dbdc04c8a7cf97b2, - target: {fileID: 3150550772099312288, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3} type: 3}
propertyPath: m_AnchoredPosition.x propertyPath: m_AnchoredPosition.x
value: 176 value: 203.5
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 3150550772099312288, guid: 6b94e789d6585a04dbdc04c8a7cf97b2, - target: {fileID: 3150550772099312288, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3} type: 3}
@ -3575,7 +3650,7 @@ PrefabInstance:
- target: {fileID: 545917028276686471, guid: 6b94e789d6585a04dbdc04c8a7cf97b2, - target: {fileID: 545917028276686471, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3} type: 3}
propertyPath: m_SizeDelta.x propertyPath: m_SizeDelta.x
value: 0 value: 40
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 3150550772099312288, guid: 6b94e789d6585a04dbdc04c8a7cf97b2, - target: {fileID: 3150550772099312288, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3} type: 3}
@ -3687,6 +3762,11 @@ PrefabInstance:
propertyPath: m_Name propertyPath: m_Name
value: BtnCancel value: BtnCancel
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 3150550772099312289, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3}
propertyPath: m_IsActive
value: 0
objectReference: {fileID: 0}
- target: {fileID: 3150550772916003707, guid: 6b94e789d6585a04dbdc04c8a7cf97b2, - target: {fileID: 3150550772916003707, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3} type: 3}
propertyPath: m_Text propertyPath: m_Text
@ -3695,12 +3775,12 @@ PrefabInstance:
- target: {fileID: 5329299856310536127, guid: 6b94e789d6585a04dbdc04c8a7cf97b2, - target: {fileID: 5329299856310536127, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3} type: 3}
propertyPath: m_AnchorMax.y propertyPath: m_AnchorMax.y
value: 0 value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 5329299856310536127, guid: 6b94e789d6585a04dbdc04c8a7cf97b2, - target: {fileID: 5329299856310536127, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3} type: 3}
propertyPath: m_AnchorMin.y propertyPath: m_AnchorMin.y
value: 0 value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 5329299856310536127, guid: 6b94e789d6585a04dbdc04c8a7cf97b2, - target: {fileID: 5329299856310536127, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3} type: 3}

View File

@ -3710,8 +3710,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0.5} m_AnchorMin: {x: 0, y: 0.5}
m_AnchorMax: {x: 0, y: 0.5} m_AnchorMax: {x: 0, y: 0.5}
m_AnchoredPosition: {x: 152, y: 0} m_AnchoredPosition: {x: 150, y: 0}
m_SizeDelta: {x: 54, y: 16} m_SizeDelta: {x: 56, y: 16}
m_Pivot: {x: 0, y: 0.5} m_Pivot: {x: 0, y: 0.5}
--- !u!222 &2307627167488625470 --- !u!222 &2307627167488625470
CanvasRenderer: CanvasRenderer:
@ -4745,7 +4745,7 @@ PrefabInstance:
- target: {fileID: 5329299856310536127, guid: 6b94e789d6585a04dbdc04c8a7cf97b2, - target: {fileID: 5329299856310536127, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3} type: 3}
propertyPath: m_AnchoredPosition.x propertyPath: m_AnchoredPosition.x
value: 20 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 5329299856310536127, guid: 6b94e789d6585a04dbdc04c8a7cf97b2, - target: {fileID: 5329299856310536127, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3} type: 3}
@ -4920,7 +4920,7 @@ PrefabInstance:
- target: {fileID: 5329299856310536127, guid: 6b94e789d6585a04dbdc04c8a7cf97b2, - target: {fileID: 5329299856310536127, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3} type: 3}
propertyPath: m_AnchoredPosition.x propertyPath: m_AnchoredPosition.x
value: 20 value: 0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 5329299856310536127, guid: 6b94e789d6585a04dbdc04c8a7cf97b2, - target: {fileID: 5329299856310536127, guid: 6b94e789d6585a04dbdc04c8a7cf97b2,
type: 3} type: 3}

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,7 @@ public delegate void ChangeLanguageDelegate();
public static class App public static class App
{ {
public static string Host = "http://192.168.0.101:5087/"; public static string Host = "http://192.168.0.101:5083/";
public static string AppVersion = Application.version; public static string AppVersion = Application.version;
@ -223,6 +223,7 @@ public static class App
InitLanguage(); InitLanguage();
#if !UNITY_EDITOR #if !UNITY_EDITOR
//测试服务器 //测试服务器
//Host = "http://pf.juze.pro/";
Host = "http://192.168.0.101:5083/"; Host = "http://192.168.0.101:5083/";
UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21000); UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21000);
TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21001); TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21001);
@ -243,6 +244,7 @@ public static class App
//UdpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.102"), 21001); //UdpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.102"), 21001);
//TcpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.102"), 21001); //TcpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.102"), 21001);
#endif #endif
if (!FB.IsInitialized) if (!FB.IsInitialized)
{ {
FB.Init(); FB.Init();

View File

@ -18,8 +18,8 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
public bool IsOptional => false; public bool IsOptional => false;
public static event EventHandler EnableChanged; public static event EventHandler EnableChanged;
private static bool? _isEnabled; private static bool _isEnabled;
public static bool? IsEnabled public static bool IsEnabled
{ {
get => _isEnabled; get => _isEnabled;
set set
@ -55,7 +55,7 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
public static RowerTaskPanel.RowerType rowerType { get; private set; } public static RowerTaskPanel.RowerType rowerType { get; private set; }
public void HandleAttributeReceived(byte[] data) public void HandleAttributeReceived(byte[] data)
{ {
Debug.Log("数据" + string.Join(",", data)); //Debug.Log("数据" + string.Join(",", data));
if (data[0] == 53) if (data[0] == 53)
{ {
PeakDriveForce = LbsToNewton(Convert.ToDouble(BitConvertHelper.ToUInt16(data, 13)) / 10); PeakDriveForce = LbsToNewton(Convert.ToDouble(BitConvertHelper.ToUInt16(data, 13)) / 10);
@ -67,7 +67,7 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
List<ushort> r = new List<ushort>(); List<ushort> r = new List<ushort>();
for (int i = 3; i < data.Length; i += 2) for (int i = 3; i < data.Length; i += 2)
{ {
ushort pull = data[i] < 10 ? (ushort)0 : Convert.ToUInt16(Math.Round(LbsToNewton(data[i]))); ushort pull = Convert.ToUInt16(Math.Round(LbsToNewton(data[i])));
r.Add(pull); r.Add(pull);
PullValue = pull; PullValue = pull;
} }
@ -94,6 +94,9 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
{ {
rowerType = null; rowerType = null;
} }
//isReadyStatus = data[9] == 0;
var time = ((data[3] << 16) + (data[2] << 8) + data[1]) / 100;
Debug.Log("划船时间"+time);
isReadyStatus = data[9] == 0; isReadyStatus = data[9] == 0;
//isReadyStatus = data[2] == 1 || data[2] == 129; //isReadyStatus = data[2] == 1 || data[2] == 129;
} }

View File

@ -52,6 +52,7 @@ namespace Assets.Scripts.Devices.Ble.Devices
{ {
Debug.Log("中控台获取"); Debug.Log("中控台获取");
this.controlPointCharacteristic = character; this.controlPointCharacteristic = character;
C2RowerData.IsEnabled = false;
} }
else if (character.MatchGuid(ServiceUuids.Characteristics.RowerData)) else if (character.MatchGuid(ServiceUuids.Characteristics.RowerData))
{ {
@ -79,7 +80,7 @@ namespace Assets.Scripts.Devices.Ble.Devices
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerCourse)) else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerCourse))
{ {
Debug.Log("c2划船机课程数据" + service.Id); Debug.Log("c2划船机课程数据" + service.Id);
//C2RowerData.IsEnabled = true; C2RowerData.IsEnabled = true;
this.hwInterface.SubscribeCharacteristic(character, null); this.hwInterface.SubscribeCharacteristic(character, null);
} }
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerControl)) else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerControl))

View File

@ -134,7 +134,7 @@ namespace Assets.Scripts.Ble
{ {
continue; continue;
} }
//Debug.Log($"設備信息,{item.IdGuid},{string.Join(";",item.IdByteArray)}" ); //Debug.Log($"設備信息,{item.IdGuid},{string.Join(";", item.IdByteArray)}");
if (item.IdByteArray == ServiceUuids.Ftms) if (item.IdByteArray == ServiceUuids.Ftms)
{ {
if (App.IsRowerMode == true) if (App.IsRowerMode == true)
@ -231,7 +231,6 @@ namespace Assets.Scripts.Ble
callback?.Invoke(self, info, s); callback?.Invoke(self, info, s);
this.callbacks.Remove(info); this.callbacks.Remove(info);
Debug.Log("连接成功!"+info.Name); Debug.Log("连接成功!"+info.Name);
Devices.Ble.Characteristic.C2RowerData.IsEnabled = info.Name.Contains("PM");
if (this.callbacks.Any()) if (this.callbacks.Any())
{ {
this.ConnectPeripheral(this.callbacks.First().Key, this.callbacks.First().Value); this.ConnectPeripheral(this.callbacks.First().Key, this.callbacks.First().Value);

View File

@ -51,6 +51,12 @@ public class RowerHomeScript : PFUIPanel
protected override void OnDestroy() protected override void OnDestroy()
{ {
Debug.Log("銷毀"); Debug.Log("銷毀");
if (RowerCommonDataInstance != null)
{
RowerCommonDataInstance.PullChanged -= PaintPullCurve;
}
C2RowerData.EnableChanged -= ModeChanged;
FtmsRowerData.RowerResChanged -= ResChanged;
} }
private IRowerDevice Rower private IRowerDevice Rower
@ -183,7 +189,7 @@ public class RowerHomeScript : PFUIPanel
var nav = transform.Find("MainNav-mobile").GetComponent<NewMainNav>(); var nav = transform.Find("MainNav-mobile").GetComponent<NewMainNav>();
var c1 = new NewMainNav.CustomButton(Resources.Load<Sprite>("Images/RowerNew/ICON_create_44"), () => 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; //return;
if (checkRowing()) return; if (checkRowing()) return;
if (C2RowerData.IsEnabled == true && C2RowerData.rowerType != null) return; if (C2RowerData.IsEnabled == true && C2RowerData.rowerType != null) return;
@ -191,7 +197,7 @@ public class RowerHomeScript : PFUIPanel
{ {
rowerType = type; rowerType = type;
HandleSelectType(); HandleSelectType();
}); },rowerType);
}, false); }, false);
//var c2 = new NewMainNav.CustomButton(Resources.Load<Sprite>("Images/RowerNew/ICON_continue_44"), () => //var c2 = new NewMainNav.CustomButton(Resources.Load<Sprite>("Images/RowerNew/ICON_continue_44"), () =>
//{ //{
@ -211,21 +217,29 @@ public class RowerHomeScript : PFUIPanel
HandleSaveDirect(); HandleSaveDirect();
}); });
UIManager.AddEvent(transform.Find("Stopped/Confirm/BtnDrop").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b => UIManager.AddEvent(transform.Find("Stopped/Confirm/BtnDrop").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
Discard();
});
if (RowerCommonDataInstance != null)
{
RowerCommonDataInstance.PullChanged -= PaintPullCurve;
RowerCommonDataInstance.PullChanged += PaintPullCurve;
}
Init();
}
private void Discard()
{ {
transform.Find("Stopped").gameObject.SetActive(false); transform.Find("Stopped").gameObject.SetActive(false);
openTimer = false; openTimer = false;
isPause = true; isPause = true;
if (C2RowerData.IsEnabled == true) if (C2RowerData.IsEnabled == true)
{ {
Utils.showToast(null, "Please press Menu to save.",int.MaxValue, stopFunc: () => C2RowerData.isReadyStatus, endCallback: Init); Utils.showToast(null, @"Press ""Menu"" to save.", int.MaxValue, stopFunc: () => C2RowerData.isReadyStatus, endCallback: Init);
} }
else else
{ {
Init(); Init();
} }
});
Init();
} }
private void HandleSelectType() private void HandleSelectType()
@ -290,7 +304,7 @@ public class RowerHomeScript : PFUIPanel
}; };
if (C2RowerData.IsEnabled == true) 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 else
{ {
@ -364,6 +378,12 @@ public class RowerHomeScript : PFUIPanel
private void StartFunc() 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) if (!isPause)
{ {
startTime = UIManager.Now.GetDateTime(); startTime = UIManager.Now.GetDateTime();
@ -409,10 +429,10 @@ public class RowerHomeScript : PFUIPanel
model.AvgPower = values.Average(x => x.power); model.AvgPower = values.Average(x => x.power);
model.AvgRate = values.Average(x => x.rate); model.AvgRate = values.Average(x => x.rate);
model.AvgHeartRate = (int)values.Average(x => x.heartRate); 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.TotalTime = RowerData.ElapsedTime;
model.TotalDistance = RowerData.TotalDistance;
model.Type = rowerType.type == 0 ? (int?)null : rowerType.type; model.Type = rowerType.type == 0 ? (int?)null : rowerType.type;
model.TypeValue = rowerType.value == 0 ? (float?)null : rowerType.value; model.TypeValue = rowerType.value == 0 ? (float?)null : rowerType.value;
model.ShadowIds = string.Join(",",GetComponent<RowerMultiModeScript>().shadowList.Select(x=>x.Nid)); 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) private void ModeChanged(object sender, EventArgs e)
{ {
print("增加服务"+RowerData.ResistanceLevel); if (RowerCommonDataInstance != null)
{
RowerCommonDataInstance.PullChanged -= PaintPullCurve; RowerCommonDataInstance.PullChanged -= PaintPullCurve;
RowerCommonDataInstance.PullChanged += PaintPullCurve; RowerCommonDataInstance.PullChanged += PaintPullCurve;
}
slider.GetComponent<Slider>().interactable = !(bool)sender; slider.GetComponent<Slider>().interactable = !(bool)sender;
transform.Find("ResBar/BtnSub").GetComponent<Button>().interactable = !(bool)sender; transform.Find("ResBar/BtnSub").GetComponent<Button>().interactable = !(bool)sender;
transform.Find("ResBar/BtnAdd").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) private void ResChanged(object sender, EventArgs e)
{ {
print("收到阻力" + sender); print("收到阻力" + sender);
if ((Convert.ToSingle(sender) > 50)) if ((Convert.ToSingle(sender) > 50) && slider)
{ {
slider.GetComponent<PFUISlider>().SetValue((Convert.ToSingle(sender) - 50) / 300f); slider.GetComponent<PFUISlider>().SetValue((Convert.ToSingle(sender) - 50) / 300f);
} }
} }
public bool checkRowing() public bool checkRowing()
{ {
if (seconds > 0) if (seconds > 0)
@ -590,6 +613,8 @@ public class RowerHomeScript : PFUIPanel
var power = RowerData.InstantaneousPower; var power = RowerData.InstantaneousPower;
var rate = RowerData.StrokeRate; var rate = RowerData.StrokeRate;
TempRowerCalc tmpdata = null; TempRowerCalc tmpdata = null;
//里程停止逻辑
if (totalDistance == RowerData.TotalDistance) if (totalDistance == RowerData.TotalDistance)
{ {
//判定一次停止 //判定一次停止
@ -600,17 +625,6 @@ public class RowerHomeScript : PFUIPanel
stopSeconds = 0; stopSeconds = 0;
transform.Find("Stopped").gameObject.SetActive(false); 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) if (stopSeconds >= 2)
{ {
transform.Find("Stopped").gameObject.SetActive(true); transform.Find("Stopped").gameObject.SetActive(true);
@ -620,7 +634,7 @@ public class RowerHomeScript : PFUIPanel
//} //}
if (rowerType.type == 2) if (rowerType.type == 2)
{ {
var remainTime = rowerType.value - (seconds++); var remainTime = rowerType.value - (++seconds);
if (remainTime == 0) if (remainTime == 0)
{ {
records.Add($"{strokeCount},{RowerData.ElapsedTime},{distance},0,0,0,{RowerData.ResistanceLevel},{heartRate},{energy}"); records.Add($"{strokeCount},{RowerData.ElapsedTime},{distance},0,0,0,{RowerData.ResistanceLevel},{heartRate},{energy}");
@ -635,7 +649,7 @@ public class RowerHomeScript : PFUIPanel
} }
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 = "---"; mid.Find("W/Value").GetComponent<Text>().text = "---";
//bottom.Find("W/AvgValue").GetComponent<Text>().text = "---"; //bottom.Find("W/AvgValue").GetComponent<Text>().text = "---";
@ -697,7 +711,7 @@ public class RowerHomeScript : PFUIPanel
} }
if (rowerType.type == 2) 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(); bottom.Find("Time/Value").GetComponent<Text>().text = TimeSpan.FromSeconds(remainTime).ToPFString();
if (remainTime == 0) if (remainTime == 0)
{ {
@ -711,12 +725,12 @@ public class RowerHomeScript : PFUIPanel
} }
else 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) if (rowerType.type == 1)
{ {
var remainDistance = rowerType.value - totalDistance; var remainDistance = rowerType.value - totalDistance;
if (remainDistance < 0) if (remainDistance <= 0)
{ {
bottom.Find("KM/Value").GetComponent<Text>().text = "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}"); 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(); 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}"); 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 }; tmpdata = new TempRowerCalc() { strokeCount = strokeCount, pace = pace, power = power, rate = rate, heartRate = heartRate, distance = distance, energy = energy };
values.Add(tmpdata); values.Add(tmpdata);
SendDataToRace(tmpdata); SendDataToRace(tmpdata);
if (C2RowerData.IsEnabled == true && C2RowerData.isReadyStatus && values.Count()>10)
{
HandleSaveDirect();
}
//Debug.Log(1); //Debug.Log(1);
} }
void SendDataToRace(TempRowerCalc tmpdata) void SendDataToRace(TempRowerCalc tmpdata)

View File

@ -116,6 +116,10 @@ public class RowerMultiModeScript : MonoBehaviour
_distance = _list[currentSecond].Distance; _distance = _list[currentSecond].Distance;
} }
x.currentDistance = _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(); userList = userList.OrderByDescending(x => x.currentDistance).ToList();
@ -194,8 +198,15 @@ public class RowerMultiModeScript : MonoBehaviour
var data = list[i]; var data = list[i];
t.gameObject.SetActive(true); t.gameObject.SetActive(true);
TweenCallback callback = () => TweenCallback callback = () =>
{
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); Utils.DisplayImageTempDict(t.Find("Left/Avatar").GetComponent<RawImage>(), data.Avatar, caches);
}
var _c = countryList.SingleOrDefault(x => x.country == data.Country); var _c = countryList.SingleOrDefault(x => x.country == data.Country);
if (_c != null) if (_c != null)
{ {
@ -287,10 +298,10 @@ public class RowerMultiModeScript : MonoBehaviour
{ {
diffWidth = 100 - ((int)rowerType.value - data.currentDistance); diffWidth = 100 - ((int)rowerType.value - data.currentDistance);
} }
if (data.isMine) //if (data.isMine)
{ //{
print("diff:" + diffWidth + ";"+ rowerType.type); // print("diff:" + diffWidth + ";"+ rowerType.type);
} //}
if (diffWidth >= 0 && diffWidth <= 100) if (diffWidth >= 0 && diffWidth <= 100)
{ {
var tWidth = (diffWidth / 100f) * width; var tWidth = (diffWidth / 100f) * width;
@ -359,21 +370,27 @@ public class RowerMultiModeScript : MonoBehaviour
{ {
game.transform.Find("Content/Country").GetComponent<Image>().sprite = Resources.Load<Sprite>(_c.source); 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) 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) else if (currentSecond >= 0 && currentSecond < item.list.Count)
{ {
game.transform.Find("Content/Time").GetComponent<Text>().text = item.list[currentSecond].Distance.ToString("#0M"); _d = item.list[currentSecond].Distance;
game.transform.Find("Content/Power").GetComponent<Text>().text = item.list[currentSecond].Power.ToString("#0W"); _p = item.list[currentSecond].Power;
} }
else else
{ {
game.transform.Find("Content/Time").GetComponent<Text>().text = item.list[item.list.Count - 1].Distance.ToString("#0M"); _d = item.list[item.list.Count - 1].Distance;
game.transform.Find("Content/Power").GetComponent<Text>().text = item.list[item.list.Count - 1].Power.ToString("#0W"); _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) if (item.isMine)
{ {
game.transform.Find("Content/Time").GetComponent<Text>().color = Utils.HexToColorHtml("#f93086"); game.transform.Find("Content/Time").GetComponent<Text>().color = Utils.HexToColorHtml("#f93086");
@ -458,30 +475,56 @@ public class RowerMultiModeScript : MonoBehaviour
return; return;
} }
var offset = pan.deltaTranslation; var offset = pan.deltaTranslation;
if (scroll.localPosition.x >= 30 || scroll.localPosition.x <= -760) return;
scroll.localPosition += new Vector3(offset.x, 0, 0); scroll.localPosition += new Vector3(offset.x, 0, 0);
} }
}; };
pan.gestureCompleteEvent += (r) => pan.gestureCompleteEvent += (r) =>
{ {
float x = 0; 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")))
{ {
t.GetComponent<Image>().color = Utils.HexToColorHtml("#ffffff"); if (scroll.localPosition.x >= startPosition.x - ((730 * 1) / 10))
}
if (scroll.localPosition.x >= startPosition.x - (730 / 2))
{ {
x = startPosition.x; x = startPosition.x;
transform.Find("Rower/Dots/d1").GetComponent<Image>().color = Utils.HexToColorHtml("#f93086"); 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 else
{ {
x = startPosition.x - 730; x = startPosition.x - 730;
transform.Find("Rower/Dots/d2").GetComponent<Image>().color = Utils.HexToColorHtml("#f93086"); selDot = "d2";
} }
}
foreach (Transform t in transform.Find("Rower/Dots"))
{
t.GetComponent<Image>().color = Utils.HexToColorHtml("#ffffff");
}
transform.Find($"Rower/Dots/{selDot}").GetComponent<Image>().color = Utils.HexToColorHtml("#f93086");
scroll.DOLocalMoveX(x, 0.5f); scroll.DOLocalMoveX(x, 0.5f);
PlayerPrefs.SetFloat("RowerMultiModeLocationX", x); PlayerPrefs.SetFloat("RowerMultiModeLocationX", x);
}; };
TouchKit.addGestureRecognizer(pan); TouchKit.addGestureRecognizer(pan);
print("注册触摸事件");
}
private void OnDestroy()
{
TouchKit.removeAllGestureRecognizers();
} }
//交换A,B索引的赛道 //交换A,B索引的赛道
void ChangeTrace(int indexA, int indexB) void ChangeTrace(int indexA, int indexB)

View File

@ -24,7 +24,7 @@ public class RowerTaskPanel : PFUIPanel
public float value { get; set; } public float value { get; set; }
} }
Transform selector, distance, time; Transform selector, distance, time;
RowerType rowerType; public RowerType rowerType;
public Action<RowerType> callBack { get; set; } public Action<RowerType> callBack { get; set; }
@ -84,12 +84,18 @@ public class RowerTaskPanel : PFUIPanel
{ {
base.Show(); base.Show();
InitAll(); InitAll();
InitValue();
} }
private void Go() private void Go()
{ {
if (rowerType.type == 0 || rowerType.value == 0) 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; return;
} }
if (callBack != null) if (callBack != null)
@ -151,6 +157,7 @@ public class RowerTaskPanel : PFUIPanel
btn.onClick.RemoveAllListeners(); btn.onClick.RemoveAllListeners();
btn.onClick.AddListener(() => btn.onClick.AddListener(() =>
{ {
InitAll();
rowerType.type = btn.transform.parent.name == "Distance" ? 1 : 2; rowerType.type = btn.transform.parent.name == "Distance" ? 1 : 2;
if (calcButton == null) if (calcButton == null)
{ {
@ -168,6 +175,16 @@ public class RowerTaskPanel : PFUIPanel
var input = item as PFUIInputField; var input = item as PFUIInputField;
input.CustomSelect = () => input.CustomSelect = () =>
{ {
string ignoreName = null;
if (input.name == "CustomizeMin")
{
ignoreName = "CustomizeS";
}
else if (input.name == "CustomizeS")
{
ignoreName = "CustomizeMin";
}
InitAll(ignoreName);
ClickDistanceBtn(null, btns); ClickDistanceBtn(null, btns);
rowerType.type = input.transform.parent.name == "Distance" ? 1 : 2; rowerType.type = input.transform.parent.name == "Distance" ? 1 : 2;
SetTextColor(input.gameObject, true); SetTextColor(input.gameObject, true);
@ -220,19 +237,65 @@ public class RowerTaskPanel : PFUIPanel
bg.GetComponent<Outline>().enabled = false; bg.GetComponent<Outline>().enabled = false;
} }
} }
public readonly Dictionary<int, List<double>> stdList = new Dictionary<int, List<double>>
private void InitAll() {
{ 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) foreach (var item in formList)
{ {
if (item is Button) 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 else
{ {
var i = item as PFUIInputField; var i = item as PFUIInputField;
i.Text = ""; 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();
}
}
}
} }
} }
} }

View File

@ -116,7 +116,7 @@ public class RowerWelldone : PFUIPanel
game.transform.Find("Content/Rank").GetComponent<Text>().text = (i + 1).ToString("00"); game.transform.Find("Content/Rank").GetComponent<Text>().text = (i + 1).ToString("00");
game.transform.Find("Content/NickName").GetComponent<Text>().text = item.NickName; game.transform.Find("Content/NickName").GetComponent<Text>().text = item.NickName;
Utils.DisplayImageTempDict(game.transform.Find("Content/Avatar").GetComponent<RawImage>(), item.WxHeadImg, caches); 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.SetParent(rankContent);
game.transform.localScale = Vector3.one; game.transform.localScale = Vector3.one;
game.SetActive(true); game.SetActive(true);

View File

@ -352,8 +352,9 @@ public class UIManager : MonoBehaviour
return this.GetPanelInstance("RowerTaskPanel", ref this.mRowerTaskPanel); return this.GetPanelInstance("RowerTaskPanel", ref this.mRowerTaskPanel);
} }
} }
public static void ShowRowerTaskPanel(Action<RowerTaskPanel.RowerType> callBack) public static void ShowRowerTaskPanel(Action<RowerTaskPanel.RowerType> callBack, RowerTaskPanel.RowerType type)
{ {
UIManager.Instance.RowerTaskPanel.rowerType = type;
UIManager.Instance.RowerTaskPanel.callBack = callBack; UIManager.Instance.RowerTaskPanel.callBack = callBack;
UIManager.Show(UIManager.Instance.RowerTaskPanel, null, true); UIManager.Show(UIManager.Instance.RowerTaskPanel, null, true);
} }

View File

@ -78,8 +78,8 @@ public class Toast : MonoBehaviour
} }
//Fade out //Fade out
yield return fadeInAndOut(txt, false, 0.5f); yield return fadeInAndOut(txt, false, 0.5f);
DestroyImmediate(gameObject);
gameObject.SetActive(false); //gameObject.SetActive(false);
} }
IEnumerator fadeInAndOut(Text targetText, bool fadeIn, float duration) IEnumerator fadeInAndOut(Text targetText, bool fadeIn, float duration)

View File

@ -20,6 +20,8 @@ namespace Assets.Scripts
public static class Utils public static class Utils
{ {
public static string ToPFString(this TimeSpan t) public static string ToPFString(this TimeSpan t)
{
if (t.TotalSeconds >= 60)
{ {
var s = "00:00:00"; var s = "00:00:00";
var r = t.ToString(@"hh\:mm\:ss"); var r = t.ToString(@"hh\:mm\:ss");
@ -30,6 +32,12 @@ namespace Assets.Scripts
} }
return r.Substring(i, r.Length - i); return r.Substring(i, r.Length - i);
} }
else
{
return $":{t.TotalSeconds.ToString("#0")}";
}
}
/*获取ip*/ /*获取ip*/
public enum ADDRESSFAM public enum ADDRESSFAM
{ {