55 lines
1.2 KiB
C#
55 lines
1.2 KiB
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using UnityEngine.UI;
|
|||
|
using TMPro;
|
|||
|
|
|||
|
public class Rematch : MonoBehaviour {
|
|||
|
|
|||
|
public static Rematch Instance { get; private set; }
|
|||
|
|
|||
|
public GameObject[] buttons;
|
|||
|
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(2);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public void Setup(){
|
|||
|
foreach(var b in buttons){
|
|||
|
b.SetActive(true);
|
|||
|
}
|
|||
|
|
|||
|
continueTextMesh.text = Localization.GetString(continueKey);
|
|||
|
continueBar.fillAmount = 1f;
|
|||
|
continueTime = Time.time;
|
|||
|
}
|
|||
|
|
|||
|
public void SelectOption(int i){
|
|||
|
PlayerProperties.playerResponse.SetLocal(i);
|
|||
|
foreach(var b in buttons){
|
|||
|
b.SetActive(false);
|
|||
|
}
|
|||
|
|
|||
|
continueTextMesh.text = Localization.GetString(waitKey);
|
|||
|
}
|
|||
|
|
|||
|
}
|