Files
test/Assets/PerfectWorld/Scripts/UI/Dialogs/DlgPetList.cs
T
Tungdv 7a96c7e252 Merge remote-tracking branch 'origin/develop' into feature/hp_pet
# Conflicts:
#	Assets/AddressableAssetsData/AddressableAssetSettings.asset
#	Assets/AddressableAssetsData/AssetGroups/Default Local Group.asset
#	Assets/PerfectWorld/Scripts/MainFiles/EC_Game.cs
#	Assets/PerfectWorld/Scripts/Move/CECPlayer.cs
#	Assets/PerfectWorld/Scripts/NPC/CECNPC.cs
#	Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommand.cs
#	Assets/PerfectWorld/Scripts/Network/CSNetwork/C2SCommand/C2SCommandFactory.cs
#	Assets/PerfectWorld/Scripts/Network/CSNetwork/GPDataType.cs
#	Assets/PerfectWorld/Scripts/Network/CSNetwork/GameSession.cs
#	Assets/PerfectWorld/Scripts/Network/UnityGameSession.cs
#	Assets/PerfectWorld/Scripts/UI/Dialogs/DlgPetList.cs
#	Assets/PerfectWorld/Scripts/UI/Dialogs/DlgPetList.cs.meta
#	Assets/PerfectWorld/Scripts/UI/Login/LoginScreenUI.cs
#	Assets/Scenes/a61.unity
#	Assets/Scripts/CECGameRun.cs
#	Assets/Scripts/CECHostPlayer.cs
#	Assets/Scripts/CECUIManager.cs
2026-02-05 17:29:54 +07:00

182 lines
8.1 KiB
C#

