54 lines
1.5 KiB
C#
54 lines
1.5 KiB
C#
using System;
|
||
using UnityEngine;
|
||
|
||
public enum BuffType
|
||
{
|
||
None,
|
||
AttackUp,
|
||
DefenseUp,
|
||
Heal
|
||
}
|
||
|
||
[Serializable]
|
||
public class BuffHandler
|
||
{
|
||
[SerializeField] private float buffDuration = 10f;
|
||
[SerializeField] private float attackBuffMultiplier = 1.5f;
|
||
[SerializeField] private float defenseBuffMultiplier = 0.5f;
|
||
[SerializeField] private float hpHealAmount = 30f;
|
||
|
||
private float attackBuffTimer;
|
||
private float defenseBuffTimer;
|
||
|
||
public bool IsAttackBuffActive => attackBuffTimer > 0f;
|
||
public bool IsDefenseBuffActive => defenseBuffTimer > 0f;
|
||
public float CurrentAttackMultiplier => IsAttackBuffActive ? attackBuffMultiplier : 1.0f;
|
||
public float CurrentDefenseMultiplier => IsDefenseBuffActive ? defenseBuffMultiplier : 1.0f;
|
||
|
||
public void UpdateTimers(float deltaTime)
|
||
{
|
||
if (attackBuffTimer > 0f) attackBuffTimer -= deltaTime;
|
||
if (defenseBuffTimer > 0f) defenseBuffTimer -= deltaTime;
|
||
}
|
||
|
||
public void ActivateBuff(BuffType type)
|
||
{
|
||
switch (type)
|
||
{
|
||
case BuffType.AttackUp:
|
||
attackBuffTimer = buffDuration;
|
||
break;
|
||
case BuffType.DefenseUp:
|
||
defenseBuffTimer = buffDuration;
|
||
break;
|
||
case BuffType.Heal:
|
||
ExecuteHeal();
|
||
break;
|
||
}
|
||
}
|
||
|
||
private void ExecuteHeal()
|
||
{
|
||
Debug.Log($"💚 HP回復バフ発動:回復量 {hpHealAmount}");
|
||
}
|
||
} |