Fix result scene + bug fix

This commit is contained in:
r.nikolin 2023-10-11 17:33:14 +03:00
parent 549d44e0c5
commit b561c6cea6
7 changed files with 1302 additions and 22052 deletions

View File

@ -2,6 +2,7 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
public class ResultSceneManager : MonoBehaviour
{
@ -9,9 +10,14 @@ public class ResultSceneManager : MonoBehaviour
public UnityEvent<int> OnDailyTop;
public UnityEvent<int> OnGlobalTop;
public UnityEvent OnNoTop;
private void Start()
public UnityEvent OnNoAllTop;
public UnityEvent OnNoDailyTop;
public UnityEvent OnNoGlobalTop;
public InputField PlayerNameInputField;
private void Awake()
{
leaderboardController = FindObjectOfType<LeaderboardController>();
@ -21,7 +27,7 @@ public class ResultSceneManager : MonoBehaviour
if (!leaderboardController.CheckCurrentPlayerDailyTop() && !leaderboardController.CheckCurrentPlayerGlobalTop())
{
OnNoTop?.Invoke();
OnNoAllTop?.Invoke();
}
}
@ -32,6 +38,8 @@ public class ResultSceneManager : MonoBehaviour
OnDailyTop?.Invoke(leaderboardController.GetCurrentPlayerDailyPos());
Debug.Log("Âû ïîïàëè â Òîï 30 èãðîêîâ äíÿ!");
}
else
OnNoDailyTop?.Invoke();
}
public void CheckGlobalTop()
@ -41,5 +49,13 @@ public class ResultSceneManager : MonoBehaviour
OnGlobalTop?.Invoke(leaderboardController.GetCurrentPlayerGlobalPos());
Debug.Log("Âû ïîïàëè â Òîï 30 èãðîêîâ çà âñ¸ âðåìÿ!");
}
else
OnNoGlobalTop?.Invoke();
}
public void SavePlayerName()
{
PlayerSetup.Instance.CurrentPlayer.Name = PlayerNameInputField.text;
leaderboardController.SaveData();
}
}

File diff suppressed because one or more lines are too long

View File

@ -163,8 +163,8 @@ public class LeaderboardController : MonoBehaviour
return _globalPlayerInfo.Players.Contains(PlayerSetup.Instance.CurrentPlayer);
}
public int GetCurrentPlayerDailyPos() => _dailyPlayerInfo.Players.IndexOf(PlayerSetup.Instance.CurrentPlayer);
public int GetCurrentPlayerGlobalPos() => _globalPlayerInfo.Players.IndexOf(PlayerSetup.Instance.CurrentPlayer);
public int GetCurrentPlayerDailyPos() => _dailyPlayerInfo.Players.IndexOf(PlayerSetup.Instance.CurrentPlayer) + 1;
public int GetCurrentPlayerGlobalPos() => _globalPlayerInfo.Players.IndexOf(PlayerSetup.Instance.CurrentPlayer) + 1;
public void SaveData()
{

View File

@ -13,23 +13,32 @@ public class LeanTimer : MonoBehaviour
public UnityEvent<float> OnUpdate = new UnityEvent<float>();
public UnityEvent OnTotalComplete;
private LTDescr LTDescr;
private void Start()
{
if (StartOnAwake)
{
StartTimer(StartValue, EndValue, Time);
ManualStart();
}
}
public void ManualStart()
{
StartTimer(StartValue, EndValue, Time);
}
public void StartTimer(float startValue, float endValue, float time, System.Action OnComplete = null)
{
LTDescr = LeanTween.value(1, 0, time).setOnUpdate((float x) =>
{
OnUpdate?.Invoke(x);
}).setOnComplete(OnComplete);
}).setOnComplete(() =>
{
OnComplete?.Invoke();
OnTotalComplete?.Invoke();
});
}
public void StopTimer(float value = 0)

View File

@ -30,6 +30,7 @@ public class SaveLoadController : MonoBehaviour
string fullDirPath = Application.persistentDataPath + DIR_PATH;
string fullFilePath = Application.persistentDataPath + DIR_PATH + $"{filename}.txt";
Debug.Log($"SAVE:{fullFilePath}");
if (!Directory.Exists(fullDirPath))
{
Directory.CreateDirectory(fullDirPath);
@ -40,7 +41,7 @@ public class SaveLoadController : MonoBehaviour
var json = JsonUtility.ToJson(so);
bf.Serialize(fs, json);
fs.Close();
Debug.Log($"SAVE:SUCCESS");
return true;
}
@ -49,7 +50,7 @@ public class SaveLoadController : MonoBehaviour
string fullDirPath = Application.persistentDataPath + DIR_PATH;
string fullFilePath = Application.persistentDataPath + DIR_PATH + $"{filename}.txt";
Debug.Log(fullFilePath);
Debug.Log($"LOAD:{fullFilePath}");
if (!Directory.Exists(fullDirPath))
{
@ -71,6 +72,7 @@ public class SaveLoadController : MonoBehaviour
so = ScriptableObject.CreateInstance<T>();
}
Debug.Log($"LOAD:SUCCESS");
return true;
}
}

View File

@ -44,6 +44,7 @@ public class UIDisplayMessage : MonoBehaviour
public void Hide()
{
IsShow = false;
if (gameObject != null)
gameObject.SetActive(false);
}

View File

@ -15,6 +15,9 @@ public class UITextShow : MonoBehaviour
public UnityEvent OnTimeTick;
public UnityEvent OnTimeEnd;
public string Prefix;
public string Postfix;
public string Text => _text.text;
private void Awake()
@ -24,7 +27,12 @@ public class UITextShow : MonoBehaviour
public void SetText(string text)
{
_text.SetText(text);
_text.SetText($"{Prefix}{text}{Postfix}");
}
public void SetText(int num)
{
SetText(num.ToString());
}
public void ShowSubtitle(string text, float delay, float afterDelay, Action onStart, Action onEnd)
@ -51,12 +59,12 @@ public class UITextShow : MonoBehaviour
for (int i = time; i > 0; i--)
{
_text.SetText(i.ToString());
SetText(i.ToString());
OnTimeTick?.Invoke();
yield return new WaitForSeconds(1);
}
_text.SetText(afterTimerText);
SetText(afterTimerText);
yield return new WaitForSeconds(afterDelay);
//_text.SetText(string.Empty);
OnTimeEnd?.Invoke();
@ -71,13 +79,13 @@ public class UITextShow : MonoBehaviour
for (int i = 0; i < text.Length; i++)
{
sb.Append(text[i]);
_text.SetText(sb);
SetText(sb.ToString());
OnTimeTick?.Invoke();
yield return new WaitForSeconds(delay);
}
yield return new WaitForSeconds(afterDelay);
_text.SetText(string.Empty);
SetText(string.Empty);
OnTimeEnd?.Invoke();
onEnd?.Invoke();
}