sea-battle-vr/Assets/Scripts/Awards/AwardsShipCounter.cs

35 lines
855 B
C#
Raw Permalink 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 System.Linq;
using TMPro;
using UnityEngine;
public class AwardsShipCounter : MonoBehaviour
{
[SerializeField] private TextMeshProUGUI CountLabel;
[SerializeField] private EnemyShip.ShipType shipType;
[SerializeField] private CanvasGroup canvasGroup;
public bool ShowScore(ScoreModel scoreModel)
{
var counter = scoreModel.ShipsCounters.FirstOrDefault(c => c.ShipType == shipType);
int count = 0;
if (counter != null)
count = counter.Count;
CountLabel.text = count.ToString();
return count > 0;
}
public void SetAlpha(float alpha)
{
if(canvasGroup == null)
{
Debug.LogError("Не назначена канвас группа", this);
return;
}
canvasGroup.alpha = alpha;
}
}