39 lines
982 B
C#
39 lines
982 B
C#
using UnityEngine;
|
||
using System;
|
||
using TMPro;
|
||
using System.Collections.Generic;
|
||
|
||
public class ShipCounters : MonoBehaviour
|
||
{
|
||
public List<ShipCounterByType> Counters;
|
||
|
||
public void Refresh(ScoreModel model)
|
||
{
|
||
if (Counters == null || Counters.Count == 0) return;
|
||
|
||
foreach (var counter in Counters)
|
||
{
|
||
var modelCounter = model.GetCounterByType(counter.Type);
|
||
if(modelCounter == null)
|
||
{
|
||
Debug.LogWarning($"Не найден счетчик с типом {counter.Type} в модели");
|
||
continue;
|
||
}
|
||
counter.CounterLabel.text = modelCounter.Count.ToString();
|
||
}
|
||
}
|
||
|
||
public void Initialize()
|
||
{
|
||
foreach (var counter in Counters)
|
||
counter.CounterLabel.text = "0";
|
||
}
|
||
|
||
[Serializable]
|
||
public class ShipCounterByType
|
||
{
|
||
public EnemyShip.ShipType Type;
|
||
public TextMeshProUGUI CounterLabel;
|
||
}
|
||
}
|