using UnityEngine; using UnityEngine.UI; public class LaunchGameScript : MonoBehaviour { public GameObject PlayerOneSelector; public GameObject PlayerTwoSelector; public Text Title; private static LaunchGameScript _current; public static LaunchGameScript Current { get { return _current; } } public bool Launching { get; set; } public bool CanWeGo { get { var p1Script = PlayerOneSelector != null ? PlayerOneSelector.GetComponent() : null; var p2Script = PlayerTwoSelector != null ? PlayerTwoSelector.GetComponent() : null; return p1Script != null && p1Script.Selected && p2Script != null && p2Script.Selected; } } public bool GoButtonActivated { get; private set; } private void Start() { _current = this; } private void Update() { var go = CanWeGo; if (Title != null && go != Title.gameObject.activeSelf) { Title.text = "Choisissez votre véhicule"; return; } Title.text = "Pour demarrer, appuyer sur les boutons valider en meme temps"; if (Input.GetButton("SubmitP1") && Input.GetButton("SubmitP2") && go) { Title.GetComponentInChildren().text = "Launching..."; new WaitForSeconds(2); GameManager.Instance.SetSkins( PlayerOneSelector.GetComponent().CurrentTransportIndex, PlayerTwoSelector.GetComponent().CurrentTransportIndex ); GameManager.Instance.LaunchRace(); } } public void SelectionChanged() { Update(); } }