2021-07-23 18:07:12 +08:00
|
|
|
|
using Assets.Scripts;
|
2021-07-27 09:18:34 +08:00
|
|
|
|
using System;
|
2021-07-23 18:07:12 +08:00
|
|
|
|
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; }
|
2021-09-13 18:21:43 +08:00
|
|
|
|
public Text Timer { get; set; }
|
2021-07-23 18:07:12 +08:00
|
|
|
|
public GameObject GoBtn { get; set; }
|
2021-07-27 09:18:34 +08:00
|
|
|
|
public GameObject Card { get; set; }
|
2021-07-23 18:07:12 +08:00
|
|
|
|
public GameObject StayBtn { get; set; }
|
2021-07-27 09:18:34 +08:00
|
|
|
|
|
2021-07-23 18:07:12 +08:00
|
|
|
|
public int ticks = 0;
|
|
|
|
|
|
|
|
|
|
|
|
public int CompetitionId { get; set; }
|
|
|
|
|
|
public int RouteId { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
protected override void Awake()
|
|
|
|
|
|
{
|
2021-07-27 09:18:34 +08:00
|
|
|
|
//Card
|
2021-09-13 18:21:43 +08:00
|
|
|
|
Timer = this.transform.Find("Card/Timer")?.GetComponent<Text>();
|
2021-07-23 18:07:12 +08:00
|
|
|
|
Content = this.transform.Find("Card/Content").GetComponent<Text>();
|
|
|
|
|
|
GoBtn = this.transform.Find("Card/Go").gameObject;
|
|
|
|
|
|
StayBtn = this.transform.Find("Card/Stay").gameObject;
|
2021-07-27 09:18:34 +08:00
|
|
|
|
Card = this.transform.Find("Card").gameObject;
|
|
|
|
|
|
|
2021-07-23 18:07:12 +08:00
|
|
|
|
UIManager.AddEvent(GoBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, Go);
|
|
|
|
|
|
UIManager.AddEvent(StayBtn, UnityEngine.EventSystems.EventTriggerType.PointerClick, Stay);
|
|
|
|
|
|
}
|
|
|
|
|
|
float t = 1f;
|
|
|
|
|
|
private void Update()
|
|
|
|
|
|
{
|
2021-09-13 18:21:43 +08:00
|
|
|
|
t -= Time.deltaTime;
|
|
|
|
|
|
while (t <= 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (ticks > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
ticks--;
|
|
|
|
|
|
if (Timer != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Timer.text = Helper.FormatTicks(ticks);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
t += 1f;
|
|
|
|
|
|
}
|
2021-07-23 18:07:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-07-27 09:18:34 +08:00
|
|
|
|
public void Set(DateTime startTime, DateTime now,string title, string sceneName, int competitionId,int routeId)
|
|
|
|
|
|
{
|
|
|
|
|
|
ticks = (int)(startTime - now).TotalSeconds;
|
2021-09-16 15:59:08 +08:00
|
|
|
|
var content = $"Your <color='#F93086'>{Helper.SubStr(title,10)}</color> race about to start";
|
2021-07-27 09:18:34 +08:00
|
|
|
|
Content.text = content;
|
|
|
|
|
|
CompetitionId = competitionId;
|
|
|
|
|
|
RouteId = routeId;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-07-23 18:07:12 +08:00
|
|
|
|
//切换到当前用户视角
|
|
|
|
|
|
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();
|
2021-09-13 18:21:43 +08:00
|
|
|
|
Utils.DestroyChildren(transform);
|
|
|
|
|
|
DestroyImmediate(gameObject);
|
2021-07-23 18:07:12 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|