using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class HUDManager : MonoBehaviour { public static HUDManager Instance { get; private set; } [SerializeField] private GameObject _computerHUD; [SerializeField] private GameObject _sellScreenHUD; private GameObject _currentHUD; public bool isUiOpen => _currentHUD != null; private void Awake() { if (Instance != null) { Debug.LogError("What? 2 HudManagers crazy!!!"); } Instance = this; } private void Update() { CheckClose(); } public void ShowComputerHUD() { ShowHUD(_computerHUD); } public void ShowSellScreenHUD(SellCounter counter) { ShowHUD(_sellScreenHUD); } private void ShowHUD(GameObject hud) { if (_currentHUD != null) { _currentHUD.SetActive(false); } _currentHUD = hud; _currentHUD.SetActive(true); } public void HideCurrentHUD() { if (_currentHUD != null) { _currentHUD.SetActive(false); _currentHUD = null; } } public void CheckClose() { if (!Input.GetKeyDown(KeyCode.Escape)) return; if (_currentHUD == null) return; HideCurrentHUD(); } //TODO: ask if its matters if i just return a SellSCreenBehaviour, or route them through the HUDManager public void SellItem(SellCounter counter, Object sellingObject) { Debug.Log(_sellScreenHUD.GetComponent()); this.ShowSellScreenHUD(counter); _sellScreenHUD.GetComponent().SetItem(counter, sellingObject); } }