NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/UI/UI_GetItemWindowController.cs

87 lines
2.2 KiB
C#

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 Toggle = UnityEngine.UI.Toggle;
using ScrollView = PhxhSDK.PhxhScrollView;
using Framework;
using System;
using Gameplay;
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///
// Use this for initialization
public override void OnAwake()
{
//bind UI GameObj
UI_GetItemWindowBinder.GetComponents(this);
BindButton(GetComponent<Button>("Image_BG"), OnBgClick);
}
private void OnBgClick()
{
CloseWindow();
}
//invoke when open window
protected override void OnOpenWindow(object data = null)
{
mItems = data as ItemCounts;
RefreshMaterial(mItems);
}
private async void RefreshMaterial(ItemCounts mItems)
{
string allName = "";
for (int i = 0; i < 5; i++)
{
GameObject itemParent = FindObj(string.Format("Image_BG/Goods/{0}", (i + 1).ToString()));
CommonUtils.DestoryAllChildGameObject(CommonUtils.GetGameObject(itemParent, "item"));
if (i < mItems.Ids.Count)
{
itemParent.SetActive(true);
ItemObj itemObj = new ItemObj((int)mItems.Ids[i], CommonUtils.GetGameObject(itemParent, "item"),ItemObj.UIType.shop);
await itemObj.Init();
CommonUtils.GetComponent<TMP_Text>(itemParent, "Text_IteamName").text = CommonUtils.GetItemName((int)mItems.Ids[i]);
//allName += TableManager.Instance.Tables.Item.Get((int)mItems.Ids[i]).ID + "X" + mItems.Counts[i];
}
else
{
itemParent.SetActive(false);
}
}
}
//invoke when reload window
protected override void OnReloadWindow(object data = null)
{
}
//invoke when close window
protected override void OnCloseWindow()
{
}
}