75 lines
1.7 KiB
C#
75 lines
1.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using DG.Tweening;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class ResultItem : MonoBehaviour
|
|
{
|
|
|
|
public TextMeshProUGUI playerText;
|
|
|
|
public TextMeshProUGUI scoreText;
|
|
|
|
public TextMeshProUGUI rankingText;
|
|
|
|
public TextMeshProUGUI shotTimeText;
|
|
|
|
public TextMeshProUGUI hitRateText;
|
|
|
|
public TextMeshProUGUI moveDisText;
|
|
|
|
public AudioSource audioSource;
|
|
|
|
|
|
/// <summary>
|
|
/// 数据滚动音效
|
|
/// </summary>
|
|
public AudioClip Data_Scrolling_Typi;
|
|
|
|
|
|
|
|
public GameObject bg;
|
|
|
|
|
|
public int index;
|
|
|
|
private float startScore = 0;
|
|
private float targetScore = 0;
|
|
|
|
|
|
|
|
public void InitData(int name, float score, int ranking, int shotTime, float hitRate, float moveDis)
|
|
{
|
|
playerText.text = "玩家" + name.ToString();
|
|
targetScore = score;
|
|
// scoreText.text = score.ToString();
|
|
rankingText.text = ranking.ToString();
|
|
shotTimeText.text = shotTime.ToString();
|
|
hitRateText.text = hitRate.ToString() + "%";
|
|
moveDisText.text = moveDis.ToString();
|
|
audioSource.PlayOneShot(Data_Scrolling_Typi, 1f);
|
|
DOTween.To(() => startScore, x => startScore = x, score, 2.6f)
|
|
.OnUpdate(UpdateNumberText)
|
|
.SetEase(Ease.Linear); ;
|
|
}
|
|
|
|
// 更新数字文本显示
|
|
void UpdateNumberText()
|
|
{
|
|
int displayNumber = Mathf.RoundToInt(startScore);
|
|
scoreText.text = displayNumber.ToString();
|
|
}
|
|
|
|
|
|
public void SetBgActive(bool value)
|
|
{
|
|
//bg.SetActive(value);
|
|
//Image imageBg = bg.GetComponent<Image>();
|
|
//DOTween.To(() => imageBg.fillAmount, x => imageBg.fillAmount = x, 1, 1f);
|
|
}
|
|
|
|
|
|
}
|