Files
VRProject/Assets/_Scripts/BuffHandler.cs
ohgushiyuga 52341100ed otamesi
2026-08-27 12:51:15 +09:00

54 lines
1.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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}");
}
}