2026-03-30 아이템 사용 진행중
This commit is contained in:
43
Assets/02_Scripts/Managers/Local/ItemEffectManager.cs
Normal file
43
Assets/02_Scripts/Managers/Local/ItemEffectManager.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System.Collections;
|
||||
using System.Threading.Tasks;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class ItemEffectManager : MonoBehaviour
|
||||
{
|
||||
public void OnSceneLoaded(Scene scene, LoadSceneMode mode)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void ItemUse(ItemInstance item)
|
||||
{
|
||||
if(item.Data.ItemEffectType == ItemEffectType.INTERVAL_DAMAGE)
|
||||
{
|
||||
IntervalDamageHealthEffect(GameManager.Instance.Level.CurrentCharacter.GetComponent<Health>(), item.Data.IntervalDamage, item.Data.IntervalDamageTime, item.Data.ItemEffectVisual);
|
||||
}
|
||||
}
|
||||
|
||||
public void IntervalDamageHealthEffect(Health health,float damage,float time,GameObject itemEffectVisual)
|
||||
{
|
||||
IntervalDamage(health, damage,time, itemEffectVisual);
|
||||
}
|
||||
|
||||
//일정 시간 동안 틱대미지 일으키는 함수
|
||||
public async void IntervalDamage(Health health, float damage,float time, GameObject itemEffectVisual)
|
||||
{
|
||||
GameObject fx_Visual = Instantiate(itemEffectVisual, health.transform); // health의 자식으로 이펙트 생성
|
||||
fx_Visual.transform.localPosition = new Vector3(0, 1.5f, 0);
|
||||
|
||||
float tickDamage = damage / time;
|
||||
while(time <=0)
|
||||
{
|
||||
health.ChangeHP(Mathf.FloorToInt(tickDamage)); //소수점 전부 버림
|
||||
if (health.CurrentHP <= 0) break;
|
||||
time--;
|
||||
await Task.Yield();
|
||||
}
|
||||
Destroy(fx_Visual);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 784f293946888364996d3928fe23ffd4
|
||||
Reference in New Issue
Block a user