using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.UIElements;
public enum type_mana
{
air_mana,
eau_mana,
feu_mana,
terre_mana
}
public class ResourceDisplay : MonoBehaviour
{
[SerializeField] private type_mana type_mana;
[SerializeField] private playerStat player;
private TextMeshProUGUI text;
[SerializeField] private Image image;
private void Start()
{
player = GameObject.FindGameObjectWithTag("Player").GetComponent<playerStat>();
text = GetComponentInChildren<TextMeshProUGUI>();
}
private void Update()
{
switch (type_mana)
{
case type_mana.air_mana:
text.text = player.air_mana.ToString();
image.fillAmount = player.air_mana / player.max_mana;
break;
case type_mana.eau_mana:
text.text = player.eau_mana.ToString();
image.fillAmount = player.eau_mana / player.max_mana;
break;
case type_mana.feu_mana:
text.text = player.feu_mana.ToString();
image.fillAmount = player.feu_mana / player.max_mana;
break;
case type_mana.terre_mana:
text.text = player.terre_mana.ToString();
image.fillAmount = player.terre_mana / player.max_mana;
break;
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class playerStat : MonoBehaviour
{
public float air_mana { get; set; }
public float eau_mana { get; set; }
public float feu_mana { get; set; }
public float terre_mana { get; set; }
public float max_mana { get; set; }
}
评论 (0)