62 lines
1.6 KiB
C#
62 lines
1.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Events;
|
|
using UnityEngine.UI;
|
|
|
|
public class ResultSceneManager : MonoBehaviour
|
|
{
|
|
private LeaderboardController leaderboardController;
|
|
|
|
public UnityEvent<int> OnDailyTop;
|
|
public UnityEvent<int> OnGlobalTop;
|
|
|
|
public UnityEvent OnNoAllTop;
|
|
public UnityEvent OnNoDailyTop;
|
|
public UnityEvent OnNoGlobalTop;
|
|
|
|
public InputField PlayerNameInputField;
|
|
|
|
private void Awake()
|
|
{
|
|
leaderboardController = FindObjectOfType<LeaderboardController>();
|
|
|
|
leaderboardController.RefreshEntries();
|
|
leaderboardController.SaveData();
|
|
|
|
|
|
if (!leaderboardController.CheckCurrentPlayerDailyTop() && !leaderboardController.CheckCurrentPlayerGlobalTop())
|
|
{
|
|
OnNoAllTop?.Invoke();
|
|
}
|
|
}
|
|
|
|
public void CheckDailyTop()
|
|
{
|
|
if (leaderboardController.CheckCurrentPlayerDailyTop())
|
|
{
|
|
OnDailyTop?.Invoke(leaderboardController.GetCurrentPlayerDailyPos());
|
|
Debug.Log("Âû ïîïàëè â Òîï 30 èãðîêîâ äíÿ!");
|
|
}
|
|
else
|
|
OnNoDailyTop?.Invoke();
|
|
}
|
|
|
|
public void CheckGlobalTop()
|
|
{
|
|
if (leaderboardController.CheckCurrentPlayerGlobalTop())
|
|
{
|
|
OnGlobalTop?.Invoke(leaderboardController.GetCurrentPlayerGlobalPos());
|
|
Debug.Log("Âû ïîïàëè â Òîï 30 èãðîêîâ çà âñ¸ âðåìÿ!");
|
|
}
|
|
else
|
|
OnNoGlobalTop?.Invoke();
|
|
}
|
|
|
|
public void SavePlayerName()
|
|
{
|
|
PlayerSetup.Instance.CurrentPlayer.Name = PlayerNameInputField.text;
|
|
leaderboardController.SaveData();
|
|
}
|
|
}
|