骑行界面优化&PCtips显示调整

This commit is contained in:
lishuo committed 2021-12-24 18:33:58 +08:00
1 parent d91dc17ea7
commit 2743c8d185
23 files changed
+1368 -769

No files matched your search

+5 -1
View File
@@ -16,7 +16,11 @@ namespace Assets.Scripts.Apis
{
return Get($"Map/GetMapToken?name={name}");
}
public string GetTipsList()
{
return Get($"Map/GetTipList");
}
/// <summary>
/// 获取路线数据
/// </summary>
+25 -12
View File
@@ -312,6 +312,7 @@ public class MainController : BaseScene
//发送消息
var list = MapUDPService.GetAllOnlineUserList();
var lang = App.GetLocalLanguage();
foreach (var item in list)
{
if (item.RouteId > 0)
@@ -332,11 +333,11 @@ public class MainController : BaseScene
var message = "";
if (item.TotalTicks == 0)
{
message = $"发起了对<color=#ff2742>{item.RouteName}</color>的挑战";
message = lang=="zh"?$"发起了对<color=#ff2742>{item.RouteName}</color>的挑战": $"start a challenge to the<color=#ff2742>{item.RouteName}</color>";
}
if (item.IsCompleted)
{
message = $"完成了<color=#ff2742>{item.RouteName}</color>的挑战";
message = lang == "zh" ? $"完成了<color=#ff2742>{item.RouteName}</color>的挑战": $"completed the challenge of the<color=#ff2742>{item.RouteName}</color>";
}
if (!string.IsNullOrEmpty(message))
{
@@ -348,23 +349,35 @@ public class MainController : BaseScene
var message = $"{item.Name}上线了";
EventQueueSystem.QueueEventOnce(new LinkedMessageEvent(item.RouteId, message, item.HeadImage, item.Name), $"{item.Id}{item.LastActiveTime}{item.Point}");
}
//距离
if (item.EndDistance > 50)
//距离50
if (item.EndDistance >= 50)
{
var message = $"在骑行过程中突破了<color=#00ff00>{"50KM"}</color>的挑战";
var message = lang == "zh" ? $"在骑行过程中突破了<color=#00ff00>{"50KM"}</color>的挑战" : $"distance up to <color=#00ff00>{"50KM"}</color> during riding!";
EventQueueSystem.QueueEventOnce(new LinkedMessageEvent(item.RouteId, message, item.HeadImage, item.Name), $"{item.RouteId}{item.Name}50KM");
}
//速度
if (item.Speed > 10)
//距离100
if (item.EndDistance >= 100)
{
var message = $"在骑行过程中速度达到了惊人的<color=#ff0000>{item.Speed}</color>KM/H";
EventQueueSystem.QueueEventOnce(new LinkedMessageEvent(item.RouteId, message, item.HeadImage, item.Name), $"{item.RouteId}{item.Name}10KM/H");
var message = lang == "zh" ? $"在骑行过程中突破了<color=#00ff00>{"100KM"}</color>的挑战": $"distance up to <color=#00ff00>{"100KM"}</color> during riding!";
EventQueueSystem.QueueEventOnce(new LinkedMessageEvent(item.RouteId, message, item.HeadImage, item.Name), $"{item.RouteId}{item.Name}50KM");
}
//速度35
if (item.Speed >= 35)
{
var message = lang == "zh" ? $"在骑行过程中速度达到了惊人的<color=#ff0000>{Math.Round(item.Speed, 2)}</color>KM/H": $"speed up to <color=#ff0000>{Math.Round(item.Speed, 2)}</color>KM/H during riding!";
EventQueueSystem.QueueEventOnce(new LinkedMessageEvent(item.RouteId, message, item.HeadImage, item.Name), $"{item.RouteId}{item.Name}35KM/H");
}
//速度50
if (item.Speed >= 50)
{
var message = lang == "zh" ? $"在骑行过程中速度达到了惊人的<color=#ff0000>{Math.Round(item.Speed,2)}</color>KM/H" : $"speed up to <color=#ff0000>{Math.Round(item.Speed, 2)}</color>KM/H during riding!";
EventQueueSystem.QueueEventOnce(new LinkedMessageEvent(item.RouteId, message, item.HeadImage, item.Name), $"{item.RouteId}{item.Name}50KM/H");
}
//功体比
if (item.WeightKg > 2)
if (item.WeightKg >= 3)
{
var message = $"在骑行过程中功体比达到了惊人的<color=#0000ff>{item.WeightKg}</color>w/kg";
EventQueueSystem.QueueEventOnce(new LinkedMessageEvent(item.RouteId, message, item.HeadImage, item.Name), $"{item.RouteId}{item.Name}2WeightKg");
var message = lang == "zh" ? $"在骑行过程中功体比达到了惊人的<color=#0000ff>{Math.Round(item.WeightKg, 2)}</color>w/kg": $"w/kg up to <color=#0000ff>{Math.Round(item.WeightKg, 2)}</color>w/kg during riding!";
EventQueueSystem.QueueEventOnce(new LinkedMessageEvent(item.RouteId, message, item.HeadImage, item.Name), $"{item.RouteId}{item.Name}3WeightKg");
}
}
}
@@ -326,12 +326,30 @@ namespace Assets.Scenes.Ride.Scripts
public static int GetNearRiderCount()
{
return onlineUserHelper.OnlineUsers.Where(c=> (c.Point[0] != 0 && c.Point[1] != 0)|| (c.Point[0] != -1 && c.Point[1] != -1)).Count();
int count = 0;
try
{
count = onlineUserHelper.OnlineUsers.Where(c => (c.Point[0] != 0 && c.Point[1] != 0) && (c.Point[0] != -1 && c.Point[1] != -1)).Count();
}
catch (Exception)
{
}
return count;
}
public static int GetAllOnlineUserCount()
{
return onlineUserHelper.OnlineUsers.Count();
int count = 0;
try
{
count = onlineUserHelper.OnlineUsers.Count();
}
catch (Exception)
{
}
return count;
}
/// <summary>
/// 获取附近的人(当前在线的所有人)
@@ -340,45 +358,46 @@ namespace Assets.Scenes.Ride.Scripts
public static IList<NearRiderModel> GetNearRiderData(int pageIndex, int pageSize = 5, double[] point = null)
{
if (point == null) return null;
var dict = new List<System.Tuple<double, OnlineUser>>();
var allOnlineUsers = onlineUserHelper.OnlineUsers.Where(c=>c.CompetitionId == 0);
foreach (var item in allOnlineUsers)
try
{
if (item.Id == App.CurrentUser.Id)
var dict = new List<System.Tuple<double, OnlineUser>>();
var allOnlineUsers = onlineUserHelper.OnlineUsers.Where(c => c.CompetitionId == 0);
foreach (var item in allOnlineUsers)
{
dict.Add(new Tuple<double, OnlineUser>(0, item));
continue;
if (item.Id == App.CurrentUser.Id)
{
dict.Add(new Tuple<double, OnlineUser>(0, item));
continue;
}
if (item.Point[0] != 0 && item.Point[1] != 0)
{
var distance = Math.Round(TurfHelper.GetDistances(point, item.Point) / 1000, 2);
dict.Add(new Tuple<double, OnlineUser>(distance, item));
}
}
if (item.Point[0] != 0 && item.Point[1] != 0)
var allList = dict.OrderBy(d => d.Item1);//.Select(d=>d.Item2);
var list = allList.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
var nearData = list.Select(n => new NearRiderModel()
{
var distance = Math.Round(TurfHelper.GetDistances(point, item.Point) / 1000, 2);
dict.Add(new Tuple<double, OnlineUser>(distance, item));
}
Headimage = n.Item2.HeadImage,
Name = n.Item2.Name,
Near = n.Item1, //Math.Round(TurfHelper.GetDistances(point, n.Point) / 1000, 2),
KGWeight = n.Item2.WeightKg.ToString(),
Speed = Math.Round(n.Item2.Speed, 1),
CountryImg = App.Host + $"User/GetCountryImg?userid={n.Item2.Id}",
IsSelf = n.Item2.IsSelf,
Id = n.Item2.Id,
Country = n.Item2.Country,
}).ToList();
return nearData;
}
var allList = dict.OrderBy(d => d.Item1);//.Select(d=>d.Item2);
var list = allList.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
var nearData = list.Select(n => new NearRiderModel()
catch (Exception)
{
Headimage = n.Item2.HeadImage,
Name = n.Item2.Name,
Near = n.Item1, //Math.Round(TurfHelper.GetDistances(point, n.Point) / 1000, 2),
KGWeight = n.Item2.WeightKg.ToString(),
Speed = Math.Round(n.Item2.Speed, 1),
CountryImg = App.Host + $"User/GetCountryImg?userid={n.Item2.Id}",
IsSelf = n.Item2.IsSelf,
Id = n.Item2.Id,
Country = n.Item2.Country,
}).ToList();
return nearData;
//return new
//{
// NearData = nearData,
// PageCount = (int)Math.Ceiling((double)allList.Count() / pageSize)
//};
}
return null;
}
}
private class OnlineUserHelper
{
@@ -315,7 +315,7 @@ namespace Assets.Scenes.Ride.Scripts
if (mainController.mapRouteRankingList == null || mainController.mapRouteRankingList.Count == 0)
{
var lang = App.GetLocalLanguage();
shadowButton.image.sprite = lang == "zh"? Resources.Load<Sprite>("Images/Ride/Shadow Mode_no"): Resources.Load<Sprite>("Images/Ride/Shadow Mode_no");
shadowButton.image.sprite = lang == "zh"? Resources.Load<Sprite>("Images/Ride/Shadow Mode_PC_d") : Resources.Load<Sprite>("Images/Ride/Shadow Mode_no");
shadowButton.enabled = false;
shadowButton.interactable = false;
}
@@ -294,28 +294,28 @@ public class CyclingController : DeviceServiceMonoBase
};
TouchKit.addGestureRecognizer(rotationRecognizer);
//单指
var touchRecognizer = new TKAnyTouchRecognizer(new TKRect(0, 0, Screen.width, Screen.height));
DateTime startTimpStamp = DateTime.Now;
Vector2 touchLocation = Vector2.down;
touchRecognizer.onEnteredEvent += (r) =>
{
touchLocation = r.startTouchLocation();
startTimpStamp = DateTime.Now;
};
touchRecognizer.onExitedEvent += (r) =>
{
if (competitionId == 0 && isStart && IsPointerOverGameObject(touchLocation))
{
var timespan = DateTime.Now - startTimpStamp;
UnityEngine.Debug.Log($"{timespan.TotalMilliseconds}");
if (timespan.TotalMilliseconds <= 120)
{
singleUIManager?.ClearPanel(null);
}
}
};
TouchKit.addGestureRecognizer(touchRecognizer);
////单指
//var touchRecognizer = new TKAnyTouchRecognizer(new TKRect(0, 0, Screen.width, Screen.height));
//DateTime startTimpStamp = DateTime.Now;
//Vector2 touchLocation = Vector2.down;
//touchRecognizer.onEnteredEvent += (r) =>
//{
// touchLocation = r.startTouchLocation();
// startTimpStamp = DateTime.Now;
//};
//touchRecognizer.onExitedEvent += (r) =>
//{
// if (competitionId == 0 && isStart && IsPointerOverGameObject(touchRecognizer.STAR))
// {
// var timespan = DateTime.Now - startTimpStamp;
// UnityEngine.Debug.Log($"{timespan.TotalMilliseconds}");
// if (timespan.TotalMilliseconds <= 120)
// {
// singleUIManager?.ClearPanel(null);
// }
// }
//};
//TouchKit.addGestureRecognizer(touchRecognizer);
//双指
var PinchRecognizer = new TKPinchRecognizer();
PinchRecognizer.gestureRecognizedEvent += (r) =>
@@ -407,14 +407,15 @@ public class CyclingController : DeviceServiceMonoBase
float touchTimer = 0.1f;
private void FixedUpdate()
{
HandleTouch();
HandleMouseScrollWheel();
}
public bool isWatch { get; set; }
private Vector3 currentCameraPos { get; set; }
Vector3 far = new Vector3(-18, 53, -48);
Vector3 plane = new Vector3(-15, 43, -40);
Vector3 near = new Vector3(-12, 35, -30);
Vector3 far = new Vector3(-18, 50, -48);
Vector3 plane = new Vector3(-15.1f, 42, -40);
Vector3 near = new Vector3(-11.4f, 31, -30);
List<Vector3> cameraList { get; set; }
/// <summary>
@@ -423,8 +424,9 @@ public class CyclingController : DeviceServiceMonoBase
private void HandleMouseScrollWheel()
{
var scrollDelta = Input.GetAxis("Mouse ScrollWheel");
UnityEngine.Debug.Log($"scrolldelta{scrollDelta}");
if (scrollDelta != 0 && Input.mousePosition != null && !IsPointerOverGameObject(Input.mousePosition))
return;
if (cameraList == null)
{
cameraList = new List<Vector3>();
@@ -450,6 +452,8 @@ public class CyclingController : DeviceServiceMonoBase
//StartCoroutine(MoveCamera(prePos, nextPos));
}
}
DateTime startTimpStamp = DateTime.Now;
private void HandleTouch()
{
if (singleUIManager == null)
@@ -459,11 +463,19 @@ public class CyclingController : DeviceServiceMonoBase
{
case 1:
{
UnityEngine.Debug.Log(Input.touches[0]);
UnityEngine.Debug.Log($"{Input.touches[0]}{Input.touches[0].phase }");
//单击切换极简模式
if (Input.touches[0].tapCount==1 && Input.touches[0].phase == TouchPhase.Moved && isStart && singleUIManager.clearLock && competitionId == 0)
if (Input.touches[0].tapCount == 1 && Input.touches[0].phase == TouchPhase.Began && isStart && singleUIManager.clearLock && competitionId == 0)
{
if (IsPointerOverGameObject(Input.mousePosition))
startTimpStamp = DateTime.Now;
}
//单击切换极简模式
if (Input.touches[0].tapCount==1 && Input.touches[0].phase == TouchPhase.Ended && isStart && singleUIManager.clearLock && competitionId == 0)
{
var interval = DateTime.Now - startTimpStamp;
UnityEngine.Debug.Log(interval);
if (interval.TotalMilliseconds<=150 && IsPointerOverGameObject(Input.mousePosition))
{
singleUIManager?.ClearPanel(null);
}
@@ -472,6 +484,7 @@ public class CyclingController : DeviceServiceMonoBase
break;
case 2:
{
return;
//双手触摸移动摄像机
// Store both touches.
Touch touchZero = Input.GetTouch(0);
@@ -154,10 +154,7 @@ namespace Assets.Scenes.Ride.Scripts
#endif
var parent = panel.transform.Find("MapRanking");
var title = panel.transform.Find("RankingTitle").gameObject;
if (list.Count == 0)
{
title.SetActive(false);
}
title.SetActive(list.Count != 0);
foreach (var item in list)
{
GameObject newObj = (GameObject)Instantiate(prefab, parent);
@@ -37,6 +37,8 @@ namespace Assets.Scenes.Ride.Scripts
OnlineUserNum.text = " "+ MapUDPService.GetNearRiderCount().ToString();
LayoutRebuilder.ForceRebuildLayoutImmediate(OnlineUserNum.rectTransform);
var nearList = MapUDPService.GetNearRiderData(pageIndex, pageSize, new double[] { playerController.Currentlatlong.x, playerController.Currentlatlong.y });
if (nearList == null)
return;
var mod = MapUDPService.GetNearRiderCount() % pageSize;
var pages = MapUDPService.GetNearRiderCount() / pageSize;
totalPages = mod > 0 ? pages + 1 : pages;
@@ -61,7 +61,7 @@ namespace Assets.Scenes.Ride.Scripts
weight = App.CurrentUser.Weight;
bicycleWeight = App.CurrentUser.BicycleWeight;
//#if UNITY_EDITOR
power = 1430;
power = 143;
//#endif
mainController.TrackResistance(currentSlope * App.RideSetting.Sensitivity / 100);
}
@@ -100,7 +100,7 @@ namespace Assets.Scenes.Ride.Scripts
timeRemaining = 1.0f;
}
}
countDownTxt.text = count==0?"GO!": count.ToString();
countDownTxt.text = count==0?App.GetLocalString("GO!"): count.ToString();
}
//重置游戏状态
public void Reset()
@@ -28,7 +28,7 @@ namespace Assets.Scenes.Ride.Scripts
_delayTime = App.delayTime;
if (_delayTime != -1)
{
appVersion.text = $"<color={getColor(_delayTime)}>{_delayTime.ToString("0")}MS</color>\n{"V" + App.AppVersion}";
appVersion.text = $"<color={getColor(_delayTime)}>{_delayTime.ToString("0")}ms</color>\n{"V" + App.AppVersion}";
}
else
{
+17 -3
View File
@@ -8,6 +8,7 @@ using UnityEngine.UI;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using DG.Tweening;
using System.Timers;
namespace Assets.Scripts.UI.Control
{
@@ -109,8 +110,18 @@ namespace Assets.Scripts.UI.Control
}
}
public bool showTooltip { get; set; }
private void BindEvent()
{
Timer timer = new Timer();
timer.Interval = 1000;
var group = tooltips.GetComponent<CanvasGroup>();
timer.Elapsed += (r, s) =>
{
timer.Stop();
group.DOFade(1, 0.5f);
};
//鼠标进入
UIManager.AddEvent(this.gameObject, EventTriggerType.PointerEnter, new UnityEngine.Events.UnityAction<UnityEngine.EventSystems.BaseEventData>(e =>
{
@@ -125,7 +136,7 @@ namespace Assets.Scripts.UI.Control
#endif
tooltips.GetComponent<CanvasGroup>().alpha = 0f;
tooltips.SetActive(true);
tooltips.GetComponent<CanvasGroup>().DOFade(1f, 0.2f);
timer.Start();
}
switch (mType)
{
@@ -154,14 +165,17 @@ namespace Assets.Scripts.UI.Control
UIManager.AddEvent(this.gameObject, EventTriggerType.PointerExit, new UnityAction<BaseEventData>(e =>
{
if (!this.isActiveAndEnabled) return;
timer.Stop();
#if !(UNITY_ANDROID || UNITY_IOS)
if (!string.IsNullOrWhiteSpace(Tooltips))
{
#else
if (!string.IsNullOrWhiteSpace(Tooltips) && showTooltip)
{
#endif
tooltips.SetActive(false);
#endif
group.DOFade(0, 1f).onComplete += () => {
tooltips.SetActive(false);
};
}
//Cursor.SetCursor(null, Vector2.zero, CursorMode.Auto);
switch (mType)
+63
View File
@@ -0,0 +1,63 @@
using System;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
using Assets.Scripts.UI.Control;
using Assets.Scripts;
public class MultiTips:PFUIText
{
private Text text;
private Button button;
private string[] tips { get; set; }
private int currentIndex = 0;
new void Awake()
{
base.Awake();
text = GetComponent<Text>();
var tiplist = ConfigHelper.mapApi.GetTipsList();
if (!string.IsNullOrEmpty(tiplist))
{
tips = tiplist.Split(',');
}
var random = new System.Random();
currentIndex = random.Next(0, tips.Length);
SetText();
}
// Start is called before the first frame update
new void Start()
{
base.Awake();
}
public void SetText()
{
if(text == null)
{
return;
}
if (currentIndex <= tips.Length)
{
text.text = tips[currentIndex];
if (currentIndex + 1 < tips.Length)
{
currentIndex++;
}
else
{
currentIndex = 0;
}
}
}
float time = 5f;
// Update is called once per frame
void Update()
{
time -= Time.deltaTime;
while (time<0)
{
SetText();
time += 5f;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 81e6186d0c08df64ba2687b894591e90
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: