先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
141 lines
4.9 KiB
C#
141 lines
4.9 KiB
C#
using asap.core;
|
|
using cfg;
|
|
using GameCore;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UniRx;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace game
|
|
{
|
|
public class HomeBtnScratchTicket : EventButtonResource
|
|
{
|
|
[SerializeField] private TMP_Text textTimer;
|
|
Button btn;
|
|
|
|
private DateTime endDateTime;
|
|
|
|
// private EventScratchTicketDataManager m_DataManager;
|
|
|
|
#region 生命周期
|
|
void Awake()
|
|
{
|
|
btn = GetComponent<Button>();
|
|
}
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
// m_DataManager = GContext.container.Resolve<EventScratchTicketDataManager>();
|
|
// m_DataManager.Init();
|
|
|
|
// 活动倒计时处理
|
|
FishingEventData fishingEventData = GContext.container.Resolve<FishingEventData>();
|
|
int fishingEventID = fishingEventData.GetEvent(7, 3);
|
|
if (fishingEventID < 0)
|
|
{
|
|
gameObject.SetActive(false);
|
|
return;
|
|
}
|
|
|
|
Tables tables = GContext.container.Resolve<Tables>();
|
|
FishingEvent fishingEvent = tables.TbFishingEvent[fishingEventID];
|
|
endDateTime = DateTime.Parse((fishingEvent.TimeDefinition as LimitedTime)?.EndTime);
|
|
|
|
TimeSpan all = GetRemainingTime(endDateTime);
|
|
double seconds = all.TotalSeconds - 1;
|
|
if (seconds < 1)
|
|
{
|
|
gameObject.SetActive(false);
|
|
return;
|
|
}
|
|
StartCoroutine(AttachTimer((float)seconds));
|
|
|
|
textTimer.text = ConvertTools.ConvertTime2(all);
|
|
|
|
Observable.Interval(TimeSpan.FromSeconds(1.0f)).Subscribe(_ =>
|
|
{
|
|
TimeSpan tmpAll = GetRemainingTime(endDateTime);
|
|
textTimer.text = ConvertTools.ConvertTime2(tmpAll);
|
|
if (tmpAll.TotalSeconds <= 0)
|
|
gameObject.SetActive(false);
|
|
}).AddTo(this);
|
|
|
|
btn.onClick.AddListener(async () =>
|
|
{
|
|
string actName = "FishingScratchTicketAct";
|
|
|
|
List<string> resList = new List<string>();
|
|
resList.Add(actName);
|
|
|
|
// EventScratchMain eventScratchMain = m_DataManager.ContinueGame();
|
|
|
|
// resList.AddRange(eventScratchMain.Addressable);
|
|
|
|
ILoadResourceService loadResourceService = GContext.container.Resolve<ILoadResourceService>();
|
|
bool isCanEnter = await loadResourceService.Loads(resList);
|
|
if (isCanEnter)
|
|
{
|
|
GContext.Publish(new UnloadActToNextAct(actName));
|
|
}
|
|
else
|
|
{
|
|
var panel = await UIManager.Instance.ShowUI(UITypes.CloudTransitionPanel);
|
|
panel.GetComponent<CloudTransitionPanel>().SetBtn(true, () => GContext.Publish(new UnloadActToNextAct(actName)));
|
|
}
|
|
});
|
|
|
|
// EventScratchMain eventScratchMain = m_DataManager.ContinueGame();
|
|
|
|
// string actName = "FishingScratchTicketAct";
|
|
// List<string> resList = new List<string>
|
|
// {
|
|
// actName,
|
|
// eventScratchMain.Icon
|
|
// };
|
|
// // 红点处理
|
|
// if (m_DataManager != null)
|
|
// {
|
|
// m_DataManager.GetChainPackData();
|
|
// if (m_DataManager.IsRedDotDisplayed()) RedPointManager.Instance.SetRedPointState(RedPointName.Home_ScratchTicket, true, m_DataManager.GetRedCount());
|
|
// else RedPointManager.Instance.SetRedPointState(RedPointName.Home_ScratchTicket, false);
|
|
// }
|
|
// else RedPointManager.Instance.SetRedPointState(RedPointName.Home_ScratchTicket, false);
|
|
//
|
|
// resList.AddRange(eventScratchMain.Addressable);
|
|
// CheckResource(resList);
|
|
}
|
|
#endregion
|
|
|
|
private TimeSpan GetRemainingTime(DateTime endDateTime)
|
|
{
|
|
return endDateTime - ZZTimeHelper.UtcNow();
|
|
}
|
|
|
|
IEnumerator AttachTimer(float time)
|
|
{
|
|
yield return new WaitForSeconds(time);
|
|
gameObject.SetActive(false);
|
|
}
|
|
|
|
protected override void OnLoadEventResource()
|
|
{
|
|
TimeSpan all = GetRemainingTime(endDateTime);
|
|
double seconds = all.TotalSeconds - 1;
|
|
if (seconds > 1)
|
|
{
|
|
// EventScratchMain eventScratchMain = m_DataManager.ContinueGame();
|
|
// if (eventScratchMain != null)
|
|
// {
|
|
// Image btn_icon = transform.Find("icon").GetComponent<Image>();
|
|
// GContext.container.Resolve<IUIService>().SetImageSprite(btn_icon, eventScratchMain.Icon);
|
|
// }
|
|
gameObject.SetActive(true);
|
|
}
|
|
}
|
|
}
|
|
}
|