备份CatanBuilding瘦身独立工程
This commit is contained in:
89
Assets/Scripts/UI/Home/HomeMapBtn.cs
Normal file
89
Assets/Scripts/UI/Home/HomeMapBtn.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user