Files
back_cantanBuilding/Assets/Scripts/UI/Home/HomeBtnFishingDuel.cs
2026-05-26 16:15:54 +08:00

72 lines
2.5 KiB
C#

using asap.core;
using cfg;
using game;
using GameCore;
using System;
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
public class HomeBtnFishingDuel : MonoBehaviour
{
GameObject redpoint;
Button btn_enter;
FishingEventData fishingEventData;
private void Awake()
{
fishingEventData = GContext.container.Resolve<FishingEventData>();
btn_enter = GetComponent<Button>();
redpoint = transform.Find("redpoint").gameObject;
Tables tables = GContext.container.Resolve<Tables>();
int fishingEventID = fishingEventData.GetEvent(5, 1);
fishingEventData.SoloCheckClaimReward();
if (fishingEventID == -1 || fishingEventData.duelData == null)
{
gameObject.SetActive(false);
return;
}
DateTime endDateTime = fishingEventData.GetEventEndTime(fishingEventID)
.AddSeconds(-tables.TbEventSoloConfig.SettlementTime);
TimeSpan all = endDateTime - ZZTimeHelper.UtcNow().UtcNowOffset();
double seconds = all.TotalSeconds - 1;
if (seconds < 1)
{
gameObject.SetActive(false);
return;
}
int redDot = GContext.container.Resolve<FishingEventData>().GetRedDotPVP(fishingEventID);
redpoint.SetActive(fishingEventData.duelData.tickets > redDot);
StartCoroutine(AttachTimer((float)seconds));
}
IEnumerator AttachTimer(float time)
{
yield return new WaitForSeconds(time);
gameObject.SetActive(false);
}
private void Start()
{
btn_enter.onClick.AddListener(OnEnter);
}
async void OnEnter()
{
ILoadResourceService loadResourceService = GContext.container.Resolve<ILoadResourceService>();
bool isCanEnter = await loadResourceService.Load(FishingDuelManager.EventPkDuel);
if (isCanEnter)
{
_ = UIManager.Instance.ShowUI(UITypes.EventFishingDuelPanel);
}
else
{
var panel = await UIManager.Instance.ShowUI(UITypes.CloudTransitionPanel);
panel.GetComponent<CloudTransitionPanel>().SetBtn(false, () =>
{
_ = UIManager.Instance.ShowUI(UITypes.EventFishingDuelPanel);
}
);
//var panel = await UIManager.Instance.ShowUI(UITypes.FishingDownLoadPopupPanel);
//panel.GetComponent<FishingDownLoadPopupPanel>().SetBtn(null, () => _ = UIManager.Instance.ShowUI(UITypes.EventFishingDuelPanel));
}
}
}