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;
using Gameplay.Level;
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;
///Auto Gen End///
private ListItem mItems;
private EShowType _showType;
private GameObject _itemTemp;
private GameObject _scrollView;
private GameObject _scrollContent;
private GameObject _goMaskBg;
private Action _callBackFunc;
public enum EShowType
{
Normal,
StorySettle
}
private struct Param
{
public EShowType type;
public ListItem listItem;
public Action cb;
public Param(EShowType Etype, ListItem list, Action callBack = null)
{
type = Etype;
listItem = list;
cb = callBack;
}
}
///
/// 打开奖励获取界面
///
public static async UniTask Open(ItemCounts itemCounts, EShowType type = EShowType.Normal, Action cb = null)
{
ListItem itemList = new(itemCounts);
return await UIManager.Instance.CreateAndOpenWindow(UINameConst.UI_GetItemWindow, new Param(type, itemList, cb));
}
public static async UniTask Open(ListItem itemList, EShowType type = EShowType.Normal, Action cb = null)
{
return await UIManager.Instance.CreateAndOpenWindow(UINameConst.UI_GetItemWindow, new Param(type, itemList, cb));
}
public static async UniTask Open(ItemList itemList, EShowType type = EShowType.Normal, Action cb = null)
{
ListItem listItem = new(itemList);
return await UIManager.Instance.CreateAndOpenWindow(UINameConst.UI_GetItemWindow, new Param(type, listItem, cb));
}
///
/// 道具
///
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 PreLoad(object data = null)
{
if (data != null)
{
var param = (Param)data;
mItems = param.listItem;
_showType = param.type;
_callBackFunc = param.cb;
}
}
public override void OnInit()
{
UI_GetItemWindowBinder.GetComponents(this);
Transform tsItemRoot = FindObj("Image_BG/Goods").transform;
_scrollView = FindObj("Image_BG/ScrollView");
_itemTemp = FindObj("Image_BG/Item");
_scrollContent = FindObj("Image_BG/ScrollView/Viewport/Content");
_goMaskBg = FindObj("Image_BG/ImageMaskBg");
BindButton(GetComponent