Merge remote-tracking branch 'origin/dev_combine' into dev_release
# Conflicts: # Assets/Scenes/Test.unity # Assets/SoftMaskForUGUI-1.0.2/Samples~/Demo/Mobile.meta
This commit is contained in:
commit
bf3b0d2642
386 files changed
+26250
-66181
No files matched your search
@@ -186,9 +186,6 @@ public class ConnectDeviceModal : PFUIPanel
|
||||
case SensorType.Trainer:
|
||||
devices = App.MainDeviceAdapter.GetDevices().Where(d => d.Sensor == SensorType && d is ITrainerDevice).ToList();
|
||||
break;
|
||||
case SensorType.Rower:
|
||||
devices = App.MainDeviceAdapter.GetDevices().Where(d => d.Sensor == SensorType && d is IRowerDevice).ToList();
|
||||
break;
|
||||
case SensorType.VirtualPower:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -181,15 +181,7 @@ public class NewMainNav : MonoBehaviour
|
||||
Utils.DisplayHead(transform.Find("Avatar").GetComponent<Image>(), App.CurrentUser.WxHeadImg);
|
||||
UIManager.AddEvent(transform.Find("Avatar").gameObject, EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
if (App.IsRowerMode == true)
|
||||
{
|
||||
if (UIManager.Instance.RowerHomeScript.checkRowing()) return;
|
||||
UIManager.ShowEditUserPanel();
|
||||
}
|
||||
else
|
||||
{
|
||||
UIManager.ShowUserInfoPanel();
|
||||
}
|
||||
UIManager.ShowUserInfoPanel();
|
||||
});
|
||||
UIManager.AddEvent(transform.Find("PF").gameObject, EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
@@ -199,25 +191,11 @@ public class NewMainNav : MonoBehaviour
|
||||
{
|
||||
SetExpand(false);
|
||||
});
|
||||
//var material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
||||
|
||||
//var rect = ((RectTransform)this.transform).rect;
|
||||
//material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height, 0));
|
||||
//this.GetComponent<Image>().material = material;
|
||||
|
||||
var device = this.transform.Find("Device");
|
||||
UIManager.AddEvent(device.gameObject, EventTriggerType.PointerClick, x =>
|
||||
{
|
||||
//Debug.Log("click device");
|
||||
if (App.IsRowerMode.HasValue && App.IsRowerMode.Value)
|
||||
{
|
||||
if (UIManager.Instance.RowerHomeScript.checkRowing()) return;
|
||||
UIManager.ShowRowerDevicePanel();
|
||||
}
|
||||
else
|
||||
{
|
||||
UIManager.ShowDevicePanel();
|
||||
}
|
||||
UIManager.ShowDevicePanel();
|
||||
});
|
||||
|
||||
home = this.transform.Find("Home").gameObject;
|
||||
|
||||
@@ -190,7 +190,6 @@ public class EditUserController : PFUIPanel, INativeOnMobileImageSelect
|
||||
mYearDropdown.AddOptions(years);
|
||||
mYearDropdown.OnValueChange = (index) =>
|
||||
{
|
||||
//Debug.Log(index);
|
||||
SetDayDropdown();
|
||||
};
|
||||
|
||||
@@ -201,7 +200,7 @@ public class EditUserController : PFUIPanel, INativeOnMobileImageSelect
|
||||
months.Add(i.ToString());
|
||||
}
|
||||
mMonthDropdown.AddOptions(months);
|
||||
//mMonthDropdown.SelectValue("9");
|
||||
|
||||
mMonthDropdown.OnValueChange = (index) =>
|
||||
{
|
||||
SetDayDropdown();
|
||||
@@ -210,12 +209,6 @@ public class EditUserController : PFUIPanel, INativeOnMobileImageSelect
|
||||
mDayDropdown.ClearOptions();
|
||||
SetDayDropdown();
|
||||
|
||||
//mDayDropdown.AddOptions()
|
||||
|
||||
//mDayDropdown.AddOptions(new List<Dropdown.OptionData>
|
||||
//{
|
||||
// new Dropdown.OptionData()
|
||||
//});
|
||||
dict = new Dictionary<string, Selectable>
|
||||
{
|
||||
{"NickName",mNickName.GetComponent<InputField>() },
|
||||
@@ -229,13 +222,6 @@ 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()
|
||||
{
|
||||
|
||||
@@ -94,13 +94,6 @@ public class HomeController : PFUIPanel
|
||||
UIManager.ShowUserInfoPanel();
|
||||
//UIManager.ShowConfirm("Quit", "Do you want to quit PowerFun?", null);
|
||||
});
|
||||
if (transform.Find("Other/BtnRower"))
|
||||
{
|
||||
UIManager.AddEvent(transform.Find("Other/BtnRower").gameObject, EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
UIManager.ShowRowerPanel();
|
||||
});
|
||||
}
|
||||
|
||||
//GetSummary();
|
||||
dict = new Dictionary<string, Sprite[]>
|
||||
|
||||
@@ -582,11 +582,5 @@ public class MapListController : PFUIPanel
|
||||
{
|
||||
caches = null;
|
||||
Resources.UnloadUnusedAssets();
|
||||
GC.Collect();
|
||||
Debug.Log("list empty");
|
||||
}
|
||||
protected override void OnDisable()
|
||||
{
|
||||
App.CurrentRouteType = "";
|
||||
}
|
||||
}
|
||||
@@ -100,13 +100,6 @@ public class NewHomeController : PFUIPanel
|
||||
UIManager.ShowUserInfoPanel();
|
||||
//UIManager.ShowConfirm("Quit", "Do you want to quit PowerFun?", null);
|
||||
});
|
||||
if (transform.Find("Other/BtnRower"))
|
||||
{
|
||||
UIManager.AddEvent(transform.Find("Other/BtnRower").gameObject, EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
UIManager.ShowRowerPanel();
|
||||
});
|
||||
}
|
||||
|
||||
//GetSummary();
|
||||
dict = new Dictionary<string, Sprite[]>
|
||||
|
||||
@@ -214,7 +214,7 @@ public class NewRouteOverviewController: PFUIPanel
|
||||
/// </summary>
|
||||
void ToList(string type)
|
||||
{
|
||||
App.CurrentRouteType = type;// "";
|
||||
App.CurrentRouteType = type;
|
||||
UIManager.ShowMapListPanel();
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 406120aa4593dd340844428cea64a7bc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -18,7 +18,7 @@ public class ResultListController : PFUIPanel
|
||||
Transform scrollContent;
|
||||
Transform routeScroll, matchScroll, rowerScroll;
|
||||
Transform routeContent, matchContent, rowerContent;
|
||||
Transform btnRoute, btnMatch ,btnRower, searchInput;
|
||||
Transform btnRoute, btnMatch , searchInput;
|
||||
Color c1, c2;
|
||||
// Start is called before the first frame update
|
||||
int pageSize = 20;
|
||||
@@ -46,7 +46,6 @@ public class ResultListController : PFUIPanel
|
||||
scroll = transform.Find("ListPanel").Find("Scroll").GetComponent<ScrollRect>();
|
||||
btnMatch = transform.Find("ListPanel").Find("BtnMatch");
|
||||
btnRoute = transform.Find("ListPanel").Find("BtnRoute");
|
||||
btnRower = transform.Find("ListPanel").Find("BtnRower");
|
||||
searchInput = transform.Find("ListPanel").Find("SearchInput");
|
||||
scrollContent = scroll.transform.Find("Viewport").Find("Content");
|
||||
routeScroll = scrollContent.Find("RouteList");
|
||||
@@ -76,14 +75,7 @@ public class ResultListController : PFUIPanel
|
||||
});
|
||||
//btnMatch.GetComponent<Button>().onClick.AddListener(() => StartScroll(0));
|
||||
}
|
||||
if (btnRower != null)
|
||||
{
|
||||
UIManager.AddEvent(btnRower.gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
{
|
||||
StartScroll(2);
|
||||
});
|
||||
}
|
||||
btns = new Transform[] { btnRoute,btnMatch,btnRower };
|
||||
btns = new Transform[] { btnRoute,btnMatch };
|
||||
if (searchInput != null)
|
||||
{
|
||||
UIManager.AddEvent(searchInput.Find("Button").gameObject, EventTriggerType.PointerClick, (b) =>
|
||||
@@ -119,20 +111,6 @@ public class ResultListController : PFUIPanel
|
||||
#if UNITY_ANDROID || UNITY_IOS
|
||||
GetList(2);
|
||||
#endif
|
||||
btnRower.gameObject.SetActive(false);
|
||||
// #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()
|
||||
@@ -211,10 +189,7 @@ public class ResultListController : PFUIPanel
|
||||
{
|
||||
r = await ConfigHelper.mapInterruptRecordApi.GetMapInterruptRecord(name, pageIndex[index], 20, filterOptionDict[index]);
|
||||
}
|
||||
else
|
||||
{
|
||||
r = await ConfigHelper.rowerApi.GetList(pageIndex[index], 20);
|
||||
}
|
||||
|
||||
if (r.result)
|
||||
{
|
||||
if (r.data.Count == 0)
|
||||
@@ -375,7 +350,5 @@ public class ResultListController : PFUIPanel
|
||||
{
|
||||
caches = null;
|
||||
Resources.UnloadUnusedAssets();
|
||||
GC.Collect();
|
||||
Debug.Log("list empty");
|
||||
}
|
||||
}
|
||||
@@ -139,18 +139,6 @@ public class RouteItem : MonoBehaviour
|
||||
//UIManager.ShowRowerResult(result.Id);
|
||||
});
|
||||
}
|
||||
btnReRide = right.Find("BtnRide");
|
||||
if (btnReRide)
|
||||
{
|
||||
UIManager.AddEvent(btnReRide.gameObject, EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
UIManager.ShowConfirm("Re-Rowing", "Rowing again?", () =>
|
||||
{
|
||||
UIManager.CloseConfirm();
|
||||
UIManager.ShowRowerPanel(result);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
//UIManager.AddEvent(transform.gameObject, EventTriggerType.PointerClick, b => UIManager.ShowRowerResult(result.Id));
|
||||
}
|
||||
@@ -270,10 +258,6 @@ public class RouteItem : MonoBehaviour
|
||||
{
|
||||
r = await ConfigHelper.mapApi.DeleteRecord(routeResult.Id);
|
||||
}
|
||||
else
|
||||
{
|
||||
r = await ConfigHelper.rowerApi.Delete(rowerResult.Id);
|
||||
}
|
||||
UIManager.CloseConfirm();
|
||||
if (r.result)
|
||||
{
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 879e9656cc32a33448968cc1f71e5e10
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,83 +0,0 @@
|
||||
using DG.Tweening;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class RowerAnimation : PFUIPanel
|
||||
{
|
||||
List<Sprite> sprites;
|
||||
Image image;
|
||||
public bool isFinish = false;
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
sprites = new List<Sprite>();
|
||||
for (int i = 1; i <= 30; i++)
|
||||
{
|
||||
sprites.Add(Resources.Load<Sprite>($"Images/Rower/序列帧/划船机{i.ToString("0000")}"));
|
||||
}
|
||||
image = transform.GetComponent<Image>();
|
||||
}
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
|
||||
//time = 0;
|
||||
|
||||
}
|
||||
int index = 0;
|
||||
//float time = 0;
|
||||
public override void Show()
|
||||
{
|
||||
//base.Show();
|
||||
|
||||
//index = 0;
|
||||
////time = 0;
|
||||
|
||||
//StartCoroutine(Animation());
|
||||
}
|
||||
public void StartAnimation()
|
||||
{
|
||||
index = 0;
|
||||
isFinish = false;
|
||||
StartCoroutine(Animation());
|
||||
}
|
||||
|
||||
IEnumerator Animation()
|
||||
{
|
||||
yield return new WaitForEndOfFrame();
|
||||
for (int i = 0; i < 15; i++)
|
||||
{
|
||||
image.sprite = sprites[i];
|
||||
yield return new WaitForSeconds(0.02666f);
|
||||
}
|
||||
for (int i = 15; i < 30; i++)
|
||||
{
|
||||
image.sprite = sprites[i];
|
||||
yield return new WaitForSeconds(0.05333f);
|
||||
}
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
//time += Time.deltaTime;
|
||||
//if (time < 0.03)
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
//time = 0;
|
||||
//if (index % 79 == 0)
|
||||
//{
|
||||
// index = 0;
|
||||
//}
|
||||
//image.sprite = sprites[index];
|
||||
//index++;
|
||||
}
|
||||
|
||||
public override void Close()
|
||||
{
|
||||
StopCoroutine(Animation());
|
||||
base.Close();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e84219e49caa1f46be9f0277fd3b7c5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,73 +0,0 @@
|
||||
using Assets.Scripts;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Android;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class RowerDevicePanel : PFUIPanel
|
||||
{
|
||||
protected override void Awake()
|
||||
{
|
||||
UIManager.AddEvent(transform.Find("Container/Tools/Back").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
App.MainDeviceAdapter.StopScan();
|
||||
Close();
|
||||
});
|
||||
}
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
public override void Show()
|
||||
{
|
||||
base.Show();
|
||||
print("开启扫描");
|
||||
#if UNITY_ANDROID || UNITY_IOS
|
||||
#if UNITY_ANDROID
|
||||
Utils.CallAndroidMethod("OpenLocationService");
|
||||
if (!Permission.HasUserAuthorizedPermission(Permission.CoarseLocation))
|
||||
{
|
||||
Permission.RequestUserPermission(Permission.CoarseLocation);
|
||||
Permission.RequestUserPermission(Permission.FineLocation);
|
||||
UIManager.ShowConfirm(App.GetLocalString("Warning"), App.GetLocalString("Powerfun need location service permission,please open the location permission.")
|
||||
, () => {
|
||||
UIManager.CloseConfirm();
|
||||
}, 2
|
||||
, () => {
|
||||
UIManager.CloseConfirm();
|
||||
});
|
||||
}
|
||||
#endif
|
||||
App.MainDeviceAdapter.StartScan();
|
||||
#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;
|
||||
}
|
||||
}
|
||||
protected override void OnDisable()
|
||||
{
|
||||
App.MainDeviceAdapter.StopScan();
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
App.MainDeviceAdapter.StopScan();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 169dd57411866874882869d55e047e57
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,478 +0,0 @@
|
||||
using Assets.Scripts.Devices.Ant;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Events;
|
||||
using Assets.Scripts.Devices.Ant.Interfaces;
|
||||
using Assets.Scripts.UI.UIEffect;
|
||||
using Assets.Scripts;
|
||||
using DG.Tweening;
|
||||
using Assets.Scripts.UI.Prefab.Device;
|
||||
using Assets.Scripts.Devices;
|
||||
using Assets.Scripts.Devices.Ble;
|
||||
|
||||
public class RowerDeviceView : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private SensorType mType;
|
||||
|
||||
private SensorType SensorType
|
||||
{
|
||||
get
|
||||
{
|
||||
//Debug.Log(mType);
|
||||
//Enum.TryParse(mType, out SensorType sensorType);
|
||||
return mType;
|
||||
}
|
||||
}
|
||||
|
||||
private GameObject mSearchButton;
|
||||
private GameObject mPairButton;
|
||||
private GameObject mDisconnectButton;
|
||||
private GameObject unconnectionPanel;
|
||||
private GameObject connectionPanel;
|
||||
private Text searchState,connSearchState;
|
||||
private ConnectDeviceModal deviceModal;
|
||||
private Text title;
|
||||
private Text noDevice;
|
||||
private Text powerValue;
|
||||
private Text powerUnit;
|
||||
//private Text cadenceValue;
|
||||
//private Text speedValue;
|
||||
//private Text heartRateValue;
|
||||
private Image logo;
|
||||
/// <summary>
|
||||
/// 没有设备的logo
|
||||
/// </summary>
|
||||
private Sprite sprite0;
|
||||
/// <summary>
|
||||
/// 连接中的logo
|
||||
/// </summary>
|
||||
private Sprite sprite1;
|
||||
/// <summary>
|
||||
/// 已连接的logo
|
||||
/// </summary>
|
||||
private Sprite sprite3;
|
||||
|
||||
private float timer = 0f;
|
||||
private void Awake()
|
||||
{
|
||||
title = this.transform.Find("Title").GetComponent<Text>();
|
||||
noDevice = this.transform.Find("NoDevice").GetComponent<Text>();
|
||||
unconnectionPanel = this.transform.Find("UnconnectionPanel").gameObject;
|
||||
mSearchButton = unconnectionPanel.transform.Find("SearchButton").gameObject;
|
||||
mPairButton = unconnectionPanel.transform.Find("PairButton").gameObject;
|
||||
searchState = unconnectionPanel.transform.Find("SearchState").GetComponent<Text>();
|
||||
//mPairButton.SetActive(false);
|
||||
connectionPanel = this.transform.Find("ConnectionPanel").gameObject;
|
||||
connSearchState = connectionPanel.transform.Find("SearchState").GetComponent<Text>();
|
||||
var material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
||||
var rect = ((RectTransform)transform).rect;
|
||||
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height * 0.2f, 0));
|
||||
this.GetComponent<Image>().material = material;
|
||||
|
||||
var img1 = unconnectionPanel.GetComponent<Image>();
|
||||
if(img1 != null)
|
||||
{
|
||||
img1.material = material;
|
||||
|
||||
//var gradient = unconnectionPanel.GetComponent<UIGradient>();
|
||||
//if (gradient != null)
|
||||
//{
|
||||
// gradient.color1 = Utils.HexToColor("353543");
|
||||
// gradient.color2 = Utils.HexToColor("23232D");
|
||||
//}
|
||||
}
|
||||
|
||||
var img2 = connectionPanel.GetComponent<Image>();
|
||||
if(img2 != null)
|
||||
{
|
||||
img2.material = material;
|
||||
|
||||
//var gradient1 = connectionPanel.GetComponent<UIGradient>();
|
||||
//if (gradient1 != null)
|
||||
//{
|
||||
// gradient1.color1 = Utils.HexToColor("FF7485");
|
||||
// gradient1.color2 = Utils.HexToColor("F93086");
|
||||
//}
|
||||
}
|
||||
|
||||
logo = this.transform.Find("Logo").GetComponent<Image>();
|
||||
|
||||
|
||||
mDisconnectButton = connectionPanel.transform.Find("DisconnectBtn").gameObject;
|
||||
var powerValueObj = connectionPanel.transform.Find("PowerValue");
|
||||
if(powerValueObj != null)
|
||||
{
|
||||
powerValue = powerValueObj.gameObject.GetComponent<Text>();
|
||||
}
|
||||
|
||||
var powerUnitObj = connectionPanel.transform.Find("PowerUnit");
|
||||
if(powerUnitObj != null)
|
||||
{
|
||||
powerUnit = powerUnitObj.gameObject.GetComponent<Text>();
|
||||
}
|
||||
|
||||
InitLogo();
|
||||
title.text = GetTitle();
|
||||
|
||||
connectionPanel.SetActive(false);
|
||||
|
||||
UIManager.AddEvent(mPairButton, EventTriggerType.PointerClick, new UnityAction<UnityEngine.EventSystems.BaseEventData>(e =>
|
||||
{
|
||||
connectButtonClick();
|
||||
}));
|
||||
UIManager.AddEvent(gameObject, EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
if (!mPairButton.activeInHierarchy && !mDisconnectButton.activeInHierarchy) return;
|
||||
var device = GetDevice();
|
||||
if (device != null && device.State == DeviceState.Connected)
|
||||
{
|
||||
UIManager.ShowConfirm(App.GetLocalString("Warning"), App.GetLocalString("Disconnect the device?"), () =>
|
||||
{
|
||||
device.Disconnect(false);
|
||||
DeviceCache.Remove(device);
|
||||
UIManager.CloseConfirm();
|
||||
}, 2, () => {
|
||||
UIManager.CloseConfirm();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
connectButtonClick();
|
||||
}
|
||||
});
|
||||
UIManager.AddEvent(mDisconnectButton, EventTriggerType.PointerClick, new UnityEngine.Events.UnityAction<BaseEventData>(e => {
|
||||
UIManager.ShowConfirm(App.GetLocalString("Warning"), App.GetLocalString("Disconnect the device?"), () =>
|
||||
{
|
||||
var device = GetDevice();
|
||||
if (device != null && device.State == DeviceState.Connected)
|
||||
{
|
||||
DeviceCache.Remove(device);
|
||||
device.Disconnect(false);
|
||||
}
|
||||
UIManager.CloseConfirm();
|
||||
}, 2, () => {
|
||||
UIManager.CloseConfirm();
|
||||
});
|
||||
return;
|
||||
|
||||
#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 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)
|
||||
{
|
||||
sprite0 = Resources.Load<Sprite>("Images/Devices/Power_0");
|
||||
sprite1 = Resources.Load<Sprite>("Images/Devices/Power_1");
|
||||
sprite3 = Resources.Load<Sprite>("Images/Devices/Power_4");
|
||||
|
||||
powerUnit.text = "W";
|
||||
}
|
||||
else if (SensorType == SensorType.Speed)
|
||||
{
|
||||
sprite0 = Resources.Load<Sprite>("Images/Devices/Speed_0");
|
||||
sprite1 = Resources.Load<Sprite>("Images/Devices/Speed_1");
|
||||
sprite3 = Resources.Load<Sprite>("Images/Devices/Speed_4");
|
||||
|
||||
powerUnit.text = "KPH";
|
||||
}
|
||||
else if (SensorType == SensorType.Cadence || SensorType == SensorType.SpeedCadence)
|
||||
{
|
||||
sprite0 = Resources.Load<Sprite>("Images/Devices/Cadence_0");
|
||||
sprite1 = Resources.Load<Sprite>("Images/Devices/Cadence_1");
|
||||
sprite3 = Resources.Load<Sprite>("Images/Devices/Cadence_4");
|
||||
|
||||
powerUnit.text = "RPM";
|
||||
}
|
||||
else if (SensorType == SensorType.HeartRate)
|
||||
{
|
||||
sprite0 = Resources.Load<Sprite>("Images/Devices/Heart Rate_1");
|
||||
sprite1 = Resources.Load<Sprite>("Images/Devices/Heart Rate_1");
|
||||
sprite3 = Resources.Load<Sprite>("Images/Devices/Heart Rate_4");
|
||||
powerValue.text = "";
|
||||
powerUnit.text = "";
|
||||
}
|
||||
else if (SensorType == SensorType.Trainer)
|
||||
{
|
||||
sprite0 = Resources.Load<Sprite>("Images/Devices/Trainer_0");
|
||||
sprite1 = Resources.Load<Sprite>("Images/Devices/Trainer_1");
|
||||
sprite3 = Resources.Load<Sprite>("Images/Devices/Trainer_4");
|
||||
}
|
||||
else if (SensorType == SensorType.Rower)
|
||||
{
|
||||
sprite0 = Resources.Load<Sprite>("Images/Rower/设备 - 划船机 - 未连接");
|
||||
sprite1 = Resources.Load<Sprite>("Images/Rower/设备 - 划船机 - 未连接");
|
||||
sprite3 = Resources.Load<Sprite>("Images/Rower/设备 - 划船机");
|
||||
powerUnit.text = "";
|
||||
powerValue.text = "";
|
||||
}
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
Main();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
//if(SensorType != SensorType.Trainer)
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
timer -= Time.deltaTime;
|
||||
if (timer <= 0)
|
||||
{
|
||||
Main();
|
||||
|
||||
timer = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void Main()
|
||||
{
|
||||
var connectedDevice = GetCurrentDevice();
|
||||
if(connectedDevice == null)
|
||||
{
|
||||
connectedDevice = GetDevice();
|
||||
}
|
||||
if(connectedDevice == null)
|
||||
{
|
||||
unconnectionPanel.SetActive(true);
|
||||
connectionPanel.SetActive(false);
|
||||
|
||||
logo.sprite = sprite0;
|
||||
|
||||
|
||||
var hasDevice = false;
|
||||
if (SensorType == SensorType.SpeedCadence)
|
||||
{
|
||||
hasDevice = App.MainDeviceAdapter.GetDevices().Any(d => d.Sensor == SensorType.SpeedCadence || d.Sensor == SensorType.Cadence);
|
||||
}
|
||||
else
|
||||
{
|
||||
hasDevice = App.MainDeviceAdapter.GetDevices().Any(d => d.Sensor == SensorType);
|
||||
}
|
||||
searchState.text = hasDevice ? App.GetLocalString("CHOOSE DEVICE") : App.GetLocalString("NO DEVICE");
|
||||
noDevice.text = "";// App.GetLocalString("NOCONN DEVICE"); //hasDevice ? App.GetLocalString("CHOOSE DEVICE") : ;
|
||||
if (hasDevice)
|
||||
{
|
||||
mSearchButton.SetActive(false);
|
||||
mPairButton.SetActive(true);
|
||||
#if UNITY_IOS || UNITY_ANDROID
|
||||
//searchState.gameObject.SetActive(false);
|
||||
#endif
|
||||
logo.sprite = sprite1;
|
||||
|
||||
//App.MainDeviceAdapter.GetDevices().First(d => d.Sensor == SensorType).Connect();
|
||||
}
|
||||
else
|
||||
{
|
||||
#if !(UNITY_IOS || UNITY_ANDROID)
|
||||
mSearchButton.SetActive(true);
|
||||
#endif
|
||||
//mPairButton.SetActive(false);
|
||||
}
|
||||
}
|
||||
else if(connectedDevice.State == DeviceState.Connecting)
|
||||
{
|
||||
unconnectionPanel.SetActive(true);
|
||||
connectionPanel.SetActive(false);
|
||||
logo.sprite = sprite1;
|
||||
|
||||
//title.text = connectedDevice.Name;
|
||||
if (connectedDevice.Network == NetworkType.BLE)
|
||||
{
|
||||
//noDevice.enabled = false;
|
||||
noDevice.text = connectedDevice.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
//noDevice.enabled = true;
|
||||
noDevice.text = connectedDevice.Name +" "+ connectedDevice.DeviceNumber.ToString();
|
||||
}
|
||||
#if (UNITY_IOS || UNITY_ANDROID)
|
||||
mPairButton.SetActive(true);
|
||||
searchState.gameObject.SetActive(true);
|
||||
#endif
|
||||
searchState.text = App.GetLocalString("Connecting...");
|
||||
|
||||
|
||||
}
|
||||
else if (connectedDevice.State == DeviceState.Connected)
|
||||
{
|
||||
unconnectionPanel.SetActive(false);
|
||||
|
||||
if (connectionPanel.activeInHierarchy == false)
|
||||
{
|
||||
var connectionCanvasGroup = connectionPanel.GetComponent<CanvasGroup>();
|
||||
connectionCanvasGroup.alpha = 0;
|
||||
connectionPanel.SetActive(true);
|
||||
connectionCanvasGroup.DOFade(1f, .3f).OnComplete(()=> {
|
||||
//if (logoSprite != null) {
|
||||
// logo.sprite = logoSprite;
|
||||
//}
|
||||
});
|
||||
DeviceCache.Add(connectedDevice);
|
||||
Debug.Log("connected");
|
||||
}
|
||||
|
||||
logo.sprite = sprite3;
|
||||
//title.text = connectedDevice.Name;
|
||||
if (connectedDevice.Network == NetworkType.BLE)
|
||||
{
|
||||
//noDevice.enabled = false;
|
||||
noDevice.text = connectedDevice.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
//noDevice.enabled = true;
|
||||
noDevice.text = connectedDevice.Name +" "+ connectedDevice.DeviceNumber.ToString();
|
||||
}
|
||||
noDevice.color = Utils.HexToColorHtml("#f93086");
|
||||
|
||||
//if (powerValue != null)
|
||||
//{
|
||||
// powerValue.text = GetValue(connectedDevice);
|
||||
//}
|
||||
}
|
||||
|
||||
//Debug.Log(Newtonsoft.Json.JsonConvert.SerializeObject(App.MainDeviceAdapter.GetDevices().Where(d => d.Sensor == SensorType)));
|
||||
}
|
||||
|
||||
string GetTitle()
|
||||
{
|
||||
switch (SensorType)
|
||||
{
|
||||
case SensorType.None:
|
||||
break;
|
||||
case SensorType.SpeedCadence:
|
||||
case SensorType.Cadence:
|
||||
return "Cadence Sensor";
|
||||
case SensorType.HeartRate:
|
||||
return "Heart Rate Monitor";
|
||||
case SensorType.Power:
|
||||
return "Power Meter";
|
||||
case SensorType.Speed:
|
||||
return "Speed Meter";
|
||||
case SensorType.Trainer:
|
||||
return "Smart Trainer";
|
||||
case SensorType.Rower:
|
||||
return "Rowing Machine";
|
||||
case SensorType.VirtualPower:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
string GetValue(AbstractDevice connectedDevice)
|
||||
{
|
||||
switch (SensorType)
|
||||
{
|
||||
case SensorType.None:
|
||||
break;
|
||||
case SensorType.SpeedCadence:
|
||||
case SensorType.Cadence:
|
||||
//cadenceValue.text = (connectedDevice as ICadenceDevice).Cadence.ToString();
|
||||
return (connectedDevice as ICadenceDevice).Cadence.ToString();
|
||||
case SensorType.HeartRate:
|
||||
return (connectedDevice as IHeartRateDevice).HeartRate.ToString();
|
||||
case SensorType.Power:
|
||||
return (connectedDevice as IPowerDevice).Power.ToString();
|
||||
case SensorType.Speed:
|
||||
return (connectedDevice as ISpeedDevice).Speed.ToString("f1");
|
||||
case SensorType.Trainer:
|
||||
//powerValue.text = (connectedDevice as IPowerDevice).Power.ToString();
|
||||
//cadenceValue.GetComponent<Text>().text = (connectedDevice as ICadenceDevice).Cadence.ToString();
|
||||
//speedValue.GetComponent<Text>().text = (connectedDevice as ISpeedDevice).Speed.ToString();
|
||||
break;
|
||||
case SensorType.VirtualPower:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
AbstractDevice GetCurrentDevice()
|
||||
{
|
||||
//return AntConnector.Instance().discoveredDevices.FirstOrDefault(d => (d.State == DeviceState.Connected || d.State == DeviceState.Connecting) && d.Sensor == SensorType);
|
||||
if(SensorType == SensorType.SpeedCadence || SensorType == SensorType.Cadence)
|
||||
{
|
||||
return App.MainDeviceAdapter.GetDevices().FirstOrDefault(d => (d.State == DeviceState.Connected || d.State == DeviceState.Connecting) && (d.Sensor == SensorType.SpeedCadence || d.Sensor == SensorType.Cadence));
|
||||
}
|
||||
return App.MainDeviceAdapter.GetDevices().FirstOrDefault(d => (d.State == DeviceState.Connected || d.State == DeviceState.Connecting) && d.Sensor == SensorType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取已经连接的设备
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
AbstractDevice GetDevice()
|
||||
{
|
||||
//return AntConnector.Instance().discoveredDevices.FirstOrDefault(d => (d.State == DeviceState.Connected || d.State == DeviceState.Connecting) && d.Sensor == SensorType);
|
||||
var devices = App.MainDeviceAdapter.GetDevices().Where(d => (d.State == DeviceState.Connected));
|
||||
switch (SensorType)
|
||||
{
|
||||
case SensorType.None:
|
||||
break;
|
||||
case SensorType.SpeedCadence:
|
||||
case SensorType.Cadence:
|
||||
return devices.FirstOrDefault(d => d is ICadenceDevice);
|
||||
case SensorType.HeartRate:
|
||||
return devices.FirstOrDefault(d => d is IHeartRateDevice);
|
||||
case SensorType.Power:
|
||||
var item = devices.FirstOrDefault(d => d is IPowerDevice);
|
||||
//if (powerValue != null)
|
||||
//{
|
||||
// powerValue.GetComponent<Text>().text = (item as IPowerDevice).Power.ToString();
|
||||
//}
|
||||
return item;
|
||||
case SensorType.Speed:
|
||||
return devices.FirstOrDefault(d => d is ISpeedDevice);
|
||||
case SensorType.Rower:
|
||||
return devices.FirstOrDefault(d => d.Sensor == SensorType.Rower);
|
||||
case SensorType.Trainer:
|
||||
var item3 = devices.FirstOrDefault(d => d.Sensor == SensorType.Trainer);
|
||||
return item3;
|
||||
case SensorType.VirtualPower:
|
||||
break;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 954bbf32f326f684c90a328ec1db5ff9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,123 +0,0 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using UnityEngine;
|
||||
using ChartAndGraph;
|
||||
using System.Collections;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class RowerGraphChartFeed : MonoBehaviour
|
||||
{
|
||||
GraphChartBase graph { get; set; }
|
||||
GraphData dataSource { get; set; }
|
||||
|
||||
void Start ()
|
||||
{
|
||||
graph = GetComponent<GraphChartBase>();
|
||||
dataSource = graph.DataSource;
|
||||
//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.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);
|
||||
// if (i == 0)
|
||||
// graph.DataSource.SetCurveInitialPoint("Player 2",i*5, Random.value * 10f + 10f);
|
||||
// else
|
||||
// graph.DataSource.AddLinearCurveToCategory("Player 2",
|
||||
// new DoubleVector2(i*5 , Random.value * 10f + 10f));
|
||||
// }
|
||||
// graph.DataSource.MakeCurveCategorySmooth("Player 2");
|
||||
// graph.DataSource.EndBatch();
|
||||
//}
|
||||
// StartCoroutine(ClearAll());
|
||||
}
|
||||
public void SetPrePoint(double x, double y)
|
||||
{
|
||||
dataSource?.AddPointToCategoryRealtime("Player 1", x, y);
|
||||
}
|
||||
public void SetCurrentPoint(double x,double y)
|
||||
{
|
||||
if(dataSource != null)
|
||||
x += dataSource.HorizontalViewOrigin;
|
||||
Debug.Log($"SetCurrentPoint:{x}-{y}");
|
||||
|
||||
dataSource?.AddPointToCategoryRealtime("Player 2", x, y);
|
||||
}
|
||||
public void ClearChart()
|
||||
{
|
||||
if (dataSource != null)
|
||||
{
|
||||
dataSource.HorizontalViewOrigin += 10;
|
||||
SetCurrentPoint(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetHistoryData(double x,List<DoubleVector2> list2 = null)
|
||||
{
|
||||
if (list2 != null && list2.Count > 0)
|
||||
{
|
||||
var offset = dataSource.HorizontalViewOrigin;
|
||||
graph.DataSource.AddPointToCategoryRealtime("Player 1", offset, 0);
|
||||
for (int i = 0; i < list2.Count; i++)
|
||||
{
|
||||
var item = list2[i];
|
||||
graph.DataSource.AddPointToCategoryRealtime("Player 1", item.x + offset, item.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetChart()
|
||||
{
|
||||
if (dataSource != null)
|
||||
{
|
||||
dataSource.HorizontalViewOrigin = -0.03;
|
||||
dataSource.ClearCategory("Player 1");
|
||||
dataSource.ClearCategory("Player 2");
|
||||
}
|
||||
}
|
||||
|
||||
public void SetData(List<DoubleVector2> list,List<DoubleVector2> list2 = null)
|
||||
{
|
||||
if (graph != null)
|
||||
{
|
||||
graph.Scrollable = false;
|
||||
//graph.HorizontalValueToStringMap[0.0] = "Zero"; // example of how to set custom axis strings
|
||||
//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.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();
|
||||
}
|
||||
}
|
||||
IEnumerator ClearAll()
|
||||
{
|
||||
yield return new WaitForSeconds(5f);
|
||||
GraphChartBase graph = GetComponent<GraphChartBase>();
|
||||
|
||||
graph.DataSource.Clear();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa4e07579b1f9574788e0b83b1fac799
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,145 +0,0 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using ChartAndGraph;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public partial class RowerHoverText : MonoBehaviour
|
||||
{
|
||||
public Text TextPrefab;
|
||||
public int FontSize = 5;
|
||||
public Vector3 TextOffset = new Vector3();
|
||||
public string Title;
|
||||
public string Unit;
|
||||
int fractionDigits = 0;
|
||||
AnyChart mChart;
|
||||
|
||||
List<Text> mItems = new List<Text>();
|
||||
List<CharItemEffectController> mRemoved = new List<CharItemEffectController>();
|
||||
|
||||
partial void HoverStart();
|
||||
void Start ()
|
||||
{
|
||||
var graph = GetComponent<GraphChart>();
|
||||
|
||||
var labels = GetComponent<ItemLabels>();
|
||||
if (labels != null)
|
||||
fractionDigits = labels.FractionDigits;
|
||||
else
|
||||
fractionDigits = 2;
|
||||
|
||||
if (graph != null)
|
||||
{
|
||||
mChart = graph;
|
||||
graph.PointHovered.AddListener(GraphHover);
|
||||
graph.NonHovered.AddListener(NonHover);
|
||||
return;
|
||||
}
|
||||
|
||||
var bar = GetComponent<CanvasBarChart>();
|
||||
if (bar != null)
|
||||
{
|
||||
mChart = bar;
|
||||
bar.BarHovered.AddListener(BarHover);
|
||||
bar.NonHovered.AddListener(NonHover);
|
||||
return;
|
||||
}
|
||||
|
||||
HoverStart();
|
||||
}
|
||||
|
||||
void NonHover()
|
||||
{
|
||||
for (int i = 0; i < mItems.Count; i++)
|
||||
{
|
||||
RemoveText(mItems[i]);
|
||||
}
|
||||
mItems.Clear();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
mRemoved.RemoveAll(x =>
|
||||
{
|
||||
if(!x.enabled)
|
||||
{
|
||||
ChartCommon.SafeDestroy(x.gameObject);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
IEnumerator SelectText(Text text)
|
||||
{
|
||||
yield return new WaitForEndOfFrame();
|
||||
if (text != null)
|
||||
{
|
||||
ChartItemEvents e = text.GetComponent<ChartItemEvents>();
|
||||
if (e != null)
|
||||
{
|
||||
e.OnMouseHover.Invoke(e.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RemoveText(Text text)
|
||||
{
|
||||
if (text != null)
|
||||
{
|
||||
ChartItemEvents e = text.GetComponent<ChartItemEvents>();
|
||||
CharItemEffectController control = text.GetComponent<CharItemEffectController>();
|
||||
if (e != null && control != null)
|
||||
{
|
||||
e.OnMouseLeave.Invoke(e.gameObject);
|
||||
mRemoved.Add(control);
|
||||
}
|
||||
else
|
||||
{
|
||||
ChartCommon.SafeDestroy(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PopText(string data,Vector3 position,bool worldPositionStays)
|
||||
{
|
||||
var canvas = GetComponentInParent<Canvas>();
|
||||
if (canvas == null || TextPrefab == null)
|
||||
return;
|
||||
NonHover();
|
||||
GameObject obj =(GameObject) GameObject.Instantiate(TextPrefab.gameObject, position + TextOffset, Quaternion.identity);
|
||||
var text = obj.GetComponent<Text>();
|
||||
text.maskable = false;
|
||||
text.text = data;
|
||||
text.fontSize = FontSize;
|
||||
obj.transform.SetParent(transform, false);
|
||||
if (worldPositionStays)
|
||||
obj.transform.position = position + TextOffset;
|
||||
else
|
||||
obj.transform.localPosition = position + TextOffset;
|
||||
Vector3 local = obj.transform.localPosition;
|
||||
local.z = 0f;
|
||||
obj.transform.localPosition = local;
|
||||
mItems.Add(text);
|
||||
StartCoroutine(SelectText(text));
|
||||
}
|
||||
|
||||
void BarHover(BarChart.BarEventArgs args)
|
||||
{
|
||||
String data = ChartAdancedSettings.Instance.FormatFractionDigits(fractionDigits, args.Value);
|
||||
PopText(data, args.TopPosition,true);
|
||||
}
|
||||
void GraphHover(GraphChartBase.GraphEventArgs args)
|
||||
{
|
||||
var graph = mChart as GraphChart;
|
||||
var point = graph.DataSource.GetPoint(args.Category, args.Index);
|
||||
Vector3 position;
|
||||
if(graph.PointToWorldSpace(out position, point.x, point.y, args.Category))
|
||||
PopText($"{Title}\n{args.YString} {Unit}", position, true);
|
||||
else
|
||||
PopText($"{Title}\n{args.YString} {Unit}", args.Position,false);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: edce4d82bd7a8544982946c6318de49b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,245 +0,0 @@
|
||||
#define Graph_And_Chart_PRO
|
||||
using UnityEngine;
|
||||
using ChartAndGraph;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
public partial class RowerLargeDataFeed : MonoBehaviour, IComparer<DoubleVector2>
|
||||
{
|
||||
public string Category = "Player 1";
|
||||
public int DownSampleToPoints = 1000;
|
||||
List<DoubleVector2> mData = new List<DoubleVector2>(); // the data held by the chart
|
||||
double pageSize = 2f;
|
||||
double currentPagePosition = 0.0;
|
||||
double currentZoom = 0f;
|
||||
GraphChartBase graph;
|
||||
double mCurrentPageSizeFactor = double.NegativeInfinity;
|
||||
void Start()
|
||||
{
|
||||
graph = GetComponent<GraphChartBase>();
|
||||
//SetInitialData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// called with Start(). These will be used to load the data into the large data feed. You should replace this with your own loading logic.
|
||||
/// </summary>
|
||||
void SetInitialData()
|
||||
{
|
||||
List<DoubleVector2> data = new List<DoubleVector2>(75);
|
||||
double x = 0f;
|
||||
double y = 20f;
|
||||
for (int i = 0; i < 75; i++) // initialize with random data
|
||||
{
|
||||
y = 20 + UnityEngine.Random.value * 80;
|
||||
Debug.Log(y);
|
||||
x += 1;
|
||||
data.Add(new DoubleVector2(x, y));
|
||||
}
|
||||
SetData(data);
|
||||
}
|
||||
|
||||
public void SaveToFile(string path)
|
||||
{
|
||||
using (StreamWriter file = new StreamWriter(path))
|
||||
{
|
||||
file.WriteLine(mData.Count);
|
||||
for (int i = 0; i < mData.Count; i++)
|
||||
{
|
||||
DoubleVector2 item = mData[i];
|
||||
file.WriteLine(item.x);
|
||||
file.WriteLine(item.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void LoadFromFile(string path)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<DoubleVector2> data = new List<DoubleVector2>();
|
||||
using (StreamReader file = new StreamReader(path))
|
||||
{
|
||||
int count = int.Parse(file.ReadLine());
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
double x = double.Parse(file.ReadLine());
|
||||
double y = double.Parse(file.ReadLine());
|
||||
data.Add(new DoubleVector2(x, y));
|
||||
}
|
||||
}
|
||||
SetData(data);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new Exception("Invalid file format");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// vertify's that the graph data is sorted so it can be searched using a binary search.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
bool VerifySorted(List<DoubleVector2> data)
|
||||
{
|
||||
if (data == null)
|
||||
return true;
|
||||
for (int i = 1; i < data.Count; i++)
|
||||
{
|
||||
if (data[i].x < data[i - 1].x)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// set the data of the large data graph
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
public void SetData(List<DoubleVector2> data)
|
||||
{
|
||||
if (data == null)
|
||||
data = new List<DoubleVector2>(); // set up an empty list instead of null
|
||||
if (VerifySorted(data) == false)
|
||||
{
|
||||
Debug.LogWarning("The data used with large data feed must be sorted acoording to the x value, aborting operation");
|
||||
return;
|
||||
}
|
||||
mData = data;
|
||||
LoadPage(currentPagePosition); // load the page at position 0
|
||||
}
|
||||
|
||||
int FindClosestIndex(double position) // if you want to know what is index is currently displayed . use binary search to find it
|
||||
{
|
||||
//NOTE :: this method assumes your data is sorted !!!
|
||||
int res = mData.BinarySearch(new DoubleVector2(position, 0.0), this);
|
||||
if (res >= 0)
|
||||
return res;
|
||||
return ~res;
|
||||
}
|
||||
|
||||
double PageSizeFactor
|
||||
{
|
||||
get
|
||||
{
|
||||
return pageSize * graph.DataSource.HorizontalViewSize;
|
||||
}
|
||||
}
|
||||
|
||||
void findPointsForPage(double position, out int start, out int end) // given a page position , find the right most and left most indices in the data for that page.
|
||||
{
|
||||
int index = FindClosestIndex(position); // use binary search to find the closest position to the current scroll point
|
||||
|
||||
double endPosition = position + PageSizeFactor;
|
||||
double startPosition = position - PageSizeFactor;
|
||||
|
||||
//starting from the current index , we find the page boundries
|
||||
for (start = index; start > 0; start--)
|
||||
{
|
||||
if (mData[start].x < startPosition) // take the first point that is out of the page. so the graph doesn't break at the edge
|
||||
break;
|
||||
}
|
||||
|
||||
for (end = index; end < mData.Count; end++)
|
||||
{
|
||||
if (mData[end].x > endPosition) // take the first point that is out of the page
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (graph != null)
|
||||
{
|
||||
//check the scrolling position of the graph. if we are past the view size , load a new page
|
||||
double pageStartThreshold = currentPagePosition - mCurrentPageSizeFactor;
|
||||
double pageEndThreshold = currentPagePosition + mCurrentPageSizeFactor - graph.DataSource.HorizontalViewSize;
|
||||
|
||||
if (graph.HorizontalScrolling < pageStartThreshold || graph.HorizontalScrolling > pageEndThreshold || currentZoom >= graph.DataSource.HorizontalViewSize * 2f)
|
||||
{
|
||||
currentZoom = graph.DataSource.HorizontalViewSize;
|
||||
mCurrentPageSizeFactor = PageSizeFactor * 0.9f;
|
||||
LoadPage(graph.HorizontalScrolling);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LoadWithoutDownSampling(int start, int end)
|
||||
{
|
||||
for (int i = start; i < end; i++) // load the data
|
||||
{
|
||||
graph.DataSource.AddPointToCategory(Category, mData[i].x, mData[i].y);
|
||||
}
|
||||
}
|
||||
|
||||
void LoadWithDownSampling(int start, int end)
|
||||
{
|
||||
int total = end - start;
|
||||
|
||||
if (DownSampleToPoints >= total)
|
||||
{
|
||||
LoadWithoutDownSampling(start, end);
|
||||
return;
|
||||
}
|
||||
|
||||
double sampleCount = ((double)total) / (double)DownSampleToPoints;
|
||||
// graph.DataSource.AddPointToCategory(Category, mData[start].x, mData[start].y);
|
||||
for (int i = 0; i < DownSampleToPoints; i++)
|
||||
{
|
||||
int fractionStart = start + (int)(i * sampleCount); // the first point with a fraction
|
||||
int fractionEnd = start + (int)((i + 1) * sampleCount); // the first point with a fraction
|
||||
fractionEnd = Math.Min(fractionEnd, mData.Count - 1);
|
||||
double x = 0, y = 0;
|
||||
double divide = 0.0;
|
||||
for (int j = fractionStart; j < fractionEnd; j++) // avarge the poins
|
||||
{
|
||||
x += mData[j].x;
|
||||
y += mData[j].y;
|
||||
divide++;
|
||||
}
|
||||
if (divide > 0.0)
|
||||
{
|
||||
x /= divide;
|
||||
y /= divide;
|
||||
graph.DataSource.AddPointToCategory(Category, x, y);
|
||||
}
|
||||
else
|
||||
Debug.Log("error");
|
||||
}
|
||||
// graph.DataSource.AddPointToCategory(Category, mData[last].x, mData[last].y);
|
||||
}
|
||||
|
||||
void LoadPage(double pagePosition)
|
||||
{
|
||||
if (graph != null)
|
||||
{
|
||||
|
||||
Debug.Log("Loading page :" + pagePosition);
|
||||
graph.DataSource.StartBatch(); // call start batch
|
||||
graph.DataSource.HorizontalViewOrigin = 0;
|
||||
int start, end;
|
||||
findPointsForPage(pagePosition, out start, out end); // get the page edges
|
||||
graph.DataSource.ClearCategory(Category); // clear the cateogry
|
||||
graph.DataSource.HorizontalViewSize = mData.Count;
|
||||
if (DownSampleToPoints <= 0)
|
||||
LoadWithoutDownSampling(start, end);
|
||||
else
|
||||
LoadWithDownSampling(start, end);
|
||||
graph.DataSource.EndBatch();
|
||||
graph.HorizontalScrolling = pagePosition;
|
||||
}
|
||||
currentPagePosition = pagePosition;
|
||||
}
|
||||
|
||||
|
||||
public int Compare(DoubleVector2 x, DoubleVector2 y)
|
||||
{
|
||||
if (x.x < y.x)
|
||||
return -1;
|
||||
if (x.x > y.x)
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7916cf3d11e8e7b4ebd8712801923455
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee3b67ceb2893134a887a9e30922821e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,121 +0,0 @@
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using ChartAndGraph;
|
||||
using DG.Tweening;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class RowerResult : PFUIPanel
|
||||
{
|
||||
RowerResultModel _model;
|
||||
private GraphChart chartPace, chartRate, chartHR;
|
||||
Transform dataContent;
|
||||
// Start is called before the first frame update
|
||||
void Awake()
|
||||
{
|
||||
var grid = transform.Find("Scroll View/Viewport/Content/Content/Table").GetComponent<GridLayoutGroup>();
|
||||
float width = (App.canvasWidth - 60 - 3) / 4;
|
||||
grid.cellSize = new Vector2(width, 37);
|
||||
var grid1 = transform.Find("Scroll View/Viewport/Content/Content/Other/Datas").GetComponent<GridLayoutGroup>();
|
||||
grid1.cellSize = new Vector2(width, 53);
|
||||
chartPace = transform.Find("Scroll View/Viewport/Content/Content/ChartPace/Chart").GetComponent<GraphChart>();
|
||||
chartPace.DataSource.VerticalViewOrigin = ChartDateUtility.TimeSpanToValue(TimeSpan.FromHours(15));
|
||||
chartPace.DataSource.VerticalViewSize = ChartDateUtility.TimeSpanToValue(TimeSpan.FromHours(15)) * -1;
|
||||
chartRate = transform.Find("Scroll View/Viewport/Content/Content/ChartRate/Chart").GetComponent<GraphChart>();
|
||||
chartHR = transform.Find("Scroll View/Viewport/Content/Content/ChartHeartRate/Chart").GetComponent<GraphChart>();
|
||||
dataContent = transform.Find("Scroll View/Viewport/Content/Content");
|
||||
UIManager.AddEvent(transform.Find("Exit").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
Close();
|
||||
});
|
||||
//var a = new List<ChartAndGraph.DoubleVector2>();
|
||||
//for (int i = 0; i < 100; i++)
|
||||
//{
|
||||
// a.Add(new ChartAndGraph.DoubleVector2(i, ChartDateUtility.TimeSpanToValue(TimeSpan.FromMinutes(300))));
|
||||
//}
|
||||
//transform.Find("Scroll View/Viewport/Content/Content/ChartPace/Chart").GetComponent<RowerLargeDataFeed>().SetData(a);
|
||||
}
|
||||
public async void Initial(string id)
|
||||
{
|
||||
transform.Find("Scroll View").GetComponent<ScrollRect>().verticalNormalizedPosition = 1;
|
||||
GetComponent<CanvasGroup>().alpha = 0;
|
||||
var res = await ConfigHelper.rowerApi.GetDetail(id);
|
||||
if (res.result)
|
||||
{
|
||||
_model = res.data;
|
||||
dataContent.Find("Title").GetComponent<Text>().text = $"{_model.CreateTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")} Free Rowing";
|
||||
dataContent.Find("Time").GetComponent<Text>().text = $"{_model.StartTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")} ~ {_model.CreateTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")}";
|
||||
dataContent.Find("TitleContent/Duration").GetComponent<Text>().text
|
||||
= $"<color=#5c5c6e>Rowing time :</color> {TimeSpan.FromSeconds(_model.TotalTime).ToString()}";
|
||||
dataContent.Find("TitleContent/Distance").GetComponent<Text>().text
|
||||
= $"<color=#5c5c6e>Distance :</color> {_model.TotalDistance}M";
|
||||
dataContent.Find("TitleContent/Device").GetComponent<Text>().text
|
||||
= $"<color=#5c5c6e>Rowing equipment :</color> {_model.ManufacturerName}";
|
||||
dataContent.Find("Table/AvgPower/Text").GetComponent<Text>().text
|
||||
= $"{TimeSpan.FromSeconds(_model.AvgPace).ToString(@"mm\:ss")} /500M";
|
||||
dataContent.Find("Table/AvgHR/Text").GetComponent<Text>().text
|
||||
= $"{_model.AvgHeartRate} BPM";
|
||||
dataContent.Find("Table/AvgRate/Text").GetComponent<Text>().text
|
||||
= $"{_model.AvgRate.ToString("#0")} SPM";
|
||||
dataContent.Find("Table/MaxPower/Text").GetComponent<Text>().text
|
||||
= $"{TimeSpan.FromSeconds(_model.MaxPace).ToString(@"mm\:ss")} /500M";
|
||||
dataContent.Find("Table/MaxHR/Text").GetComponent<Text>().text
|
||||
= $"{_model.MaxHeartRate} BPM";
|
||||
dataContent.Find("Table/MaxRate/Text").GetComponent<Text>().text
|
||||
= $"{_model.MaxRate.ToString("#0")} SPM";
|
||||
dataContent.Find("ChartPace/Avg/Value").GetComponent<Text>().text
|
||||
= $"{TimeSpan.FromSeconds(_model.AvgPace).ToString(@"mm\:ss")} /500M";
|
||||
dataContent.Find("ChartRate/Avg/Value").GetComponent<Text>().text
|
||||
= $"{_model.AvgRate.ToString("#0")} SPM";
|
||||
dataContent.Find("ChartHeartRate/Avg/Value").GetComponent<Text>().text
|
||||
= $"{_model.AvgHeartRate.ToString("#0")} BPM";
|
||||
dataContent.Find("ChartPace/Max/Value").GetComponent<Text>().text
|
||||
= $"{TimeSpan.FromSeconds(_model.MaxPace).ToString(@"mm\:ss")} /500M";
|
||||
dataContent.Find("ChartRate/Max/Value").GetComponent<Text>().text
|
||||
= $"{_model.MaxRate.ToString("#0")} SPM";
|
||||
dataContent.Find("ChartHeartRate/Max/Value").GetComponent<Text>().text
|
||||
= $"{_model.MaxHeartRate.ToString("#0")} BPM";
|
||||
dataContent.Find("Other/Datas/Calories/Value").GetComponent<Text>().text
|
||||
= $"{(_model.Kj ?? 0).ToString("#0")} KCAL";
|
||||
dataContent.Find("Other/Datas/StrokeCount/Value").GetComponent<Text>().text
|
||||
= _model.StrokeCount.ToString();
|
||||
//var b = _model.ChartList.Select((x, i) => new DoubleVector2(i, ChartDateUtility.TimeSpanToValue(TimeSpan.FromMinutes(x.Pace + UnityEngine.Random.value * 300)))).ToList();
|
||||
//Debug.Log(_model.ChartList.Select((x, i) => new DoubleVector2(i, ChartDateUtility.TimeSpanToValue(TimeSpan.FromMinutes(x.Pace + UnityEngine.Random.value * 300)))).ToList());
|
||||
//var a = new List<DoubleVector2>();
|
||||
//for (int i = 0; i < 100; i++)
|
||||
//{
|
||||
// a.Add(new DoubleVector2(i, UnityEngine.Random.value * 200));
|
||||
//}
|
||||
chartPace.GetComponent<RowerLargeDataFeed>()
|
||||
.SetData(_model.ChartList.Select((x, i) =>
|
||||
{
|
||||
if (x.Pace == 0)
|
||||
{
|
||||
return new DoubleVector2(i, ChartDateUtility.TimeSpanToValue(TimeSpan.FromHours(15)) - 2000);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new DoubleVector2(i, ChartDateUtility.TimeSpanToValue(TimeSpan.FromMinutes(x.Pace)));
|
||||
}
|
||||
|
||||
}).ToList());
|
||||
chartRate.GetComponent<RowerLargeDataFeed>()
|
||||
.SetData(_model.ChartList.Select((x, i) => new DoubleVector2(i, x.Rate)).ToList());
|
||||
chartHR.GetComponent<RowerLargeDataFeed>()
|
||||
//.SetData(a);
|
||||
.SetData(_model.ChartList.Select((x, i) => new DoubleVector2(i, x.HeartRate)).ToList());
|
||||
}
|
||||
GetComponent<CanvasGroup>().DOFade(1, 0.3f);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aa3ab67bcc540104589072a282858e44
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,36 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class RowerSelector : PFUIPanel
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
var btnRide = transform.Find("Container/BtnRide").gameObject;
|
||||
if (btnRide)
|
||||
{
|
||||
UIManager.AddEvent(btnRide, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
Close();
|
||||
UIManager.ShowHomePanel();
|
||||
});
|
||||
}
|
||||
|
||||
var btnRower = transform.Find("Container/BtnRower").gameObject;
|
||||
if (btnRower)
|
||||
{
|
||||
UIManager.AddEvent(btnRower, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
Close();
|
||||
UIManager.ShowRowerPanel();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 062e7f4cad92a34488b81254ede4cbe9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,352 +0,0 @@
|
||||
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; }
|
||||
public bool EqualTo(RowerType rowerType) {
|
||||
return this.type == rowerType.type && this.value == rowerType.value;
|
||||
}
|
||||
}
|
||||
Transform selector, distance, time;
|
||||
public RowerType rowerType { get; set; }
|
||||
|
||||
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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 11dfa3e099daeb942b6e8e105572548c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,109 +0,0 @@
|
||||
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 =>
|
||||
//{
|
||||
|
||||
//});
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c7400b2488409db4cad823eb13d103b4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,186 +0,0 @@
|
||||
using Assets.Scripts;
|
||||
using Assets.Scripts.Apis.Models;
|
||||
using Facebook.Unity;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
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("Container/BtnDefine").gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b =>
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float timer = 1f, remainTime = 10f;
|
||||
bool startTime = false;
|
||||
RowerSegmentData data;
|
||||
public async void Initial(string id,Action init)
|
||||
{
|
||||
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);
|
||||
if (item.GradeStr.Contains("DNF"))
|
||||
{
|
||||
game.transform.Find("Content/Time").GetComponent<Text>().text = "DNF";
|
||||
}
|
||||
else
|
||||
{
|
||||
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 = i == 0 ? TimeSpan.FromSeconds(item.Ticks).ToString(@"hh\:mm\:ss\.ff"): TimeSpan.FromSeconds(item.Ticks).ToString(@"hh\:mm\:ss");
|
||||
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();
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a0932c4066cf3c24da73e66759aaec1f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user