First project upload

This commit is contained in:
Rohan
2026-06-26 22:41:39 +05:30
parent 7f6e734b16
commit 604c0c786a
4637 changed files with 4299718 additions and 489307 deletions

View File

@@ -0,0 +1,44 @@
using UnityEngine;
public class CashBag : MonoBehaviour
{
[Header("Cash Range")]
[SerializeField] private int minCash = 50;
[SerializeField] private int maxCash = 200;
private void OnTriggerEnter(Collider other)
{
Debug.Log("TRIGGERED BY: " + other.name);
if (other.CompareTag("Player") || other.CompareTag("Enemy"))
{
CashManager cash = other.GetComponentInParent<CashManager>();
if (cash != null)
{
Debug.Log("FOUND CashManager on: " + cash.gameObject.name);
}
else
{
Debug.Log("NO CashManager on: " + other.name);
}
if (cash != null)
{
int randomAmount = Random.Range(minCash, maxCash + 1);
cash.AddCash(randomAmount);
Debug.Log("Picked Cash: $" + randomAmount);
}
PlayerControllerNewRohan player = other.GetComponent<PlayerControllerNewRohan>();
if (player != null)
{
player.PlayPickupAnimation();
}
Destroy(gameObject); // ALWAYS destroy
}
}
}