using BrewMonster.Network;
using BrewMonster.Scripts.Pet;
using CSNetwork.GPDataType;
using ModelRenderer.Scripts.GameData;
using System;
using System.IO;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
namespace BrewMonster.UI
{
public class CDlgPetList : AUIDialog
{
public const int CDLGPETLIST_SLOT_MAX = 10;
public const int CDLGPETLIST_PAGE_MAX = 2;
[SerializeField] private Button[] m_pBtn_Summon = new Button[CDLGPETLIST_SLOT_MAX];
[SerializeField] private Button[] m_pBtn_Recall = new Button[CDLGPETLIST_SLOT_MAX];
[SerializeField] private Button[] m_pBtn_Detail = new Button[CDLGPETLIST_SLOT_MAX];
[SerializeField] private Button[] m_pBtn_Banish = new Button[CDLGPETLIST_SLOT_MAX];
[SerializeField] private Button[] m_pBtn_Evolution = new Button[CDLGPETLIST_SLOT_MAX];
[SerializeField] private Image[] m_pImg_Icon = new Image[CDLGPETLIST_SLOT_MAX];
[SerializeField] private TextMeshProUGUI[] m_pLab_Name = new TextMeshProUGUI[CDLGPETLIST_SLOT_MAX];
[SerializeField] private TextMeshProUGUI[] m_pLab_Level = new TextMeshProUGUI[CDLGPETLIST_SLOT_MAX];
[SerializeField] private TextMeshProUGUI[] m_pTxt_Name = new TextMeshProUGUI[CDLGPETLIST_SLOT_MAX];
[SerializeField] private TextMeshProUGUI[] m_pTxt_Level = new TextMeshProUGUI[CDLGPETLIST_SLOT_MAX];
int m_nPageIndex;
public void OnInitDialog()
{
//string szText = "";
//int i;
//for (i = 0; i < CDLGPETLIST_SLOT_MAX; i++)
//{
// szText = string.Format("Img_Icon{0}", i + 1);
// m_pImg_Icon[i] = (PAUIIMAGEPICTURE)GetDlgItem(szText);
// sprintf(szText, "Lab_Name%d", i + 1);
// m_pLab_Name[i] = (PAUILABEL)GetDlgItem(szText);
// sprintf(szText, "Lab_Level%d", i + 1);
// m_pLab_Level[i] = (PAUILABEL)GetDlgItem(szText);
// sprintf(szText, "Txt_Name%d", i + 1);
// m_pTxt_Name[i] = (PAUILABEL)GetDlgItem(szText);
// sprintf(szText, "Txt_Level%d", i + 1);
// m_pTxt_Level[i] = (PAUILABEL)GetDlgItem(szText);
// sprintf(szText, "Btn_Recall%d", i + 1);
// m_pBtn_Recall[i] = (PAUIIMAGEPICTURE)GetDlgItem(szText);
// sprintf(szText, "Btn_Summon%d", i + 1);
// m_pBtn_Summon[i] = (PAUIIMAGEPICTURE)GetDlgItem(szText);
// sprintf(szText, "Btn_Detail%d", i + 1);
// m_pBtn_Detail[i] = (PAUIIMAGEPICTURE)GetDlgItem(szText);
// sprintf(szText, "Btn_Banish%d", i + 1);
// m_pBtn_Banish[i] = (PAUIIMAGEPICTURE)GetDlgItem(szText);
// sprintf(szText, "Btn_P%d", i + 1);
// m_pBtn_Evolution[i] = (PAUIIMAGEPICTURE)GetDlgItem(szText);
//}
//for (i = 0; i < CDLGPETLIST_PAGE_MAX; i++)
//{
// m_pBtn_Page[i] = NULL;
// DDX_Control(AString().Format("Btn_Page%d", i + 1), m_pBtn_Page[i]);
// m_pBtn_Page[i].SetPushed(false);
//}
//m_nPageIndex = 0;
//m_pBtn_Page[0].SetPushed(true);
//return true;
}
bool IsPetDye(int nSlot)
{
return false;
//TO DO: fix later
//return nSlot >= 0
// && GetGameUIMan().m_pDlgPetDye.IsShow()
// && GetGameUIMan().m_pDlgPetDye.GetPetSlot() == nSlot;
}
void UpdateList()
{
string strText = "";
CECPetCorral pPetCorral = GetHostPlayer().GetPetCorral();
elementdataman pDB = ElementDataManProvider.GetElementDataMan();
DATA_TYPE DataType = new DATA_TYPE();
int i;
for (i = 0; i < CDLGPETLIST_SLOT_MAX; i++)
{
int nPetSlot = i + m_nPageIndex * CDLGPETLIST_SLOT_MAX;
if (nPetSlot < pPetCorral.GetPetSlotNum())
{
m_pLab_Level[i].color = new Color(255f / 255f, 203f / 255f, 74f / 255f);
m_pLab_Name[i].color = new Color(255f / 255f, 203f / 255f, 74f / 255f);
}
else
{
m_pLab_Level[i].color = new Color(128f / 128f, 128f / 128f, 128f / 128f);
m_pLab_Name[i].color = new Color(128f / 128f, 128f / 128f, 128f / 128f);
}
CECPetData pPet = pPetCorral.GetPetData(nPetSlot);
if (pPet != null)
{
bool bEnable = (pPetCorral.GetActivePetIndex() == nPetSlot && GetHostPlayer().IsOperatingPet() == 0);
m_pBtn_Recall[i].enabled = (bEnable);
bEnable = (pPetCorral.GetActivePetIndex() != nPetSlot && GetHostPlayer().IsOperatingPet() == 0);
m_pBtn_Summon[i].gameObject.SetActive(bEnable);
m_pBtn_Detail[i].gameObject.SetActive(true);
strText = string.Format(GetStringFromTable(801).Replace("%d", "{0}"), pPet.GetLevel());
m_pTxt_Level[i].SetText(strText);
m_pTxt_Name[i].SetText(pPet.GetName());
if ((pPet.GetClass() == (int)GP_PET_TYPE.GP_PET_CLASS_COMBAT || pPet.GetClass() == (int)GP_PET_TYPE.GP_PET_CLASS_EVOLUTION) && pPet.GetHPFactor() == 0.0f || IsPetDye(nPetSlot))
m_pImg_Icon[i].color = new Color(128f/ 255f, 128f / 255f, 128f / 255f);
else
m_pImg_Icon[i].color = new Color(255f/ 255f, 255f / 255f, 255f / 255f);
//m_pImg_Icon[i].SetData(1);
//m_pImg_Icon[i].SetDataPtr((void*)1);
object pDBEssence = pDB.get_data_ptr((uint)pPet.GetTemplateID(),
ID_SPACE.ID_SPACE_ESSENCE, ref DataType);
if (pDBEssence != null)
{
PET_ESSENCE pET = (PET_ESSENCE)pDBEssence;
string strFile = "";
af_GetFileTitle(pET.FileIcon,out strFile);
strFile.ToLower();
m_pImg_Icon[i].sprite = EC_Game.GetGameRun().GetUIManager().GetSpriteInListIvtr(strFile);
}
else
{
m_pImg_Icon[i].sprite = null;
//m_pImg_Icon[i].SetHint(_AL(""));
}
m_pBtn_Evolution[i].gameObject.SetActive(pPet.GetClass() == (int)GP_PET_TYPE.GP_PET_CLASS_COMBAT || pPet.GetClass() == (int)GP_PET_TYPE.GP_PET_CLASS_EVOLUTION);
}
else
{
m_pBtn_Summon[i].gameObject.SetActive(false);
m_pBtn_Recall[i].gameObject.SetActive(false);
m_pBtn_Detail[i].gameObject.SetActive(false);
m_pBtn_Evolution[i].gameObject.SetActive(false);
// m_pBtn_Banish[i].Enable(false);
//m_pImg_Icon[i].SetDataPtr(NULL);
m_pTxt_Level[i].text = "";
m_pTxt_Name[i].text = "";
m_pImg_Icon[i].sprite = null;
//m_pImg_Icon[i].SetHint(_AL(""));
//m_pImg_Icon[i].SetData(0);
}
}
}
public bool af_GetFileTitle(string lpszFile, out string lpszTitle)
{
lpszTitle = string.Empty;
if (string.IsNullOrEmpty(lpszFile))
return lpszFile != null;
if (lpszFile.EndsWith("\\") || lpszFile.EndsWith("/"))
return false;
lpszTitle = Path.GetFileNameWithoutExtension(lpszFile);
return true;
}
public void OnCommandSummon(int slot)
{
CECPetCorral pPetCorral = GetHostPlayer().GetPetCorral();
int nSlot = slot - 1;
nSlot += m_nPageIndex* CDLGPETLIST_SLOT_MAX;
// ·ÉÐÐ-¡·Æï³Ë
if (GetHostPlayer().GetActionSwitcher() != null && GetHostPlayer().GetActionSwitcher().OnFlyToRideAction(nSlot))
return;
GetHostPlayer().SummonPet(nSlot);
}
}
}