77 lines
1.8 KiB
C#
77 lines
1.8 KiB
C#
using System.Collections;
|
|
using System.Reflection;
|
|
using log4net;
|
|
using Managers;
|
|
using SlimUI.ModernMenu;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.SceneManagement;
|
|
public class MatchEndMenu : MonoBehaviour
|
|
{
|
|
private static ILog Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
|
private Canvas Canvas;
|
|
public GameObject Camera;
|
|
public GameObject UIEventSystem;
|
|
public GameObject MenuButtons;
|
|
public GameObject FocusButtonRematch;
|
|
|
|
private EventSystem eventSystem;
|
|
|
|
// Start is called before the first frame update
|
|
void Awake()
|
|
{
|
|
Canvas = gameObject.GetComponent<Canvas>();
|
|
Canvas.enabled = false;
|
|
MenuButtons.SetActive(false);
|
|
eventSystem = UIEventSystem.GetComponent<EventSystem>();
|
|
}
|
|
|
|
public void Show(Transform transform)
|
|
{
|
|
gameObject.transform.position = transform.position;
|
|
gameObject.transform.rotation = transform.rotation;
|
|
Canvas.enabled = true;
|
|
Camera.SetActive(true);
|
|
UIEventSystem.SetActive(true);
|
|
MenuButtons.SetActive(true);
|
|
eventSystem.SetSelectedGameObject(FocusButtonRematch, null);
|
|
}
|
|
|
|
public void Hide()
|
|
{
|
|
Canvas.enabled = false;
|
|
Camera.SetActive(false);
|
|
UIEventSystem.SetActive(false);
|
|
}
|
|
|
|
public void OnRematch()
|
|
{
|
|
MatchManager.G.StartRematch();
|
|
Hide();
|
|
}
|
|
|
|
public void OnMainMenu()
|
|
{
|
|
StartCoroutine(StartSceneTransition());
|
|
}
|
|
|
|
private IEnumerator StartSceneTransition()
|
|
{
|
|
Canvas.enabled = false;
|
|
SceneManager.LoadScene((int)Scenes.MainMenu, LoadSceneMode.Additive);
|
|
yield return new WaitForSeconds(0.2f);
|
|
GameObject menu = GameObject.Find("Main Menu Camera");
|
|
if (menu != null && menu.TryGetComponent(out SlimUIMainMenu menuScript))
|
|
{
|
|
UIManager.G.HideHUD();
|
|
menuScript.MenuTransition(Camera.GetComponent<Camera>().transform);
|
|
}
|
|
else
|
|
{
|
|
Log.Error("Can't transition back to main menu. Menu camera or script not found.");
|
|
}
|
|
}
|
|
|
|
|
|
}
|