47 lines
1.5 KiB
C#
47 lines
1.5 KiB
C#
using UnityEngine;
|
|
|
|
/// <summary>
|
|
/// Attach to the Player. Watches the inventory for the Bunny Hop Boots being
|
|
/// equipped/unequipped and adjusts max stamina accordingly.
|
|
/// </summary>
|
|
public class BootsEffect : MonoBehaviour
|
|
{
|
|
[Tooltip("Must match the ItemDefinition itemName exactly.")]
|
|
public string bootsItemName = "Bunny Hop Boots";
|
|
public float boostedMaxStamina = 200f;
|
|
|
|
private Inventory _inventory;
|
|
private Player _player;
|
|
private bool _boosted = false;
|
|
|
|
void Start()
|
|
{
|
|
_inventory = GetComponent<Inventory>();
|
|
_player = GetComponent<Player>();
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
if (_inventory == null || _player == null) return;
|
|
|
|
// Find the boots entry in inventory
|
|
var entry = _inventory.items.Find(e => e.DisplayName == bootsItemName);
|
|
bool shouldBoost = entry != null && entry.isEquipped;
|
|
|
|
if (shouldBoost && !_boosted)
|
|
{
|
|
_player.maxStamina = boostedMaxStamina;
|
|
_player.stamina = Mathf.Min(_player.stamina + (boostedMaxStamina - 100f), boostedMaxStamina);
|
|
_boosted = true;
|
|
Debug.Log("[BootsEffect] Boots equipped — stamina boosted to " + boostedMaxStamina);
|
|
}
|
|
else if (!shouldBoost && _boosted)
|
|
{
|
|
_player.maxStamina = 100f;
|
|
_player.stamina = Mathf.Min(_player.stamina, 100f);
|
|
_boosted = false;
|
|
Debug.Log("[BootsEffect] Boots unequipped — stamina restored to 100");
|
|
}
|
|
}
|
|
}
|