Working on health and passing turn without using two dice pairs

This commit is contained in:
Max Dodd 2025-01-23 10:22:22 +01:00
parent 31917ba415
commit 9e6cbb22da
5 changed files with 521 additions and 4 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();
}
}