40 lines
993 B
C#
40 lines
993 B
C#
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);
|
|
}
|
|
} |