2021-07-23 10:02:09 +08:00
|
|
|
|
using Assets.Scripts.Apis.Models;
|
|
|
|
|
|
using System.Collections;
|
2021-07-20 09:58:01 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
2021-07-23 18:07:12 +08:00
|
|
|
|
using UnityEngine.SceneManagement;
|
2021-07-20 09:58:01 +08:00
|
|
|
|
|
|
|
|
|
|
public class RaceButtonGroupScript : MonoBehaviour
|
|
|
|
|
|
{
|
2021-07-26 14:08:43 +08:00
|
|
|
|
private Transform BtnEnter, BtnCancel, BtnWatch, BtnJoin;
|
2021-07-23 10:02:09 +08:00
|
|
|
|
public MapCompetition map { get; set; }
|
2021-07-23 15:04:29 +08:00
|
|
|
|
public Transform parent { get; set; }
|
2021-07-20 09:58:01 +08:00
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
|
void Start()
|
|
|
|
|
|
{
|
|
|
|
|
|
BtnEnter = transform.Find("BtnEnter");
|
|
|
|
|
|
BtnCancel = transform.Find("BtnCancel");
|
|
|
|
|
|
BtnWatch = transform.Find("BtnWatch");
|
2021-07-26 14:08:43 +08:00
|
|
|
|
BtnJoin = transform.Find("BtnJoin");
|
2021-07-20 09:58:01 +08:00
|
|
|
|
if (BtnEnter != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.AddEvent(BtnEnter.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b => GoEnter());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (BtnCancel != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.AddEvent(BtnCancel.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b => GoCancel());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (BtnWatch != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.AddEvent(BtnWatch.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b => GoWatch());
|
|
|
|
|
|
}
|
2021-07-26 14:08:43 +08:00
|
|
|
|
if (BtnJoin != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
UIManager.AddEvent(BtnJoin.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b => GoJoin());
|
|
|
|
|
|
}
|
2021-07-20 09:58:01 +08:00
|
|
|
|
}
|
2021-07-26 14:08:43 +08:00
|
|
|
|
void GoJoin()
|
2021-07-20 09:58:01 +08:00
|
|
|
|
{
|
2021-07-29 15:45:44 +08:00
|
|
|
|
UIManager.ShowConfirm("Join", "Do you want to join?", () =>
|
2021-07-23 15:04:29 +08:00
|
|
|
|
{
|
2021-07-26 19:50:10 +08:00
|
|
|
|
if (!map.HasJoin)
|
|
|
|
|
|
{
|
|
|
|
|
|
parent.GetComponent<RaceItemScript>().Join();
|
|
|
|
|
|
}
|
|
|
|
|
|
App.RouteIdParam = map.RouteId;
|
2021-07-27 13:29:41 +08:00
|
|
|
|
UIManager.UpdateJoinCompetition();
|
2021-07-26 19:50:10 +08:00
|
|
|
|
UIManager.CloseConfirm();
|
|
|
|
|
|
});
|
2021-07-26 14:08:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
void GoEnter()
|
|
|
|
|
|
{
|
2021-07-26 14:11:10 +08:00
|
|
|
|
App.RouteIdParam = map.RouteId;
|
2021-07-26 14:09:21 +08:00
|
|
|
|
App.CompetionId = map.Id;
|
|
|
|
|
|
SceneManager.LoadScene("Ride");
|
2021-07-20 09:58:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
void GoCancel()
|
|
|
|
|
|
{
|
2021-07-29 15:45:44 +08:00
|
|
|
|
UIManager.ShowConfirm("Cancel Reservation", "Do you want to cancel reservation?", () =>
|
2021-07-23 15:04:29 +08:00
|
|
|
|
{
|
2021-07-26 19:50:10 +08:00
|
|
|
|
if (map.HasJoin)
|
|
|
|
|
|
{
|
|
|
|
|
|
parent.GetComponent<RaceItemScript>().CancelJoin();
|
2021-07-27 13:29:41 +08:00
|
|
|
|
UIManager.UpdateJoinCompetition();
|
2021-07-26 19:50:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
UIManager.CloseConfirm();
|
|
|
|
|
|
});
|
2021-07-20 09:58:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
void GoWatch()
|
|
|
|
|
|
{
|
2021-07-23 18:11:58 +08:00
|
|
|
|
App.RouteIdParam = map.RouteId;
|
|
|
|
|
|
App.CompetionId = map.Id;
|
|
|
|
|
|
SceneManager.LoadScene("Ride");
|
2021-07-20 09:58:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
|
void Update()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|