73 lines
2.2 KiB
C#
73 lines
2.2 KiB
C#
using asap.core;
|
|
using GameCore;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
//专用目标奖励活动礼包按钮
|
|
public class GiftButton : EventButtonResource
|
|
{
|
|
public Button btn_gift;
|
|
public TMP_Text text_time;
|
|
public Image bg;
|
|
public Image icon;
|
|
public GameObject redpoint;
|
|
UIType uIType;
|
|
string iconName;
|
|
private void Reset()
|
|
{
|
|
btn_gift = GetComponent<Button>();
|
|
text_time = transform.Find("text_time").GetComponent<TMP_Text>();
|
|
bg = transform.Find("bg").GetComponent<Image>();
|
|
icon = transform.Find("icon").GetComponent<Image>();
|
|
redpoint = transform.Find("redpoint").gameObject;
|
|
}
|
|
private void Start()
|
|
{
|
|
btn_gift.onClick.AddListener(OnClickTargetGift);
|
|
}
|
|
public void Init(UIType uIType, string icon)
|
|
{
|
|
this.uIType = uIType;
|
|
iconName = icon;
|
|
CheckResource(new List<string>() { uIType.Name, iconName });
|
|
}
|
|
|
|
async void OnClickTargetGift()
|
|
{
|
|
var collectingTargetInit = GContext.container.Resolve<FishingEventData>().collectingTargetInit;
|
|
if (collectingTargetInit != null)
|
|
{
|
|
btn_gift.enabled = false;
|
|
//ExitAutoFishing();
|
|
//退出自动钓鱼
|
|
bool isCanEnter = await GContext.container.Resolve<ILoadResourceService>().Load(collectingTargetInit.GiftPrefab);
|
|
if (isCanEnter)
|
|
{
|
|
await UIManager.Instance.ShowUI(uIType);
|
|
}
|
|
else
|
|
{
|
|
var panel = await UIManager.Instance.ShowUI(UITypes.CloudTransitionPanel);
|
|
panel.GetComponent<CloudTransitionPanel>().SetBtn(false, () =>
|
|
{
|
|
_ = UIManager.Instance.ShowUI(uIType);
|
|
});
|
|
}
|
|
btn_gift.enabled = true;
|
|
}
|
|
}
|
|
public void SetTime(string value)
|
|
{
|
|
text_time.text = value;
|
|
}
|
|
|
|
protected override void OnLoadEventResource()
|
|
{
|
|
IUIService uiService = GContext.container.Resolve<IUIService>();
|
|
uiService.SetImageSprite(icon, iconName);
|
|
gameObject.SetActive(true);
|
|
}
|
|
}
|