Files
2026-07-21 08:58:18 +05:30

95 lines
2.2 KiB
C#

using UnityEngine;
public class PlayerDepositStation : MonoBehaviour
{
private PlayerControllerNewRohan currentPlayer;
private bool playerInside;
private void OnTriggerEnter(Collider other)
{
// HUMAN PLAYER
PlayerControllerNewRohan player =
other.GetComponent<PlayerControllerNewRohan>();
if (player != null)
{
CashManager cash =
other.GetComponent<CashManager>();
InteractionManager.CurrentInteraction =
() => currentPlayer?.StartDeposit(15f);
if (cash != null && cash.currentCash > 0)
{
currentPlayer = player;
playerInside = true;
UI_Manager.Instance?.ShowInteractionPrompt(
"Press the interaction button to deposit the cash.");
MobileInteractButton.Instance?.Show();
}
return;
}
// AI
SimpleTeamAI ai =
other.GetComponent<SimpleTeamAI>();
if (ai != null)
{
CashManager cash =
other.GetComponent<CashManager>();
if (cash == null || cash.currentCash <= 0)
return;
ai.StartDepositEffect();
ai.StartDeposit(15f);
}
}
private void Update()
{
if (!playerInside)
return;
//if (Input.GetKeyDown(KeyCode.F))
//{
// StartPlayerDeposit();
//}
}
private void OnTriggerExit(Collider other)
{
if (!other.CompareTag("Player"))
return;
PlayerControllerNewRohan player =
other.GetComponent<PlayerControllerNewRohan>();
if (player != null)
{
player.CancelDeposit();
}
playerInside = false;
currentPlayer = null;
UI_Manager.Instance?.HideActionTimer();
MobileInteractButton.Instance?.Hide();
InteractionManager.Clear();
}
public void StartPlayerDeposit()
{
if (!playerInside)
return;
currentPlayer?.StartDeposit(15f);
UI_Manager.Instance?.HideActionTimer();
}
}