using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; using Lemon.GenericLib.Generics; public class BoardUIScript : MonoBehaviour { [Header("Runtime")] [SerializeField] private float currentComboCountdown; [SerializeField] private float currentWarningCountdown; [SerializeField] private float scoreTextOriginY; [SerializeField] private float comboTextOriginY; [SerializeField] private float warningTextOriginY; [Header("Refrences")] [SerializeField] private TextMeshPro titleTMP; [SerializeField] private TextMeshPro scoreTMP; [SerializeField] private TextMeshPro comboTMP; [SerializeField] private TextMeshPro warningTMP; [SerializeField] private GameObject warningOBJ; [SerializeField] private GameObject comboOBJ; [SerializeField] private float scoreJumpDistance = 0.25f; [SerializeField] private float scoreJumpTime = 0.5f; [SerializeField] private float comboUITimer = 3f; [SerializeField] private float warningUITimer = 3f; private bool initialized = false; private void CheckInit() { if (!initialized) { //initialization code here titleTMP.text = "Player"; scoreTMP.text = "0"; comboTMP.text = "x0"; warningTMP.text = "x0"; warningOBJ.SetActive(false); comboOBJ.SetActive(false); scoreTextOriginY = scoreTMP.transform.localPosition.y; comboTextOriginY = comboTMP.transform.localPosition.y; warningTextOriginY = warningTMP.transform.localPosition.y; initialized = true; } } private void Start() { CheckInit(); } private void Update() { if (currentComboCountdown <= 0) { comboTMP.text = "x0"; comboOBJ.SetActive(false); } else { currentComboCountdown -= Time.deltaTime; } if (currentWarningCountdown <= 0) { warningTMP.text = "x0"; warningOBJ.SetActive(false); } else { currentWarningCountdown -= Time.deltaTime; } } public void SetScore(int value) { scoreTMP.transform.LeanMoveLocalY(scoreTextOriginY + scoreJumpDistance, scoreJumpTime).setLoopPingPong(1).setEase(LeanTweenType.easeOutQuad).setOnComplete(() => scoreTMP.transform.LeanMoveLocalY( scoreTextOriginY,0)); scoreTMP.text = value.ToString(); } public void SetCombo(int value) { currentComboCountdown = comboUITimer; comboTMP.text = "x" + value; comboOBJ.SetActive(true); comboTMP.transform.LeanMoveLocalY(comboTextOriginY + scoreJumpDistance, scoreJumpTime).setLoopPingPong(1).setEase(LeanTweenType.easeOutQuad).setOnComplete(() => comboTMP.transform.LeanMoveLocalY(comboTextOriginY, 0)); } public void SetWarning(int value) { currentWarningCountdown = warningUITimer; warningTMP.text = "x" + value; warningOBJ.SetActive(true); warningTMP.transform.LeanMoveLocalY(warningTextOriginY + scoreJumpDistance, scoreJumpTime).setLoopPingPong(1).setEase(LeanTweenType.easeOutQuad).setOnComplete(() => warningTMP.transform.LeanMoveLocalY(warningTextOriginY, 0)); } public void SetPlayerName(string value) { titleTMP.text = value; } }