90 lines
2.6 KiB
C#
90 lines
2.6 KiB
C#
using System.Collections.Generic;
|
|
using System.Collections;
|
|
using System.Globalization;
|
|
using System.Threading.Tasks;
|
|
using DDD;
|
|
using UnityEngine.Networking;
|
|
using Firebase.Database;
|
|
using Firebase.Extensions;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace DDD
|
|
{
|
|
public class RankRow : MonoBehaviour
|
|
{
|
|
private DatabaseReference m_Reference;
|
|
|
|
[SerializeField] private TextMeshProUGUI rankText;
|
|
|
|
[SerializeField] private TextMeshProUGUI nameText;
|
|
|
|
[SerializeField] private TextMeshProUGUI roundText;
|
|
|
|
[SerializeField] private TextMeshProUGUI goldText;
|
|
|
|
[SerializeField] private TextMeshProUGUI timeText;
|
|
|
|
[SerializeField] private TextMeshProUGUI triesText;
|
|
|
|
[SerializeField] private FirebaseManager firebaseManager;
|
|
|
|
void Start()
|
|
{
|
|
m_Reference = FirebaseDatabase.DefaultInstance.RootReference;
|
|
}
|
|
|
|
public void SetValue(string boardRank, string boardName, string boardRound, string boardGold, string boardTime,
|
|
string boardTries)
|
|
{
|
|
rankText.text = boardRank;
|
|
nameText.text = boardName;
|
|
roundText.text = boardRound;
|
|
goldText.text = boardGold;
|
|
timeText.text = boardTime;
|
|
triesText.text = boardTries;
|
|
}
|
|
|
|
public float duration = 3.0f; // 알파 변화에 걸리는 시간
|
|
public float maxAlpha = 0.5f; // 알파 최대값
|
|
|
|
public void StartAlpha()
|
|
{
|
|
StartCoroutine(PulseAlpha());
|
|
}
|
|
|
|
private IEnumerator PulseAlpha()
|
|
{
|
|
while (true)
|
|
{
|
|
// 0 -> maxAlpha로 변화
|
|
yield return StartCoroutine(ChangeAlpha(0, maxAlpha, duration / 2));
|
|
// maxAlpha -> 0으로 변화
|
|
yield return StartCoroutine(ChangeAlpha(maxAlpha, 0, duration / 2));
|
|
}
|
|
}
|
|
|
|
private IEnumerator ChangeAlpha(float from, float to, float duration)
|
|
{
|
|
float elapsedTime = 0f;
|
|
Color color = GetComponent<Image>().color;
|
|
|
|
while (elapsedTime < duration)
|
|
{
|
|
elapsedTime += Time.unscaledDeltaTime;
|
|
float newAlpha = Mathf.Lerp(from, to, elapsedTime / duration);
|
|
GetComponent<Image>().color = new Color(color.r, color.g, color.b, newAlpha);
|
|
yield return null;
|
|
}
|
|
|
|
GetComponent<Image>().color = new Color(color.r, color.g, color.b, to);
|
|
}
|
|
|
|
public void SetValueName(string boardName)
|
|
{
|
|
nameText.text = boardName;
|
|
}
|
|
|
|
}
|
|
} |