Project_WL/Assets/Script/UI/PC/Info/PCInfoUI_Center.cs

65 lines
2.1 KiB
C#
Raw Normal View History

2024-12-15 01:39:39 +00:00
using TMPro;
using UnityEngine;
2024-12-31 04:49:01 +00:00
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
2024-12-15 01:39:39 +00:00
using UnityEngine.UI;
2024-12-30 05:00:34 +00:00
public class PCInfoUI_Center : UI3DModel
2024-12-15 01:39:39 +00:00
{
public TextMeshProUGUI[] texts; // 0 코스튬 이름, 1 코스튬 대사
public RawImage RawImage_costume;
2024-12-31 04:49:01 +00:00
public GameObject[] gos; // 0 코스튬 착용 버튼
2024-12-15 01:39:39 +00:00
2024-12-31 03:16:50 +00:00
PCInfoUI_PCListCard SelectCard;
2024-12-31 04:49:01 +00:00
AsyncOperationHandle<Texture> currentHandle;
2024-12-31 03:16:50 +00:00
public void Set(PCInfoUI_PCListCard choiceCard)
2024-12-15 01:39:39 +00:00
{
2024-12-31 03:16:50 +00:00
if (!DSUtil.CheckNull(SelectCard))
SelectCard.gos[0].SetActive(false);
SelectCard = choiceCard;
SelectCard.gos[0].SetActive(true);
SelectCard = choiceCard;
2024-12-31 04:49:01 +00:00
var costumeid = SelectCard.Get_IntData();
var costumeData = table_costumelist.Ins.Get_Data_orNull(costumeid);
RawImage_costume.enabled = false;
if (!DSUtil.CheckNull(costumeData))
{
AddrResourceMgr.Ins.LoadObject<Texture>($"Assets/Res_Addr/PCCostumeImage/{costumeData.s_Image}.png", handle =>
{
2024-12-31 04:49:01 +00:00
if (currentHandle.IsValid())
{
Addressables.Release(currentHandle);
RawImage_costume.texture = null; // 기존 Texture 참조 해제
}
currentHandle = handle;
RawImage_costume.enabled = true;
RawImage_costume.texture = handle.Result;
});
2024-12-30 05:00:34 +00:00
Set_3DModel($"Assets/Res_Addr/PC/{costumeData.s_Prefab}.prefab");
}
2024-12-31 04:49:01 +00:00
gos[0].SetActive(CanEquip());
}
bool CanEquip()
{
var sdata = ServerInfo.Ins.m_ServerData;
var costumeid = SelectCard.Get_IntData();
if (sdata.Get_EqiupmentEquip(eItem.PCCostume) == costumeid || !sdata.IsObtainItem(costumeid))
return false;
return true;
2024-12-15 01:39:39 +00:00
}
2024-12-31 03:16:50 +00:00
public void OnClick_EquipCostume()
{
2024-12-31 04:49:01 +00:00
if (!CanEquip()) return;
var sdata = ServerInfo.Ins.m_ServerData;
sdata.Equip.Set_Equip(eItem.PCCostume, SelectCard.Get_IntData());
PCInfoUI.Ins.Set();
2024-12-31 03:16:50 +00:00
}
2024-12-15 01:39:39 +00:00
}