Practice_Unity/Assets/Scripts/UI/ExpBar.cs
Seonkyu.kim 60d64f1069 작업
1. UI - 조이스틱 UIManager에 추가 및 Scene에서 호출 방식 변경
2. UI - 경험치 바 앞에 레벨 아이콘 추가
3. 몬스터 죽었을때 경험치로 변경
4. 경험치 바와 레벨 아이콘 연동

Todo
1. 투사체 공격 만들기
2. 몬스터가 플레이어 쫓아오게 만들기
3. 몬스터를 카메라 외각에서 다량으로 생성하는 기능 추가하기
4. 몬스터가 캐릭터 공격시 체력 닳게 하기
5. 메뉴 UI 만들기
6. 레벨업시 획득 스킬 UI 만들기
7. 체력바 UI 만들기
8. 공격시 데미지 띄우는 UI 만들기
2025-10-02 17:37:10 +09:00

34 lines
965 B
C#

using System;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class ExpBar : MonoBehaviour
{
private Image _valueBar;
private TMPro.TextMeshProUGUI _levelText;
private void Awake()
{
_valueBar = transform.Find("ValueBar").GetComponent<Image>();
_levelText = transform.Find("Lv_Icon/Lv_BackGround/Lv_Text").GetComponent<TextMeshProUGUI>();
RectTransform fillRect = _valueBar.rectTransform;
fillRect.anchorMax = new Vector2(0, 1);
_levelText.text = 1.ToString();
}
public void UpdateValue(int level, float currentExp, float maxExp)
{
if (_valueBar == null) return;
float expRatio = 0f;
if (maxExp > 0) expRatio = currentExp / maxExp;
RectTransform fillRect = _valueBar.rectTransform;
fillRect.anchorMax = new Vector2(expRatio, 1);
if (_levelText != null)
_levelText.text = level.ToString();
}
}