骑行界面&赛事界面调整&设备断开功能
This commit is contained in:
1 parent
467a6f3810
commit
99081519bb
43 files changed
+3658
-697
No files matched your search
@@ -41,6 +41,7 @@ public class ConnectDeviceModal : PFUIPanel
|
||||
private UnityEngine.Object deviceItem;
|
||||
private VerticalLayoutGroup content;
|
||||
private PfUIButton connectBtn;
|
||||
private Text connectBtnText;
|
||||
private Dictionary<string, DeviceItem> deviceList;
|
||||
private Text noDevice,Title;
|
||||
private RectTransform searchIconRect;
|
||||
@@ -75,34 +76,54 @@ public class ConnectDeviceModal : PFUIPanel
|
||||
deviceItem = Resources.Load("UI/Prefab/Device/DeviceItem");
|
||||
|
||||
connectBtn = container.Find("ConnectBtn").GetComponent<PfUIButton>();
|
||||
connectBtnText = connectBtn.transform.Find("Text").GetComponent<Text>();
|
||||
|
||||
UIManager.AddEvent(connectBtn.gameObject, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
|
||||
{
|
||||
foreach (var item in deviceList)
|
||||
if (!connectBtnText.text.Equals("DISCONNECT"))
|
||||
{
|
||||
if (item.Value.GetStatus() == false)
|
||||
foreach (var item in deviceList)
|
||||
{
|
||||
if (SensorType == SensorType.SpeedCadence)
|
||||
if (item.Value.GetStatus() == false)
|
||||
{
|
||||
if (item.Value.DeviceInfo.Sensor == SensorType.SpeedCadence || item.Value.DeviceInfo.Sensor == SensorType.Cadence)
|
||||
if (SensorType == SensorType.SpeedCadence)
|
||||
{
|
||||
if (item.Value.DeviceInfo.Sensor == SensorType.SpeedCadence || item.Value.DeviceInfo.Sensor == SensorType.Cadence)
|
||||
{
|
||||
//Debug.Log("断开设备" + item.Value.DeviceInfo.Name);
|
||||
item.Value.DeviceInfo.Disconnect();
|
||||
DeviceCache.Remove(item.Value.DeviceInfo);
|
||||
}
|
||||
}
|
||||
else if (item.Value.DeviceInfo.Sensor == SensorType)
|
||||
{
|
||||
//Debug.Log("断开设备" + item.Value.DeviceInfo.Name);
|
||||
item.Value.DeviceInfo.Disconnect();
|
||||
DeviceCache.Remove(item.Value.DeviceInfo);
|
||||
}
|
||||
}
|
||||
else if (item.Value.DeviceInfo.Sensor == SensorType)
|
||||
{
|
||||
item.Value.DeviceInfo.Disconnect();
|
||||
DeviceCache.Remove(item.Value.DeviceInfo);
|
||||
}
|
||||
}
|
||||
var dd = deviceList.Select(d => d.Value).Where(d => d.GetStatus()).FirstOrDefault();
|
||||
if (dd != null)
|
||||
{
|
||||
dd.DeviceInfo.Connect();
|
||||
DeviceCache.Add(dd.DeviceInfo);
|
||||
}
|
||||
}
|
||||
var dd = deviceList.Select(d => d.Value).Where(d => d.GetStatus()).FirstOrDefault();
|
||||
if (dd != null)
|
||||
else
|
||||
{
|
||||
dd.DeviceInfo.Connect();
|
||||
DeviceCache.Add(dd.DeviceInfo);
|
||||
foreach (var item in deviceList)
|
||||
{
|
||||
Debug.Log("116" + item.Value.DeviceInfo.Name+ item.Value.GetStatus().ToString());
|
||||
if (item.Value.GetStatus())
|
||||
{
|
||||
if (item.Value.DeviceInfo.Sensor == SensorType)
|
||||
{
|
||||
item.Value.DeviceInfo.Disconnect();
|
||||
Debug.Log("121" + item.Value.DeviceInfo.Name + "断开");
|
||||
DeviceCache.Remove(item.Value.DeviceInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.Close();
|
||||
}));
|
||||
@@ -172,10 +193,18 @@ public class ConnectDeviceModal : PFUIPanel
|
||||
gameObject.transform.localScale = new Vector3(1, 1, 1);
|
||||
var deviceItemObj = gameObject.GetComponent<DeviceItem>();
|
||||
deviceItemObj.DeviceInfo = device;
|
||||
|
||||
|
||||
UIManager.AddEvent(deviceItemObj.gameObject, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<BaseEventData>(e =>
|
||||
{
|
||||
deviceItemObj.Set(true);
|
||||
if (deviceItemObj.DeviceInfo.Sensor != SensorType.Trainer && SensorType != SensorType.Trainer && deviceItemObj.DeviceInfo.State == DeviceState.Connected)
|
||||
{
|
||||
connectBtnText.text = "DISCONNECT";
|
||||
}
|
||||
else
|
||||
{
|
||||
connectBtnText.text = "CONNECT";
|
||||
}
|
||||
foreach (var item in deviceList)
|
||||
{
|
||||
if (item.Key != deviceItemObj.DeviceInfo.Id)
|
||||
@@ -197,13 +226,20 @@ public class ConnectDeviceModal : PFUIPanel
|
||||
deviceList.Add(device.Id, deviceItemObj);
|
||||
}
|
||||
|
||||
if(deviceList.All(d=>d.Value.GetStatus() == false))
|
||||
if(deviceList.All(d=>d.Value.GetStatus() == false))
|
||||
{
|
||||
var firstDevice = deviceList.Select(d => d.Value).Where(d => d.DeviceInfo.State == DeviceState.Connected).OrderByDescending(d => d.DeviceInfo.Priority).FirstOrDefault();
|
||||
if (firstDevice != null)
|
||||
{
|
||||
firstDevice.Set(true);
|
||||
|
||||
if (firstDevice.DeviceInfo.Sensor != SensorType.Trainer && SensorType != SensorType.Trainer && firstDevice.DeviceInfo.State == DeviceState.Connected)
|
||||
{
|
||||
connectBtnText.text = "DISCONNECT";
|
||||
}
|
||||
else
|
||||
{
|
||||
connectBtnText.text = "CONNECT";
|
||||
}
|
||||
//connectBtn.text.text = "DISCOUNECT";
|
||||
noDevice.text = firstDevice.DeviceInfo.Name;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user