39 lines
982 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
}
}