Merge branch 'dev_cyp' into dev_ar_cyp

# Conflicts:
#	Assets/Resources/UI/Font/HanWangZonYi.ttf.meta
#	Assets/Resources/UI/language.json
#	Assets/Scenes/Login.unity
#	Assets/Scripts/Apis/Models/MapRoute.cs
#	Assets/Scripts/App.cs
#	Assets/Scripts/ConfigHelper.cs
#	Assets/Scripts/Scenes/Ride/Scripts/PlayerController.cs
#	Assets/Scripts/UIManager.cs
#	Assets/Scripts/Utils/Utils.cs
This commit is contained in:
lishuo committed 2022-06-02 11:30:37 +08:00
commit e513eeac5c
301 files changed
+49814 -11770

No files matched your search

+1 -1
View File
@@ -191,7 +191,7 @@ namespace Assets.Scripts.Apis
private async Task<T> ParseJsonAsync<T>(HttpResponseMessage response)
{
var result = await response.Content.ReadAsStringAsync();
Console.WriteLine(result);
//Console.WriteLine(result);
return JsonConvert.DeserializeObject<T>(result, new JsonSerializerSettings {
DateTimeZoneHandling = DateTimeZoneHandling.Local
});
+32
View File
@@ -0,0 +1,32 @@
using Assets.Scripts.Apis.Models;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace Assets.Scripts.Apis
{
public class MailApi : ApiBase
{
public async Task<JsonResult<List<MailModel>>> GetList(int pageIndex,int pageSize, int type)
{
var result = await GetAsync<JsonResult<List<MailModel>>>($"Message/GetList?pageIndex={pageIndex}&pageSize={pageSize}&type={type}");
return result;
}
public async Task<JsonResult<object>> MarkRead(int id)
{
var result = await PostAsync<JsonResult<object>>("Message/MarkRead",new { id});
return result;
}
public async Task<JsonResult<object>> Delete(int id)
{
var result = await PostAsync<JsonResult<object>>("Message/Delete", new { id });
return result;
}
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 593b04d43282490459537d561d16096d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+9 -2
View File
@@ -1,5 +1,4 @@
using Assets.Scenes.Ride.Scripts.Model;
using Assets.Scenes.Ride.Scripts.Model;
using Assets.Scripts.Apis.Models;
using System;
using System.Collections.Generic;
@@ -231,6 +230,14 @@ namespace Assets.Scripts.Apis
return result;
}
public async Task<JsonResult<object>> ApplyOpenRoute(int id)
{
var result = await PostAsync<JsonResult<object>>($"Map/ApplyOpenRoute", new { id });
return result;
}
public async Task<JsonResult<List<MapRouteAreaItem>>> GetRecommendAreaList()
{
var result = await GetAsync<JsonResult<List<MapRouteAreaItem>>>($"MapRouteArea/GetRecommendAreaList");
@@ -38,5 +38,10 @@ namespace Assets.Scripts.Apis
{
return Get<JsonResult<AntManufacturer>>($"MapRecord/GetAntManufacturerById?id={id}");
}
public async Task<JsonResult<byte[]>> GetRecordSnapShot(int id)
{
return await GetAsync<JsonResult<byte[]>>($"Share/GetRecordSnapShot?id={id}");
}
}
}
+20
View File
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Assets.Scripts.Apis.Models
{
public class MailModel
{
public int Id { get; set; }
public string Title { get; set; }
public string Desc { get; set; }
public bool IsRead { get; set; }
public DateTime CreateTime { get; set; }
public int Type { get; set; }
public int SendUserId { get; set; }
public string SendNickName { get; set; }
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3dd81357979eb03468cc496795d1e8fd
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+1
View File
@@ -120,6 +120,7 @@ namespace Assets.Scripts.Apis.Models
//最近骑行列表使用
public RouteResult RecentRecord { get; set; }
public bool IsEnabled { get; set; }
public string Url { get; set; }
public string FileName { get; set; }
public int FileSize { get; set; }
@@ -29,6 +29,9 @@ namespace Assets.Scripts.Apis.Models
public ushort StrokeCount { get; set; }
public uint TotalDistance { get; set; }
public int TotalTime { get; set; }
public int? Type { get; set; }
public double? TypeValue { get; set; }
public string ShadowIds { get; set; }
}
public class RowerChartModel
{
@@ -36,6 +39,8 @@ namespace Assets.Scripts.Apis.Models
public ushort Pace { get; set; }
public uint Rate { get; set; }
public int HeartRate { get; set; }
public int Distance { get; set; }
public int StrokeCount { get; set; }
}
public class RowerResultModel
{
@@ -60,5 +65,55 @@ namespace Assets.Scripts.Apis.Models
public int TotalTime { get; set; }
public List<RowerChartModel> ChartList { get; set; }
public string Cover { get; set; }
public int? Type { get; set; }
public double? TypeValue { get; set; }
public double Ticks { get; set; }
}
public class SegmentList
{
public int Ticks { get; set; }
public int Distance { get; set; }
public int Speed { get; set; }
public int Power { get; set; }
public int HeartRate { get; set; }
public int StrokeCount { get; set; }
public int Energy { get; set; }
public int Rate { get; set; }
}
public class RowerRank
{
public string Id { get; set; }
public int UserId { get; set; }
public double Time { get; set; }
public int TotalDistance { get; set; }
public string NickName { get; set; }
public string WxHeadImg { get; set; }
public DateTime CreateTime { get; set; }
public bool isFinished { get; set; }
public List<RowerChartModel> list { get; set; }
public string Country { get; set; }
public int Nid { get; set; }
public double Ticks { get; set; }
public int rankNum { get; set; }
}
public class Info
{
public string CreateTime { get; set; }
public string MyRank { get; set; }
public int? Type { get; set; }
public string TypeStr { get; set; }
public string MyRankLeft { get; set; }
}
public class RowerSegmentData
{
public List<SegmentList> segmentList { get; set; }
public List<RowerRank> ranks { get; set; }
public Info info { get; set; }
}
}
+1 -1
View File
@@ -17,7 +17,7 @@ namespace Assets.Scripts.Apis
protected async override Task<HttpResponseMessage> SendAsync(
HttpRequestMessage request, CancellationToken cancellationToken)
{
var badreqText = App.GetLocalLanguage() == "zh" ? "请检查网络连接是否正常" : "Please check if the network connection is normal.";
var badreqText = App.GetLocalString("Please check the network status!");
try
{
var response = await base.SendAsync(request, cancellationToken).ConfigureAwait(false);
+20
View File
@@ -32,9 +32,29 @@ namespace Assets.Scripts.Apis
return await GetAsync<JsonResult<RowerResultModel>>($"Rower/GetDetail?Id={id}");
}
public async Task<JsonResult<RowerSegmentData>> GetSegmentDataAndRanking(string id)
{
return await GetAsync<JsonResult<RowerSegmentData>>($"Rower/GetSegmentDataAndRanking?Id={id}");
}
public async Task<JsonResult<object>> Delete(string Id)
{
return await PostAsync<JsonResult<object>>($"Rower/Delete",new { Id});
}
public async Task<JsonResult<List<RowerRank>>> GetShadowList(RowerTaskPanel.RowerType rowerType)
{
return await GetAsync<JsonResult<List<RowerRank>>>($"Rower/GetShadowList?type={rowerType.type}&typeValue={rowerType.value}");
}
public async Task<JsonResult<List<RowerRank>>> GetReRowShadowList(string id)
{
return await GetAsync<JsonResult<List<RowerRank>>>($"Rower/GetReRowShadowList?Id={id}");
}
public async Task<JsonResult<byte[]>> GetRecordSnapShot(string id)
{
return await GetAsync<JsonResult<byte[]>>($"Share/GetRowerRecordSnapShot?Id={id}");
}
}
}
+42 -24
View File
@@ -15,6 +15,7 @@ using System.Timers;
using Newtonsoft.Json;
using Facebook.Unity;
using Assets.Scenes.Ride.Scripts;
using System.Linq;
public delegate void ChangeLanguageDelegate();
@@ -40,7 +41,7 @@ public static class App
public static double longitude { get; internal set; }
public static string is401 { get; set; }
public static bool FromLogin => false;
public static bool? _IsRowerMode = null;
private static bool? _IsRowerMode = null;
public static bool? IsRowerMode
{
get => _IsRowerMode;
@@ -197,41 +198,58 @@ public static class App
public static string Model { get; set; }
public static List<MailModel> CurrentUserMails { get; set; }
//public static event hasNotReadEvent;
public static event EventHandler HasNotReadChanged;
public static bool _hasNotRead;
public static bool hasNotRead
{
get => _hasNotRead;
set
{
_hasNotRead = value;
if (HasNotReadChanged != null)
{
HasNotReadChanged(value, new EventArgs());
}
}
}
public static bool CanOpenAd = false;
public static Dictionary<string, string> websiteDict = new Dictionary<string, string>()
{
{"https://wx.powerfun.com.cn/","http://www.powerfun.com/" },
{"http://pf.juze.pro/","http://pfweb.juze.pro/" }
{"http://pf.juze.pro/","http://pfweb.juze.pro/" },
{"http://192.168.0.101:5087/","http://192.168.0.101:3081/" },
{"http://192.168.0.101:5083/","http://pfweb.juze.pro/" }
};
static App()
{
InitLanguage();
#if !UNITY_EDITOR
//测试服务器 Host = "http://192.168.0.101:5083/";
Host = "http://pf.juze.pro/";
UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21000);
TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21001);
//线上
//Host = "https://wx.powerfun.com.cn/";
//UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 11000);
//TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 11001);
//#if !UNITY_EDITOR
// //测试服务器
// Host = "http://pf.juze.pro/";
// UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21000);
// TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 21001);
// //线上
// //Host = "https://wx.powerfun.com.cn/";
// //UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 11000);
// //TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 11001);
// //本地
// //Host = "http://192.168.0.101:5085/";
// //UdpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.97"), 11000);
// //TcpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.102"), 21001);
// Debug.unityLogger.logEnabled = false;
//#else
// //Host = "http://pf.juze.pro/";
// //Host = "http://192.168.0.101:5087/";
// UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 11000);
// TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 11001);
// //UdpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.102"), 21001);
// //TcpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.102"), 21001);
//#endif
//本地
//Host = "http://192.168.0.101:5087/";
//UdpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.97"), 11000);
//TcpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.102"), 21001);
//Debug.unityLogger.logEnabled = false;
#else
//Host = "http://pf.juze.pro/";
//Host = "http://192.168.0.101:5087/";
UdpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 11000);
TcpAddress = new IPEndPoint(IPAddress.Parse("47.97.84.8"), 11001);
//UdpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.102"), 21001);
//TcpAddress = new IPEndPoint(IPAddress.Parse("192.168.0.102"), 21001);
#endif
var now = DateTime.Now;
if (!FB.IsInitialized)
{
FB.Init();
+9
View File
@@ -79,6 +79,15 @@ namespace Assets.Scripts
}
}
private static MailApi _mailApi;
internal static MailApi mailApi
{
get
{
if (_mailApi == null) _mailApi = new MailApi();
return _mailApi;
}
}
private static GameRoomApi _gameRoomApi;
public static GameRoomApi GameRoomApi
{
@@ -9,7 +9,10 @@ namespace Assets.Scripts.Devices.Ant.Interfaces
{
interface IRowerDevice
{
C2RowerData c2RowerData { get; }
FtmsRowerData rowerData { get; }
void Reset();
void SetResistanceLevel(ushort v);
void C2GetStatus(byte[] bs);
}
}
+2 -1
View File
@@ -38,7 +38,8 @@ namespace Assets.Scripts.Devices.Ant
SpeedCadence,
Trainer,
VirtualPower,
Rower
Rower,
FtmsTrainer
}
public enum NetworkType
+31 -5
View File
@@ -57,18 +57,30 @@ namespace Assets.Scripts.Devices.Ble
}
public override void StartScan()
{
{
hwInterface.StartScan((device) =>
{
{
if (!discoveredDevices.ContainsKey(device.Peripheral.Address))
{
Debug.Log($"发现设备{ device.Peripheral.Address }, \t\tName:{ device.Peripheral.Name }, type:{ device.SensorType }");
Debug.Log($"发现设备{ device.Peripheral.Address }, \t\tName:{ device.Peripheral.Name }, type:{ device.SensorType } 服务:{string.Join(",", device.Services)}");
if (string.IsNullOrWhiteSpace(device.Peripheral.Name))
{
return;
}
if (device.SensorType == Ant.SensorType.Trainer)
if (device.SensorType == Ant.SensorType.FtmsTrainer)
{
var device1 = new Ftms(device.Peripheral, hwInterface);
if (discoveredDevices.ContainsKey(device.Peripheral.Address))
{
discoveredDevices[device.Peripheral.Address] = device1;
}
else
{
discoveredDevices.Add(device.Peripheral.Address, device1);
}
}
else if (device.SensorType == Ant.SensorType.Trainer)
{
//var device1 = new Ftms(device.Peripheral, hwInterface);
//discoveredDevices.Add(device.Peripheral.Address, device0);
@@ -122,7 +134,21 @@ namespace Assets.Scripts.Devices.Ble
{
//TODO:取消注释,自动连接设备
//Debug.Log("自动连接" + device111.Id);
device111.Connect();
if (App.IsRowerMode == true)
{
if (device111.Sensor == Ant.SensorType.Rower || device111.Sensor == Ant.SensorType.HeartRate)
{
device111.Connect();
}
}
else if(App.IsRowerMode == false)
{
if (device111.Sensor != Ant.SensorType.Rower)
{
device111.Connect();
}
}
}
}
@@ -0,0 +1,208 @@
using Assets.Scripts.Ble;
using Assets.Scripts.Devices.Ble.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;
namespace Assets.Scripts.Devices.Ble.Characteristic
{
public class C2RowerData : ICharacteristic, IRowerCommonData
{
public Guid Uuid => ServiceUuids.Characteristics.C2RowerData35;
public Guid ServiceUuid => ServiceUuids.Characteristics.C2Service;
public bool IsOptional => false;
public static event EventHandler EnableChanged;
private static bool _isEnabled;
public static bool IsEnabled
{
get => _isEnabled;
set
{
_isEnabled = value;
if (EnableChanged != null)
{
EnableChanged(_isEnabled, new EventArgs());
}
}
}
//0.1 lbs of force, max=6553.5m 单位0.1磅
public double PeakDriveForce { get; set; }
public double AverageDriveForce { get; set; }
public event EventHandler PullChanged;
private ushort _pullValue;
public ushort PullValue
{
get { return _pullValue; }
set
{
_pullValue = value;
if (this.PullChanged != null)
{
this.PullChanged(this, new EventArgs());
}
}
}
public static bool isReadyStatus { get; private set; }
public static RowerTaskPanel.RowerType rowerType { get; private set; }
public void HandleAttributeReceived(byte[] data)
{
Debug.Log("数据" + string.Join(",", data));
if (data[0] == 0x35)
{
PeakDriveForce = LbsToNewton(Convert.ToDouble(BitConvertHelper.ToUInt16(data, 13)) / 10, true);
AverageDriveForce = LbsToNewton(Convert.ToDouble(BitConvertHelper.ToUInt16(data, 15)) / 10, true);
ElapsedTime = (int)(Convert.ToDouble(BitConvertHelper.ToUInt24(data, 1)) / 100);
TotalDistance = (uint)(Convert.ToDouble(BitConvertHelper.ToUInt24(data, 4)) / 10);
StrokeCount = BitConvertHelper.ToUInt16(data, 19);
Debug.Log($"峰力值:{PeakDriveForce} 均力值{AverageDriveForce}");
}
else if (data[0] == 0x3d)
{
//老款表头不支持
List<ushort> r = new List<ushort>();
for (int i = 3; i < data.Length; i += 2)
{
ushort pull = data[i] < 5 ? (ushort)0 : Convert.ToUInt16(Math.Round(LbsToNewton(data[i], true)));
r.Add(pull);
PullValue = pull;
}
Debug.Log("拉力曲线:" + string.Join(",", r));
}
else if (data[0] == 0x31)
{
byte status = data[18];
int value = (data[17] << 16) + (data[16] << 8) + data[15];
if (status == 128 && value != 0)
{
rowerType = new RowerTaskPanel.RowerType();
rowerType.type = 1;
rowerType.value = value;
}
else if (status == 0)
{
rowerType = new RowerTaskPanel.RowerType();
rowerType.type = 2;
rowerType.value = value / 100;
}
else
{
rowerType = null;
}
//isReadyStatus = data[9] == 0;
var time = ((data[3] << 16) + (data[2] << 8) + data[1]) / 100;
Debug.Log("划船时间" + time);
isReadyStatus = data[9] == 0;
if (RowerResChanged != null)
{
RowerResChanged.Invoke(data[19], new EventArgs());
}
ResistanceLevel = data[19];
//isReadyStatus = data[2] == 1 || data[2] == 129;
}
else if (data[0] == 0x32)
{
InstantaneousPace = (ushort)(Convert.ToDouble(BitConvertHelper.ToUInt16(data, 8)) / 100);
AveragePace = (ushort)(Convert.ToDouble(BitConvertHelper.ToUInt16(data, 10)) / 100);
//AveragePower = BitConvertHelper.ToUInt16(data, 17);
StrokeRate = (uint)data[6];
}
else if (data[0] == 0x33)
{
TotalEnergy = BitConvertHelper.ToUInt16(data, 7);
AveragePower = BitConvertHelper.ToUInt16(data, 5);
}
else if (data[0] == 0x36)
{
InstantaneousPower = BitConvertHelper.ToUInt16(data, 4);
//TotalEnergy = BitConvertHelper.ToUInt16(data, 6);
}
//else if (data[0] == 0x39)
//{
// AverageStrokeRate = (int)data[11];
// ResistanceLevel = (int)data[16];
//}
//else if (data[0] == 34)
//{
// isReadyStatus = data[2] == 1 || data[2] == 129;
//}
}
public event EventHandler StartEvent;
private double LbsToNewton(double lbs,bool isKg = false) => 4.4482216 * lbs * (isKg ? (1f / 9.8f) : 1f);
public void SetUnavailable()
{
//throw new NotImplementedException();
}
/// <summary>
/// 划桨频率
/// </summary>
public uint StrokeRate { get; set; } = 0;
/// <summary>
/// 划桨次数
/// </summary>
public UInt16 StrokeCount { get; set; } = 0;
/// <summary>
/// 平均划桨频率
/// </summary>
public int AverageStrokeRate { get; set; } = 0;
private UInt32 _totalDistance = 0;
public UInt32 TotalDistance
{
get => _totalDistance;
set
{
if (_totalDistance == 0 && value != 0 && StartEvent != null)
{
StartEvent.Invoke(null, new EventArgs());
}
_totalDistance = value;
}
}
//private UInt16 _instantaneousPace = 0;
/// <summary>
/// 即时配速
/// </summary>
public UInt16 InstantaneousPace { get; set; } = 0;
/// <summary>
/// 平均配速
/// </summary>
public UInt16 AveragePace { get; set; } = 0;
public int InstantaneousPower { get; set; } = 0;
public int AveragePower { get; set; } = 0;
public int ElapsedTime { get; set; } = 0;
public int TotalEnergy { get; set; } = 0;
public int EnergyPerHour { get; set; } = 0;
public int EnergyPerMinute { get; set; } = 0;
public event EventHandler RowerResChanged;
public int ResistanceLevel { get; set; } = 0;
public void Reset()
{
this.StrokeRate = 0;
this.StrokeCount = 0;
this.AverageStrokeRate = 0;
this.TotalDistance = 0;
this.InstantaneousPace = 0;
this.AveragePace = 0;
this.InstantaneousPower = 0;
this.AveragePower = 0;
this.ResistanceLevel = 0;
this.TotalEnergy = 0;
this.EnergyPerHour = 0;
this.EnergyPerMinute = 0;
this.ElapsedTime = 0;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 64ae3a6d26480b04c8fed17cc833d179
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -1,4 +1,5 @@
using Assets.Scripts.Ble;
using Assets.Scripts.Devices.Ant;
using Assets.Scripts.Devices.Ble.Interfaces;
using System;
using System.Collections.Generic;
@@ -9,46 +10,77 @@ using UnityEngine;
namespace Assets.Scripts.Devices.Ble.Characteristic
{
public class FtmsRowerData : ICharacteristic
public class FtmsRowerData : ICharacteristic, IRowerCommonData
{
/// <summary>
/// 划桨频率
/// </summary>
public uint StrokeRate { get; private set; } = 0;
public uint StrokeRate { get; set; } = 0;
/// <summary>
/// 划桨次数
/// </summary>
public UInt16 StrokeCount { get; private set; } = 0;
public UInt16 StrokeCount { get; set; } = 0;
/// <summary>
/// 平均划桨频率
/// </summary>
public int AverageStrokeRate { get; private set; } = 0;
public int AverageStrokeRate { get; set; } = 0;
public UInt32 TotalDistance { get; private set; } = 0;
private UInt32 _totalDistance = 0;
public UInt32 TotalDistance
{
get => _totalDistance;
set
{
if (_totalDistance == 0 && value != 0 && StartEvent != null)
{
StartEvent.Invoke(null, new EventArgs());
}
_totalDistance = value;
}
}
//private UInt16 _instantaneousPace = 0;
/// <summary>
/// 即时配速
/// </summary>
public UInt16 InstantaneousPace { get; private set; } = 0;
public UInt16 InstantaneousPace { get; set; } = 0;
/// <summary>
/// 平均配速
/// </summary>
public UInt16 AveragePace { get; private set; } = 0;
public UInt16 AveragePace { get; set; } = 0;
public int InstantaneousPower { get; private set; } = 0;
public int InstantaneousPower { get; set; } = 0;
public int AveragePower { get; private set; } = 0;
public int ResistanceLevel { get; private set; } = 0;
public int AveragePower { get; set; } = 0;
public event EventHandler RowerResChanged;
private int commonRes = 50;
private int thinkRes = 50;
public int ResistanceLevel
{
get
{
var device = App.MainDeviceAdapter.GetDevices().FirstOrDefault(d => (d.State == DeviceState.Connected) && d.Sensor == SensorType.Rower);
if (device == null) return 0;
if (device.Name.Contains("Think"))
{
return thinkRes;
}
else
{
return commonRes;
}
}
set { }
}
/// <summary>
/// 运行时间
/// </summary>
public int ElapsedTime { get; private set; } = 0;
public int TotalEnergy { get; private set; } = 0;
public int EnergyPerHour { get; private set; } = 0;
public int EnergyPerMinute { get; private set; } = 0;
public int ElapsedTime { get; set; } = 0;
public int TotalEnergy { get; set; } = 0;
public int EnergyPerHour { get; set; } = 0;
public int EnergyPerMinute { get; set; } = 0;
public double PeakDriveForce { get; set; } = 0;
public double AverageDriveForce { get; set; } = 0;
public Guid Uuid => ServiceUuids.Characteristics.RowerData;
@@ -59,6 +91,8 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
public RowerDataFlag Flags;
//拉力相关
public event EventHandler PullChanged;
//开始事件
public event EventHandler StartEvent;
private ushort _pullValue;
public ushort PullValue
{
@@ -152,7 +186,12 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
}
if (this.Flags.HasFlag(RowerDataFlag.ResistanceLevel))
{
this.ResistanceLevel = BitConvertHelper.ToInt16(data, b);
this.commonRes = BitConvertHelper.ToInt16(data, b);
var device = App.MainDeviceAdapter.GetDevices().FirstOrDefault(d => (d.State == DeviceState.Connected) && d.Sensor == SensorType.Rower);
if (device != null && !device.Name.Contains("Think") && RowerResChanged != null)
{
RowerResChanged.Invoke(this.commonRes, null);
}
b += this.SizeOfDataForFlag(RowerDataFlag.ResistanceLevel);
}
if (this.Flags.HasFlag(RowerDataFlag.ExpendedEnergy))
@@ -184,20 +223,45 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
{
b += this.SizeOfDataForFlag(RowerDataFlag.RemainingTime);
}
if (this.Flags.HasFlag(RowerDataFlag.ThinkDragFactor))
{
this.thinkRes = BitConvertHelper.ToInt16(data, b + 1);
var device = App.MainDeviceAdapter.GetDevices().FirstOrDefault(d => (d.State == DeviceState.Connected) && d.Sensor == SensorType.Rower);
if (device != null && device.Name.Contains("Think") && RowerResChanged != null)
{
RowerResChanged.Invoke(this.thinkRes, null);
}
b += this.SizeOfDataForFlag(RowerDataFlag.ThinkDragFactor);
}
if (this.Flags.HasFlag(RowerDataFlag.Pull))
{
List<ushort> list = new List<ushort>();
for (int pullB = 4; pullB < data.Length; pullB += 2)
{
var val = BitConverter.ToUInt16(data, pullB);
val = Convert.ToUInt16(((double)val) /9.8f);
list.Add(val);
PullValue = val;
}
if (pullList == null) pullList = new List<ushort>();
foreach (var pull in list)
{
if (pull == 0)
{
if (pullList.Count != 0)
{
PeakDriveForce = pullList.Max();
AverageDriveForce = (double)pullList.Average(x=>x);
}
pullList.Clear();
}
pullList.Add(pull);
}
Debug.Log("拉力:" + string.Join(",",list));
}
//Debug.Log("原始数据:" + string.Join(",", data));
}
List<ushort> pullList;
public void Reset()
{
this.StrokeRate = 0;
@@ -208,7 +272,9 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
this.AveragePace = 0;
this.InstantaneousPower = 0;
this.AveragePower = 0;
this.ResistanceLevel = 0;
//this.commonRes = 50;
//this.thinkRes = 50;
//this.ResistanceLevel = 0;
this.TotalEnergy = 0;
this.EnergyPerHour = 0;
this.EnergyPerMinute = 0;
@@ -258,6 +324,9 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
case RowerDataFlag.RemainingTime:
num = 2;
break;
case RowerDataFlag.ThinkDragFactor:
num = 5;
break;
default:
break;
}
@@ -288,7 +357,9 @@ namespace Assets.Scripts.Devices.Ble.Characteristic
//单周期能耗
SingleEnergy = 8192,
//拉力曲綫
Pull = 16384
Pull = 16384,
//Think 阻力
ThinkDragFactor = 32768
}
+160 -18
View File
@@ -6,6 +6,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using UnityEngine;
@@ -16,44 +17,92 @@ namespace Assets.Scripts.Devices.Ble.Devices
private FtmsRowerData _rowerData;
public FtmsRowerData rowerData { get => _rowerData; }
C2RowerData _c2RowerData;
public C2RowerData c2RowerData { get => _c2RowerData; }
private List<BleServiceInfo> Services;
private BleCharacteristicInfo controlPointCharacteristic;
public FtmsRower(BlePeripheralInfo peripheralInfo, IBleWinHwInterface bleWinHwInterface) :base(peripheralInfo, bleWinHwInterface, Ant.SensorType.Rower)
private BleCharacteristicInfo c2Control;
public FtmsRower(BlePeripheralInfo peripheralInfo, IBleWinHwInterface bleWinHwInterface) : base(peripheralInfo, bleWinHwInterface, Ant.SensorType.Rower)
{
Debug.Log(24);
base.Characteristics.Add(new FtmsFitnessMachineFeature());
//划船机
this._rowerData = new FtmsRowerData();
base.Characteristics.Add(rowerData);
this._c2RowerData = new C2RowerData();
base.Characteristics.Add(c2RowerData);
bleWinHwInterface.CharacteristicReadEvent -= CharacteristicReadMainCallback;
bleWinHwInterface.CharacteristicReadEvent += CharacteristicReadMainCallback;
}
protected override void CreateServices(List<BleServiceInfo> discoveredServices)
{
this.Services = discoveredServices;
Debug.Log("服务+" + string.Join(",", Services.Select(x => x.Id.ToString())));
foreach (var service in this.Services)
{
hwInterface.DiscoverCharacteristic(service, (hwInterface, service1, response) =>
{
foreach (var character in response.Data)
{
//Debug.Log(character.Id.ToString());
if (character.MatchGuid(ServiceUuids.Characteristics.FitnessMachineControlPoint))
{
Debug.Log("中控台获取");
this.controlPointCharacteristic = character;
}
C2RowerData.IsEnabled = false;
}
else if (character.MatchGuid(ServiceUuids.Characteristics.RowerData))
{
Debug.Log("划船机");
this.hwInterface.SubscribeCharacteristic(character, (hw, cha, res) =>
{
//Debug.Log("1111111111111111111111");
//Debug.WriteLine(res.ToString());
var res1 = (res as BleResponse<byte[]>);
Debug.Log("收到消息划船机:" + string.Join(",", res1));
});
Debug.Log("ftms划船机" + service.Id);
this.hwInterface.SubscribeCharacteristic(character, null);
}
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerData35))
{
Debug.Log("c2划船机基本数据" + service.Id);
//C2RowerData.IsEnabled = true;
this.hwInterface.SubscribeCharacteristic(character, null);
}
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerData3d))
{
Debug.Log("c2划船机拉力数据" + service.Id);
//C2RowerData.IsEnabled = true;
this.hwInterface.SubscribeCharacteristic(character, null);
}
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerData32))
{
this.hwInterface.SubscribeCharacteristic(character, null);
}
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerData33))
{
this.hwInterface.SubscribeCharacteristic(character, null);
}
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerData36))
{
this.hwInterface.SubscribeCharacteristic(character, null);
}
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerData39))
{
this.hwInterface.SubscribeCharacteristic(character, null);
}
//else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerStatus))
//{
// Debug.Log("c2划船机响应数据" + service.Id);
// //C2RowerData.IsEnabled = true;
// this.hwInterface.SubscribeCharacteristic(character, null);
//}
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerCourse))
{
Debug.Log("c2划船机课程数据" + service.Id);
C2RowerData.IsEnabled = true;
this.hwInterface.SubscribeCharacteristic(character, null);
}
else if (character.MatchGuid(ServiceUuids.Characteristics.C2RowerControl))
{
Debug.Log("c2划船机控制台");
this.c2Control = character;
}
}
});
@@ -62,20 +111,113 @@ namespace Assets.Scripts.Devices.Ble.Devices
private void CharacteristicReadMainCallback(IBleWinHwInterface hwInterface, BleCharacteristicInfo characteristic, BleResponse<byte[]> response)
{
foreach (var item in base.Characteristics)
//var tc = base.Characteristics.SingleOrDefault(x => x.Uuid == ServiceUuids.Characteristics.C2RowerData);
//tc.HandleAttributeReceived(new byte[] { 61, 89, 0, 0, 0, 33, 0, 33, 0, 46, 0, 46, 0, 53, 0, 60, 0, 60, 0, 68, 0, 68, 0, 0, 0 });
//tc.HandleAttributeReceived(new byte[] { 53, 223, 211, 0, 162, 57, 0, 82, 62, 96, 0, 94, 2, 183, 3, 125, 2, 208, 7, 203, 0 });
if (characteristic.MatchGuid(ServiceUuids.Characteristics.RowerData))
{
if (characteristic.MatchGuid(item.Uuid))
var c = base.Characteristics.SingleOrDefault(x => x.Uuid == ServiceUuids.Characteristics.RowerData);
if (c != null && !C2RowerData.IsEnabled)
{
//Debug.Log(string.Join(",", response.Data));
item.HandleAttributeReceived(response.Data);
c.HandleAttributeReceived(response.Data);
}
}
else
{
var c = base.Characteristics.SingleOrDefault(x => x.Uuid == ServiceUuids.Characteristics.C2RowerData35);
if (c != null)
{
var data = new byte[] { characteristic.Id.ToByteArray()[0] }.Concat(response.Data).ToArray();
c.HandleAttributeReceived(data);
}
}
//foreach (var item in base.Characteristics)
//{
// if (characteristic.MatchGuid(item.Uuid) || characteristic.Id == ServiceUuids.Characteristics.C2RowerData1)
// {
// if (item.Uuid == ServiceUuids.Characteristics.C2RowerData1)
// {
// Debug.Log("c2");
// var data = new byte[] { item.Uuid.ToByteArray()[0] }.Concat(response.Data).ToArray();
// item.HandleAttributeReceived(data);
// }
// else if (item.Uuid == ServiceUuids.Characteristics.RowerData)
// {
// Debug.Log("ftms");
// item.HandleAttributeReceived(response.Data);
// }
// }
//}
}
public void C2GetStatus(byte[] bs)
{
if (C2RowerData.IsEnabled == true)
{
//等对csafe协议研究透彻后写
if (this.c2Control != null)
{
var cmd = bs;
byte a = cmd[0];
for (int i = 1; i < cmd.Length; i++)
{
a ^= cmd[i];
}
cmd = new byte[] { 0xf1 }.Concat(cmd).Concat(new byte[] { a, 0xf2 }).ToArray();
Debug.Log("发送获取命令" + string.Join(",", cmd));
hwInterface.WriteCharacteristic(this.c2Control, cmd);
//hwInterface.WriteCharacteristic(this.c2Control, new byte[] { 0xF1, 0x81, 0x81, 0xF2 });
}
}
}
public void Reset()
{
Debug.Log("发送重置命令"+this.controlPointCharacteristic.ToString());
hwInterface.WriteCharacteristic(this.controlPointCharacteristic, new byte[] { 0x01 });
if (C2RowerData.IsEnabled == true)
{
////等对csafe协议研究透彻后写
//if (this.c2Control != null)
//{
// Debug.Log("发送重置命令" + this.c2Control.ToString());
// hwInterface.WriteCharacteristic(this.c2Control, new byte[] { 0xF1, 0x80, 0x80, 0xF2 });
// //hwInterface.WriteCharacteristic(this.c2Control, new byte[] { 0xF1, 0x81, 0x81, 0xF2 });
//}
}
else
{
if (this.controlPointCharacteristic != null)
{
Debug.Log("发送重置命令" + this.controlPointCharacteristic.ToString());
hwInterface.WriteCharacteristic(this.controlPointCharacteristic, new byte[] { 0x01 });
}
}
}
public void SetResistanceLevel(ushort v)
{
if (C2RowerData.IsEnabled == true)
{
//等对csafe协议研究透彻后写
//if (this.c2Control != null)
//{
// var data = new byte[] { 0x29 }.Concat(BitConverter.GetBytes(v)).ToArray();
// byte checksum = (byte)((byte)(data[0] ^ data[1]) ^ data[2]);
// var r = new byte[] { 0xF1 }.Concat(data).Concat(new byte[] { checksum, 0xf2 }) .ToArray();
// Debug.Log($"设置阻力{v}, {string.Join(",", r)}");
// hwInterface.WriteCharacteristic(this.c2Control, r);
//}
}
else
{
if (this.controlPointCharacteristic != null)
{
//特注:81是think专有指令,后期可能需要兼容其他设备
var r = new byte[] { 0x81 }.Concat(BitConverter.GetBytes((ushort)(50 + v))).ToArray();
Debug.Log($"设置阻力{v}, {string.Join(",", r)}");
hwInterface.WriteCharacteristic(this.controlPointCharacteristic, r);
}
}
}
}
}
@@ -0,0 +1,50 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Assets.Scripts.Devices.Ble.Interfaces
{
interface IRowerCommonData
{
event EventHandler PullChanged;
ushort PullValue { get; set; }
double PeakDriveForce { get; set; }
double AverageDriveForce { get; set; }
/// <summary>
/// 划桨频率
/// </summary>
uint StrokeRate { get; set; }
/// <summary>
/// 划桨次数
/// </summary>
UInt16 StrokeCount { get; set;}
/// <summary>
/// 平均划桨频率
/// </summary>
int AverageStrokeRate { get; set; }
UInt32 TotalDistance { get; set; }
/// <summary>
/// 即时配速
/// </summary>
UInt16 InstantaneousPace { get; set; }
/// <summary>
/// 平均配速
/// </summary>
UInt16 AveragePace { get; set; }
int InstantaneousPower { get; set; }
int AveragePower { get; set; }
int ElapsedTime { get; set; }
int TotalEnergy { get; set; }
int EnergyPerHour { get; set; }
int EnergyPerMinute { get; set; }
int ResistanceLevel { get; set; }
void Reset();
event EventHandler StartEvent;
event EventHandler RowerResChanged;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7b9b93075aa03cf4587d75a49b2bfaa8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -44,6 +44,10 @@ namespace Assets.Scripts.Ble
(byte) 24,
(byte) 38
};
public static readonly byte[] C2Rower = new byte[]
{
(byte)206,(byte)6
};
public static readonly byte[] KineticInRide = new byte[16]
{
(byte) 233,
@@ -164,6 +168,7 @@ namespace Assets.Scripts.Ble
new ServiceUuid(new Guid("6e40fec1-b5a3-f393-e0a9-e50e24dcca9e"), ServiceUuids.TacxBle, true),
new ServiceUuid(new Guid("01007b34-3576-8b40-8918-8ff3949ce592"), ServiceUuids.Elite, true),
new ServiceUuid(new Guid("3a01f4c0-37a8-6541-bab9-654ef70747c6"), ServiceUuids.PowerBeam, true),
new ServiceUuid(new Guid("CE060000-43E5-11E4-916C-0800200C9A66"), ServiceUuids.C2Rower,true),
};
public static readonly IReadOnlyList<ServiceUuid> CyclingServices = ServiceUuids.Services.Where(s => s.IsCycling).ToList();
@@ -367,6 +372,23 @@ namespace Assets.Scripts.Ble
public static Guid WahooFitnessSensorMeasurementInput = new Guid("A026E016-0A7D-4AB3-97FA-F1500F9FEB8B");
public static Guid RowerData = new Guid("00002AD1-0000-1000-8000-00805F9B34FB");
public static Guid C2RowerControl = new Guid("ce060021-43e5-11e4-916c-0800200c9a66");
//0x35 有峰力值和均力值
public static Guid C2RowerData35 = new Guid("ce060035-43e5-11e4-916c-0800200c9a66");
//拉力曲线
public static Guid C2RowerData3d = new Guid("ce06003D-43e5-11e4-916c-0800200c9a66");
//c2划船机状态
public static Guid C2RowerStatus = new Guid("ce060022-43e5-11e4-916c-0800200c9a66");
//c2划船机课程
public static Guid C2RowerCourse = new Guid("CE060031-43E5-11E4-916C-0800200C9A66");
public static Guid C2RowerData32 = new Guid("CE060032-43E5-11E4-916C-0800200C9A66");
public static Guid C2RowerData33 = new Guid("CE060033-43E5-11E4-916C-0800200C9A66");
public static Guid C2RowerData36 = new Guid("CE060036-43E5-11E4-916C-0800200C9A66");
public static Guid C2RowerData39 = new Guid("CE060039-43E5-11E4-916C-0800200C9A66");
public static Guid C2Service = new Guid("CE060030-43E5-11E4-916C-0800200C9A66");
//ce060030-43e5-11e4-916c-0800200c9a66
}
}
@@ -134,17 +134,14 @@ namespace Assets.Scripts.Ble
{
continue;
}
//Debug.Log($"設備信息,{item.IdGuid},{string.Join(";",item.IdByteArray)}" );
if (item.IdByteArray == ServiceUuids.Ftms)
//Debug.Log($"設備{App.IsRowerMode}信息,{item.IdGuid},{string.Join(";", item.IdByteArray)}");
if (item.IdByteArray == ServiceUuids.Ftms || item.IdByteArray == ServiceUuids.C2Rower)
{
if (App.IsRowerMode == true)
{
sensor = SensorType.Rower;
}
else
{
sensor = SensorType.Trainer;
}
sensor = SensorType.Rower;
//else
//{
// sensor = SensorType.FtmsTrainer;
//}
}
else if (item.IdByteArray == ServiceUuids.HeartRate)
{
@@ -230,7 +227,7 @@ namespace Assets.Scripts.Ble
{
callback?.Invoke(self, info, s);
this.callbacks.Remove(info);
Debug.Log("连接成功!");
Debug.Log("连接成功!"+info.Name);
if (this.callbacks.Any())
{
this.ConnectPeripheral(this.callbacks.First().Key, this.callbacks.First().Value);
@@ -373,8 +370,11 @@ namespace Assets.Scripts.Ble
{
this.characteristicNotificationCallbacks.Add(characteristic.Peripheral, callback);
}
BluetoothLEHardwareInterface.Log("SubscribeCharacteristic" + characteristic.Peripheral.Name + characteristic.Service.ToString() + characteristic.Service.ToString());
BluetoothLEHardwareInterface.SubscribeCharacteristicWithDeviceAddress(characteristic.Peripheral.Address, characteristic.Service.ToString(), characteristic.Id.ToString(), null, (deviceAddress, characteristric, bytes) =>
Debug.Log("SubscribeCharacteristic" + characteristic.Peripheral.Name + characteristic.Service.ToString() + characteristic.Service.ToString());
BluetoothLEHardwareInterface.SubscribeCharacteristicWithDeviceAddress(characteristic.Peripheral.Address, characteristic.Service.ToString(), characteristic.Id.ToString(), (a,b)=>
{
Debug.Log("返回特征值," + a + "," + b);
}, (deviceAddress, characteristric, bytes) =>
{
if (characteristicReadEvent != null)
{
+10 -1
View File
@@ -164,7 +164,16 @@ public class WeChatController
public void ShareImageToWX(int scene, byte[] image)
{
#if UNITY_ANDROID
mainActivityClass.CallStatic("ShareImageToWX", scene, image);
mainActivityClass.CallStatic("ShareImageToWX", scene, image,null);
#elif UNITY_IOS
ShareImgToWX(scene,image,image.Length);
#endif
}
public void ShareImageToWX(int scene, byte[] image,byte[] thumb)
{
#if UNITY_ANDROID
mainActivityClass.CallStatic("ShareImageToWX", scene, image, thumb);
#elif UNITY_IOS
ShareImgToWX(scene,image,image.Length);
#endif
+16
View File
@@ -23,6 +23,22 @@ public static class PFConstants
return Application.persistentDataPath + "/RowerRecords/";
}
}
/// <summary>
/// 划船机训练保存在本地的路径
/// </summary>
public static string RowerRecordCacheFolder
{
get
{
if (!Directory.Exists(Application.persistentDataPath + "/RowerRecordCaches/"))
{
Directory.CreateDirectory(Application.persistentDataPath + "/RowerRecordCaches/");
}
return Application.persistentDataPath + "/RowerRecordCaches/";
}
}
/// <summary>
/// 课程训练保存在本地的路径
/// </summary>
+20 -12
View File
@@ -32,6 +32,7 @@ public class MainController : BaseScene
Loom.Initialize();
msg = transform.Find("GameObject/Message").GetComponent<CanvasGroup>();
InitialMessage();
MailReceiver.Instance().GetMessage();
#if UNITY_ANDROID || UNITY_IOS
transform.GetComponent<CanvasScaler>().referenceResolution = new Vector2(844, 390);
//transform.Find("Panel").GetComponent<RectTransform>().sizeDelta = new Vector2(844, 390);
@@ -308,18 +309,25 @@ public class MainController : BaseScene
//{
// UIManager.ShowHomePanel();
//});
//#if UNITY_ANDROID || UNITY_IOS
// if (!App.IsRowerMode.HasValue)
// {
// UIManager.ShowRowerSelector();
// return;
// }
// if (App.IsRowerMode == true)
// {
// UIManager.ShowRowerPanel();
// return;
// }
//#endif
#if UNITY_ANDROID || UNITY_IOS
#region 划船机功能:隐藏骑行
UIManager.ShowRowerPanel();
return;
#endregion
if (!App.IsRowerMode.HasValue)
{
UIManager.ShowHomePanel();
UIManager.ShowRowerSelector();
return;
}
if (App.IsRowerMode == true)
{
UIManager.ShowHomePanel();
UIManager.ShowRowerPanel();
return;
}
#endif
LastRide();//检查本地异常中断的骑行并弹窗提示继续
if (App.MainSceneParam.ContainsKey("Name") && !string.IsNullOrEmpty(App.MainSceneParam["Name"]))
{
@@ -93,7 +93,7 @@ namespace Assets.Scenes.Ride.Scripts
{
var now = DateTime.Now;
//超过一秒没有收到消息
Console.WriteLine($"Heartbeat_Elapsed{(now - LastActiveTime).TotalSeconds}");
//Console.WriteLine($"Heartbeat_Elapsed{(now - LastActiveTime).TotalSeconds}");
if ((now - LastActiveTime).TotalSeconds > 1)
{
onlineUserHelper.SetOnlineUser(new List<ReceiveMsgModel>());
@@ -119,7 +119,7 @@ namespace Assets.Scenes.Ride.Scripts.Network
protected override void OnDisconnected()
{
//base.OnDisconnected();
Console.WriteLine("tcp断线,3秒后重连");
//Console.WriteLine("tcp断线,3秒后重连");
Thread.Sleep(3000);
if (!_stop)
@@ -825,9 +825,9 @@ public BaseUIManager singleUIManager;
Camera.main.transform.DOLocalMove(neareast, 1f);
//StartCoroutine(MoveCamera(far, near));//初始摄像头
var check = CheckAnt();
//#if UNITY_EDITOR
#if UNITY_EDITOR
check = true;
//#endif
#endif
if (check || isWatch)
{
singleUIManager.StartRide();
@@ -61,9 +61,9 @@ namespace Assets.Scenes.Ride.Scripts
cadance = mainController.UpdateCadence();
weight = App.CurrentUser.Weight;
bicycleWeight = App.CurrentUser.BicycleWeight;
//#if UNITY_EDITOR
power = 400;
//#endif
#if UNITY_EDITOR
power = 300;
#endif
mainController.TrackResistance(currentSlope * App.RideSetting.Sensitivity / 100);
}
catch (Exception ex)
@@ -9,6 +9,10 @@ using DG.Tweening;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
using Facebook.Unity;
using System.Web;
using UnityEngine.Networking;
using System.Collections;
using System.Threading.Tasks;
namespace Assets.Scenes.Ride.Scripts
{
@@ -104,11 +108,13 @@ namespace Assets.Scenes.Ride.Scripts
photoURL: new Uri(cyclingController.mapRoute.CoverImage));
}
private void shareToWx(BaseEventData b)
{
private async void shareToWx(BaseEventData b)
{
UIManager.Instance.StartCoroutine(ShowLoading());
var res = await ConfigHelper.mapInterruptRecordApi.GetRecordSnapShot(cyclingController.RankingId);
if (App.weChatController.IsWeChatAppInstalled())
{
App.weChatController.ShareWebpageToWX(0, $"{App.CurrentUser.WebHost}RoutesRecords/{cyclingController.RankingId}?Token={App.CurrentUser.cookie}", cyclingController.mapRoute.Name, "By " + App.CurrentUser.Nickname,null);
App.weChatController.ShareImageToWX(0, res.data, Resources.Load<Sprite>("Images/pf").texture.EncodeToJPG());
}
else
{
@@ -116,11 +122,18 @@ namespace Assets.Scenes.Ride.Scripts
}
}
private void shareToWxGp(BaseEventData b)
private IEnumerator ShowLoading()
{
Utils.showToast(null, "首次分享图片会消耗一些时间,请耐心等待", type: 1);
yield return null;
}
private async void shareToWxGp(BaseEventData b)
{
UIManager.Instance.StartCoroutine(ShowLoading());
var res = await ConfigHelper.mapInterruptRecordApi.GetRecordSnapShot(cyclingController.RankingId);
if (App.weChatController.IsWeChatAppInstalled())
{
App.weChatController.ShareWebpageToWX(1, $"{App.CurrentUser.WebHost}RoutesRecords/{cyclingController.RankingId}?Token={App.CurrentUser.cookie}", cyclingController.mapRoute.Name, "By " + App.CurrentUser.Nickname,null);
App.weChatController.ShareImageToWX(1, res.data,Resources.Load<Sprite>("Images/pf").texture.EncodeToJPG());
}
else
{
+38 -23
View File
@@ -30,13 +30,17 @@ namespace Assets.Scripts.UI.Control
}
string placeHolderText;
public Action CustomSelect = null, CustomDeSelect = null,CustomEnter = null;
public void OnSelect(BaseEventData eventData)
{
if (this.gameObject.activeInHierarchy == false)
{
return;
}
if (CustomSelect != null)
{
CustomSelect.Invoke();
}
isSelected = true;
//throw new NotImplementedException();
this.mInnerInputField.OnSelect(eventData);
@@ -63,7 +67,10 @@ namespace Assets.Scripts.UI.Control
{
return;
}
if (CustomDeSelect != null)
{
CustomDeSelect.Invoke();
}
isSelected = false;
this.mInnerInputField.OnDeselect(eventData);
transform.Find("Placeholder").GetComponent<Text>().text = App.GetLocalString(placeHolderText);
@@ -72,7 +79,33 @@ namespace Assets.Scripts.UI.Control
//image.sprite = png1;
outline.enabled = false;
}
void OnEnter(BaseEventData eventData)
{
if (isSelected)
{
return;
}
if (CustomEnter != null)
{
CustomEnter.Invoke();
}
outline.enabled = true;
ColorUtility.TryParseHtmlString("#6E6E7D", out Color color);
outline.effectColor = color;
}
private void OnExit(BaseEventData eventData)
{
if (isSelected)
{
return;
}
if (CustomDeSelect != null)
{
CustomDeSelect.Invoke();
}
//outline = this.gameObject.AddComponent<Outline>();
outline.enabled = false;
}
void Awake()
{
Material material = null;
@@ -95,26 +128,8 @@ namespace Assets.Scripts.UI.Control
//UIManager.AddEvent(this.mInnerInputField.gameObject, EventTriggerType.PointerClick, new UnityAction<BaseEventData>(this.OnSelect));
UIManager.AddEvent(this.mInnerInputField.gameObject, EventTriggerType.Select, new UnityAction<BaseEventData>(this.OnSelect));
UIManager.AddEvent(this.mInnerInputField.gameObject, EventTriggerType.Deselect, new UnityAction<BaseEventData>(this.OnDeselect));
UIManager.AddEvent(this.mInnerInputField.gameObject, EventTriggerType.PointerEnter, new UnityAction<BaseEventData>((e) =>
{
if (isSelected)
{
return;
}
outline.enabled = true;
ColorUtility.TryParseHtmlString("#6E6E7D", out Color color);
outline.effectColor = color;
}));
UIManager.AddEvent(this.mInnerInputField.gameObject, EventTriggerType.PointerExit, new UnityAction<BaseEventData>(e =>
{
if (isSelected)
{
return;
}
//outline = this.gameObject.AddComponent<Outline>();
outline.enabled = false;
}));
UIManager.AddEvent(this.mInnerInputField.gameObject, EventTriggerType.PointerEnter, new UnityAction<BaseEventData>(this.OnEnter));
UIManager.AddEvent(this.mInnerInputField.gameObject, EventTriggerType.PointerExit, new UnityAction<BaseEventData>(OnExit));
placeHolderText = transform.Find("Placeholder").GetComponent<Text>().text;
}
+70 -3
View File
@@ -1,22 +1,89 @@
using System.Collections;
using Assets.Scripts;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
public class PFUISlider : MonoBehaviour
{
private Text text;
private Slider slider;
public System.Func<float, float> valueHandler = (a) => a * 100;
private List<Color> colorGradientList;
private void Awake()
{
text = transform.Find("Text").GetComponent<Text>();
slider = transform.GetComponent<Slider>();
text.text = $"{(slider.value * 100).ToString("#0")}%";
//text.text = $"{(slider.value * 100).ToString("#0")}";
//slider.onValueChanged.AddListener((f) =>
//{
// text.text = $"{valueHandler(f).ToString("#0")}";
//});
colorGradientList = SetColorGradient(new List<Color>
{
Utils.HexToColorHtml("#ffffff"),
Utils.HexToColorHtml("#27DFE3"),
Utils.HexToColorHtml("#27E363"),
Utils.HexToColorHtml("#E3D427"),
Utils.HexToColorHtml("#E33B27"),
},
new List<int>
{
50,50,100,100
});
}
public bool runCallback = false;
public void SetValueChanged(System.Action<float> a)
{
slider = transform.GetComponent<Slider>();
slider.onValueChanged.RemoveAllListeners();
slider.onValueChanged.AddListener((f) =>
{
text.text = $"{(f * 100).ToString("#0")}%";
var step = 1f / (colorGradientList.Count-1);
var index = (int)Math.Round(f / step, 0);
slider.targetGraphic.color = colorGradientList[index];
text.text = $"{valueHandler(f).ToString("#0")}";
a.Invoke(f);
});
}
public void SetValue(float a)
{
slider.value = a;
}
public List<Color> SetColorGradient(List<Color> list, int divideCount)
{
var res = new List<Color>();
for (int i = 0; i < list.Count - 1; i++)
{
Color c = list[i], nc = list[i + 1];
var diff = new Tuple<float, float, float>((nc.r - c.r) / divideCount, (nc.g - c.g) / divideCount, (nc.b - c.b) / divideCount);
for (int j = 0; j < divideCount; j++)
{
res.Add(new Color(c.r + diff.Item1 * j, c.g + diff.Item2 * j, c.b + diff.Item3 * j));
}
}
return res;
}
public List<Color> SetColorGradient(List<Color> list, List<int> divideList)
{
if (list.Count != divideList.Count+1) return null;
var res = new List<Color>();
for (int i = 0; i < list.Count - 1; i++)
{
Color c = list[i], nc = list[i + 1];
var divideCount = divideList[i];
var diff = new Tuple<float, float, float>((nc.r - c.r) / divideCount, (nc.g - c.g) / divideCount, (nc.b - c.b) / divideCount);
for (int j = 0; j < divideCount; j++)
{
res.Add(new Color(c.r + diff.Item1 * j, c.g + diff.Item2 * j, c.b + diff.Item3 * j));
}
}
return res;
}
// Start is called before the first frame update
void Start()
{
+1 -1
View File
@@ -34,7 +34,7 @@ namespace Assets.Scripts.UI.Control
private Text text;
//private Texture2D cursor;
private Outline outline;
private Button mButton;
public Button mButton { get;set; }
private Sequence se = null;
private Sequence a;
private TweenerCore<float, float, FloatOptions> b;
@@ -1,9 +1,11 @@
using Assets.Scripts;
using Assets.Scripts.Apis.Models;
using Facebook.Unity;
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.SceneManagement;
#if UNITY_STANDALONE_WIN
@@ -30,6 +32,9 @@ public class ActivityController : PFUIPanel
#endif
#else
webView = browser.GetComponent<UniWebView>();
webView.Frame = new Rect(0, 0, Screen.width, Screen.height);
webView.ReferenceRectTransform = browser.GetComponent<RectTransform>();
#endif
//webView.Show();
}
@@ -76,6 +81,7 @@ public class ActivityController : PFUIPanel
{
if (action == null)
{
//webView.UserAgent = "tes "+ App.GetLocalLanguage();
webView.LoadURL(url, true);
}
else
@@ -88,10 +94,10 @@ public class ActivityController : PFUIPanel
{
Debug.Log("开始");
// Load a URL.
webView.Frame = new Rect(0, 0, Screen.width, Screen.height);
webView.ReferenceRectTransform = browser.GetComponent<RectTransform>();
webView.Hide();
webView.SetUserAgent($"UniWebView {Application.platform} {Application.version}");
webView.BackgroundColor = Utils.HexToColorHtml("#23232d");
//webView.CleanCache();
if (action == null)
{
webView.Load(url);
@@ -112,6 +118,7 @@ public class ActivityController : PFUIPanel
case "Close": CloseFunc(); break;
case "StartRide": StartRide(int.Parse(message.Args["id"]),message.Args.ContainsKey("routeResult")?message.Args["routeResult"]:null); break;
case "Share": Share(int.Parse(message.Args["type"]),int.Parse(message.Args["id"])); break;
case "ShareRower": ShareRower(int.Parse(message.Args["type"]), message.Args["url"], message.Args["title"]); break;
case "OpenUrl": OpenUrl(message.Args["url"]); break;
default:break;
}
@@ -123,30 +130,57 @@ public class ActivityController : PFUIPanel
Application.OpenURL(System.Net.WebUtility.UrlDecode(url));
}
private void Share(int type,int id)
private void Share(int type, int id)
{
string url = $"http://pfweb.juze.pro/Activity/LightUpChina/Share?userId={App.CurrentUser.Id}";
if (type < 2)
{
if (App.weChatController.IsWeChatAppInstalled())
{
App.weChatController.ShareWebpageToWX(type, url, "点亮中国活动", "by " + App.CurrentUser.Nickname, null);
App.weChatController.ShareWebpageToWX(type, url, App.GetLocalString("Light up China Share"), "by " + App.CurrentUser.Nickname, null);
}
}
else if (type == 2)
{
UnityEngine.GUIUtility.systemCopyBuffer = url;
RunJavaScript("window.postMessage(\"webview;复制成功\")");
RunJavaScript($"window.postMessage(\"webview;{App.GetLocalString("Copy Success")}\")");
}
else
{
Facebook.Unity.FB.ShareLink(contentURL: new Uri(url),
contentTitle: "点亮中国活动",
contentTitle: App.GetLocalString("Light up China Share"),
contentDescription: "By " + App.CurrentUser.Nickname,
photoURL: new Uri(App.CurrentUser.WxHeadImg));
}
}
/// <summary>
///
/// </summary>
/// <param name="sharetype">0 1</param>
/// <param name="id">记录id</param>
/// <param name="type">rower ride</param>
private void ShareRower(int type, string url, string title)
{
if (type < 2)
{
if (App.weChatController.IsWeChatAppInstalled())
{
App.weChatController.ShareWebpageToWX(type, url, title, "By " + App.CurrentUser.Nickname, null);
RunJavaScript("window.postMessage(\"webview;Endshare\")");
}
else
{
Utils.showToast(null, "未安装微信");
}
}
else
{
FB.ShareLink(contentURL: new Uri(url),
contentTitle: title,
contentDescription: $"By {App.CurrentUser.Nickname}");
}
}
private void StartRide(int id,string routeResult)
{
App.RouteIdParam = id;
@@ -161,6 +195,9 @@ public class ActivityController : PFUIPanel
{
CancelInvoke("StartPageFunc");
Close();
webView.LoadHTMLString("<div style=\"background:#23232d\" />", this.url);
//Destroy(gameObject);
//UIManager.Instance.mActivityController = null;
}
private void RunJavaScript(string js)
@@ -14,7 +14,7 @@ using Assets.Scripts.Devices;
public class ConnectDeviceModal : PFUIPanel
{
private float timer = 1.0f;
private float timer = 0f;
private SensorType mSensorType = SensorType.None;
public SensorType SensorType {
get {
@@ -22,7 +22,6 @@ public class ConnectDeviceModal : PFUIPanel
}
set
{
//Debug.Log(value);
mSensorType = value;
var deviceInfoStr = Utils.deviceDict[value.ToString()];
if (deviceInfoStr != null)
@@ -30,7 +29,7 @@ public class ConnectDeviceModal : PFUIPanel
var deviceInfo = deviceInfoStr.Split('|');
if (deviceInfo.Length == 2)
{
Title.text = deviceInfo[0];
Title.text = App.GetLocalString(deviceInfo[0]);
Logo.sprite = Resources.Load<Sprite>(deviceInfo[1]);
}
}
@@ -60,7 +59,7 @@ public class ConnectDeviceModal : PFUIPanel
content = panel.Find("Scroll View").Find("Viewport").Find("Content").GetComponent<VerticalLayoutGroup>();
noDevice = container.Find("NoDevice").GetComponent<Text>();
noDevice.text = App.GetLocalString("NO DEVICE");
searchIconRect = container.Find("SearchIcon").GetComponent<RectTransform>();
_x = searchIconRect.localPosition.x;
_y = searchIconRect.localPosition.y;
@@ -148,7 +147,7 @@ public class ConnectDeviceModal : PFUIPanel
if(timer <= 0)
{
SearchDevice();
timer = 1.0f;
timer += 1.0f;
}
Move();
@@ -203,27 +202,6 @@ public class ConnectDeviceModal : PFUIPanel
UIManager.AddEvent(deviceItemObj.gameObject, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
{
deviceItemObj.Set(true);
var trainer = SensorType == SensorType.Trainer && deviceItemObj.DeviceInfo.State == DeviceState.Connected;
var nontrainer = deviceItemObj.DeviceInfo.Sensor != SensorType.Trainer && SensorType != SensorType.Trainer && deviceItemObj.DeviceInfo.State == DeviceState.Connected;
if (trainer || nontrainer)
{
connectBtnText.text = App.GetLocalString("DISCONNECT");
connectBtnText.GetComponent<PFUIText>().key = "DISCONNECT";
}
else
{
connectBtnText.text = App.GetLocalString("CONNECT");
connectBtnText.GetComponent<PFUIText>().key = "CONNECT";
}
foreach (var item in deviceList)
{
if (item.Key != deviceItemObj.DeviceInfo.Id)
{
item.Value.Set(false);
}
}
}));
//UIManager.AddEvent(deviceItemObj.gameObject, EventTriggerType.Deselect, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
@@ -244,21 +222,14 @@ public class ConnectDeviceModal : PFUIPanel
if (firstDevice != null)
{
firstDevice.Set(true);
var trainer = SensorType == SensorType.Trainer && firstDevice.DeviceInfo.State == DeviceState.Connected;
var nontrainer = firstDevice.DeviceInfo.Sensor != SensorType.Trainer && SensorType != SensorType.Trainer && firstDevice.DeviceInfo.State == DeviceState.Connected;
if(trainer || nontrainer)
}
else
{
var defaultDevice = deviceList.FirstOrDefault();
if (defaultDevice.Value != null)
{
connectBtnText.text = App.GetLocalString("DISCONNECT");
connectBtnText.GetComponent<PFUIText>().key = "DISCONNECT";
defaultDevice.Value.Set(true);
}
else
{
connectBtnText.text = App.GetLocalString("CONNECT");
connectBtnText.GetComponent<PFUIText>().key = "CONNECT";
}
//connectBtn.text.text = "DISCOUNECT";
noDevice.text = firstDevice.DeviceInfo.Name;
}
//DeviceItem firstDevice;
//var devicesTemp = deviceList.Select(d => d.Value).Where(d => d.DeviceInfo.State == DeviceState.Connected);
@@ -267,8 +238,45 @@ public class ConnectDeviceModal : PFUIPanel
// firstDevice = devicesTemp.FirstOrDefault(d=>d)
//}
}
//如果没有可连接的设备按钮只读
connectBtn.mButton.enabled = deviceList.Count > 0;
connectBtn.mButton.interactable = deviceList.Count > 0;
}
}
//选中需要连接的设备
public void SelectDevice(DeviceItem deviceItemObj)
{
var trainer = SensorType == SensorType.Trainer && deviceItemObj.DeviceInfo.State == DeviceState.Connected;
var nontrainer = deviceItemObj.DeviceInfo.Sensor != SensorType.Trainer && SensorType != SensorType.Trainer && deviceItemObj.DeviceInfo.State == DeviceState.Connected;
if (trainer || nontrainer)
{
connectBtnText.text = App.GetLocalString("DISCONNECT");
connectBtnText.GetComponent<PFUIText>().key = "DISCONNECT";
}
else
{
connectBtnText.text = App.GetLocalString("CONNECT");
connectBtnText.GetComponent<PFUIText>().key = "CONNECT";
}
foreach (var item in deviceList)
{
if (item.Key != deviceItemObj.DeviceInfo.Id)
{
item.Value.Set(false);
}
}
noDevice.text = deviceItemObj.DeviceInfo.Name + "-"+ deviceItemObj.DeviceInfo.DeviceNumber;
if (deviceItemObj.DeviceInfo.State == DeviceState.Connected)
{
noDevice.color = Color.white;
}
else
{
noDevice.color = Utils.HexToColor("5C5C6E");
}
}
public override void Show()
{
@@ -153,6 +153,8 @@ public class DeviceItem : Selectable, IEventSystemHandler, IPointerClickHandler
if (this.isOn)
{
SetSelectedStyle();
var manager = FindObjectOfType<ConnectDeviceModal>();
manager.SelectDevice(this);
}
else
{
@@ -70,7 +70,7 @@ public class DeviceView : MonoBehaviour
mSearchButton = unconnectionPanel.transform.Find("SearchButton").gameObject;
mPairButton = unconnectionPanel.transform.Find("PairButton").gameObject;
searchState = unconnectionPanel.transform.Find("SearchState").GetComponent<Text>();
mPairButton.SetActive(false);
//mPairButton.SetActive(false);
connectionPanel = this.transform.Find("ConnectionPanel").gameObject;
#if UNITY_IOS || UNITY_ANDROID
unconnectionButton = unconnectionPanel.GetComponent<Button>();
@@ -137,7 +137,10 @@ public class DeviceView : MonoBehaviour
connectButtonClick();
}));
#endif
UIManager.AddEvent(mSearchButton, EventTriggerType.PointerClick, new UnityAction<UnityEngine.EventSystems.BaseEventData>(e =>
{
connectButtonClick();
}));
UIManager.AddEvent(mPairButton, EventTriggerType.PointerClick, new UnityAction<UnityEngine.EventSystems.BaseEventData>(e =>
{
connectButtonClick();
@@ -276,7 +279,7 @@ public class DeviceView : MonoBehaviour
connectionPanel.SetActive(false);
logo.sprite = sprite0;
noDevice.text = App.GetLocalString("NO DEVICE");
searchState.text = App.GetLocalString("Searching...");
var hasDevice = false;
@@ -286,6 +289,7 @@ public class DeviceView : MonoBehaviour
else {
hasDevice = App.MainDeviceAdapter.GetDevices().Any(d => d.Sensor == SensorType);
}
noDevice.text = hasDevice? App.GetLocalString("CHOOSE DEVICE") : App.GetLocalString("NO DEVICE");
//Debug.Log(hasDevice);
if (hasDevice)
{
@@ -303,7 +307,7 @@ public class DeviceView : MonoBehaviour
#if !(UNITY_IOS || UNITY_ANDROID)
mSearchButton.SetActive(true);
#endif
mPairButton.SetActive(false);
//mPairButton.SetActive(false);
}
}
else if(connectedDevice.State == DeviceState.Connecting)
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1fa036e3dd69a3a4686ffb7a3bfb530a
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,59 @@
using Assets.Scripts;
using Assets.Scripts.Apis.Models;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class MailDetailController : PFUIPanel
{
// Start is called before the first frame update
ScrollRect scroll;
protected override void Awake()
{
UIManager.AddEvent(transform.Find("Container/Exit").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, async b =>
{
CloseSelf();
});
UIManager.AddEvent(transform.Find("Container/BtnDelete").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
UIManager.ShowConfirm(App.GetLocalString("Delete"), App.GetLocalString("Are you sure you want to delete this email?"), async () =>
{
if (mail != null)
{
await ConfigHelper.mailApi.Delete(mail.Id);
Utils.showToast(null, "Success", type: 1);
UIManager.CloseConfirm();
CloseSelf();
}
});
});
scroll = transform.Find("Container/Content/Scroll View").GetComponent<ScrollRect>();
}
void Start()
{
}
// Update is called once per frame
void Update()
{
}
MailModel mail;
public async void Initial(MailModel item)
{
this.mail = item;
await ConfigHelper.mailApi.MarkRead(item.Id);
transform.Find("Container/Title").GetComponent<Text>().text = item.Title;
scroll.content.Find("Text").GetComponent<Text>().text = $"{item.Desc}\n\n{item.SendNickName}";
}
private async void CloseSelf()
{
Close();
await MailReceiver.Instance().GetMessage();
UIManager.Instance.MailListController.Show();
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 74fe80f225b0aff448f240dde817f640
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,37 @@
using Assets.Scripts;
using Assets.Scripts.Apis.Models;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class MailItemController : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void Initial(MailModel item)
{
var color = item.IsRead ? Utils.HexToColorHtml("#5C5C6E") : Utils.HexToColorHtml("#ffffff");
Text title = transform.Find("Content/Title").GetComponent<Text>(), time = transform.Find("Content/Time").GetComponent<Text>();
title.text = item.Title;
time.text = item.CreateTime.ToString("yyyy-MM-dd HH:mm:ss");
title.color = color;
time.color = color;
transform.Find("Content/MailImage").GetComponent<Image>().color = color;
UIManager.AddEvent(gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
UIManager.ShowMailDetailPanel(item);
});
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 896523cde19693d4ca337b93a7880c8a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,60 @@
using Assets.Scripts;
using Assets.Scripts.Apis.Models;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class MailListController : PFUIPanel
{
// Start is called before the first frame update
ScrollRect scroll;
GameObject mail;
protected override void Awake()
{
UIManager.AddEvent(transform.Find("Container/Exit").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
Close();
});
scroll = transform.Find("Container/Content/Right/Scroll View").GetComponent<ScrollRect>();
#if UNITY_STANDALONE_WIN
mail = Resources.Load<GameObject>("UI/Prefab/Mail/MailItem");
#else
mail = Resources.Load<GameObject>("UI/Prefab/Mail/MailItem-mob");
#endif
}
public override void Show()
{
base.Show();
DisplayMails(App.CurrentUserMails);
}
private void DisplayMails(List<MailModel> list)
{
if (list == null) return;
scroll.content.DestroyChildren();
if (mail != null)
{
foreach (var item in list)
{
var obj = Instantiate(mail);
obj.GetComponent<MailItemController>().Initial(item);
//obj.SendMessage("Initial", );
obj.transform.SetParent(scroll.content.transform);
obj.transform.localScale = new Vector3(1, 1, 1);
}
}
}
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: cdfbce372733cb8438be420f311cb56e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,64 @@
using Assets.Scripts;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using UnityEngine;
using UnityEngine.UI;
public class MailReceiver : MonoBehaviour
{
// Start is called before the first frame update
private static MailReceiver _instance = null;
public static bool Exists()
{
return _instance != null;
}
public static MailReceiver Instance()
{
if (!Exists())
{
throw new Exception("UnityMainThreadDispatcher could not find the UnityMainThreadDispatcher object. Please ensure you have added the MainThreadExecutor Prefab to your scene.");
}
return _instance;
}
void Awake()
{
if (_instance == null)
{
_instance = this;
}
DontDestroyOnLoad(gameObject);
}
void Start()
{
}
float timer = 10f;
// Update is called once per frame
void Update()
{
timer -= Time.deltaTime;
if (timer < 0)
{
GetMessage();
timer += 10;
}
}
public async Task GetMessage()
{
var res = await ConfigHelper.mailApi.GetList(0, 100, 0);
if (res.result)
{
App.CurrentUserMails = res.data;
App.hasNotRead = res.data.Count(x => !x.IsRead) > 0;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 227da2d8b06aad34ca648aa8c2ab5f05
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+14 -1
View File
@@ -3,6 +3,7 @@ using DG.Tweening;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
@@ -81,7 +82,20 @@ public class MainNav : MonoBehaviour
{
UIManager.ShowFeedBackModal();
});
UIManager.AddEvent(transform.Find("Mail").gameObject, EventTriggerType.PointerClick, x =>
{
UIManager.ShowMailListPanel();
});
App.HasNotReadChanged -= ShowMailDot;
App.HasNotReadChanged += ShowMailDot;
}
private void ShowMailDot(object sender, EventArgs e)
{
if (transform)
{
transform.Find("Mail/Dot").gameObject.SetActive((bool)sender);
}
}
public void ShowRowerTab()
@@ -126,7 +140,6 @@ public class MainNav : MonoBehaviour
}
#endif
}
public void ShowExit()
{
if (exit)
+39 -3
View File
@@ -114,10 +114,21 @@ public class MapItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandler,
if (!isModal)
{
transform.Find("CollectImg").GetComponent<Button>().onClick.RemoveAllListeners();
transform.Find("CollectImg").GetComponent<Button>().onClick.AddListener(Collect);
if (App.CurrentRouteType == "My Upload")
{
transform.Find("CollectImg").GetComponent<Button>().onClick.AddListener(ApplyOpenRoute);
}
else
{
transform.Find("CollectImg").GetComponent<Button>().onClick.AddListener(Collect);
}
}
transform.Find("CollectImg").Find("Image").GetComponent<Image>().sprite =
UIManager.Instance.collectDict[myMap.IsFavorite];
App.CurrentRouteType != "My Upload"?UIManager.Instance.collectDict[myMap.IsFavorite]: UIManager.Instance.uploadDict[myMap.IsEnabled];
if (App.CurrentRouteType == "My Upload")
{
transform.Find("CollectImg").Find("Image").GetComponent<RectTransform>().sizeDelta = new Vector2(25, 20f);
}
#if !(UNITY_ANDROID || UNITY_IOS)
transform.Find("CollectImg").gameObject.SetActive(false);
#endif
@@ -129,7 +140,8 @@ public class MapItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandler,
SetActive4Button(false);
var isRecent = App.CurrentRouteType == "Recent Routes" && myMap.RecentRecord != null && myMap.RecentRecord.ContinueCyclingParam != null && !isModal;
var isRecent = myMap.RecentRecord != null && myMap.RecentRecord.ContinueCyclingParam != null && !isModal;
//var isRecent = App.CurrentRouteType == "Recent Routes" && myMap.RecentRecord != null && myMap.RecentRecord.ContinueCyclingParam != null && !isModal;
transform.Find("BtnContinue").gameObject.SetActive(isRecent);
transform.Find("BtnReride").gameObject.SetActive(isRecent);
transform.Find("MapHBImg").gameObject.SetActive(!isRecent);
@@ -165,6 +177,30 @@ public class MapItem : MonoBehaviour, IPointerExitHandler, IPointerEnterHandler,
}
}
void ApplyOpenRoute()
{
if (!map.IsEnabled)
{
UIManager.ShowConfirm(App.GetLocalString("Request to make the route public"), App.GetLocalString("Do you want to make the route public?"), async () =>
{
var res = await ConfigHelper.mapApi.ApplyOpenRoute(map.Id);
if (res.result)
{
Utils.showToast(null, App.GetLocalString("Submitted, please wait for background review."), type: 1);
UIManager.CloseConfirm();
}
else
{
Utils.showToast(null, res.errMsg);
}
});
}
else
{
Utils.showToast(null, App.GetLocalString("Route is public."), type: 1);
}
}
private void Ride()
{
App.RouteIdParam = map.Id;
+115 -27
View File
@@ -16,10 +16,19 @@ public class NewMainNav : MonoBehaviour
{
public Sprite image;
public UnityAction action;
public bool isAlways;
public CustomButton(Sprite image, UnityAction action)
{
this.image = image;
this.action = action;
isAlways = true;
}
public CustomButton(Sprite image, UnityAction action,bool isAlways)
{
this.image = image;
this.action = action;
isAlways = false;
}
}
private GameObject exit;
@@ -28,23 +37,30 @@ public class NewMainNav : MonoBehaviour
float delayTime = 0;
private List<string> typeArray = new List<string>()
{
"Back","Exit","Home","Device","Delay","Setting","Support","Avatar","Custom","Custom2"
"Back","Exit","Home","Device","Delay","Setting","Support","Avatar","Custom","Custom2","Mail","Custom3"
};
private List<int> indexs = new List<int>();
private int? shrinkIndex = null;
private CustomButton custom = null,custom2 = null;
private CustomButton custom = null,custom2 = null, custom3 = null;
/// <summary>
///
/// </summary>
/// <param name="indexs">仅展开显示的按钮:1:"Exit",3:"Device",4:"Delay",5:"Setting",6:"Support",7:"Avatar"</param>
/// <param name="shrinkIndex">合上后仍显示的按钮:0:"Back",2:"Home",null:仅PF</param>
/// <param name="custom">自定义按钮 8:c1 9:c2</param>
public void SetButtonActive(List<int> indexs,int? shrinkIndex = null, CustomButton custom = null, CustomButton custom2 = null)
/// <param name="custom">自定义按钮 8:c1 9:c2 11:c3</param>
public void SetButtonActive(List<int> indexs,int? shrinkIndex = null, CustomButton custom = null, CustomButton custom2 = null,CustomButton custom3 = null,bool ShowMail = true)
{
this.indexs = indexs;
if (ShowMail)
{
//邮箱常驻(除划船机)
this.indexs.Add(10);
}
this.shrinkIndex = shrinkIndex;
this.custom = custom;
this.custom2 = custom2;
this.custom3 = custom3;
if (custom != null)
{
transform.Find("Custom").GetComponent<Button>().onClick.RemoveAllListeners();
@@ -59,23 +75,39 @@ public class NewMainNav : MonoBehaviour
transform.Find("Custom2").GetComponent<Image>().sprite = custom2.image;
indexs.Add(9);
}
if (custom3 != null)
{
transform.Find("Custom3").GetComponent<Button>().onClick.RemoveAllListeners();
transform.Find("Custom3").GetComponent<Button>().onClick.AddListener(custom3.action);
transform.Find("Custom3").GetComponent<Image>().sprite = custom3.image;
indexs.Add(11);
}
SetExpand(false);
}
/// <summary>
/// true:展开 false:关闭
/// </summary>
/// <param name="flag"></param>
public void SetExpand(bool flag)
{
if (flag)
{
autoClose = true;
}
else
{
autoClose = false;
}
closeTime = 5f;
List<string> types = new List<string>();
if (indexs != null)
{
types = typeArray.Where((x, i) => indexs.Contains(i)).ToList();
}
string shrinkName = null;
if (shrinkIndex.HasValue && (shrinkIndex == 0 || shrinkIndex == 2))
if (shrinkIndex.HasValue && isShrinkIndex(shrinkIndex.Value))
{
shrinkName = typeArray[shrinkIndex.Value];
}
@@ -96,18 +128,27 @@ public class NewMainNav : MonoBehaviour
item.gameObject.SetActive(types.Contains(item.name));
}
}
else
else
{
item.gameObject.SetActive(item.name == "PF"|| item.name == shrinkName);
item.gameObject.SetActive(item.name == "PF" || item.name == shrinkName);
}
//自定义按钮出来
if (item.name == "Custom")
if (item.name == "Custom" || item.name == "Custom2" || item.name == "Custom3")
{
item.gameObject.SetActive(custom != null && types.Contains(item.name));
}
else if (item.name == "Custom2")
{
item.gameObject.SetActive(custom2 != null && types.Contains(item.name));
//自定义按钮出来
CustomButton c = null;
if (item.name == "Custom")
{
c = custom;
}
else if (item.name == "Custom2")
{
c = custom2;
}
else if (item.name == "Custom3")
{
c = custom3;
}
item.gameObject.SetActive(c != null && types.Contains(item.name) && (flag || !flag && c.isAlways));
}
}
}
@@ -115,7 +156,7 @@ public class NewMainNav : MonoBehaviour
public void ShowButton(string v)
{
var i = typeArray.FindIndex((x)=>x == v);
if (i == -1 || i == 0 || i == 2)
if (i == -1 || isShrinkIndex(i))
{
return;
}
@@ -125,7 +166,7 @@ public class NewMainNav : MonoBehaviour
public void HideButton(string v)
{
var i = typeArray.FindIndex((x) => x == v);
if (i == -1 || i == 0 || i == 2)
if (i == -1 || isShrinkIndex(i))
{
return;
}
@@ -140,7 +181,14 @@ public class NewMainNav : MonoBehaviour
Utils.DisplayHead(transform.Find("Avatar").GetComponent<Image>(), App.CurrentUser.WxHeadImg);
UIManager.AddEvent(transform.Find("Avatar").gameObject, EventTriggerType.PointerClick, b =>
{
UIManager.ShowUserInfoPanel();
if (App.IsRowerMode == true)
{
UIManager.ShowEditUserPanel();
}
else
{
UIManager.ShowUserInfoPanel();
}
});
UIManager.AddEvent(transform.Find("PF").gameObject, EventTriggerType.PointerClick, b =>
{
@@ -160,7 +208,15 @@ public class NewMainNav : MonoBehaviour
UIManager.AddEvent(device.gameObject, EventTriggerType.PointerClick, x =>
{
//Debug.Log("click device");
UIManager.ShowDevicePanel();
if (App.IsRowerMode.HasValue && App.IsRowerMode.Value)
{
if (UIManager.Instance.RowerHomeScript.checkRowing()) return;
UIManager.ShowRowerDevicePanel();
}
else
{
UIManager.ShowDevicePanel();
}
});
home = this.transform.Find("Home").gameObject;
@@ -212,8 +268,21 @@ public class NewMainNav : MonoBehaviour
{
UIManager.ShowFeedBackModal();
});
UIManager.AddEvent(transform.Find("Mail").gameObject, EventTriggerType.PointerClick, x =>
{
UIManager.ShowMailListPanel();
});
App.HasNotReadChanged -= ShowMailDot;
App.HasNotReadChanged += ShowMailDot;
}
private void ShowMailDot(object sender, EventArgs e)
{
if (transform)
{
transform.Find("Mail/Dot").gameObject.SetActive((bool)sender);
}
}
public void ShowRowerTab()
{
@@ -230,7 +299,10 @@ public class NewMainNav : MonoBehaviour
transform.Find("Home").gameObject.SetActive(false);
}
}
private bool isShrinkIndex(int ind)
{
return ind == 0 || ind == 2;
}
// Start is called before the first frame update
void Start()
{
@@ -238,19 +310,25 @@ public class NewMainNav : MonoBehaviour
}
bool isTouch = false;
float hideTime = 5;
bool autoClose = false;
float closeTime = 5;
// Update is called once per frame
void Update()
{
if (Input.touchCount > 0)
if (Input.touchCount > 0)
{
Debug.Log(235);
isTouch = true;
if (autoClose)
{
closeTime = 5f;
}
GetComponent<CanvasGroup>().DOFade(1, 0.5f);
}
hideTime -= Time.deltaTime;
if (hideTime < 0)
if (hideTime < 0)
{
if (!isTouch)
if (!isTouch)
{
GetComponent<CanvasGroup>().DOFade(0.4f, 0.5f);
}
@@ -262,16 +340,26 @@ public class NewMainNav : MonoBehaviour
{
Debug.Log("小时");
delayTime = 0;
transform.Find("Delay/Tooltips").GetComponent<CanvasGroup>().DOFade(0, 0.5f).onComplete = ()=>
transform.Find("Delay/Tooltips").GetComponent<CanvasGroup>().DOFade(0, 0.5f).onComplete = () =>
{
transform.Find("Delay/Tooltips").gameObject.SetActive(false);
};
}
else if(delayTime > 0)
else if (delayTime > 0)
{
Debug.Log(delayTime);
delayTime -= Time.deltaTime;
}
closeTime -= Time.deltaTime;
if (closeTime < 0)
{
if (autoClose)
{
Debug.Log("关一次");
SetExpand(false);
}
}
}
}
@@ -229,8 +229,13 @@ public class EditUserController : PFUIPanel, INativeOnMobileImageSelect
{"ContactPhone",mPhone.GetComponent<InputField>() },
{"ContactAddress",mAddr.GetComponent<InputField>() },
};
#region 划船机功能:隐藏骑行相关的
if (App.IsRowerMode == true)
{
transform.Find("Panel/MainPanel/BW").gameObject.SetActive(false);
transform.Find("Panel/MainPanel/WD").gameObject.SetActive(false);
}
#endregion
}
async Task Login()
{
@@ -43,7 +43,10 @@ public class HomeController : PFUIPanel
var BtnContainer = transform.Find("MainFuncContainer");
#if UNITY_ANDROID || UNITY_IOS
var nav = transform.Find("MainNav-mobile").GetComponent<NewMainNav>();
nav.SetButtonActive(new List<int> { 1, 3, 4, 6 });
nav.SetButtonActive(new List<int> { 1, 3, 4, 6 },null,new NewMainNav.CustomButton(Resources.Load<Sprite>("Images/RowerNew/ICON_mode_44"), () =>
{
UIManager.ShowRowerSelector();
},false));
newNav = nav;
UIManager.AddEvent(transform.Find("TodayData/Datas/Distance").gameObject, EventTriggerType.PointerClick, b =>
{
File diff suppressed because it is too large. Load diff
@@ -119,6 +119,19 @@ public class ResultListController : PFUIPanel
#if UNITY_ANDROID || UNITY_IOS
GetList(2);
#endif
#region 划船机功能:隐藏骑行记录
#if UNITY_ANDROID || UNITY_IOS
btnRower.transform.localPosition = new Vector3(btnRower.transform.localPosition.x, btnRoute.transform.localPosition.y, btnRower.transform.localPosition.z);
btnRoute.gameObject.SetActive(false);
btnMatch.gameObject.SetActive(false);
transform.Find("ListPanel/Line").gameObject.SetActive(false);
transform.Find("ListPanel/Line2").gameObject.SetActive(false);
StartScroll(2);
//scrollContent.localPosition = new Vector3(674 * -2, scrollContent.localPosition.y, scrollContent.localPosition.z);//.DOLocalMoveX(674 * index * -1, 0.3f);
//btnRower.GetComponent<Text>().color = Utils.HexToColor("#ffffff");
#endif
#endregion
}
public void Load()
@@ -177,6 +190,7 @@ public class ResultListController : PFUIPanel
Load();
StartScroll(1);
}
}
Dictionary<int, bool> isEnd = new Dictionary<int, bool>
{
@@ -91,11 +91,32 @@ public class RouteItem : MonoBehaviour
{
Utils.DisplayImage(raw, result.Cover, true);
}
row1.Find("Time").GetComponent<Text>().text = $"<color=#5c5c6e>{App.GetLocalString("Rowing time")}:</color>{TimeSpan.FromSeconds(result.TotalTime).ToString()}";
row1.Find("Distance").GetComponent<Text>().text = $"<color=#5c5c6e>{App.GetLocalString("Distance")}:</color>{result.TotalDistance}M";
row1.Find("Time").GetComponent<Text>().text = $"<color=#5c5c6e>{App.GetLocalString("Rowing time")}:</color>{TimeSpan.FromSeconds(result.Ticks).ToString()}";
row1.Find("Distance").GetComponent<Text>().text = $"<color=#5c5c6e>{App.GetLocalString("row distance")}:</color>{result.TotalDistance}M";
row2.Find("Device").GetComponent<Text>().text = $"<color=#5c5c6e>{App.GetLocalString("Rowing equipment")}:</color>{result.ManufacturerName}";
left.Find("Progress").gameObject.SetActive(false);
left.Find("Main/Name").GetComponent<Text>().text = $"{result.CreateTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")} Free Rowing";
string typeStr = "Free";
if (result.Type == 1)
{
typeStr = $"{result.TypeValue}M";
}
else if (result.Type == 2 && result.TypeValue.HasValue)
{
var ts = TimeSpan.FromSeconds(result.TypeValue.Value);
if (ts.TotalHours >= 1)
{
typeStr = ts.TotalHours.ToString("#0.0") + "h";
}
else if (ts.TotalMinutes >= 1)
{
typeStr = ts.TotalMinutes.ToString("#0.0") + "min";
}
else
{
typeStr = result.TypeValue.Value + "s";
}
}
left.Find("Main/Name").GetComponent<Text>().text = $"{result.CreateTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")} {typeStr} Rowing";
left.Find("Main/Time").GetComponent<Text>().text = $"{result.StartTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")} ~ {result.CreateTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")}";
var rect = left.Find("Main").GetComponent<RectTransform>();
rect.sizeDelta = new Vector2(399,rect.sizeDelta.y);
@@ -108,7 +129,14 @@ public class RouteItem : MonoBehaviour
{
UIManager.AddEvent(btnDetail.gameObject, EventTriggerType.PointerClick, b =>
{
UIManager.ShowRowerResult(result.Id);
//UIManager.ShowActivityPanel("http://192.168.0.101:3081/rower/record/27C0BE5C-3818-45D0-A2FD-681AC2ACFB64?UserId=16650");
#if UNITY_ANDROID || UNITY_IOS
UIManager.ShowActivityPanel($"{App.websiteDict[App.Host]}rower/record/{result.Id}?UserId={App.CurrentUser.Id}");
#else
Application.OpenURL($"{App.websiteDict[App.Host]}rower/record/{result.Id}?Token={App.CurrentUser.cookie}");
#endif
//Application.OpenURL($"{App.websiteDict[App.Host]}rower/record/{result.Id}?Token={App.CurrentUser.cookie}");
//UIManager.ShowRowerResult(result.Id);
});
}
btnReRide = right.Find("BtnRide");
@@ -119,7 +147,7 @@ public class RouteItem : MonoBehaviour
UIManager.ShowConfirm("Re-Rowing", "Rowing again?", () =>
{
UIManager.CloseConfirm();
UIManager.ShowRowerPanel();
UIManager.ShowRowerPanel(result);
});
});
}
@@ -50,12 +50,12 @@ public class RowerAnimation : PFUIPanel
for (int i = 0; i < 15; i++)
{
image.sprite = sprites[i];
yield return new WaitForSeconds(0.02f);
yield return new WaitForSeconds(0.02666f);
}
for (int i = 15; i < 30; i++)
{
image.sprite = sprites[i];
yield return new WaitForSeconds(0.04f);
yield return new WaitForSeconds(0.05333f);
}
}
@@ -0,0 +1,50 @@
using Assets.Scripts;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class RowerDevicePanel : PFUIPanel
{
protected override void Awake()
{
UIManager.AddEvent(transform.Find("Container/Tools/Back").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
Close();
});
}
// Start is called before the first frame update
void Start()
{
}
public override void Show()
{
base.Show();
print("开启扫描");
#if UNITY_ANDROID || UNITY_IOS
App.MainDeviceAdapter.StartScan();
#if UNITY_ANDROID
Utils.CallAndroidMethod("OpenLocationService");
#endif
#endif
}
float timer = 1f;
// Update is called once per frame
void Update()
{
timer -= Time.deltaTime;
if (timer <= 0)
{
if (App.MainDeviceAdapter.GetState(Assets.Scripts.Devices.ConnectionInterface.BLE) == Assets.Scripts.Devices.DeviceAdapterState.On)
{
transform.Find("Container/Tools/BlueTooth").GetComponent<Image>().sprite = Resources.Load<Sprite>("Images/RowerNew/ICON_bluetooth_44_on");
}
else
{
transform.Find("Container/Tools/BlueTooth").GetComponent<Image>().sprite = Resources.Load<Sprite>("Images/RowerNew/ICON_bluetooth_44");
}
timer += 1f;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 169dd57411866874882869d55e047e57
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -67,7 +67,7 @@ public class RowerDeviceView : MonoBehaviour
mSearchButton = unconnectionPanel.transform.Find("SearchButton").gameObject;
mPairButton = unconnectionPanel.transform.Find("PairButton").gameObject;
searchState = unconnectionPanel.transform.Find("SearchState").GetComponent<Text>();
mPairButton.SetActive(false);
//mPairButton.SetActive(false);
connectionPanel = this.transform.Find("ConnectionPanel").gameObject;
var material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
@@ -124,21 +124,13 @@ public class RowerDeviceView : MonoBehaviour
UIManager.AddEvent(mPairButton, EventTriggerType.PointerClick, new UnityAction<UnityEngine.EventSystems.BaseEventData>(e =>
{
if (deviceModal == null)
{
#if UNITY_IOS || UNITY_ANDROID
var obj = Resources.Load("UI/Prefab/Device/Mobile/ConnectDeviceModal");
#else
var obj = Resources.Load("UI/Prefab/Device/ConnectDeviceModal");
#endif
GameObject gameObject = (GameObject)Instantiate(obj);
deviceModal = gameObject.GetComponent<ConnectDeviceModal>();
}
deviceModal.SensorType = this.SensorType;
UIManager.Show(deviceModal, null, true);
connectButtonClick();
}));
UIManager.AddEvent(gameObject, EventTriggerType.PointerClick, b =>
{
if (!mPairButton.activeInHierarchy && !mDisconnectButton.activeInHierarchy) return;
connectButtonClick();
});
UIManager.AddEvent(mDisconnectButton, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<BaseEventData>(e => {
//var device = GetDevice();
//if(device != null && device.State == DeviceState.Connected)
@@ -156,9 +148,23 @@ public class RowerDeviceView : MonoBehaviour
deviceModal.SensorType = this.SensorType;
UIManager.Show(deviceModal, null, true);
}));
}
void connectButtonClick()
{
if (deviceModal == null)
{
#if UNITY_IOS || UNITY_ANDROID
var obj = Resources.Load("UI/Prefab/Device/Mobile/ConnectDeviceModal");
#else
var obj = Resources.Load("UI/Prefab/Device/ConnectDeviceModal");
#endif
GameObject gameObject = (GameObject)Instantiate(obj);
deviceModal = gameObject.GetComponent<ConnectDeviceModal>();
}
deviceModal.SensorType = this.SensorType;
UIManager.Show(deviceModal, null, true);
}
void InitLogo()
{
if (SensorType == SensorType.Power)
@@ -244,8 +250,8 @@ public class RowerDeviceView : MonoBehaviour
connectionPanel.SetActive(false);
logo.sprite = sprite0;
noDevice.text = "NO DEVICE";
searchState.text = "Searching...";
noDevice.text = App.GetLocalString("NO DEVICE");
searchState.text = App.GetLocalString("Searching...");
var hasDevice = false;
if (SensorType == SensorType.SpeedCadence)
@@ -272,7 +278,7 @@ public class RowerDeviceView : MonoBehaviour
#if !(UNITY_IOS || UNITY_ANDROID)
mSearchButton.SetActive(true);
#endif
mPairButton.SetActive(false);
//mPairButton.SetActive(false);
}
}
else if(connectedDevice.State == DeviceState.Connecting)
@@ -6,8 +6,11 @@ using System.Collections.Generic;
public class RowerGraphChartFeed : MonoBehaviour
{
void Start ()
GraphChartBase graph { get; set; }
void Start ()
{
graph = GetComponent<GraphChartBase>();
//GraphChartBase graph = GetComponent<GraphChartBase>();
//if (graph != null)
//{
@@ -16,7 +19,7 @@ public class RowerGraphChartFeed : MonoBehaviour
// graph.DataSource.StartBatch();
// graph.DataSource.ClearCategory("Player 1");
// graph.DataSource.ClearAndMakeBezierCurve("Player 2");
// for (int i = 0; i <10000; i++)
// {
// graph.DataSource.AddPointToCategory("Player 1",i*5,Random.value*10f + 20f);
@@ -29,29 +32,39 @@ public class RowerGraphChartFeed : MonoBehaviour
// graph.DataSource.MakeCurveCategorySmooth("Player 2");
// graph.DataSource.EndBatch();
//}
// StartCoroutine(ClearAll());
// StartCoroutine(ClearAll());
}
public void SetData(List<DoubleVector2> list)
public void SetData(List<DoubleVector2> list,List<DoubleVector2> list2 = null)
{
GraphChartBase graph = GetComponent<GraphChartBase>();
if (graph != null)
{
graph.Scrollable = false;
//graph.HorizontalValueToStringMap[0.0] = "Zero"; // example of how to set custom axis strings
graph.DataSource.StartBatch();
//graph.DataSource.StartBatch();
graph.DataSource.ClearCategory("Player 1");
graph.DataSource.ClearCategory("Player 2");
graph.ClearCache();
for (int i = 0; i < list.Count; i++)
{
var item = list[i];
graph.DataSource.AddPointToCategory("Player 1", item.x, item.y);
graph.DataSource.AddPointToCategoryRealtime("Player 2", item.x, item.y);
//if (i == 0)
// graph.DataSource.SetCurveInitialPoint("Player 1", item.x, item.y);
//else
// graph.DataSource.AddLinearCurveToCategory("Player 1", new DoubleVector2(item.x, item.y));
}
if (list2 != null)
{
for (int i = 0; i < list2.Count; i++)
{
var item = list2[i];
graph.DataSource.AddPointToCategoryRealtime("Player 1", item.x, item.y);
}
}
//graph.DataSource.MakeCurveCategorySmooth("Player 1");
graph.DataSource.EndBatch();
//graph.DataSource.EndBatch();
}
}
IEnumerator ClearAll()
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ee3b67ceb2893134a887a9e30922821e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,349 @@
using Assets.Scripts;
using Assets.Scripts.UI.Control;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
public class RowerTaskPanel : PFUIPanel
{
public class RowerType
{
/// <summary>
/// 1 里程 2 时间
/// </summary>
public int type { get; set; }
/// <summary>
/// 里程:m 时间:s
/// </summary>
public float value { get; set; }
}
Transform selector, distance, time;
public RowerType rowerType;
public Action<RowerType> callBack { get; set; }
protected override void Awake()
{
distance = transform.Find("Main/Distance");
time = transform.Find("Main/Time");
rowerType = new RowerType();
UIManager.AddEvent(transform.Find("Main/BtnGo").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
Go();
});
UIManager.AddEvent(transform.Find("Main/BtnCancel").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
Close();
});
UIManager.AddEvent(transform.Find("Main/BtnFreeMode").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
rowerType.type = 0;
rowerType.value = 0;
if (callBack != null)
{
callBack.Invoke(rowerType);
}
Close();
});
//var bg = transform.Find("Main/Time/Inputbg").gameObject;
//UIManager.AddEvent(bg, UnityEngine.EventSystems.EventTriggerType.PointerEnter, b =>
// {
// bg.GetComponent<Outline>().enabled = true;
// bg.GetComponent<Outline>().effectColor = Utils.HexToColorHtml("#353543");
// });
//UIManager.AddEvent(bg, UnityEngine.EventSystems.EventTriggerType.Select, b =>
//{
// bg.GetComponent<Outline>().enabled = true;
// bg.GetComponent<Outline>().effectColor = Utils.HexToColorHtml("#f93086");
//});
//UIManager.AddEvent(bg, UnityEngine.EventSystems.EventTriggerType.Deselect, b =>
//{
// bg.GetComponent<Outline>().enabled = false;
//});
formList = new List<object>
{
distance.Find("Btn500").GetComponent<Button>(),
distance.Find("Btn1000").GetComponent<Button>(),
distance.Find("Btn2000").GetComponent<Button>(),
distance.Find("Btn5000").GetComponent<Button>(),
distance.Find("Btn10000").GetComponent<Button>(),
distance.Find("Customize").GetComponent<PFUIInputField>(),
time.Find("Btn30").GetComponent<Button>(),
time.Find("CustomizeMin").GetComponent<PFUIInputField>(),
time.Find("CustomizeS").GetComponent<PFUIInputField>(),
};
InitDistance();
}
public override void Show()
{
base.Show();
InitAll();
InitValue();
}
private void Go()
{
if (rowerType.type == 0 || rowerType.value == 0)
{
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 (rowerType.type == 2 && rowerType.value < 20)
{
Utils.showToast(null, "Minimum time is 20s.", isOnly: true);
return;
}
if (callBack != null)
{
callBack.Invoke(rowerType);
}
Close();
}
List<object> formList = null;
private void InitDistance()
{
Func<Transform, float, float, float> calc = (t, a, b) => t.parent.name == "Distance" ? a : a * 60 + b;
AddListener(formList, (t, v) =>
{
if (t.parent.name == "Distance")
{
rowerType.type = 1;
if (float.TryParse(v, out float f))
{
rowerType.value = f;
}
else
{
rowerType.value = 0;
}
}
else
{
rowerType.type = 2;
rowerType.value = 0;
var min = time.Find("CustomizeMin").GetComponent<InputField>().text;
var s = time.Find("CustomizeS").GetComponent<InputField>().text;
if (float.TryParse(min, out float a))
{
rowerType.value += 60 * a;
}
if (float.TryParse(s, out float b))
{
if (b < 0 || b > 59)
{
Utils.showToast(null, "Please enter an integer between 0-59.");
time.Find("CustomizeS").GetComponent<InputField>().text = "";
return;
}
rowerType.value += b;
}
}
}, calc);
}
private void AddListener(IEnumerable<object> list, UnityAction<Transform,string> inputCustomAction, Func<Transform, float,float,float> calcButton = null)
{
var btns = list.Where(x => x is Button).Select(x => x as Button);
foreach (var item in list)
{
if (item is Button)
{
var btn = item as Button;
btn.onClick.RemoveAllListeners();
btn.onClick.AddListener(() =>
{
InitAll();
rowerType.type = btn.transform.parent.name == "Distance" ? 1 : 2;
if (calcButton == null)
{
rowerType.value = float.Parse(btn.name.Replace("Btn", ""));
}
else
{
rowerType.value = calcButton.Invoke(btn.transform ,float.Parse(btn.name.Replace("Btn", "")), 0);
}
ClickDistanceBtn(btn, btns);
});
}
else if (item is PFUIInputField)
{
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);
SetBgColor(input,2);
};
input.CustomDeSelect = () =>
{
SetTextColor(input.gameObject, false);
SetBgColor(input, 3);
};
input.CustomEnter = () =>
{
SetBgColor(input, 1);
};
if (inputCustomAction != null)
{
input.GetComponent<InputField>().onEndEdit.RemoveAllListeners();
input.GetComponent<InputField>().onEndEdit.AddListener((v) => inputCustomAction(input.transform, v));
}
}
}
}
Dictionary<string, int> inputStatusDict = null;
private void SetBgColor(PFUIInputField input, int v)
{
if (inputStatusDict == null)
{
inputStatusDict = new Dictionary<string, int>
{
{"CustomizeMin",3 },{"CustomizeS",3 }
};
}
if (!inputStatusDict.ContainsKey(input.name)) return;
//只要有一个select,enter 常亮 两个都exit,deselect 关掉
inputStatusDict[input.name] = v;
var bg = transform.Find("Main/Time/Inputbg").gameObject;
if (inputStatusDict.Count(x=>x.Value == 1) > 0)
{
bg.GetComponent<Outline>().enabled = true;
bg.GetComponent<Outline>().effectColor = Utils.HexToColorHtml("#6E6E7D");
}
else if (inputStatusDict.Count(x => x.Value == 2) > 0)
{
bg.GetComponent<Outline>().enabled = true;
bg.GetComponent<Outline>().effectColor = Utils.HexToColorHtml("#f93086");
}
else if(inputStatusDict.Count(x => x.Value == 3) == 2)
{
bg.GetComponent<Outline>().enabled = false;
}
}
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)
{
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)
{
SetButtonColor(item, false);
}
if (btn)
{
SetButtonColor(btn, true);
}
}
private void SetButtonColor(Button btn, bool flag)
{
SetTextColor(btn.gameObject, flag);
btn.gameObject.GetComponent<Image>().color = flag ? Utils.HexToColorHtml("#f93086") : Utils.HexToColorHtml("#23232d");
}
private void SetTextColor(GameObject btn, bool flag)
{
if (btn.transform.Find("t1"))
{
btn.transform.Find("t1").GetComponent<Text>().color = flag ? Utils.HexToColorHtml("#ffffff") : Utils.HexToColorHtml("#9E9EAD");
}
if (btn.transform.Find("t2"))
{
btn.transform.Find("t2").GetComponent<Text>().color = flag ? Utils.HexToColorHtml("#ffffff") : Utils.HexToColorHtml("#9E9EAD");
}
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 11dfa3e099daeb942b6e8e105572548c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,109 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
using UnityEngine.UI;
using Assets.Scripts;
//using ZenFulcrum.EmbeddedBrowser;
public class RowerTraceAnimated : MonoBehaviour
{
// Start is called before the first frame update
Vector3? v1, v2, v3;
void Start()
{
//print(v1.Value.ToString() + v2.Value.ToString() + v3.Value.ToString());
}
private void Awake()
{
if (!v1.HasValue) v1 = transform.localPosition;
if (!v2.HasValue) v2 = transform.Find("p1").localPosition;
if (!v3.HasValue) v3 = transform.Find("p2").localPosition;
}
/// <summary>
///
/// </summary>
/// <param name="time"></param>
/// <param name="callback"></param>
/// <param name="type"></param>
/// <returns></returns>
public Sequence startAnimation(float time, TweenCallback callback, int type = 0)
{
//if (sq != null && sq.IsPlaying())
//{
// return null;
//}
Transform c = transform, c1 = c.Find("p1"), c2 = c.Find("p2");
var rect = c.GetComponent<RectTransform>();
var dirOffset = 0f;
if (type == 1) dirOffset = -1f * rect.sizeDelta.y;
var offset = rect.sizeDelta.y / 2;
var sq = DOTween.Sequence();
sq.AppendCallback(() =>
{
c2.localPosition = v3.Value + new Vector3(0, dirOffset, 0);
c2.localRotation = Quaternion.Euler(new Vector3(type == 1 ? 270 : 90, 0, 0));
c2.GetComponent<Image>().color = Utils.HexToColorHtml("#353543FF");
callback();
//print(c.localPosition.ToString() + c.Find("p1").localPosition.ToString() + c.Find("p2").localPosition.ToString());
});
var sq1 = DOTween.Sequence();
sq1.Join(c2.GetComponent<Image>().DOFade(0, time));
sq1.Join(c.DORotate(new Vector3(type == 1 ? 90 : -90, 0, 0), time));
sq1.Join(c.DOLocalMoveY(v1.Value.y + (type == 0 ? -offset : offset), time));
sq1.Join(c.DOLocalMoveZ(v1.Value.z + offset, time));
//var sq2 = DOTween.Sequence();
//sq2.Append(c.DOLocalMoveZ(v1.Value.z + offset*0.14f, time * 0.5f));
//sq2.Append(c.DOLocalMoveZ(v1.Value.z + offset, time * 0.5f));
//sq1.Join(sq2);
sq.Append(sq1);
sq.AppendCallback(() =>
{
var tmp = c1;
c1 = c2;
c2 = tmp;
c1.name = "p1";
c2.name = "p2";
c.localPosition = v1.Value;
c1.localPosition = v2.Value;
c2.localPosition = v3.Value + new Vector3(0, dirOffset, 0);
c.localRotation = Quaternion.Euler(Vector3.zero);
c1.localRotation = Quaternion.Euler(Vector3.zero);
c2.localRotation = Quaternion.Euler(new Vector3(type == 1 ? 270 : 90, 0, 0));
});
sq.Play();
return sq;
}
// Update is called once per frame
void Update()
{
}
}
//var c = transform.Find("Container");
//int i = 1;
//UIManager.AddEvent(transform.Find("Button").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
// {
// var sq = DOTween.Sequence();
// i++;
// sq.AppendCallback(() =>
// {
// c.Find("p1").SetAsLastSibling();
// c.Find(i % 2 == 0 ? "p2" : "p3").SetAsLastSibling();
// });
// sq.Join(c.DORotate(new Vector3(90 * (i % 2 == 0 ? -1 : 1), 0, 0), 1));
// sq.Join(c.DOLocalMoveY(50 * (i % 2 == 0 ? -1 : 1), 1f));
// sq.Append(c.DOLocalMoveZ(0, 0.5f));
// sq.Append(c.DOLocalMoveZ(50, 0.5f));
// sq.Play();
// });
//int i = 1;
//UIManager.AddEvent(transform.Find("Button").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
//{
//});
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c7400b2488409db4cad823eb13d103b4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+152 -24
View File
@@ -1,4 +1,6 @@
using Assets.Scripts.Apis.Models;
using Assets.Scripts;
using Assets.Scripts.Apis.Models;
using Facebook.Unity;
using System;
using System.Collections;
using System.Collections.Generic;
@@ -7,45 +9,171 @@ using UnityEngine.UI;
public class RowerWelldone : PFUIPanel
{
[SerializeField]
GameObject AllRecord, Record,Rank;
Dictionary<string, Texture> caches;
Transform rankContent, gradeContent;
private Action initFunc;
public string id { get; private set; }
public override void Show()
{
base.Show();
Debug.Log("well done show");
}
// Start is called before the first frame update
protected override void Awake()
{
caches = new Dictionary<string, Texture>();
rankContent = transform.Find("Container/Left/Scroll View").GetComponent<ScrollRect>().content;
gradeContent = transform.Find("Container/Right/Scroll View").GetComponent<ScrollRect>().content;
}
void Start()
{
UIManager.AddEvent(transform.Find("BtnDefine").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
UIManager.AddEvent(transform.Find("Container/BtnDefine").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
Close();
UIManager.ShowHomePanel();
UIManager.ShowUserInfoPanel();
CloseModal();
//UIManager.ShowHomePanel();
//UIManager.ShowUserInfoPanel();
});
UIManager.AddEvent(transform.Find("Container/BtnView").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
CloseModal();
#if UNITY_ANDROID || UNITY_IOS
UIManager.ShowActivityPanel($"{App.websiteDict[App.Host]}rower/record/{id}?UserId={App.CurrentUser.Id}");
#else
Application.OpenURL($"{App.websiteDict[App.Host]}rower/record/{id}?Token={App.CurrentUser.cookie}");
#endif
});
UIManager.AddEvent(transform.Find("Container/Share/Wx").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
if (data == null) return;
App.weChatController.ShareWebpageToWX(0, $"{App.websiteDict[App.Host]}rower/record/{id}?UserId={App.CurrentUser.Id}", $"我在{data.info.TypeStr}的划船比赛中获得第{data.info.MyRankLeft}名!赶紧来一起划船吧!", $"By {App.CurrentUser.Nickname}", null);
});
UIManager.AddEvent(transform.Find("Container/Share/WxMoment").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
if (data == null) return;
App.weChatController.ShareWebpageToWX(1, $"{App.websiteDict[App.Host]}rower/record/{id}?UserId={App.CurrentUser.Id}", $"我在{data.info.TypeStr}的划船比赛中获得第{data.info.MyRankLeft}名!赶紧来一起划船吧!", $"By {App.CurrentUser.Nickname}", null);
});
UIManager.AddEvent(transform.Find("Container/Share/Fb").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
{
if (data == null) return;
FB.ShareLink(contentURL: new Uri($"{App.websiteDict[App.Host]}rower/record/{id}?UserId={App.CurrentUser.Id}"),
contentTitle: $"PowerFun {data.info.TypeStr} Rowing",
contentDescription: $"By {App.CurrentUser.Nickname}");
//App.weChatController.ShareWebpageToWX(1, , , , null);
});
}
// Update is called once per frame
void Update()
{
if (Input.touchCount > 0)
{
startTime = false;
transform.Find("Container/BtnDefine/Text").GetComponent<Text>().text = $"{App.GetLocalString("DEFINE")}";
}
if (startTime)
{
timer -= Time.deltaTime;
if (timer <= 0)
{
remainTime--;
if (remainTime == 0)
{
CloseModal();
return;
}
transform.Find("Container/BtnDefine/Text").GetComponent<Text>().text = $"{App.GetLocalString("DEFINE")}({remainTime.ToString("#0")})";
timer += 1f;
}
}
}
RowerRecordModel model;
public void Initial(RowerRecordModel model)
float timer = 1f, remainTime = 10f;
bool startTime = false;
RowerSegmentData data;
public async void Initial(string id,Action init)
{
Debug.Log("Initial");
if (model == null) return;
this.model = model;
transform.Find("Time/Value1").GetComponent<Text>().text = model.CreateTime.ToLocalTime().ToString("yyyy-MM-dd");
transform.Find("Time/Value2").GetComponent<Text>().text = model.CreateTime.ToLocalTime().ToString("HH:mm:ss");
transform.Find("RowingTime/Value").GetComponent<Text>().text = TimeSpan.FromSeconds(model.TotalTime).ToString();
transform.Find("Distance/Value").GetComponent<Text>().text = $"{model.TotalDistance.ToString()}M";
var datas = transform.Find("Other/Datas");
datas.Find("AvgRate/Value").GetComponent<Text>().text = $"{model.AvgRate.ToString("#0")}";
datas.Find("MaxRate/Value").GetComponent<Text>().text = $"{model.MaxRate.ToString()}";
datas.Find("AvgPower/Value").GetComponent<Text>().text = $"{model.AvgPower.ToString("#0")}";
datas.Find("MaxPower/Value").GetComponent<Text>().text = $"{model.MaxPower.ToString()}";
datas.Find("MaxPace/Value").GetComponent<Text>().text = $"{TimeSpan.FromSeconds(model.MaxPace).ToString(@"mm\:ss")}";
datas.Find("AvgPace/Value").GetComponent<Text>().text = $"{TimeSpan.FromSeconds(model.AvgPace).ToString(@"mm\:ss")}";
datas.Find("Calories/Value").GetComponent<Text>().text = $"{(model.Kj ?? 0).ToString("#0")}";
datas.Find("StrokeCount/Value").GetComponent<Text>().text = $"{model.StrokeCount}";
if (string.IsNullOrEmpty(id)) return;
this.initFunc = init;
this.id = id;
var res = await ConfigHelper.rowerApi.GetSegmentDataAndRanking(id);
if (res.result)
{
this.data = res.data;
DisplayData(res.data, caches);
startTime = true;
remainTime = 30f;
timer = 1f;
transform.Find("Container/BtnDefine/Text").GetComponent<Text>().text = $"{App.GetLocalString("DEFINE")}({remainTime.ToString("#0")})";
}
}
private void DisplayData(RowerSegmentData data, Dictionary<string, Texture> caches)
{
rankContent.DestroyChildren();
gradeContent.DestroyChildren();
for (int i = 0; i < data.ranks.Count; i++)
{
var item = data.ranks[i];
var game = Instantiate<GameObject>(Rank);
game.transform.Find("Content/Rank").GetComponent<Text>().text = item.rankNum.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.Ticks).ToString(@"hh\:mm\:ss") : item.TotalDistance.ToString("#0M");
game.transform.SetParent(rankContent);
game.transform.localScale = Vector3.one;
game.SetActive(true);
if (new Guid(item.Id) == new Guid(id))
{
game.transform.Find("Content/Rank").GetComponent<Text>().color = Utils.HexToColorHtml("#f93086");
game.transform.Find("Content/NickName").GetComponent<Text>().color = Utils.HexToColorHtml("#f93086");
game.transform.Find("Content/Time").GetComponent<Text>().color = Utils.HexToColorHtml("#f93086");
}
else
{
game.transform.Find("Content/Rank").GetComponent<Text>().color = Utils.HexToColorHtml("#ffffff");
game.transform.Find("Content/NickName").GetComponent<Text>().color = Utils.HexToColorHtml("#ffffff");
game.transform.Find("Content/Time").GetComponent<Text>().color = Utils.HexToColorHtml("#ffffff");
}
}
for (int i = 0; i < data.segmentList.Count; i++)
{
var item = data.segmentList[i];
var game = i == 0 ? Instantiate<GameObject>(AllRecord) : Instantiate<GameObject>(Record);
var content = i != 0 ? game.transform.Find("Content") : game.transform;
content.Find("Index").GetComponent<Text>().text = i == 0 ? "ALL" : i.ToString("00");
content.Find("Time").GetComponent<Text>().text = TimeSpan.FromSeconds(item.Ticks).ToString();
content.Find("Distance").GetComponent<Text>().text = item.Distance.ToString("#0");
content.Find("500").GetComponent<Text>().text = TimeSpan.FromSeconds(item.Speed).ToString().Substring(3, 5);
content.Find("Power").GetComponent<Text>().text = item.Power.ToString("#0");
content.Find("HR").GetComponent<Text>().text = item.HeartRate.ToString("#0");
content.Find("Count").GetComponent<Text>().text = item.StrokeCount.ToString("#0");
content.Find("Carlories").GetComponent<Text>().text = item.Rate.ToString("#0");
//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("#0");
game.transform.SetParent(gradeContent);
game.transform.localScale = Vector3.one;
game.SetActive(true);
}
transform.Find("Container/Left/MyRank").GetComponent<Text>().text = data.info.MyRank;
transform.Find("Container/Right/Time").GetComponent<Text>().text = data.info.CreateTime;
}
public void CloseModal()
{
startTime = false;
if (initFunc != null)
{
initFunc.Invoke();
}
Close();
}
}
+86 -6
View File
@@ -16,6 +16,7 @@ using System;
using Assets.Scenes.Ride.Scripts;
using UnityEngine.SceneManagement;
using System.Threading;
using Assets.Scripts.Devices.Ant;
public class UIManager : MonoBehaviour
{
@@ -320,7 +321,7 @@ public class UIManager : MonoBehaviour
return this.GetPanelInstance("RowerPanel", ref this.mRowerHomeScript);
}
}
public static void ShowRowerPanel()
public static void ShowRowerPanel(RowerResultModel r = null)
{
App.IsRowerMode = true;
// App.MainDeviceAdapter.ClearDevice();
@@ -328,6 +329,9 @@ public class UIManager : MonoBehaviour
// App.MainDeviceAdapter.StartScan();
//#endif
stack.Clear();
UIManager.Instance.MainPanel.GetComponent<Image>().sprite =
Resources.Load<Sprite>("Images/RowerNew/bg_huachuanji");
UIManager.Instance.RowerHomeScript.ReRow(r);
UIManager.Show(UIManager.Instance.RowerHomeScript, UIManager.Instance.MainPanel);
}
//结束页
@@ -339,13 +343,13 @@ public class UIManager : MonoBehaviour
return this.GetPanelInstance("RowerWelldone", ref this.mRowerWelldone);
}
}
public static void ShowRowerWelldone(RowerRecordModel model)
public static void ShowRowerWelldone(string id, Action init)
{
Debug.Log("進入welldone");
UIManager.Show(UIManager.Instance.RowerWelldone, null, true);
if (UIManager.Instance.RowerWelldone)
{
UIManager.Instance.RowerWelldone.Initial(model);
UIManager.Instance.RowerWelldone.Initial(id,init);
}
}
//结果页
@@ -376,9 +380,47 @@ public class UIManager : MonoBehaviour
public static void ShowRowerSelector()
{
Debug.Log("进入Rower");
foreach (var d in App.MainDeviceAdapter.GetDevices())
{
if (d.State == DeviceState.Connected || d.State == DeviceState.Connecting)// && (d.Sensor == SensorType.Trainer || d.Sensor == SensorType.Rower || d.Sensor == SensorType.HeartRate)
{
d.Disconnect();
}
}
App.MainDeviceAdapter.StopScan();
UIManager.Show(UIManager.Instance.RowerSelector, null, true);
}
/*划船机页面*/
#region 新版划船机页面
private RowerDevicePanel mRowerDevicePanel;
public RowerDevicePanel RowerDevicePanel
{
get
{
return this.GetPanelInstance("RowerDevicePanel", ref this.mRowerDevicePanel);
}
}
public static void ShowRowerDevicePanel()
{
//App.MainDeviceAdapter.StartScan();
UIManager.Show(UIManager.Instance.RowerDevicePanel, null, true);
}
private RowerTaskPanel mRowerTaskPanel;
public RowerTaskPanel RowerTaskPanel
{
get
{
return this.GetPanelInstance("RowerTaskPanel", ref this.mRowerTaskPanel);
}
}
public static void ShowRowerTaskPanel(Action<RowerTaskPanel.RowerType> callBack, RowerTaskPanel.RowerType type)
{
UIManager.Instance.RowerTaskPanel.rowerType = type;
UIManager.Instance.RowerTaskPanel.callBack = callBack;
UIManager.Show(UIManager.Instance.RowerTaskPanel, null, true);
}
#endregion
#region 新版路线页面
private NewRouteOverviewController mNewRouteOverviewController;
public NewRouteOverviewController NewRouteOverviewPanel
@@ -446,8 +488,8 @@ public class UIManager : MonoBehaviour
}
public static void ShowActivityPanel(string url)
{
UIManager.Show(UIManager.Instance.ActivityController, null, true);
UIManager.Instance.ActivityController.Initial(url);
UIManager.Show(UIManager.Instance.ActivityController, null, true);
}
//活动弹窗
ActivityAdController mActivityAdController;
@@ -476,7 +518,39 @@ public class UIManager : MonoBehaviour
{
UIManager.Show(UIManager.Instance.AddressController, null, true);
}
#region 邮件相关
MailListController mMailListController;
public MailListController MailListController
{
get
{
return this.GetPanelInstance("MailListPanel", ref this.mMailListController);
}
}
public static void ShowMailListPanel()
{
UIManager.Show(UIManager.Instance.MailListController, null, true);
}
MailDetailController mMailDetailController;
public MailDetailController MailDetailController
{
get
{
return this.GetPanelInstance("MailDetailPanel", ref this.mMailDetailController);
}
}
public static void ShowMailDetailPanel(MailModel item)
{
UIManager.Instance.MailDetailController.Initial(item);
UIManager.Instance.Invoke("ShowMailDetailPanel", 0.1f);
}
public void ShowMailDetailPanel()
{
UIManager.Show(UIManager.Instance.MailDetailController, null, true);
}
#endregion
#region 比赛点击弹窗
private RaceModalScript mRaceModalScript;
public RaceModalScript RaceDetailModal
@@ -553,6 +627,11 @@ public class UIManager : MonoBehaviour
{ false,Resources.Load<Sprite>("Images/p-4灰")},
{ true,Resources.Load<Sprite>("Images/p-4")},
};
uploadDict = new Dictionary<bool, Sprite>
{
{ false,Resources.Load<Sprite>("Images/upload/1")},
{ true,Resources.Load<Sprite>("Images/upload/2")},
};
//var a = Resources.Load<TextAsset>("UI/simpleCountry");
//var clist = JsonConvert.DeserializeObject<List<CountryInfo>>(a.text);
@@ -712,14 +791,14 @@ public class UIManager : MonoBehaviour
private static PFUIPanel currentPanel = null;
public static void Show(PFUIPanel panelToShow, PFUIPanel parent = null, bool modal = false)
{
Debug.Log($"show :{panelToShow.name}");
if (UIManager.Instance == null || panelToShow == null)
{
return;
}
if (UIManager.Instance.MainPanel != null && parent == UIManager.Instance.MainPanel)
{
App.currentPageIsHome = panelToShow.Equals(UIManager.Instance.HomePanel);
//App.currentPageIsHome = panelToShow.Equals(UIManager.Instance.NewHomePanel);
App.currentPageIsHome = panelToShow.GetType().Name.Equals("HomeController");
}
if (modal)
@@ -1312,6 +1391,7 @@ public class UIManager : MonoBehaviour
}
}
public Dictionary<bool, Sprite> collectDict { get; private set; }
public Dictionary<bool, Sprite> uploadDict { get; private set; }
private int _userInfoIndex;
public int userInfoIndex
{
+2 -2
View File
@@ -78,8 +78,8 @@ public class Toast : MonoBehaviour
}
//Fade out
yield return fadeInAndOut(txt, false, 0.5f);
gameObject.SetActive(false);
DestroyImmediate(gameObject);
//gameObject.SetActive(false);
}
IEnumerator fadeInAndOut(Text targetText, bool fadeIn, float duration)
+34 -2
View File
@@ -21,6 +21,25 @@ namespace Assets.Scripts
public static class Utils
{
public static string ToPFString(this TimeSpan t)
{
if (t.TotalSeconds >= 60)
{
var s = "00:00:00";
var r = t.ToString(@"hh\:mm\:ss");
int i = 0;
for (; i < r.Length; i++)
{
if (s[i] != r[i]) break;
}
return r.Substring(i, r.Length - i);
}
else
{
return $":{t.TotalSeconds.ToString("#0")}";
}
}
/*获取ip*/
public enum ADDRESSFAM
{
@@ -145,7 +164,7 @@ namespace Assets.Scripts
{"HeartRate","Heart Rate Monitor|Images/Devices/Heart Rate_3" },
{"SpeedCadence","Cadence Sensor|Images/Devices/Cadence_3" },
{"Speed","Speed Meter|Images/Devices/Speed_3" },
{"Rower","Rower Machine|Images/Rower/设备 - 划船机" }
{"Rower","Rowing Machine|Images/Rower/设备 - 划船机" }
};
}
return _deviceDict;
@@ -167,7 +186,7 @@ namespace Assets.Scripts
/// <param name="showSeconds"></param>
/// <param name="endCallback"></param>
/// <param name="_parent"></param>
public static void showToast(GameObject p, string text, int duration = 2, int type = 0, Func<bool> stopFunc = null, bool isLowest = false,bool showSeconds = false,Action endCallback = null,PFUIPanel _parent = null)
public static void showToast(GameObject p, string text, int duration = 2, int type = 0, Func<bool> stopFunc = null, bool isLowest = false,bool showSeconds = false,Action endCallback = null,PFUIPanel _parent = null,bool isOnly = false)
{
var parent = UIManager.Instance.ModalsPanel;
if (parent == null)
@@ -185,6 +204,7 @@ namespace Assets.Scripts
var toast = parent.transform.Find("ToastContainer");
if (toast != null)
{
if (isOnly) return;
MonoBehaviour.DestroyImmediate(toast.gameObject);
}
#if UNITY_IOS || UNITY_ANDROID
@@ -891,6 +911,18 @@ namespace Assets.Scripts
}
}
public static IEnumerator ShareImageToWx(int scene, byte[] image)
{
if (App.weChatController.IsWeChatAppInstalled())
{
App.weChatController.ShareImageToWX(scene, image);
}
else
{
Utils.showToast(null, "未安装微信");
}
yield return null;
}
public static string GetClipboard()
{
return UnityEngine.GUIUtility.systemCopyBuffer;