325 lines
7.9 KiB
C#
325 lines
7.9 KiB
C#
using DG.Tweening;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
/// <summary>
|
|
/// 游戏UI_视图层
|
|
/// </summary>
|
|
public partial class GameUI
|
|
{
|
|
/// <summary>
|
|
/// 分数
|
|
/// </summary>
|
|
public TextMeshProUGUI score;
|
|
|
|
/// <summary>
|
|
/// 行驶距离
|
|
/// </summary>
|
|
public TextMeshProUGUI operatingRange;
|
|
|
|
/// <summary>
|
|
/// 倒计时
|
|
/// </summary>
|
|
public TextMeshProUGUI countDown;
|
|
|
|
/// <summary>
|
|
/// 加减分数显示
|
|
/// </summary>
|
|
public TextMeshProUGUI addScore;
|
|
|
|
/// <summary>
|
|
/// 惊险超车持续显示
|
|
/// </summary>
|
|
public TextMeshProUGUI closeCall;
|
|
|
|
/// <summary>
|
|
/// 试玩技能
|
|
/// </summary>
|
|
public TextMeshProUGUI tril;
|
|
|
|
/// <summary>
|
|
/// 闪白倒计时
|
|
/// </summary>
|
|
public TextMeshProUGUI shimmerCountDownText;
|
|
|
|
/// <summary>
|
|
/// 倒计时遮挡
|
|
/// </summary>
|
|
public Image countDownkeepOut;
|
|
|
|
/// <summary>
|
|
/// 闪白倒计时
|
|
/// </summary>
|
|
public Image shimmerCountDown;
|
|
|
|
/// <summary>
|
|
/// 速度特效点
|
|
/// </summary>
|
|
public Transform speedFXPoint;
|
|
|
|
/// <summary>
|
|
/// 左预警点
|
|
/// </summary>
|
|
public Transform leftEarlyWarningPoint;
|
|
|
|
/// <summary>
|
|
/// 右预警点
|
|
/// </summary>
|
|
public Transform rightEarlyWarningPoint;
|
|
|
|
/// <summary>
|
|
/// 距离进度
|
|
/// </summary>
|
|
public Slider distanceProgress;
|
|
|
|
/// <summary>
|
|
/// 预警
|
|
/// </summary>
|
|
public GameObject earlyWarning;
|
|
|
|
/// <summary>
|
|
/// 技能条对象
|
|
/// </summary>
|
|
public GameObject skillBarObj;
|
|
|
|
/// <summary>
|
|
/// 关卡进度对象
|
|
/// </summary>
|
|
public GameObject endDistance;
|
|
|
|
/// <summary>
|
|
/// 分数显示
|
|
/// </summary>
|
|
public GameObject scoreShow;
|
|
|
|
/// <summary>
|
|
/// 倒计时不显示
|
|
/// </summary>
|
|
public CanvasGroup countdownEnds;
|
|
|
|
/// <summary>
|
|
/// 惊险超车屏幕效果
|
|
/// </summary>
|
|
public CanvasGroup dangerousOvertaking;
|
|
|
|
/// <summary>
|
|
/// 加减分数动画
|
|
/// </summary>
|
|
public Animation addScoreAnim;
|
|
|
|
/// <summary>
|
|
/// 倒计时对象动画
|
|
/// </summary>
|
|
public Animator countDownAnim;
|
|
|
|
/// <summary>
|
|
/// 闪白倒计时
|
|
/// </summary>
|
|
private Tween shimmerCountDownTween;
|
|
|
|
/// <summary>
|
|
/// 显示行驶距离
|
|
/// </summary>
|
|
public void ShowOperatingRange(float operatingRange, float target)
|
|
{
|
|
this.operatingRange.text = operatingRange.ToString("0") + "m";
|
|
distanceProgress.value = operatingRange / target;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置总分数
|
|
/// </summary>
|
|
public void SetTotalScore(float value)
|
|
{
|
|
score.gameObject.SetActive(true);
|
|
score.text = value.ToString("0");
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置试玩技能显示
|
|
/// </summary>
|
|
private void SetTril()
|
|
{
|
|
tril.gameObject.SetActive(UserDataManager.Instance.IsTrySkill());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置相机
|
|
/// </summary>
|
|
public void SetCamear()
|
|
{
|
|
GetComponent<Canvas>().worldCamera = Camera.main;
|
|
GetComponent<Canvas>().planeDistance = 0.5f;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置倒计时不显示的对象
|
|
/// </summary>
|
|
public void SetCountdownEnds(bool isTrue)
|
|
{
|
|
countdownEnds.DOKill();
|
|
if (isTrue)
|
|
{
|
|
countdownEnds.DOFade(1, 1f);
|
|
}
|
|
else
|
|
{
|
|
countdownEnds.alpha = 0;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 惊险超车屏幕效果
|
|
/// </summary>
|
|
public void SetDangerousOvertaking()
|
|
{
|
|
dangerousOvertaking.DOFade(1, 0.5f).SetUpdate(true).OnComplete(() =>
|
|
{
|
|
dangerousOvertaking.DOFade(0, 0.3f);
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置倒计时遮挡
|
|
/// </summary>
|
|
public void SetCountDownkeepOut()
|
|
{
|
|
countDownkeepOut.DOFade(0, 0.8f).OnComplete(() =>
|
|
{
|
|
countDownkeepOut.DOFade(1, 0.3f);
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置倒计时遮挡
|
|
/// </summary>
|
|
/// <param name="isTrue"></param>
|
|
public void SetCountDownkeepOut(bool isTrue)
|
|
{
|
|
if (isTrue)
|
|
{
|
|
countDownkeepOut.gameObject.SetActive(true);
|
|
countDownkeepOut.color = new Color(0, 0, 0, 1);
|
|
}
|
|
else
|
|
{
|
|
countDownkeepOut.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置倒计时
|
|
/// </summary>
|
|
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;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置闪白倒计时
|
|
/// </summary>
|
|
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();
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置惊险超车持续奖励
|
|
/// </summary>
|
|
public void SetCloseCall(int value)
|
|
{
|
|
SetCloseCall(true);
|
|
closeCall.text = "CLOSE CALL" + "x" + value;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置惊险超车持续奖励显藏
|
|
/// </summary>
|
|
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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置额外加分
|
|
/// </summary>
|
|
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);
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置预警点
|
|
/// </summary>
|
|
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);
|
|
});
|
|
}
|
|
}
|