First project upload
This commit is contained in:
95
Assets/New Lowpoly Models/Scripts/PlayerDepositStation.cs
Normal file
95
Assets/New Lowpoly Models/Scripts/PlayerDepositStation.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
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 F To Deposit");
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user