63 lines
1.8 KiB
C#
63 lines
1.8 KiB
C#
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();
|
|
}
|
|
}
|
|
}
|