90 lines
2.4 KiB
C#
90 lines
2.4 KiB
C#
using asap.core;
|
|
using GameCore;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class HomeMapBtn : MonoBehaviour, IUIRedPoint
|
|
{
|
|
string key = "Home.Map";
|
|
public GameObject redPoint;
|
|
public GameObject redpoint_big;
|
|
public TMP_Text text_redpoint_big;
|
|
Button _btn;
|
|
void Awake()
|
|
{
|
|
_btn = GetComponent<Button>();
|
|
RedPointManager.Instance.AddRedPoint(key, this);
|
|
}
|
|
void Start()
|
|
{
|
|
_btn.onClick.AddListener(OnClick);
|
|
}
|
|
async void OnClick()
|
|
{
|
|
var _playerFishData = GContext.container.Resolve<PlayerFishData>();
|
|
if (_playerFishData.IsOpenMap)
|
|
{
|
|
GameObject go = await UIManager.Instance.ShowUI(UITypes.FishingMapPanel);
|
|
if (go != null)
|
|
{
|
|
GContext.Publish(new HideHomePanelEvent());
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
var _fishingEventData = GContext.container.Resolve<FishingEventData>();
|
|
ToastPanel.Show(_fishingEventData.GetTipforUnlocked(_playerFishData.MapTipforUnlocked));
|
|
}
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
SetRedPointState(RedPointManager.Instance.GetRedPointState(key));
|
|
}
|
|
public void SetRedPointState(bool state)
|
|
{
|
|
string subKey = HomeBtnMiniBP.redKey + MiniBattlePassType.Fishcard;
|
|
state |= RedPointManager.Instance.GetRedPointState(subKey);
|
|
if (redpoint_big != null && text_redpoint_big != null)
|
|
{
|
|
if (!state)
|
|
{
|
|
redpoint_big.SetActive(false);
|
|
}
|
|
else
|
|
{
|
|
int count = RedPointManager.Instance.GetRedPointCount(key);
|
|
count += RedPointManager.Instance.GetRedPointCount(subKey);
|
|
if (count > 1)
|
|
{
|
|
redpoint_big.SetActive(true);
|
|
if (count > 99)
|
|
{
|
|
text_redpoint_big.text = "99+";
|
|
}
|
|
else
|
|
{
|
|
text_redpoint_big.text = count.ToString();
|
|
}
|
|
state = false;
|
|
}
|
|
else
|
|
{
|
|
redpoint_big.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
if (redPoint != null)
|
|
{
|
|
redPoint.SetActive(state);
|
|
}
|
|
}
|
|
private void OnDestroy()
|
|
{
|
|
RedPointManager.Instance.RemoveRedPoint(key);
|
|
}
|
|
|
|
}
|