Files
ft/Client/Assets/Scripts/EventBlocks/UI/EventBlockCompleteShowPanel.cs
2026-06-29 21:18:33 +08:00

128 lines
3.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using asap.core;
using cfg;
using EventCubeMelt;
using GameCore;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace EventBlocks.UI
{
public class EventBlockCompleteShowPanel : BasePanel
{
private EventCubeMeltManager _thisEventManager;
private Button _btnClose;
private Button _btnClaim;
private TMP_Text _txtDes;
private Transform _box;
[SerializeField]
// 道具
private EventBlockShowItem[] items;
//-
private ZZVideoRawImageDecoder _videoBoxDecoder;
//-
private Tables _tables;
private void Awake()
{
_thisEventManager = GContext.container.Resolve<EventCubeMeltManager>();
_tables = GContext.container.Resolve<Tables>();
//
_btnClose = transform.Find("p_panel_btn_close").GetComponent<Button>();
_btnClaim = transform.Find("root/btn_claim/btn_green").GetComponent<Button>();
_txtDes = transform.Find("root/Txt_des").GetComponent<TMP_Text>();
_box = transform.Find("root/Box");
_videoBoxDecoder = transform.Find("root/Video_box").GetComponent<ZZVideoRawImageDecoder>();
_btnClose.onClick.AddListener(OnClose);
_btnClaim.onClick.AddListener(OnClaim);
}
//-
protected override void Start()
{
base.Start();
var stageList = _thisEventManager.EventStageList;
var uiService = GContext.container.Resolve<IUIService>();
for (var index = 0; index < stageList.Count; index++)
{
var item = items[index];
var stage = stageList[index];
var collectionData = _tables.TbEventCubeMeltCollection.DataList.FirstOrDefault(data => data.ID == stage);
item.SetItemData(collectionData,uiService);
}
//-
var stageCount = _thisEventManager.StageCount;
var currentStage = _thisEventManager.EventData.CurrentStagetId;
_txtDes.text = LocalizationMgr.GetFormatTextValue("UI_EventBlockVikingPanel_3",currentStage + 1,stageCount);
}
//- 整理
protected override void OnDestroy()
{
base.OnDestroy();
}
private void OnClose()
{
ELog("OnClose");
GContext.Publish(new EventBlockGetReward());
}
public async void OnClaim()
{
_btnClaim.gameObject.SetActive(false);
_box.GetComponent<Animation>().Stop();
_box.gameObject.SetActive(false);
await RunVideoPlay();
// OnClose();
GContext.Publish(new EventBlockGetReward());
}
private async Task RunVideoPlay()
{
_videoBoxDecoder.gameObject.SetActive(true);
await Awaiters.Seconds(4f);
}
public void UpdateStage(int stageId)
{
ELog($"UpdateItem ->{stageId}");
}
#region Log
private static void LogWarning(string message)
{
Debug.LogWarning($"<color=yellow>{nameof(EventBlockCompleteShowPanel)} => {message}</color>");
}
private static void LogError(string message)
{
Debug.LogError($"<color=red>{nameof(EventBlockCompleteShowPanel)} => {message}</color>");
}
private static void ELog(string message)
{
#if UNITY_EDITOR
if (!EventCubeMeltLogPolicy.EnableELog) return;
Debug.Log($"<color=orange>{nameof(EventBlockCompleteShowPanel)} => {message}</color>");
#endif
}
#endregion
}
}