using Assets.Scripts.Apis.Models; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class RaceButtonGroupScript : MonoBehaviour { private Transform BtnEnter, BtnCancel, BtnWatch, BtnJoin; public MapCompetition map { get; set; } public Transform parent { get; set; } // Start is called before the first frame update void Start() { BtnEnter = transform.Find("BtnEnter"); BtnCancel = transform.Find("BtnCancel"); BtnWatch = transform.Find("BtnWatch"); BtnJoin = transform.Find("BtnJoin"); 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()); } if (BtnJoin != null) { UIManager.AddEvent(BtnJoin.gameObject, UnityEngine.EventSystems.EventTriggerType.PointerClick, b => GoJoin()); } } void GoJoin() { UIManager.ShowConfirm("Apply", "Are you wanting to apply?", () => { if (!map.HasJoin) { parent.GetComponent().Join(); } App.RouteIdParam = map.RouteId; UIManager.UpdateJoinCompetition(); UIManager.CloseConfirm(); }); } void GoEnter() { App.RouteIdParam = map.RouteId; App.CompetionId = map.Id; SceneManager.LoadScene("Ride"); } void GoCancel() { UIManager.ShowConfirm("Cancel application", "Are you wanting to cancel the application?", () => { if (map.HasJoin) { parent.GetComponent().CancelJoin(); UIManager.UpdateJoinCompetition(); } UIManager.CloseConfirm(); }); } void GoWatch() { App.RouteIdParam = map.RouteId; App.CompetionId = map.Id; SceneManager.LoadScene("Ride"); } // Update is called once per frame void Update() { } }