added inventory and stamina system

This commit is contained in:
2026-02-17 15:38:46 +00:00
parent 8b975163a0
commit 27f2931ce1
43 changed files with 2980 additions and 250 deletions

View File

@@ -0,0 +1,36 @@
using UnityEngine;
/// <summary>
/// Add to a pickup GameObject alongside PickupItem.
/// When the item is collected, applies a one-time boost to the player's max stamina.
/// </summary>
[RequireComponent(typeof(PickupItem))]
public class StaminaBoostPickup : MonoBehaviour
{
[Tooltip("Max stamina will be set to this value when picked up.")]
public float newMaxStamina = 200f;
void Start()
{
// Hook into PickupItem's collect event via a simple poll
var pickup = GetComponent<PickupItem>();
// We override by watching PickupItem's collected state each frame
StartCoroutine(WatchForCollect(pickup));
}
System.Collections.IEnumerator WatchForCollect(PickupItem pickup)
{
// Wait until the pickup is destroyed (collected)
while (pickup != null)
yield return null;
// Find player and apply boost
Player p = FindObjectOfType<Player>();
if (p != null)
{
p.maxStamina = newMaxStamina;
p.stamina = newMaxStamina;
Debug.Log($"[StaminaBoost] Max stamina set to {newMaxStamina}");
}
}
}