77 lines
1.9 KiB
C#
77 lines
1.9 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.EventSystems;
|
|
using TMPro;
|
|
|
|
public class Rematch : MonoBehaviour {
|
|
|
|
public static Rematch Instance { get; private set; }
|
|
|
|
public GameObject[] spButtons;
|
|
public GameObject[] mpButtons;
|
|
public TextMeshProUGUI continueTextMesh;
|
|
public string continueKey, waitKey;
|
|
|
|
public Image continueBar;
|
|
public float continueDuration = 10f;
|
|
private float continueTime;
|
|
|
|
private void Awake() {
|
|
Instance = this;
|
|
}
|
|
|
|
private void Update() {
|
|
if (GameTransition.Instance.state == GameState.Continue){
|
|
var delta = Mathf.Clamp01(1f - (Time.time - continueTime) / continueDuration);
|
|
|
|
continueBar.fillAmount = delta;
|
|
|
|
if (delta <= 0f && PlayerProperties.playerResponse.GetLocal() == -1){
|
|
PlayerProperties.playerResponse.SetLocal(0);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void Setup(){
|
|
if (NetworkManager.inRoom){
|
|
foreach(var b in mpButtons){
|
|
b.SetActive(true);
|
|
}
|
|
foreach(var b in spButtons){
|
|
b.SetActive(false);
|
|
}
|
|
|
|
EventSystem.current.SetSelectedGameObject(mpButtons[0].transform.GetChild(0).gameObject);
|
|
} else {
|
|
foreach(var b in mpButtons){
|
|
b.SetActive(false);
|
|
}
|
|
foreach(var b in spButtons){
|
|
b.SetActive(true);
|
|
}
|
|
|
|
EventSystem.current.SetSelectedGameObject(spButtons[0].transform.GetChild(0).gameObject);
|
|
}
|
|
|
|
continueTextMesh.text = Localization.GetString(continueKey);
|
|
continueBar.fillAmount = 1f;
|
|
continueTime = Time.time;
|
|
}
|
|
|
|
public void SelectOption(int i){
|
|
EventSystem.current.SetSelectedGameObject(null);
|
|
PlayerProperties.playerResponse.SetLocal(i);
|
|
foreach(var b in mpButtons){
|
|
b.SetActive(false);
|
|
}
|
|
foreach(var b in spButtons){
|
|
b.SetActive(false);
|
|
}
|
|
|
|
continueTextMesh.text = Localization.GetString(waitKey);
|
|
}
|
|
|
|
}
|