109 lines
3.5 KiB
C#
109 lines
3.5 KiB
C#
using System;
|
|
using Steamworks;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class LevelUpPanel : MonoBehaviour
|
|
{
|
|
public Text LevelText;
|
|
|
|
public Text RewardText;
|
|
|
|
public Text MapNameText;
|
|
|
|
public Text expBoostText;
|
|
|
|
public Text cashBoostText;
|
|
|
|
public Text progressExpText;
|
|
|
|
public GameObject NewMapIcon;
|
|
|
|
public GameObject addSkillPointObject;
|
|
|
|
public Image progressBar;
|
|
|
|
private Animator animator;
|
|
|
|
private float closeTimer;
|
|
|
|
public static event Action OnLevelUpGlobal;
|
|
|
|
private void Start()
|
|
{
|
|
animator = GetComponent<Animator>();
|
|
Popup();
|
|
CheckNewMap();
|
|
CheckAddPoint();
|
|
if ((bool)FScriptsHandler.Instance)
|
|
{
|
|
GameManager.Instance.SetMouseCurrsor(val: true);
|
|
FScriptsHandler.Instance.m_PlayerMain.firstPersonController.frezzePosition = true;
|
|
FScriptsHandler.Instance.m_PlayerMain.firstPersonController.frezzeRotation = true;
|
|
}
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
LevelUpPanel.OnLevelUpGlobal?.Invoke();
|
|
}
|
|
|
|
private bool AllMapUnlocked()
|
|
{
|
|
for (int i = 0; i < GameManager.Instance.gameLocations.Length; i++)
|
|
{
|
|
if (GameManager.Instance.gameLocations[i].isEnabled && Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerLevel < GameManager.Instance.gameLocations[i].levelrequired && !Singleton<SaveDataManager>.Instance.IsCurrentlySandbox())
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private void CheckNewMap()
|
|
{
|
|
if (AllMapUnlocked() && !Singleton<SaveDataManager>.Instance.IsCurrentlySandbox() && SteamUserStats.GetAchievement("ALL_MAPS_ACHIEVEMENT", out var pbAchieved) && !pbAchieved && SteamUserStats.SetAchievement("ALL_MAPS_ACHIEVEMENT"))
|
|
{
|
|
SteamUserStats.StoreStats();
|
|
}
|
|
for (int i = 0; i < GameManager.Instance.gameLocations.Length; i++)
|
|
{
|
|
if (GameManager.Instance.gameLocations[i].isEnabled && Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerLevel == GameManager.Instance.gameLocations[i].levelrequired)
|
|
{
|
|
NewMapIcon.SetActive(value: true);
|
|
MapNameText.text = GameManager.Instance.gameLocations[i].name;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void CheckAddPoint()
|
|
{
|
|
if (Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().GameMode != GameManager.PlayerData.CPlayer.GameMode.Realistic && Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerLevel % 2 == 0 && Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerLevel < 41)
|
|
{
|
|
addSkillPointObject.SetActive(value: true);
|
|
}
|
|
}
|
|
|
|
private void Popup()
|
|
{
|
|
float value = Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerLevel * 10;
|
|
LevelText.text = Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerLevel.ToString();
|
|
progressExpText.text = GameManager.Instance.formatNumber(long.Parse(Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerExp.ToString("F0"))) + "/" + GameManager.Instance.formatNumber(long.Parse(Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerMaxExp.ToString("F0")));
|
|
progressBar.fillAmount = Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerExp / Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerMaxExp;
|
|
RewardText.text = value.ToString();
|
|
expBoostText.text = "x1";
|
|
cashBoostText.text = "x1";
|
|
GameManager.Instance._playerData.AddSubPlayerCashValue(value);
|
|
}
|
|
|
|
public void CloseLevelPopUp()
|
|
{
|
|
if ((bool)FScriptsHandler.Instance)
|
|
{
|
|
GameManager.Instance.SetMouseCurrsor(val: false);
|
|
FScriptsHandler.Instance.m_PlayerMain.firstPersonController.UnFrezzeLook();
|
|
}
|
|
GameManager.Instance.CloseLevelUpPopUp();
|
|
}
|
|
}
|