working on health and passing turn without using two dice pairs

This commit is contained in:
Max 2025-01-21 17:22:00 +01:00
parent 31917ba415
commit 63209a12dc
5 changed files with 245 additions and 0 deletions

View file

@ -0,0 +1,33 @@
using Microsoft.Unity.VisualStudio.Editor;
using TMPro;
using UnityEngine;
public class Player : MonoBehaviour
{
[SerializeField] private int health;
[SerializeField] private int maxHealth;
[SerializeField] private GameObject healthGameObject;
public void TakeDamage(int damage)
{
if (health + damage > 0)
{
health -= damage;
UpdateGUI();
}
}
public void Heal(int healAmount)
{
if (health + healAmount <= maxHealth)
{
health += healAmount;
UpdateGUI();
}
}
private void UpdateGUI()
{
healthGameObject.GetComponent<TextMeshProUGUI>().text = health.ToString();
}
}