Files
test/Assets/PerfectWorld/Scripts/UI/Action/CDlgSkillSubAction.cs
T
2026-02-03 14:57:23 +07:00

120 lines
3.7 KiB
C#

using BrewMonster.Assets.PerfectWorld.Scripts.UI.GamePlay;
using BrewMonster.UI;
using System;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
namespace BrewMonster
{
public class CDlgSkillSubAction : MonoBehaviour
{
[SerializeField] List<ActionInfo> m_aActionInfo = new List<ActionInfo>();
[SerializeField] Transform orderContain;
[SerializeField] AUIImagePicture orderTemplate;
[SerializeField] AUIImagePicture actionTemplate;
[SerializeField] Transform actionContain;
private void Awake()
{
if (orderContain == null)
{
BMLogger.LogError("CDlgSkillSubAction: orderContain is not assigned!");
return;
}
;
if (actionContain == null)
{
BMLogger.LogError("CDlgSkillSubAction: actionContain is not assigned!");
return;
}
Init();
}
private void OnEnable()
{
OnShowDialog();
}
public void Init()
{
int[] objCount = { 8, 2, 2, 27 };
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < objCount[i]; j++)
{
var orderTP = Instantiate(orderTemplate, orderContain);
orderTP.gameObject.SetActive(true);
m_aActionInfo.Add(new ActionInfo
{
image = orderTP,
pLabel = orderTP.GetComponentInChildren<TextMeshProUGUI>()
});
}
}
for (int j = 0; j < 27; j++)
{
var actionTP = Instantiate(actionTemplate, actionContain);
actionTP.gameObject.SetActive(true);
m_aActionInfo.Add(new ActionInfo
{
image = actionTP,
pLabel = actionTP.GetComponentInChildren<TextMeshProUGUI>()
});
}
}
public void OnShowDialog()
{
AUIImagePicture pImage;
TextMeshProUGUI pLabel;
CECShortcut pSCThis;
string strFile = "";
var gameUIMan = CECUIManager.Instance.GetInGameUIMan();
CECGameRun pGameRun = CECGameRun.Instance;
int[] objCount = { 8, 2, 2, 27 };
CECShortcutSet[] a_pSC =
{
pGameRun.GetGenCmdShortcuts(),
pGameRun.GetTeamCmdShortcuts(),
pGameRun.GetTradeCmdShortcuts(),
pGameRun.GetPoseCmdShortcuts()
};
int count = 0;
for (int i = 0; i < a_pSC.Length; i++)
{
for (int j = 0; j < objCount[i]; j++)
{
pImage = m_aActionInfo[count].image;
pLabel = m_aActionInfo[count].pLabel;
if (!pImage) break;
if (j < a_pSC[i].GetShortcutNum())
{
pSCThis = a_pSC[i].GetShortcut(j);
pImage.SetDataPtr(pSCThis, "ptr_CECShortcut");
strFile = pSCThis.GetIconFile();
gameUIMan.SetCover(pImage, strFile, EC_GAMEUI_ICONS.ICONS_ACTION);
pLabel.SetText(pSCThis.GetDesc());
}
else
{
/* pImage->Show(false);
pLabel->Show(false);*/
}
count++;
}
}
}
[Serializable]
public struct ActionInfo
{
public AUIImagePicture image;
public TextMeshProUGUI pLabel;
}
}
}