using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.UIElements;
using Button = UnityEngine.UI.Button;
using Image = UnityEngine.UI.Image;
using Framework;
using System;
using Gameplay;
using Cysharp.Threading.Tasks;
using PhxhSDK;
using cfg.ActorCfg;
public class UI_GetItemWindowController : UIWindow
{
//UI GameObj
///Auto Gen Start///
public Image Image_BG;
public Image Image_ItemPic;
public Image Image_Bar;
public TMP_Text Text_ItemNum;
public TMP_Text Text_IteamName;
public TMP_Text Text_Continue;
private ItemCounts mItems;
///Auto Gen End///
///
/// 打开奖励获取界面
///
public static async UniTask Open(ItemCounts itemCounts)
{
return await UIManager.Instance.CreateAndOpenWindow(UINameConst.UI_GetItemWindow, itemCounts);
}
///
/// 道具
///
private class Item : UIGameObjectWrapper
{
///
/// 道具名
///
private TMP_Text textName;
///
/// 通用道具
///
private GenericItem genericItem;
public Item(GameObject root) : base(root)
{
textName = GetComponent("Text_IteamName");
genericItem = new GenericItem(FindObj("GenericItem"));
}
public void SetInfo(int itemId, int count)
{
DataItem dataItem = TableManager.Instance.Tables.Item.Get(itemId);
if (dataItem == null)
{
DebugUtil.LogError($"获取配置错误 id:{itemId}");
return;
}
textName.text = CommonUtils.GetLocalizeText(dataItem.NameLocal);
genericItem.SetInfo(dataItem, count);
IsScaleShow = true;
}
public override void Dispose()
{
genericItem.Dispose();
genericItem = null;
base.Dispose();
}
}
///
/// 道具列表
///
private List- listItem;
public override void OnInit()
{
UI_GetItemWindowBinder.GetComponents(this);
Transform tsItemRoot = FindObj("Image_BG/Goods").transform;
listItem = new(tsItemRoot.childCount);
for (int i = 0; i < tsItemRoot.childCount; ++i)
{
listItem.Add(new Item(tsItemRoot.GetChild(i).gameObject));
}
BindButton(GetComponent