Files
Gnome-s-Bounty/Assets/Scripts/Managers/UiManager.cs
T
vova 39e4e51866 Add player controller, state management, and input handling
- Implemented PlayerController.cs to manage player movement and actions.
- Created PlayerState.cs to track player lives, coins, and key status.
- Added CameraFollow.cs for smooth camera movement following the player.
- Developed Character.cs as an abstract class for character behavior.
- Introduced Enums.cs for defining TreasureType and MapElementType.
- Added IDoor interface for door interactions.
- Created InputActions.cs for handling player input actions.
- Implemented MainMenu.cs for basic menu functionality including play and exit options.
2026-06-17 22:43:59 +03:00

45 lines
958 B
C#

using TMPro;
using UnityEngine;
public class UIManager : MonoBehaviour
{
[SerializeField]
private TextMeshProUGUI _totalCoins;
[SerializeField]
private GameObject _keyIcon;
private PlayerState _playerState;
// Start is called before the first frame update
void Start()
{
_playerState = GetComponent<PlayerState>();
if (_playerState != null)
{
_playerState.OnPlayerTakeItem += UpdateUi;
}
}
private void UpdateUi(object sender, TreasureType e)
{
switch (e)
{
case TreasureType.Coin:
_totalCoins.text = _playerState.TotalCoins.ToString();
break;
case TreasureType.Key:
_keyIcon.SetActive(true);
break;
}
}
void OnDestroy()
{
if (_playerState != null)
{
_playerState.OnPlayerTakeItem -= UpdateUi;
}
}
}