63 lines
1.6 KiB
C#
63 lines
1.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.InputSystem;
|
|
using UnityEngine.EventSystems;
|
|
|
|
public class InGameUI : MonoBehaviour{
|
|
|
|
[SerializeField] Button winDefaultButton = default;
|
|
[SerializeField] Button loseDefaultButton = default;
|
|
|
|
bool inWinScreen;
|
|
|
|
[SerializeField] PlayerInput playerInput = default;
|
|
string currentControlScheme;
|
|
|
|
void Update(){
|
|
if (playerInput.currentControlScheme != currentControlScheme){
|
|
currentControlScheme = playerInput.currentControlScheme;
|
|
if (currentControlScheme == "Keyboard"){
|
|
Cursor.lockState = CursorLockMode.None;
|
|
EventSystem.current.SetSelectedGameObject(null);
|
|
}else{
|
|
if (inWinScreen){
|
|
winDefaultButton.Select();
|
|
}else{
|
|
loseDefaultButton.Select();
|
|
}
|
|
Cursor.lockState = CursorLockMode.Locked;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void GameOver(bool win){
|
|
if (win){
|
|
inWinScreen = true;
|
|
winDefaultButton.Select();
|
|
}else{
|
|
inWinScreen = false;
|
|
loseDefaultButton.Select();
|
|
}
|
|
}
|
|
|
|
public void Quit(){
|
|
Application.Quit();
|
|
}
|
|
|
|
public void Retry(){
|
|
Time.timeScale = 1;
|
|
SceneManager.LoadScene(1);
|
|
}
|
|
|
|
public void Menu(){
|
|
Time.timeScale = 1;
|
|
SceneManager.LoadScene(0);
|
|
}
|
|
|
|
public void PlaySound(string sound){
|
|
AudioManager.instance.Play(sound);
|
|
}
|
|
}
|