init
This commit is contained in:
commit
16da8e4dde
333 changed files with 109229 additions and 0 deletions
63
Assets/Scripts/InGameUI.cs
Normal file
63
Assets/Scripts/InGameUI.cs
Normal file
|
@ -0,0 +1,63 @@
|
|||
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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue