60 lines
1.7 KiB
C#
60 lines
1.7 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class LaunchGameScript : MonoBehaviour
|
|
{
|
|
public GameObject PlayerOneSelector;
|
|
public GameObject PlayerTwoSelector;
|
|
public GameObject GoButton;
|
|
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<SelectorBehavior>() : null;
|
|
var p2Script = PlayerTwoSelector != null ?
|
|
PlayerTwoSelector.GetComponent<SelectorBehavior>() : 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 (GoButton != null && go != GoButton.activeSelf)
|
|
{
|
|
GoButton.SetActive(go);
|
|
return;
|
|
}
|
|
if (Input.GetButton("SubmitP1") && Input.GetButton("SubmitP2") && go)
|
|
{
|
|
GoButton.GetComponentInChildren<Text>().text = "Launching...";
|
|
new WaitForSeconds(2);
|
|
GameManager.Instance.SetSkins(
|
|
PlayerOneSelector.GetComponent<SelectorBehavior>().CurrentTransportIndex,
|
|
PlayerTwoSelector.GetComponent<SelectorBehavior>().CurrentTransportIndex
|
|
);
|
|
GameManager.Instance.LaunchRace();
|
|
}
|
|
}
|
|
|
|
public void SelectionChanged()
|
|
{
|
|
Update();
|
|
|
|
}
|
|
}
|