合并后微调,增加赛事提醒功能
This commit is contained in:
parent
21529db9dc
commit
7f8ac10d47
@ -2,6 +2,7 @@
|
|||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
public class RaceButtonGroupScript : MonoBehaviour
|
public class RaceButtonGroupScript : MonoBehaviour
|
||||||
{
|
{
|
||||||
@ -28,7 +29,9 @@ public class RaceButtonGroupScript : MonoBehaviour
|
|||||||
}
|
}
|
||||||
void GoEnter()
|
void GoEnter()
|
||||||
{
|
{
|
||||||
Debug.Log(map);
|
App.RouteIdParam = map.RouteId;
|
||||||
|
App.CompetionId = map.Id;
|
||||||
|
SceneManager.LoadScene("Ride");
|
||||||
}
|
}
|
||||||
void GoCancel()
|
void GoCancel()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -112,8 +112,8 @@ RectTransform:
|
|||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 1}
|
m_AnchorMin: {x: 0, y: 1}
|
||||||
m_AnchorMax: {x: 0, y: 1}
|
m_AnchorMax: {x: 0, y: 1}
|
||||||
m_AnchoredPosition: {x: 98.5, y: -109}
|
m_AnchoredPosition: {x: 108.5, y: -109}
|
||||||
m_SizeDelta: {x: 82, y: 22}
|
m_SizeDelta: {x: 102, y: 22}
|
||||||
m_Pivot: {x: 0.5, y: 0.5}
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
--- !u!222 &4634055342823246341
|
--- !u!222 &4634055342823246341
|
||||||
CanvasRenderer:
|
CanvasRenderer:
|
||||||
@ -149,13 +149,13 @@ MonoBehaviour:
|
|||||||
m_BestFit: 0
|
m_BestFit: 0
|
||||||
m_MinSize: 1
|
m_MinSize: 1
|
||||||
m_MaxSize: 40
|
m_MaxSize: 40
|
||||||
m_Alignment: 4
|
m_Alignment: 3
|
||||||
m_AlignByGeometry: 0
|
m_AlignByGeometry: 0
|
||||||
m_RichText: 1
|
m_RichText: 1
|
||||||
m_HorizontalOverflow: 0
|
m_HorizontalOverflow: 0
|
||||||
m_VerticalOverflow: 0
|
m_VerticalOverflow: 0
|
||||||
m_LineSpacing: 1
|
m_LineSpacing: 1
|
||||||
m_Text: Total time
|
m_Text: Riding Time
|
||||||
--- !u!1 &8655198199642205025
|
--- !u!1 &8655198199642205025
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
1313
Assets/Resources/UI/Prefab/Panel/RaceAlertPanel.prefab
Normal file
1313
Assets/Resources/UI/Prefab/Panel/RaceAlertPanel.prefab
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,7 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 593994e2f8e5e644796cbad931c5338b
|
||||||
|
PrefabImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -37,9 +37,9 @@ namespace Assets.Scripts.Apis
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
//查询我参与的比赛列表
|
//查询我参与的比赛列表
|
||||||
public JsonResult<List<JoinedCompetitionModel>> GetMyCompetitionList(string name)
|
public JsonResult<List<JoinedCompetitionModel>> GetMyCompetitionList()
|
||||||
{
|
{
|
||||||
var list = Get<JsonResult<dynamic>>($"/MapCompetition/GetMyList?name={ name }");
|
var list = Get<JsonResult<dynamic>>($"/MapCompetition/v0/GetMyList");
|
||||||
|
|
||||||
return new JsonResult<List<JoinedCompetitionModel>>
|
return new JsonResult<List<JoinedCompetitionModel>>
|
||||||
{
|
{
|
||||||
|
|||||||
@ -51,6 +51,9 @@ public static class App
|
|||||||
//public static string AppDownloadUrl { get; internal set; }
|
//public static string AppDownloadUrl { get; internal set; }
|
||||||
//public static string AppVersionCode { get; internal set; }
|
//public static string AppVersionCode { get; internal set; }
|
||||||
|
|
||||||
|
public static List<JoinedCompetitionModel> JoinedCompetitionList { get; set; }//我参加的比赛
|
||||||
|
public static List<int> CompetitionIdList = new List<int>();
|
||||||
|
|
||||||
private static MainDeviceAdapter mainDeviceAdapter;
|
private static MainDeviceAdapter mainDeviceAdapter;
|
||||||
public static MainDeviceAdapter MainDeviceAdapter
|
public static MainDeviceAdapter MainDeviceAdapter
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1056,6 +1056,8 @@ public class LoginController : MonoBehaviour
|
|||||||
}
|
}
|
||||||
App.CurrentUser = data;
|
App.CurrentUser = data;
|
||||||
App.RideSetting.Sensitivity = data.Sensitivity;
|
App.RideSetting.Sensitivity = data.Sensitivity;
|
||||||
|
//查询我参加的比赛
|
||||||
|
UIManager.UpdateJoinCompetition();
|
||||||
SceneManager.LoadScene("MainScene");
|
SceneManager.LoadScene("MainScene");
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -53,6 +53,11 @@ public class MainController : BaseScene
|
|||||||
{
|
{
|
||||||
UIManager.ShowUserInfoPanel();
|
UIManager.ShowUserInfoPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (App.MainSceneParam["Name"] == "RaceHomePanel")
|
||||||
|
{
|
||||||
|
UIManager.ShowRaceHomePanel();
|
||||||
|
}
|
||||||
App.MainSceneParam["Name"] = string.Empty;
|
App.MainSceneParam["Name"] = string.Empty;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -63,14 +68,21 @@ public class MainController : BaseScene
|
|||||||
//UIManager.ShowBigMapPanel();
|
//UIManager.ShowBigMapPanel();
|
||||||
//UIManager.ShowEarthPanel();
|
//UIManager.ShowEarthPanel();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UIManager.UpdateJoinCompetition();//查询当前我参加的赛事
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
float t = 1f;
|
||||||
// Update is called once per frame
|
// Update is called once per frame
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
|
t -= Time.deltaTime;
|
||||||
|
while (t <= 0)
|
||||||
|
{
|
||||||
|
UIManager.SendCompetitionStartMessage("Main");
|
||||||
|
t = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Login()
|
private async Task Login()
|
||||||
|
|||||||
@ -193,6 +193,7 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
this.gameObject.SetActive(false);
|
this.gameObject.SetActive(false);
|
||||||
this.Destroy();
|
this.Destroy();
|
||||||
SceneManager.LoadScene("MainScene");
|
SceneManager.LoadScene("MainScene");
|
||||||
|
App.MainSceneParam["Name"] = "RaceHomePanel";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -55,7 +55,7 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
{
|
{
|
||||||
//显示倒计时面板信息
|
//显示倒计时面板信息
|
||||||
//ShowCountDown(s.Item1, "remaining");
|
//ShowCountDown(s.Item1, "remaining");
|
||||||
ShowCountDown(cyclingController.currentPlayer.TotalTicks, "Riding Time");
|
ShowCountDown(s.Item1, "Remaining Time");
|
||||||
}
|
}
|
||||||
//显示当前选手骑行时间
|
//显示当前选手骑行时间
|
||||||
Timer.gameObject.SetActive(true);
|
Timer.gameObject.SetActive(true);
|
||||||
|
|||||||
@ -159,7 +159,7 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
processText.text = $"{(f).ToString("#0")}%";
|
processText.text = $"{(f).ToString("#0")}%";
|
||||||
});
|
});
|
||||||
|
|
||||||
if (process == 100)
|
if (process >= 100)
|
||||||
{
|
{
|
||||||
rideNow.interactable = true;
|
rideNow.interactable = true;
|
||||||
rideNow.enabled = true;
|
rideNow.enabled = true;
|
||||||
|
|||||||
@ -148,6 +148,10 @@ public class CyclingController : DeviceServiceMonoBase
|
|||||||
if (timer <= 0)//定时器 一秒执行一次
|
if (timer <= 0)//定时器 一秒执行一次
|
||||||
{
|
{
|
||||||
TcpHandler();
|
TcpHandler();
|
||||||
|
if (competitionId == 0)
|
||||||
|
{
|
||||||
|
UIManager.SendCompetitionStartMessage("Ride");
|
||||||
|
}
|
||||||
timer = 1.0f;
|
timer = 1.0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,8 @@ using System.Collections.Generic;
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using DG.Tweening;
|
using DG.Tweening;
|
||||||
|
using Assets.Scripts.Apis.Models;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Assets.Scenes.Ride.Scripts
|
namespace Assets.Scenes.Ride.Scripts
|
||||||
{
|
{
|
||||||
@ -65,4 +67,21 @@ namespace Assets.Scenes.Ride.Scripts
|
|||||||
this.url = url;
|
this.url = url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//赛事开始事件3
|
||||||
|
public class CompetitonStartMessageEvent : GameEvent
|
||||||
|
{
|
||||||
|
public string title;//赛事标题
|
||||||
|
public int competitionId;//赛事id
|
||||||
|
public int routeId;//路书id
|
||||||
|
public DateTime StartTime;//赛事开始时间
|
||||||
|
|
||||||
|
|
||||||
|
public CompetitonStartMessageEvent(string Title, int Id, int RouteId, DateTime StartTime)
|
||||||
|
{
|
||||||
|
this.title = Title;
|
||||||
|
this.competitionId = Id;
|
||||||
|
this.routeId = RouteId;
|
||||||
|
this.StartTime = StartTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using Assets.Scripts;
|
using Assets.Scenes.Ride.Scripts;
|
||||||
|
using Assets.Scripts;
|
||||||
using Assets.Scripts.Apis;
|
using Assets.Scripts.Apis;
|
||||||
using Assets.Scripts.Apis.Models;
|
using Assets.Scripts.Apis.Models;
|
||||||
using Assets.Scripts.UI.Control;
|
using Assets.Scripts.UI.Control;
|
||||||
@ -74,7 +75,8 @@ public class HomeController : PFUIPanel
|
|||||||
|
|
||||||
UIManager.AddEvent(userInfo.Find("BtnMore").gameObject, EventTriggerType.PointerClick, x =>
|
UIManager.AddEvent(userInfo.Find("BtnMore").gameObject, EventTriggerType.PointerClick, x =>
|
||||||
{
|
{
|
||||||
UIManager.ShowUserInfoPanel();
|
// UIManager.ShowUserInfoPanel();
|
||||||
|
UIManager.ShowRaceAlertPanel();
|
||||||
//UIManager.ShowConfirm("Quit", "Do you want to quit PowerFun?", null);
|
//UIManager.ShowConfirm("Quit", "Do you want to quit PowerFun?", null);
|
||||||
});
|
});
|
||||||
//GetSummary();
|
//GetSummary();
|
||||||
@ -113,14 +115,7 @@ public class HomeController : PFUIPanel
|
|||||||
//进入比赛
|
//进入比赛
|
||||||
private void GoMatch(BaseEventData e)
|
private void GoMatch(BaseEventData e)
|
||||||
{
|
{
|
||||||
//TODO:进入比赛列表
|
|
||||||
UIManager.ShowRaceHomePanel();
|
UIManager.ShowRaceHomePanel();
|
||||||
return;
|
|
||||||
#region 测试比赛
|
|
||||||
App.CompetionId = 1048;
|
|
||||||
App.RouteIdParam = 1215;
|
|
||||||
SceneManager.LoadScene("Ride");
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
private void OnHover(BaseEventData e)
|
private void OnHover(BaseEventData e)
|
||||||
{
|
{
|
||||||
|
|||||||
62
Assets/Scripts/UI/Prefab/Panel/RaceAlertController.cs
Normal file
62
Assets/Scripts/UI/Prefab/Panel/RaceAlertController.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
using Assets.Scripts;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.EventSystems;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
namespace Assets.Scenes.Ride.Scripts
|
||||||
|
{
|
||||||
|
public class RaceAlertController : PFUIPanel
|
||||||
|
{
|
||||||
|
public Text Content { get; set; }
|
||||||
|
public Text Timer { get; set; }
|
||||||
|
|
||||||
|
public GameObject GoBtn { get; set; }
|
||||||
|
public GameObject StayBtn { get; set; }
|
||||||
|
|
||||||
|
public int ticks = 0;
|
||||||
|
|
||||||
|
public int CompetitionId { get; set; }
|
||||||
|
public int RouteId { get; set; }
|
||||||
|
|
||||||
|
protected override void Awake()
|
||||||
|
{
|
||||||
|
Timer = this.transform.Find("Card/Timer").GetComponent<Text>();
|
||||||
|
Content = this.transform.Find("Card/Content").GetComponent<Text>();
|
||||||
|
GoBtn = this.transform.Find("Card/Go").gameObject;
|
||||||
|
StayBtn = this.transform.Find("Card/Stay").gameObject;
|
||||||
|
|
||||||
|
UIManager.AddEvent(GoBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, Go);
|
||||||
|
UIManager.AddEvent(StayBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, Stay);
|
||||||
|
}
|
||||||
|
float t = 1f;
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
t -= Time.deltaTime;
|
||||||
|
while (t <= 0)
|
||||||
|
{
|
||||||
|
if (ticks > 0)
|
||||||
|
{
|
||||||
|
ticks--;
|
||||||
|
Timer.text = Helper.FormatTicks(ticks);
|
||||||
|
}
|
||||||
|
t = 1f;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//切换到当前用户视角
|
||||||
|
public void Go(BaseEventData baseEventData)
|
||||||
|
{
|
||||||
|
App.CompetitionIdList.Add(CompetitionId);
|
||||||
|
App.CompetionId = CompetitionId;
|
||||||
|
App.RouteIdParam = RouteId;
|
||||||
|
SceneManager.LoadScene("Ride");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Stay(BaseEventData baseEventData)
|
||||||
|
{
|
||||||
|
App.CompetitionIdList.Add(CompetitionId);
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/Scripts/UI/Prefab/Panel/RaceAlertController.cs.meta
Normal file
11
Assets/Scripts/UI/Prefab/Panel/RaceAlertController.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 1640d8d75dcdfa744896cf9c703dca2b
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@ -13,6 +13,7 @@ using Assets.Scripts.Apis.Models;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using System;
|
using System;
|
||||||
|
using Assets.Scenes.Ride.Scripts;
|
||||||
|
|
||||||
public class UIManager : MonoBehaviour
|
public class UIManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
@ -110,12 +111,12 @@ public class UIManager : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private CyclingController mCyclingController;
|
private RaceAlertController mRaceAlertPanel;
|
||||||
public CyclingController CyclingController
|
public RaceAlertController RaceAlertPanel
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return this.GetPanelInstance("CyclingController", ref this.mCyclingController);
|
return this.GetPanelInstance("RaceAlertPanel", ref this.mRaceAlertPanel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -207,8 +208,20 @@ public class UIManager : MonoBehaviour
|
|||||||
Debug.Log(123);
|
Debug.Log(123);
|
||||||
InitNow();
|
InitNow();
|
||||||
}
|
}
|
||||||
|
EventQueueSystem.AddListener<CompetitonStartMessageEvent>(CompetitonStartHandler);
|
||||||
|
}
|
||||||
|
//比赛即将开始消息提醒
|
||||||
|
private void CompetitonStartHandler(CompetitonStartMessageEvent e)
|
||||||
|
{
|
||||||
|
ShowRaceAlertPanel();
|
||||||
|
if (mRaceAlertPanel != null)
|
||||||
|
{
|
||||||
|
mRaceAlertPanel.ticks = (int)(e.StartTime.ToLocalTime() - Now.GetDateTime()).TotalSeconds;
|
||||||
|
mRaceAlertPanel.Content.text = $"Your {e.title} race about to start";
|
||||||
|
mRaceAlertPanel.CompetitionId = e.competitionId;
|
||||||
|
mRaceAlertPanel.RouteId = e.routeId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
@ -220,6 +233,39 @@ public class UIManager : MonoBehaviour
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
//重新查询已经参赛列表
|
||||||
|
public static void UpdateJoinCompetition()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (App.CurrentUser != null)
|
||||||
|
{
|
||||||
|
var api = ConfigHelper.mapCompetitionApi;
|
||||||
|
var s = api.GetMyCompetitionList();
|
||||||
|
App.JoinedCompetitionList = s.data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//通知用户当前最近的一场比赛开始
|
||||||
|
public static void SendCompetitionStartMessage(string sceneName)
|
||||||
|
{
|
||||||
|
if (App.JoinedCompetitionList != null)
|
||||||
|
{
|
||||||
|
foreach (var item in App.JoinedCompetitionList)
|
||||||
|
{
|
||||||
|
var onStart = (item.StartTime.ToLocalTime() - Now.GetDateTime()).TotalMinutes <= 5 && (item.StartTime.ToLocalTime() - Now.GetDateTime()).TotalMinutes >= 0;
|
||||||
|
var notify = App.CompetitionIdList.Contains(item.Id);
|
||||||
|
if (onStart && !notify)
|
||||||
|
{
|
||||||
|
EventQueueSystem.QueueEvent(new CompetitonStartMessageEvent(item.Title, item.Id, item.RouteId, item.StartTime.ToLocalTime()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private T GetPanelInstance<T>(string prefabName, ref T internalComponent)
|
private T GetPanelInstance<T>(string prefabName, ref T internalComponent)
|
||||||
{
|
{
|
||||||
@ -410,6 +456,11 @@ public class UIManager : MonoBehaviour
|
|||||||
UIManager.Show(UIManager.Instance.EditUserPanel, UIManager.Instance.MainPanel);
|
UIManager.Show(UIManager.Instance.EditUserPanel, UIManager.Instance.MainPanel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void ShowRaceAlertPanel()
|
||||||
|
{
|
||||||
|
UIManager.Show(UIManager.Instance.RaceAlertPanel, null, true);
|
||||||
|
}
|
||||||
|
|
||||||
//LoadingPf loading;
|
//LoadingPf loading;
|
||||||
public static void ShowLoadingDialogBox()
|
public static void ShowLoadingDialogBox()
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user