Batch 1 - Scripts
This commit is contained in:
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user