using System; using System.Collections.Generic; using Code.Example.Race.Racer; using Code.Example.Race.Track; using Code.Infrastructure.EventBus; using Code.Infrastructure.UI; using Reflex.Attributes; using TMPro; using UnityEngine; using UnityEngine.Rendering; namespace Code.Example.Race.UI { public class PlayerScoreCounter : UIPanel, IScoreChangedHandle { [SerializeField] private TMP_Text playerScore; private EventBus _eventBus; [Inject] private void Construct(EventBus eventBus) { _eventBus = eventBus; _eventBus.Subscribe(this); } public override void Open(Action callback = null) { playerScore.gameObject.SetActive(true); // image.DOColor(shownColor, 1f).onComplete = () => callback?.Invoke(); } public override void Close(Action callback = null) { playerScore.gameObject.SetActive(true); // image.DOColor(hiddenColor, 1f).onComplete += () => callback?.Invoke(); } public void OnRacerPassedCheckpoint(Racer.AI.Racer racer) { } public void ScoreChanged(int racer, int additionalScore, List> scores) { // if (racer.Data.type == RacerType.Player) string output = ""; foreach (var score in scores) output += $@"{score.Key}: {score.Value}\n"; playerScore.text = output; } } }