Selling Functionality, Picking up items, Basic computer

This commit is contained in:
2024-10-21 01:07:44 +02:00
parent f594bdf112
commit 19b7964f83
117 changed files with 9452 additions and 540 deletions

64
Assets/HUDManager.cs Normal file
View File

@@ -0,0 +1,64 @@
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<SellScreenController>());
this.ShowSellScreenHUD(counter);
_sellScreenHUD.GetComponent<SellScreenController>().SetItem(counter, sellingObject);
}
}