小调整

This commit is contained in:
suntao 2021-05-12 10:42:26 +08:00
parent a7ea02f70a
commit 53ec9c60ac
10 changed files with 42 additions and 73 deletions

View File

@ -1,26 +0,0 @@
using Mapbox.Directions;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Assets.Scenes.Ride.Scripts
{
public class PlayerFactory : MonoBehaviour
{
[SerializeField]
public GameObject _playerPrefab;
// Start is called before the first frame update
void Start()
{
if (_playerPrefab != null)
{
for (int i = 0; i < 100; i++)
{
Instantiate(_playerPrefab, new Vector3(i, 1, 0), Quaternion.identity);
}
}
}
}
}

View File

@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: d3579ed37837f6c4cb6197c19a9ef8af
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

Before

Width:  |  Height:  |  Size: 291 KiB

After

Width:  |  Height:  |  Size: 291 KiB

View File

@ -100,5 +100,5 @@ TextureImporter:
pSDRemoveMatte: 0 pSDRemoveMatte: 0
pSDShowRemoveMatteOption: 0 pSDShowRemoveMatteOption: 0
userData: userData:
assetBundleName: assetBundleName: ab
assetBundleVariant: assetBundleVariant:

View File

@ -62,7 +62,7 @@ namespace Assets.Scripts.Apis
user.ContactPhone = ret.data.ContactPhone; user.ContactPhone = ret.data.ContactPhone;
user.ContactAddress = ret.data.ContactAddress; user.ContactAddress = ret.data.ContactAddress;
user.Sensitivity = ret.data.Sensitivity; user.Sensitivity = ret.data.Sensitivity;
if (ret.data.ConnectedToStrava != null) //if (ret.data.ConnectedToStrava != null)
{ {
user.ConnectedToStrava = ret.data.ConnectedToStrava; user.ConnectedToStrava = ret.data.ConnectedToStrava;
} }
@ -224,7 +224,7 @@ namespace Assets.Scripts.Apis
return Newtonsoft.Json.JsonConvert.DeserializeObject<JsonResult<object>>(res); return Newtonsoft.Json.JsonConvert.DeserializeObject<JsonResult<object>>(res);
} }
public async Task<JsonResult<object>> Update(UserResultModel currUser, string filePath = "") public JsonResult<object> Update(UserResultModel currUser, string filePath = "")
{ {
//return await PostAsync<JsonResult<dynamic>>("User/UpdateUserSetting", new { //return await PostAsync<JsonResult<dynamic>>("User/UpdateUserSetting", new {
// UID = currUser.Id, // UID = currUser.Id,

View File

@ -4,8 +4,6 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using ANT_Managed_Library; using ANT_Managed_Library;
using Assets.Scripts.UI.Prefab.Device;
using UnityEngine;
namespace Assets.Scripts.Devices.Ant namespace Assets.Scripts.Devices.Ant
{ {
@ -36,6 +34,9 @@ namespace Assets.Scripts.Devices.Ant
private bool IsBackgroundScanning { get; set; } private bool IsBackgroundScanning { get; set; }
//int searchingDeviceIndex = -1; //int searchingDeviceIndex = -1;
/// <summary>
/// 可以搜索的设备
/// </summary>
private List<AbstractAntDevice> deviceList = new List<AbstractAntDevice>(); private List<AbstractAntDevice> deviceList = new List<AbstractAntDevice>();
public bool IsAvailable = false; public bool IsAvailable = false;
@ -43,17 +44,28 @@ namespace Assets.Scripts.Devices.Ant
/// 设备号,频道编号 /// 设备号,频道编号
/// </summary> /// </summary>
public readonly List<UserdChannel> usedChannels = new List<UserdChannel>(); public readonly List<UserdChannel> usedChannels = new List<UserdChannel>();
/// <summary>
/// 搜索到的设备
/// </summary>
public readonly List<AbstractAntDevice> discoveredDevices = new List<AbstractAntDevice>(); public readonly List<AbstractAntDevice> discoveredDevices = new List<AbstractAntDevice>();
private Action<AbstractAntDevice> _action; private Action<AbstractAntDevice> _action;
private static AntConnector _antConnector; private static AntConnector _antConnector;
public static AntConnector Instance(Action<AbstractAntDevice> action = null) private Action<object> _log;
/// <summary>
///
/// </summary>
/// <param name="action">探索到新的设备</param>
/// <returns></returns>
public static AntConnector Instance(Action<AbstractAntDevice> action = null,
Action<object> log = null)
{ {
if (_antConnector == null) if (_antConnector == null)
{ {
_antConnector = new AntConnector(); _antConnector = new AntConnector();
_antConnector._action = action; _antConnector._action = action;
_antConnector._log = log;
} }
return _antConnector; return _antConnector;
@ -226,7 +238,7 @@ namespace Assets.Scripts.Devices.Ant
//设备断开连接 //设备断开连接
else if (antEventId == ANT_ReferenceLibrary.ANTEventID.EVENT_RX_FAIL_GO_TO_SEARCH_0x08) else if (antEventId == ANT_ReferenceLibrary.ANTEventID.EVENT_RX_FAIL_GO_TO_SEARCH_0x08)
{ {
Debug.Log(antEventId.ToString() + ", " + string.Join(",", response.messageContents)); _log?.Invoke(antEventId.ToString() + ", " + string.Join(",", response.messageContents));
var cc1 = usedChannels.Where(d => d.Index == channelIndex).FirstOrDefault(); var cc1 = usedChannels.Where(d => d.Index == channelIndex).FirstOrDefault();
var dd1 = discoveredDevices.SingleOrDefault(d => d.searchProfile.deviceNumber.ToString() == cc1.DeviceNumber && d.searchProfile.deviceType.ToString() == cc1.DeviceTypeId); var dd1 = discoveredDevices.SingleOrDefault(d => d.searchProfile.deviceNumber.ToString() == cc1.DeviceNumber && d.searchProfile.deviceType.ToString() == cc1.DeviceTypeId);
@ -300,24 +312,20 @@ namespace Assets.Scripts.Devices.Ant
if (device2 != null) if (device2 != null)
{ {
//ReSearch(); //ReSearch();
_action?.Invoke(device2);
if (device2.State == DeviceState.Connected) if (device2.State == DeviceState.Connected)
{ {
device2.handleChannelResponse(response); device2.handleChannelResponse(response);
return; return;
} }
else if (device2.State == DeviceState.Disconnected) //else if (device2.State == DeviceState.Disconnected)
{ //{
//var deviceInfo = deviceService.Get(App.CurrentUser.Id, $"{ device2.searchProfile.deviceNumber }:{ device2.searchProfile.deviceType }"); //var deviceInfo = deviceService.Get(App.CurrentUser.Id, $"{ device2.searchProfile.deviceNumber }:{ device2.searchProfile.deviceType }");
//if (deviceInfo != null && deviceInfo.Paired) //if (deviceInfo != null && deviceInfo.Paired)
//{ //{
// device2.Connect(); // device2.Connect();
//} //}
//}
if(_action != null)
{
_action(device2);
}
}
return; return;
} }
var device1 = deviceList.SingleOrDefault(d => d.searchProfile.deviceType == deviceTypeId); var device1 = deviceList.SingleOrDefault(d => d.searchProfile.deviceType == deviceTypeId);

View File

@ -796,9 +796,9 @@ public class LoginController : MonoBehaviour
/// <summary> /// <summary>
/// 去最后一页准备进入主场景 /// 去最后一页准备进入主场景
/// </summary> /// </summary>
async void goRegEnd() void goRegEnd()
{ {
if (!await UpdateInfo()) return; if (!UpdateInfo()) return;
if (pageNums == 5) if (pageNums == 5)
{ {
this.StartScrollPanel(4); this.StartScrollPanel(4);
@ -839,7 +839,7 @@ public class LoginController : MonoBehaviour
/// 注册页2 修改信息 /// 注册页2 修改信息
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
async Task<bool> UpdateInfo() bool UpdateInfo()
{ {
if (userResult == null) return false; if (userResult == null) return false;
var _days = signForm.days.GetComponent<PFUIDropdown>(); var _days = signForm.days.GetComponent<PFUIDropdown>();
@ -874,7 +874,7 @@ public class LoginController : MonoBehaviour
{ {
userResult.Nickname = userResult.Phone; userResult.Nickname = userResult.Phone;
} }
var r = await ConfigHelper.userApi.Update(userResult); var r = ConfigHelper.userApi.Update(userResult);
return r.result; return r.result;
//userResult.Birthday.v //userResult.Birthday.v
} }

View File

@ -19,13 +19,17 @@ public class MainController : MonoBehaviour
DeviceCache.Init(PFConstants.DeviceCacheFolder); DeviceCache.Init(PFConstants.DeviceCacheFolder);
AntConnector.Instance((device2) => { AntConnector.Instance((device2) => {
//自动连接 if (device2.State == DeviceState.Disconnected)
if (DeviceCache.Exist(device2))
{ {
Debug.Log("自动连接" + device2.DeviceNumber); //Debug.Log($"探索到新的设备{ device2.DeviceNumber }");
device2.Connect(); //自动连接
if (DeviceCache.Exist(device2))
{
Debug.Log("自动连接" + device2.DeviceNumber);
device2.Connect();
}
} }
}); }, Debug.Log);
//Debug.Log(Application.dataPath); //Debug.Log(Application.dataPath);

View File

@ -290,22 +290,16 @@ public class DeviceView : MonoBehaviour
break; break;
case SensorType.Cadence: case SensorType.Cadence:
return "Cadence Sensor"; return "Cadence Sensor";
break;
case SensorType.HeartRate: case SensorType.HeartRate:
return "Heart Rate Monitor"; return "Heart Rate Monitor";
break;
case SensorType.Power: case SensorType.Power:
return "Power Meter"; return "Power Meter";
break;
case SensorType.Speed: case SensorType.Speed:
break; break;
case SensorType.SpeedCadence: case SensorType.SpeedCadence:
return "Speed Meter"; return "Speed Meter";
break;
case SensorType.Trainer: case SensorType.Trainer:
return "Smart Trainer"; return "Smart Trainer";
break;
case SensorType.VirtualPower: case SensorType.VirtualPower:
break; break;
default: default:

View File

@ -293,7 +293,7 @@ public class EditUserController : PFUIPanel
//UIManager.ShowAlert("result.errMsg"); //UIManager.ShowAlert("result.errMsg");
} }
async void SaveFunc() void SaveFunc()
{ {
var user = JsonConvert.DeserializeObject<UserResultModel>(JsonConvert.SerializeObject(App.CurrentUser)); var user = JsonConvert.DeserializeObject<UserResultModel>(JsonConvert.SerializeObject(App.CurrentUser));
user.Birthday = new DateTime(int.Parse(mYearDropdown.SelectedItem), int.Parse(mMonthDropdown.SelectedItem), int.Parse(mDayDropdown.SelectedItem)); user.Birthday = new DateTime(int.Parse(mYearDropdown.SelectedItem), int.Parse(mMonthDropdown.SelectedItem), int.Parse(mDayDropdown.SelectedItem));
@ -324,7 +324,7 @@ public class EditUserController : PFUIPanel
user.Contact = mName.Text; user.Contact = mName.Text;
user.ContactPhone = mPhone.Text; user.ContactPhone = mPhone.Text;
user.ContactAddress = mAddr.Text; user.ContactAddress = mAddr.Text;
var result = await userApi.Update(user); var result = userApi.Update(user);
App.isChanged = false; App.isChanged = false;
if (result.result == false) if (result.result == false)
{ {
@ -348,9 +348,9 @@ public class EditUserController : PFUIPanel
LoadDataSync(); LoadDataSync();
} }
async void ChangeAvatar(string path) void ChangeAvatar(string path)
{ {
var r = await userApi.Update(App.CurrentUser, path); var r = userApi.Update(App.CurrentUser, path);
App.isChanged = false; App.isChanged = false;
if (r.result) if (r.result)
{ {