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

88 lines
2.1 KiB
C#
Raw Normal View History

2023-10-19 15:00:19 +08:00
using Framework;
using Gameplay.Net;
using System;
using System.Collections;
using System.Collections.Generic;
using TapTap.AntiAddiction.Localization;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.UIElements;
using Button = UnityEngine.UI.Button;
using Image = UnityEngine.UI.Image;
public class UIGiftCodeAwardsController: UIWindow
{
//UI GameObj
///Auto Gen Start///
private Button mSureBtn;
private Button mCloseBtn;
private ItemCounts mItems;
///Auto Gen End///
// Use this for initialization
public override void OnAwake()
{
//bind UI GameObj
mSureBtn= GetComponent<Button>("bg/SureBtn");
mCloseBtn = GetComponent<Button>("ReturnBtn");
BindButton(mSureBtn, OnSureBtnClose);
BindButton(mCloseBtn, OnReturnBtnClose);
}
private void OnReturnBtnClose()
{
CloseWindow();
}
private void OnSureBtnClose()
{
CloseWindow();
}
//invoke when open window
protected override void OnOpenWindow(object data = null)
{
mItems=data as ItemCounts;
RefreshMaterial(mItems);
}
private void RefreshMaterial(ItemCounts mItems)
{
string allName = "";
for (int i = 0; i < 3; i++)
{
GameObject itemParent = FindObj(string.Format("UI_Materals/{0}", (i + 1).ToString()));
Utils.CommonUtils.DestoryAllChildGameObject(Utils.CommonUtils.GetGameObject(itemParent, "item"));
if ((i + 1) <= mItems.Ids.Count)
{
itemParent.SetActive(true);
ItemObj itemObj = new ItemObj((int)mItems.Ids[i], Utils.CommonUtils.GetGameObject(itemParent, "item"));
Utils.CommonUtils.GetComponent<TMP_Text>(itemParent, "value").text = mItems.Counts[i].ToString();
allName += TableManager.Instance.Tables.Item.Get((int)mItems.Ids[i]).ID+"X"+ mItems.Counts[i];
}
else
{
itemParent.SetActive(false);
}
}
GetComponent<TMP_Text>("Text_AwardsText").text = allName;
}
//invoke when reload window
protected override void OnReloadWindow(object data = null)
{
}
}