using DG.Tweening; using TMPro; using UnityEngine; using UnityEngine.UI; /// /// 游戏UI_视图层 /// public partial class GameUI { /// /// 分数 /// public TextMeshProUGUI score; /// /// 行驶距离 /// public TextMeshProUGUI operatingRange; /// /// 倒计时 /// public TextMeshProUGUI countDown; /// /// 加减分数显示 /// public TextMeshProUGUI addScore; /// /// 惊险超车持续显示 /// public TextMeshProUGUI closeCall; /// /// 试玩技能 /// public TextMeshProUGUI tril; /// /// 闪白倒计时 /// public TextMeshProUGUI shimmerCountDownText; /// /// 倒计时遮挡 /// public Image countDownkeepOut; /// /// 闪白倒计时 /// public Image shimmerCountDown; /// /// 速度特效点 /// public Transform speedFXPoint; /// /// 左预警点 /// public Transform leftEarlyWarningPoint; /// /// 右预警点 /// public Transform rightEarlyWarningPoint; /// /// 距离进度 /// public Slider distanceProgress; /// /// 预警 /// public GameObject earlyWarning; /// /// 技能条对象 /// public GameObject skillBarObj; /// /// 关卡进度对象 /// public GameObject endDistance; /// /// 分数显示 /// public GameObject scoreShow; /// /// 倒计时不显示 /// public CanvasGroup countdownEnds; /// /// 惊险超车屏幕效果 /// public CanvasGroup dangerousOvertaking; /// /// 加减分数动画 /// public Animation addScoreAnim; /// /// 倒计时对象动画 /// public Animator countDownAnim; /// /// 闪白倒计时 /// private Tween shimmerCountDownTween; /// /// 显示行驶距离 /// public void ShowOperatingRange(float operatingRange, float target) { this.operatingRange.text = operatingRange.ToString("0") + "m"; distanceProgress.value = operatingRange / target; } /// /// 设置总分数 /// public void SetTotalScore(float value) { score.gameObject.SetActive(true); score.text = value.ToString("0"); } /// /// 设置试玩技能显示 /// private void SetTril() { tril.gameObject.SetActive(UserDataManager.Instance.IsTrySkill()); } /// /// 设置相机 /// public void SetCamear() { GetComponent().worldCamera = Camera.main; GetComponent().planeDistance = 0.5f; } /// /// 设置倒计时不显示的对象 /// public void SetCountdownEnds(bool isTrue) { countdownEnds.DOKill(); if (isTrue) { countdownEnds.DOFade(1, 1f); } else { countdownEnds.alpha = 0; } } /// /// 惊险超车屏幕效果 /// public void SetDangerousOvertaking() { dangerousOvertaking.DOFade(1, 0.5f).SetUpdate(true).OnComplete(() => { dangerousOvertaking.DOFade(0, 0.3f); }); } /// /// 设置倒计时遮挡 /// public void SetCountDownkeepOut() { countDownkeepOut.DOFade(0, 0.8f).OnComplete(() => { countDownkeepOut.DOFade(1, 0.3f); }); } /// /// 设置倒计时遮挡 /// /// public void SetCountDownkeepOut(bool isTrue) { if (isTrue) { countDownkeepOut.gameObject.SetActive(true); countDownkeepOut.color = new Color(0, 0, 0, 1); } else { countDownkeepOut.gameObject.SetActive(false); } } /// /// 设置倒计时 /// public void SetCountDown(string value, E_CountDownType e_CountDownType) { countDown.gameObject.SetActive(true); countDown.text = value; switch (e_CountDownType) { case E_CountDownType.Three: case E_CountDownType.Two: case E_CountDownType.One: countDownAnim.SetTrigger("isCommon"); break; case E_CountDownType.GO: countDownAnim.SetTrigger("isGO"); DelayedProcessingManager.Instance.ResetDelayDoSecond("CountDown", this, 1, () => { countDown.gameObject.SetActive(false); }); break; } } /// /// 设置闪白倒计时 /// public void SetShimmerCountDownSetActive(bool isShow) { if (!UserDataManager.Instance.userData.guidance.isOverInitialEntry) return; shimmerCountDown.gameObject.SetActive(isShow); if(isShow) { float value = 4; shimmerCountDownTween=DOTween.To(() => value, x => value = x, 0, 4).OnUpdate(() => { shimmerCountDown.fillAmount = value / 4; shimmerCountDownText.text = value.ToString("0"); if(value<=0) { SetShimmerCountDownSetActive(false); } }); } else { if(shimmerCountDownTween!=null) { shimmerCountDownTween.Kill(); } } } /// /// 设置惊险超车持续奖励 /// public void SetCloseCall(int value) { SetCloseCall(true); closeCall.text = "CLOSE CALL" + "x" + value; } /// /// 设置惊险超车持续奖励显藏 /// public void SetCloseCall(bool isTrue) { if (isTrue) { closeCall.transform.DOKill(); closeCall.transform.localScale = Vector3.zero; closeCall.transform.DOScale(Vector3.one * 1.1f, 0.2f).OnComplete(() => { closeCall.transform.DOScale(Vector3.one * 1, 0.1f); }); } closeCall.gameObject.SetActive(isTrue); } /// /// 设置额外加分 /// public void SetExtraScore(float value) { addScore.gameObject.SetActive(true); addScore.text = "+" + value.ToString("0"); addScoreAnim.Play(MyConstant.ShakeShow); DelayedProcessingManager.Instance.ResetDelayDoSecond("AddScore", this, 2f, () => { addScoreAnim.Play(MyConstant.ShakeHide); }); } /// /// 设置预警点 /// public void SetEarlyWarning(E_DirectionType e_DirectionType) { earlyWarning.gameObject.SetActive(true); switch (e_DirectionType) { case E_DirectionType.Left: earlyWarning.transform.position = leftEarlyWarningPoint.position; break; case E_DirectionType.Right: earlyWarning.transform.position = rightEarlyWarningPoint.position; break; } DelayedProcessingManager.Instance.DelayDoSecond(this, 2, () => { earlyWarning.gameObject.SetActive(false); }); } }