CapersProject/Assets/02.Scripts/Ui/Tycoon/RankRow.cs

90 lines
2.6 KiB
C#
Raw Normal View History

2024-12-19 10:20:44 +00:00
using System.Collections.Generic;
using System.Collections;
using System.Globalization;
using System.Threading.Tasks;
2025-01-02 10:44:51 +00:00
using BlueWater;
2024-12-19 10:20:44 +00:00
using UnityEngine.Networking;
using Firebase.Database;
using Firebase.Extensions;
using TMPro;
2024-12-17 10:44:39 +00:00
using UnityEngine;
2025-01-02 10:44:51 +00:00
using UnityEngine.UI;
2024-12-17 10:44:39 +00:00
2025-01-02 10:44:51 +00:00
namespace BlueWater
2024-12-17 10:44:39 +00:00
{
2025-01-02 10:44:51 +00:00
public class RankRow : MonoBehaviour
2024-12-19 10:20:44 +00:00
{
2025-01-02 10:44:51 +00:00
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)
2024-12-19 10:20:44 +00:00
{
2025-01-02 10:44:51 +00:00
rankText.text = boardRank;
nameText.text = boardName;
roundText.text = boardRound;
goldText.text = boardGold;
timeText.text = boardTime;
triesText.text = boardTries;
2024-12-19 10:20:44 +00:00
}
2025-01-02 10:44:51 +00:00
public float duration = 3.0f; // 알파 변화에 걸리는 시간
public float maxAlpha = 0.5f; // 알파 최대값
2024-12-17 10:44:39 +00:00
2025-01-02 10:44:51 +00:00
public void StartAlpha()
2024-12-19 10:20:44 +00:00
{
2025-01-02 10:44:51 +00:00
StartCoroutine(PulseAlpha());
}
2024-12-19 10:20:44 +00:00
2025-01-02 10:44:51 +00:00
private IEnumerator PulseAlpha()
2024-12-19 10:20:44 +00:00
{
2025-01-02 10:44:51 +00:00
while (true)
2024-12-19 10:20:44 +00:00
{
2025-01-02 10:44:51 +00:00
// 0 -> maxAlpha로 변화
yield return StartCoroutine(ChangeAlpha(0, maxAlpha, duration / 2));
// maxAlpha -> 0으로 변화
yield return StartCoroutine(ChangeAlpha(maxAlpha, 0, duration / 2));
2024-12-19 10:20:44 +00:00
}
2025-01-02 10:44:51 +00:00
}
private IEnumerator ChangeAlpha(float from, float to, float duration)
2024-12-19 10:20:44 +00:00
{
2025-01-02 10:44:51 +00:00
float elapsedTime = 0f;
Color color = GetComponent<Image>().color;
2024-12-19 10:20:44 +00:00
2025-01-02 10:44:51 +00:00
while (elapsedTime < duration)
2024-12-19 10:20:44 +00:00
{
2025-01-02 10:44:51 +00:00
elapsedTime += Time.deltaTime;
float newAlpha = Mathf.Lerp(from, to, elapsedTime / duration);
GetComponent<Image>().color = new Color(color.r, color.g, color.b, newAlpha);
yield return null;
2024-12-19 10:20:44 +00:00
}
2024-12-17 10:44:39 +00:00
2025-01-02 10:44:51 +00:00
GetComponent<Image>().color = new Color(color.r, color.g, color.b, to);
2024-12-19 10:20:44 +00:00
}
2025-01-02 10:44:51 +00:00
public void SetValueName(string boardName)
2024-12-19 10:20:44 +00:00
{
2025-01-02 10:44:51 +00:00
nameText.text = boardName;
}
2024-12-17 10:44:39 +00:00
}
2025-01-02 10:44:51 +00:00
}