Implemented loot GUI

This commit is contained in:
Max 2025-02-24 17:33:00 +01:00
parent 1e95378bb1
commit f2f6e8620a
43 changed files with 2135 additions and 20 deletions

View file

@ -135,7 +135,7 @@ namespace DungeonGenerator
private void AddRewardsToRoomObject(GameObject roomGO, List<LootType> loot)
{
RoomRewards rewards = roomGO.AddComponent<RoomRewards>();
RoomRewards rewards = roomGO.GetComponent<RoomRewards>();
foreach (LootType type in loot)
{
switch (type)

View file

@ -5,6 +5,7 @@ using UnityEngine;
public class Player : MonoBehaviour
{
[SerializeField] private int maxHealth;
[SerializeField] private int diamonds;
[SerializeField] private GameObject healthGameObject;
private int _healthIndex = 0;
private readonly int[] _healthBar = {0, 0, -1, -2, -4, -6, -9, -12, -16, -20};
@ -13,6 +14,11 @@ public class Player : MonoBehaviour
UpdateGUI();
}
public void GetDiamonds(int count)
{
diamonds += count;
}
public void TakeDamage(int damage)
{
if (_healthIndex + damage < _healthBar.Length)

View file

@ -8,9 +8,25 @@ public class RoomRewards : MonoBehaviour
public static event Action<int> DamageDealt;
[SerializeField] public int Diamonds = 0;
[SerializeField] private GameObject diamondsGO;
[SerializeField] public int Damage = 0;
[SerializeField] private GameObject chestGO;
[SerializeField] public bool Chest = false;
private void Start()
{
if (chestGO != null)
{
chestGO.SetActive(Chest);
}
if (diamondsGO != null)
{
diamondsGO.SetActive(Diamonds > 0);
}
}
public void TriggerGetReward()
{
if (Diamonds > 0)