Batch 1 - Scripts
This commit is contained in:
22
Assets/New Lowpoly Models/Scripts/BillboardNew.cs
Normal file
22
Assets/New Lowpoly Models/Scripts/BillboardNew.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class BillboardNew : MonoBehaviour
|
||||
{
|
||||
Camera cam;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
cam = Camera.main;
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (cam == null)
|
||||
cam = Camera.main;
|
||||
|
||||
if (cam == null)
|
||||
return;
|
||||
|
||||
transform.forward = cam.transform.forward;
|
||||
}
|
||||
}
|
||||
2
Assets/New Lowpoly Models/Scripts/BillboardNew.cs.meta
Normal file
2
Assets/New Lowpoly Models/Scripts/BillboardNew.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 26bee8a4aff1043438c449430761bc33
|
||||
25
Assets/New Lowpoly Models/Scripts/CamerasTouchArea.cs
Normal file
25
Assets/New Lowpoly Models/Scripts/CamerasTouchArea.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class CameraTouchArea : MonoBehaviour, IPointerDownHandler, IDragHandler
|
||||
{
|
||||
public static Vector2 LookDelta;
|
||||
|
||||
private Vector2 lastPosition;
|
||||
|
||||
public void OnPointerDown(PointerEventData eventData)
|
||||
{
|
||||
lastPosition = eventData.position;
|
||||
}
|
||||
|
||||
public void OnDrag(PointerEventData eventData)
|
||||
{
|
||||
LookDelta = eventData.position - lastPosition;
|
||||
lastPosition = eventData.position;
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
LookDelta = Vector2.zero;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 66297c96b861aad4c81dd175dcc43013
|
||||
@@ -49,6 +49,29 @@ public class CashManager : MonoBehaviour
|
||||
}
|
||||
|
||||
UpdateUI();
|
||||
|
||||
if (IsHumanPlayer())
|
||||
{
|
||||
UpdatePlayerObjectiveUI();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdatePlayerObjectiveUI()
|
||||
{
|
||||
if (!IsHumanPlayer() || UI_Manager.Instance == null)
|
||||
return;
|
||||
|
||||
UI_Manager.Instance.UpdatePlayerCash(currentCash);
|
||||
|
||||
if (currentCash > 0)
|
||||
UI_Manager.Instance.ShowDepositObjective();
|
||||
else
|
||||
UI_Manager.Instance.ShowOpenVaultObjective();
|
||||
}
|
||||
|
||||
private bool IsHumanPlayer()
|
||||
{
|
||||
return GetComponent<PlayerControllerNewRohan>() != null;
|
||||
}
|
||||
|
||||
void UpdateUI()
|
||||
@@ -65,6 +88,11 @@ public class CashManager : MonoBehaviour
|
||||
{
|
||||
currentCash += amount;
|
||||
|
||||
if (IsHumanPlayer())
|
||||
{
|
||||
UI_Manager.Instance?.ShowCashPopup(amount);
|
||||
}
|
||||
|
||||
switch (team)
|
||||
{
|
||||
case TeamMember.Team.PlayerTeam:
|
||||
@@ -80,6 +108,8 @@ public class CashManager : MonoBehaviour
|
||||
break;
|
||||
}
|
||||
|
||||
UpdatePlayerObjectiveUI();
|
||||
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
@@ -104,6 +134,13 @@ public class CashManager : MonoBehaviour
|
||||
|
||||
currentCash = 0;
|
||||
|
||||
if (IsHumanPlayer())
|
||||
{
|
||||
AudioManager.Instance?.PlaySFX("DepositComplete");
|
||||
}
|
||||
|
||||
UpdatePlayerObjectiveUI();
|
||||
|
||||
UpdateUI();
|
||||
|
||||
return amount;
|
||||
@@ -144,6 +181,8 @@ public class CashManager : MonoBehaviour
|
||||
|
||||
currentCash = 0;
|
||||
|
||||
UpdatePlayerObjectiveUI();
|
||||
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
|
||||
27
Assets/New Lowpoly Models/Scripts/CashPopupUI.cs
Normal file
27
Assets/New Lowpoly Models/Scripts/CashPopupUI.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class CashPopupUI : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TextMeshProUGUI amountText;
|
||||
|
||||
public void Show(int amount)
|
||||
{
|
||||
amountText.text = $"+${amount:N0}";
|
||||
|
||||
AudioManager.Instance?.PlaySFX("CashPopup");
|
||||
|
||||
gameObject.SetActive(true);
|
||||
|
||||
StopAllCoroutines();
|
||||
StartCoroutine(HideRoutine());
|
||||
}
|
||||
|
||||
IEnumerator HideRoutine()
|
||||
{
|
||||
yield return new WaitForSeconds(1.5f);
|
||||
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
2
Assets/New Lowpoly Models/Scripts/CashPopupUI.cs.meta
Normal file
2
Assets/New Lowpoly Models/Scripts/CashPopupUI.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 740a4258753985548b8ab0f4b59f25aa
|
||||
@@ -4,6 +4,6 @@ public class FPSManager : MonoBehaviour
|
||||
{
|
||||
void Awake()
|
||||
{
|
||||
Application.targetFrameRate = 60;
|
||||
Application.targetFrameRate = 1000;
|
||||
}
|
||||
}
|
||||
8
Assets/New Lowpoly Models/Scripts/Minimap.meta
Normal file
8
Assets/New Lowpoly Models/Scripts/Minimap.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f416dcd6817fdd94db07d59bea652386
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
95
Assets/New Lowpoly Models/Scripts/Minimap/EdgeIndicator.cs
Normal file
95
Assets/New Lowpoly Models/Scripts/Minimap/EdgeIndicator.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class EdgeIndicator : MonoBehaviour
|
||||
{
|
||||
[HideInInspector]
|
||||
public EdgeTarget Target;
|
||||
|
||||
private RectTransform rect;
|
||||
private Image image;
|
||||
|
||||
private RectTransform minimapRect;
|
||||
private MinimapManager minimap;
|
||||
|
||||
private float radius;
|
||||
|
||||
public void Initialize(
|
||||
EdgeTarget target,
|
||||
RectTransform minimapRectTransform,
|
||||
float edgePadding)
|
||||
{
|
||||
Target = target;
|
||||
|
||||
minimapRect = minimapRectTransform;
|
||||
minimap = FindObjectOfType<MinimapManager>();
|
||||
|
||||
rect = GetComponent<RectTransform>();
|
||||
image = GetComponent<Image>();
|
||||
|
||||
image.sprite = target.icon;
|
||||
image.color = target.iconColor;
|
||||
|
||||
radius = Mathf.Min(minimapRect.rect.width, minimapRect.rect.height) * 0.5f - edgePadding;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Target == null)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
return;
|
||||
}
|
||||
|
||||
if (minimap == null || minimap.MinimapCamera == null || minimap.Player == null)
|
||||
return;
|
||||
|
||||
Camera cam = minimap.MinimapCamera;
|
||||
|
||||
// Position of the target in the minimap camera
|
||||
Vector3 viewport = cam.WorldToViewportPoint(Target.transform.position);
|
||||
|
||||
// If target is visible inside minimap, hide the edge arrow
|
||||
bool visible =
|
||||
viewport.z > 0 &&
|
||||
viewport.x >= 0f &&
|
||||
viewport.x <= 1f &&
|
||||
viewport.y >= 0f &&
|
||||
viewport.y <= 1f;
|
||||
|
||||
if (visible)
|
||||
{
|
||||
image.enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
image.enabled = true;
|
||||
|
||||
// Direction from player to target
|
||||
Vector3 worldDir = Target.transform.position - minimap.Player.position;
|
||||
|
||||
Vector2 dir = new Vector2(worldDir.x, worldDir.z).normalized;
|
||||
|
||||
// If your minimap rotates, rotate direction too
|
||||
if (minimap.rotateWithPlayer)
|
||||
{
|
||||
float angle = -minimap.Player.eulerAngles.y * Mathf.Deg2Rad;
|
||||
|
||||
float cos = Mathf.Cos(angle);
|
||||
float sin = Mathf.Sin(angle);
|
||||
|
||||
dir = new Vector2(
|
||||
dir.x * cos - dir.y * sin,
|
||||
dir.x * sin + dir.y * cos
|
||||
);
|
||||
}
|
||||
|
||||
// Place arrow on edge of minimap
|
||||
rect.anchoredPosition = dir * radius;
|
||||
|
||||
// Rotate arrow to point toward target
|
||||
float rot = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
|
||||
|
||||
rect.localRotation = Quaternion.Euler(0, 0, rot - 90f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 90eb04afe3bc588458146859ad793297
|
||||
@@ -0,0 +1,92 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class EdgeIndicatorManager : MonoBehaviour
|
||||
{
|
||||
public static EdgeIndicatorManager Instance;
|
||||
|
||||
[Header("References")]
|
||||
public MinimapManager minimapManager;
|
||||
public RectTransform edgeContainer;
|
||||
public EdgeIndicator indicatorPrefab;
|
||||
|
||||
[Header("Settings")]
|
||||
public float edgePadding = 18f;
|
||||
public float refreshInterval = 1f;
|
||||
|
||||
private readonly Dictionary<EdgeTarget, EdgeIndicator> indicators =
|
||||
new Dictionary<EdgeTarget, EdgeIndicator>();
|
||||
|
||||
float timer;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (minimapManager == null)
|
||||
minimapManager = FindObjectOfType<MinimapManager>();
|
||||
|
||||
RefreshTargets();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
timer += Time.deltaTime;
|
||||
|
||||
if (timer >= refreshInterval)
|
||||
{
|
||||
timer = 0;
|
||||
RefreshTargets();
|
||||
}
|
||||
}
|
||||
|
||||
void RefreshTargets()
|
||||
{
|
||||
EdgeTarget[] targets = FindObjectsOfType<EdgeTarget>();
|
||||
|
||||
HashSet<EdgeTarget> currentTargets = new HashSet<EdgeTarget>(targets);
|
||||
|
||||
//-------------------------------------
|
||||
// Remove destroyed targets
|
||||
//-------------------------------------
|
||||
|
||||
List<EdgeTarget> remove = new List<EdgeTarget>();
|
||||
|
||||
foreach (var pair in indicators)
|
||||
{
|
||||
if (pair.Key == null || !currentTargets.Contains(pair.Key))
|
||||
{
|
||||
if (pair.Value != null)
|
||||
Destroy(pair.Value.gameObject);
|
||||
|
||||
remove.Add(pair.Key);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var t in remove)
|
||||
indicators.Remove(t);
|
||||
|
||||
//-------------------------------------
|
||||
// Add new targets
|
||||
//-------------------------------------
|
||||
|
||||
foreach (EdgeTarget target in targets)
|
||||
{
|
||||
if (indicators.ContainsKey(target))
|
||||
continue;
|
||||
|
||||
EdgeIndicator arrow =
|
||||
Instantiate(indicatorPrefab, edgeContainer);
|
||||
|
||||
arrow.Initialize(
|
||||
target,
|
||||
edgeContainer,
|
||||
edgePadding);
|
||||
|
||||
indicators.Add(target, arrow);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c1c3c18764486f7478515f771cac46bb
|
||||
17
Assets/New Lowpoly Models/Scripts/Minimap/EdgeTarget.cs
Normal file
17
Assets/New Lowpoly Models/Scripts/Minimap/EdgeTarget.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class EdgeTarget : MonoBehaviour
|
||||
{
|
||||
public enum TargetType
|
||||
{
|
||||
Enemy,
|
||||
Vault,
|
||||
Deposit,
|
||||
Objective
|
||||
}
|
||||
|
||||
[Header("Indicator")]
|
||||
public TargetType targetType;
|
||||
public Sprite icon;
|
||||
public Color iconColor = Color.white;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 262b041e5698df34b992d80ceab7e3b6
|
||||
8
Assets/New Lowpoly Models/Scripts/Player.meta
Normal file
8
Assets/New Lowpoly Models/Scripts/Player.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b7513d3dac2791f4eb86f28f153761ea
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -77,7 +77,7 @@ public class PlayerControllerNewRohan : MonoBehaviour
|
||||
animator = GetComponent<Animator>();
|
||||
stamina = GetComponent<Stamina>();
|
||||
|
||||
StopDepositEffect();
|
||||
//StopDepositEffect();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
@@ -274,6 +274,9 @@ public class PlayerControllerNewRohan : MonoBehaviour
|
||||
isAttacking = true;
|
||||
canMove = false;
|
||||
|
||||
FindClosestEnemy();
|
||||
FaceTarget();
|
||||
|
||||
SetTrails(true);
|
||||
|
||||
if (IsTargetInRange())
|
||||
@@ -412,6 +415,9 @@ public class PlayerControllerNewRohan : MonoBehaviour
|
||||
|
||||
void FaceTarget()
|
||||
{
|
||||
if (target == null)
|
||||
return;
|
||||
|
||||
Vector3 dir = target.position - transform.position;
|
||||
dir.y = 0;
|
||||
|
||||
@@ -421,6 +427,35 @@ public class PlayerControllerNewRohan : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private void FindClosestEnemy()
|
||||
{
|
||||
TeamMember myTeam = GetComponent<TeamMember>();
|
||||
|
||||
float closestDistance = Mathf.Infinity;
|
||||
Transform closestEnemy = null;
|
||||
|
||||
TeamMember[] allCharacters = FindObjectsOfType<TeamMember>();
|
||||
|
||||
foreach (TeamMember character in allCharacters)
|
||||
{
|
||||
if (character == myTeam)
|
||||
continue;
|
||||
|
||||
if (character.CurrentTeam == myTeam.CurrentTeam)
|
||||
continue;
|
||||
|
||||
float distance = Vector3.Distance(transform.position, character.transform.position);
|
||||
|
||||
if (distance < closestDistance)
|
||||
{
|
||||
closestDistance = distance;
|
||||
closestEnemy = character.transform;
|
||||
}
|
||||
}
|
||||
|
||||
target = closestEnemy;
|
||||
}
|
||||
|
||||
public void PlayVaultOpen(System.Action onComplete)
|
||||
{
|
||||
StartCoroutine(VaultRoutine(onComplete));
|
||||
@@ -26,7 +26,7 @@ public class PlayerDepositStation : MonoBehaviour
|
||||
playerInside = true;
|
||||
|
||||
UI_Manager.Instance?.ShowInteractionPrompt(
|
||||
"Press F To Deposit");
|
||||
"Press the interaction button to deposit the cash.");
|
||||
|
||||
MobileInteractButton.Instance?.Show();
|
||||
}
|
||||
|
||||
40
Assets/New Lowpoly Models/Scripts/PlayerTeamCashUI.cs
Normal file
40
Assets/New Lowpoly Models/Scripts/PlayerTeamCashUI.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class PlayerTeamCashUI : MonoBehaviour
|
||||
{
|
||||
private readonly List<CashManager> teammates = new();
|
||||
|
||||
private void Start()
|
||||
{
|
||||
CashManager[] all = FindObjectsOfType<CashManager>();
|
||||
|
||||
foreach (CashManager cash in all)
|
||||
{
|
||||
TeamMember team = cash.GetComponent<TeamMember>();
|
||||
|
||||
if (team == null)
|
||||
continue;
|
||||
|
||||
if (team.CurrentTeam != TeamMember.Team.PlayerTeam)
|
||||
continue;
|
||||
|
||||
if (cash.GetComponent<PlayerControllerNewRohan>() != null)
|
||||
continue;
|
||||
|
||||
teammates.Add(cash);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (UI_Manager.Instance == null)
|
||||
return;
|
||||
|
||||
if (teammates.Count > 0)
|
||||
UI_Manager.Instance.UpdateTeammate1Cash(teammates[0].currentCash);
|
||||
|
||||
if (teammates.Count > 1)
|
||||
UI_Manager.Instance.UpdateTeammate2Cash(teammates[1].currentCash);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 53858e4bb09074f4299b82c2bbe8cbe0
|
||||
@@ -33,6 +33,8 @@ public class SimpleTeamAI : MonoBehaviour
|
||||
[SerializeField] private float attackRange = 2f;
|
||||
[SerializeField] private float attackCooldown = 1.2f;
|
||||
[SerializeField] private float targetPriorityRange = 100f;
|
||||
private float nextCombatSearch;
|
||||
[SerializeField] private float combatSearchInterval = 0.3f;
|
||||
|
||||
[Header("Collection Settings")]
|
||||
[SerializeField] private float scanRadius = 15f;
|
||||
@@ -172,13 +174,18 @@ public class SimpleTeamAI : MonoBehaviour
|
||||
{
|
||||
SetState(AIState.Hit);
|
||||
}
|
||||
else if (isBusy)
|
||||
if (isBusy)
|
||||
{
|
||||
// Keep current state while opening vault / hit / special action
|
||||
anim.SetFloat("Speed", 0f);
|
||||
return;
|
||||
}
|
||||
//else if (isBusy)
|
||||
//{
|
||||
// // Keep current state while opening vault / hit / special action
|
||||
//}
|
||||
else
|
||||
{
|
||||
cashManager = GetComponent<CashManager>();
|
||||
//cashManager = GetComponent<CashManager>();
|
||||
|
||||
if (cashManager != null && cashManager.currentCash >= depositCashAmount)
|
||||
{
|
||||
@@ -186,7 +193,11 @@ public class SimpleTeamAI : MonoBehaviour
|
||||
}
|
||||
else
|
||||
{
|
||||
combatTarget = FindNearestCombatTarget();
|
||||
if (Time.time >= nextCombatSearch)
|
||||
{
|
||||
nextCombatSearch = Time.time + combatSearchInterval;
|
||||
combatTarget = FindNearestCombatTarget();
|
||||
}
|
||||
|
||||
if (combatTarget != null)
|
||||
{
|
||||
|
||||
43
Assets/New Lowpoly Models/Scripts/TeamMemberHealthUI.cs
Normal file
43
Assets/New Lowpoly Models/Scripts/TeamMemberHealthUI.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class TeamMemberHealthUI : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Health enemyHealth;
|
||||
|
||||
[Header("Health Sliders")]
|
||||
[SerializeField] private Slider healthSlider;
|
||||
[SerializeField] private Slider secondHealthSlider;
|
||||
|
||||
void Start()
|
||||
{
|
||||
if (enemyHealth == null) return;
|
||||
|
||||
UpdateHealthBar(enemyHealth.currentHealth, enemyHealth.maxHealth);
|
||||
|
||||
enemyHealth.OnHealthChanged += UpdateHealthBar;
|
||||
}
|
||||
|
||||
void UpdateHealthBar(float current, float max)
|
||||
{
|
||||
if (healthSlider != null)
|
||||
{
|
||||
healthSlider.maxValue = max;
|
||||
healthSlider.value = current;
|
||||
}
|
||||
|
||||
if (secondHealthSlider != null)
|
||||
{
|
||||
secondHealthSlider.maxValue = max;
|
||||
secondHealthSlider.value = current;
|
||||
}
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
if (enemyHealth != null)
|
||||
{
|
||||
enemyHealth.OnHealthChanged -= UpdateHealthBar;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2429a0099bbd7a940b7652710ebc61f1
|
||||
@@ -7,8 +7,12 @@ public class UI_Manager : MonoBehaviour
|
||||
public static UI_Manager Instance;
|
||||
|
||||
[SerializeField] private TextMeshProUGUI playerCarryText;
|
||||
[SerializeField] private TextMeshProUGUI playerCashText;
|
||||
[SerializeField] private TextMeshProUGUI playerDepositText;
|
||||
|
||||
[SerializeField] private TextMeshProUGUI teammate1CarryText;
|
||||
[SerializeField] private TextMeshProUGUI teammate2CarryText;
|
||||
|
||||
[SerializeField] private TextMeshProUGUI enemy1CarryText;
|
||||
[SerializeField] private TextMeshProUGUI enemy1DepositText;
|
||||
|
||||
@@ -18,10 +22,14 @@ public class UI_Manager : MonoBehaviour
|
||||
[SerializeField] private TextMeshProUGUI actionTimerText;
|
||||
[SerializeField] private TextMeshProUGUI depositTimerText;
|
||||
|
||||
[SerializeField] private TextMeshProUGUI objectiveText;
|
||||
|
||||
[SerializeField] private Slider playerProgressSlider;
|
||||
[SerializeField] private Slider enemy1ProgressSlider;
|
||||
[SerializeField] private Slider enemy2ProgressSlider;
|
||||
|
||||
[SerializeField] private CashPopupUI cashPopup;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
@@ -35,6 +43,27 @@ public class UI_Manager : MonoBehaviour
|
||||
$"{amount:N0}";
|
||||
}
|
||||
|
||||
public void ShowCashPopup(int amount)
|
||||
{
|
||||
cashPopup?.Show(amount);
|
||||
}
|
||||
|
||||
public void UpdatePlayerCash(int amount)
|
||||
{
|
||||
if (playerCashText != null)
|
||||
playerCashText.text = $"${amount:N0}";
|
||||
}
|
||||
|
||||
public void UpdateTeammate1Cash(int amount)
|
||||
{
|
||||
teammate1CarryText.text = $"${amount:N0}";
|
||||
}
|
||||
|
||||
public void UpdateTeammate2Cash(int amount)
|
||||
{
|
||||
teammate2CarryText.text = $"${amount:N0}";
|
||||
}
|
||||
|
||||
public void UpdatePlayerDepositCash(int amount)
|
||||
{
|
||||
playerDepositText.text =
|
||||
@@ -73,17 +102,26 @@ public class UI_Manager : MonoBehaviour
|
||||
|
||||
public void UpdateDepositTimer(float timeLeft)
|
||||
{
|
||||
if (objectiveText != null)
|
||||
objectiveText.gameObject.SetActive(false);
|
||||
|
||||
depositTimerText.text =
|
||||
"Depositing: " + Mathf.CeilToInt(timeLeft).ToString();
|
||||
"Depositing: " + Mathf.CeilToInt(timeLeft);
|
||||
}
|
||||
|
||||
public void HideDepositTimer()
|
||||
{
|
||||
depositTimerText.text = "";
|
||||
|
||||
if (objectiveText != null)
|
||||
objectiveText.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public void UpdateActionTimer(string actionName, float timeLeft)
|
||||
{
|
||||
if (objectiveText != null)
|
||||
objectiveText.gameObject.SetActive(false);
|
||||
|
||||
actionTimerText.text =
|
||||
actionName + ": " + Mathf.CeilToInt(timeLeft);
|
||||
}
|
||||
@@ -91,10 +129,34 @@ public class UI_Manager : MonoBehaviour
|
||||
public void HideActionTimer()
|
||||
{
|
||||
actionTimerText.text = "";
|
||||
|
||||
if (objectiveText != null)
|
||||
objectiveText.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public void ShowInteractionPrompt(string message)
|
||||
{
|
||||
if (objectiveText != null)
|
||||
objectiveText.gameObject.SetActive(false);
|
||||
|
||||
actionTimerText.text = message;
|
||||
}
|
||||
|
||||
public void ShowOpenVaultObjective()
|
||||
{
|
||||
if (objectiveText != null)
|
||||
objectiveText.text = "-> Open a vault to collect cash.";
|
||||
}
|
||||
|
||||
public void ShowDepositObjective()
|
||||
{
|
||||
if (objectiveText != null)
|
||||
objectiveText.text = "-> Deposit your cash at a deposit dtation.";
|
||||
}
|
||||
|
||||
public void HideObjective()
|
||||
{
|
||||
if (objectiveText != null)
|
||||
objectiveText.text = "";
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,13 @@ public class Vault : MonoBehaviour
|
||||
currentPlayer = player;
|
||||
currentCashManager = other.GetComponent<CashManager>();
|
||||
|
||||
// Player must deposit before opening another vault
|
||||
if (currentCashManager != null && currentCashManager.currentCash >= vaultCash)
|
||||
{
|
||||
UI_Manager.Instance?.ShowInteractionPrompt("Deposit your cash before opening another vault.");
|
||||
return;
|
||||
}
|
||||
|
||||
playerInside = true;
|
||||
|
||||
MobileInteractButton.Instance?.Show();
|
||||
@@ -36,7 +43,7 @@ public class Vault : MonoBehaviour
|
||||
|
||||
if (!isBeingOpened)
|
||||
{
|
||||
UI_Manager.Instance?.ShowInteractionPrompt("Press F To Open Vault");
|
||||
UI_Manager.Instance?.ShowInteractionPrompt("Press the interaction button to open vault.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,6 +86,12 @@ public class Vault : MonoBehaviour
|
||||
isBeingOpened)
|
||||
return;
|
||||
|
||||
if (currentCashManager.currentCash >= vaultCash)
|
||||
{
|
||||
UI_Manager.Instance?.ShowInteractionPrompt("Deposit your cash before opening another vault.");
|
||||
return;
|
||||
}
|
||||
|
||||
UI_Manager.Instance?.HideActionTimer();
|
||||
|
||||
isBeingOpened = true;
|
||||
|
||||
@@ -8,11 +8,16 @@ public class VaultMinimapMarker : MonoBehaviour
|
||||
|
||||
private GameObject marker;
|
||||
|
||||
private void LateUpdate()
|
||||
private void Start()
|
||||
{
|
||||
CreateMarker();
|
||||
}
|
||||
|
||||
//private void LateUpdate()
|
||||
//{
|
||||
// CreateMarker();
|
||||
//}
|
||||
|
||||
private void CreateMarker()
|
||||
{
|
||||
marker = GameObject.CreatePrimitive(PrimitiveType.Quad);
|
||||
|
||||
30
Assets/New Lowpoly Models/Scripts/WorldIcon.cs
Normal file
30
Assets/New Lowpoly Models/Scripts/WorldIcon.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class WorldIcon : MonoBehaviour
|
||||
{
|
||||
[SerializeField] Transform target;
|
||||
[SerializeField] float height = 3f;
|
||||
|
||||
Camera cam;
|
||||
|
||||
void Start()
|
||||
{
|
||||
cam = Camera.main;
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
if (cam == null)
|
||||
return;
|
||||
|
||||
transform.position = target.position + Vector3.up * height;
|
||||
|
||||
transform.forward = cam.transform.forward;
|
||||
|
||||
float distance = Vector3.Distance(cam.transform.position, target.position);
|
||||
|
||||
float scale = Mathf.Clamp(distance * 0.015f, 1f, 2.5f);
|
||||
|
||||
transform.localScale = Vector3.one * scale;
|
||||
}
|
||||
}
|
||||
2
Assets/New Lowpoly Models/Scripts/WorldIcon.cs.meta
Normal file
2
Assets/New Lowpoly Models/Scripts/WorldIcon.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 523266fa276e1804395c630cce596804
|
||||
46
Assets/New Lowpoly Models/Scripts/WorldMarker.cs
Normal file
46
Assets/New Lowpoly Models/Scripts/WorldMarker.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class WorldMarker : MonoBehaviour
|
||||
{
|
||||
[Header("References")]
|
||||
[SerializeField] private Transform target;
|
||||
[SerializeField] private TextMeshProUGUI distanceText;
|
||||
|
||||
private Camera cam;
|
||||
private Transform player;
|
||||
|
||||
void Start()
|
||||
{
|
||||
cam = Camera.main;
|
||||
|
||||
PlayerControllerNewRohan p = FindObjectOfType<PlayerControllerNewRohan>();
|
||||
if (p != null)
|
||||
player = p.transform;
|
||||
}
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
if (cam == null)
|
||||
cam = Camera.main;
|
||||
|
||||
if (player == null)
|
||||
{
|
||||
PlayerControllerNewRohan p = FindObjectOfType<PlayerControllerNewRohan>();
|
||||
if (p != null)
|
||||
player = p.transform;
|
||||
}
|
||||
|
||||
if (cam == null || player == null)
|
||||
return;
|
||||
|
||||
// Billboard
|
||||
transform.forward = cam.transform.forward;
|
||||
|
||||
// Distance
|
||||
float distance = Vector3.Distance(player.position, target.position);
|
||||
|
||||
distanceText.text = $"{Mathf.RoundToInt(distance)}m";
|
||||
}
|
||||
}
|
||||
2
Assets/New Lowpoly Models/Scripts/WorldMarker.cs.meta
Normal file
2
Assets/New Lowpoly Models/Scripts/WorldMarker.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ce259faccb268847adbd48bdc508558
|
||||
Reference in New Issue
Block a user