using System; using TMPro; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.SceneManagement; using UnityEngine.UI; public class StatsMenu : MonoBehaviour { [SerializeField] private GameObject panel; [SerializeField] private TMP_Text normalBerryStat; [SerializeField] private TMP_Text poisonBerryStat; [SerializeField] private TMP_Text slowBerryStat; [SerializeField] private TMP_Text ultraBerryStat; [SerializeField] private TMP_Text speedyBerryStat; [SerializeField] private TMP_Text coinBerryStat; [SerializeField] private TMP_Text randomBerryStat; [SerializeField] private TMP_Text antiBerryStat; [SerializeField] private TMP_Text coinStat; [SerializeField] private Image playerIcon; [SerializeField] private Image playerOverlay; [SerializeField] private TMP_Text xpUsernameText; [SerializeField] private TMP_Text xpText; [SerializeField] private TMP_Text xpLevelText; [SerializeField] private RectTransform progressFilledRect; void Start() { normalBerryStat.text = BazookaManager.Instance.GetGameStoreTotalNormalBerries().ToString(); poisonBerryStat.text = BazookaManager.Instance.GetGameStoreTotalPoisonBerries().ToString(); slowBerryStat.text = BazookaManager.Instance.GetGameStoreTotalSlowBerries().ToString(); ultraBerryStat.text = BazookaManager.Instance.GetGameStoreTotalUltraBerries().ToString(); speedyBerryStat.text = BazookaManager.Instance.GetGameStoreTotalSpeedyBerries().ToString(); coinBerryStat.text = BazookaManager.Instance.GetGameStoreTotalCoinBerries().ToString(); randomBerryStat.text = BazookaManager.Instance.GetGameStoreTotalRandomBerries().ToString(); antiBerryStat.text = BazookaManager.Instance.GetGameStoreTotalAntiBerries().ToString(); coinStat.text = BazookaManager.Instance.GetCustomBirdIconData().Balance.ToString(); var customIcon = BazookaManager.Instance.GetCustomBirdIconData().Selected; if (customIcon == null) { int icon = BazookaManager.Instance.GetBirdIcon(); int overlay = BazookaManager.Instance.GetBirdOverlay(); var iconColor = BazookaManager.Instance.GetColorSettingIcon(); var overlayColor = BazookaManager.Instance.GetColorSettingOverlay(); playerIcon.sprite = Resources.Load("Icons/Icons/bird_" + icon); if (icon == 1) playerIcon.sprite = Tools.GetIconForUser(BazookaManager.Instance.GetAccountID() ?? 0); playerOverlay.sprite = Resources.Load("Icons/Overlays/overlay_" + overlay); if (overlay != 0) playerOverlay.gameObject.SetActive(true); if (overlay == 8) playerOverlay.rectTransform.localPosition = new Vector3(-27.6232f, 23.42824f, 0f); else if (overlay == 11) playerOverlay.rectTransform.localPosition = new Vector3(-24.5611f, 32.250931f, 0f); else if (overlay == 13) playerOverlay.rectTransform.localPosition = new Vector3(-27.56624f, 23.25544f, 0f); try { playerIcon.color = new Color( int.Parse(iconColor[0].ToString()) / 255f, int.Parse(iconColor[1].ToString()) / 255f, int.Parse(iconColor[2].ToString()) / 255f ); playerOverlay.color = new Color( int.Parse(overlayColor[0].ToString()) / 255f, int.Parse(overlayColor[1].ToString()) / 255f, int.Parse(overlayColor[2].ToString()) / 255f ); } catch { playerIcon.color = Color.white; playerOverlay.color = Color.white; } } else { var waitingForCustomIcon = playerIcon.gameObject.AddComponent(); waitingForCustomIcon.ID = customIcon; CustomIconLoader.Init(new[] { waitingForCustomIcon }); } var (_, level, currentXpInLevel, totalXpForLevel, percentDone) = Tools.GetLevelInfo(); xpUsernameText.text = BazookaManager.Instance.GetAccountName() ?? ""; xpText.text = $"{Tools.FormatWithCommas(currentXpInLevel.ToString())}/{Tools.FormatWithCommas(totalXpForLevel.ToString())} xp"; xpLevelText.text = "Level " + Tools.FormatWithCommas(level.ToString()); SetXPProgressFilled((int)percentDone); Tools.RefreshHierarchy(panel); } async void Update() { if (Keyboard.current.escapeKey.wasPressedThisFrame) await SceneManager.LoadSceneAsync("MainMenu"); } void SetXPProgressFilled(int progress) { int newProgress = Math.Clamp(progress, 0, 100); progressFilledRect.sizeDelta = new Vector2(newProgress * 3, progressFilledRect.sizeDelta.y); progressFilledRect.anchoredPosition = new Vector2((newProgress * 3 - 300f) * 0.5f, progressFilledRect.anchoredPosition.y); } }