Files
test/Assets/PerfectWorld/Scripts/UI/SkillUI/DlgAssignSub.cs
T
2026-03-18 13:40:27 +07:00

93 lines
3.4 KiB
C#

using BrewMonster.Assets.PerfectWorld.Scripts.UI.GamePlay;
using BrewMonster.UI;
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace BrewMonster
{
public class DlgAssignSub : AUIDialog
{
private readonly SortedSet<int> m_skills = new();
[SerializeField] private Transform ptSkillContainer;
[SerializeField] private Transform psSkillContainer;
[SerializeField] private List<AUIToggle> psSkillSlotList;
[SerializeField] private List<AUIToggle> ptSkillSlotList;
private void Awake()
{
SetUp();
}
private void SetUp()
{
LoadChildToList(ptSkillContainer, ptSkillSlotList);
LoadChildToList(psSkillContainer, psSkillSlotList);
}
private void LoadChildToList(Transform parentTF, List<AUIToggle> slotList)
{
foreach (Transform child in parentTF)
{
AUIToggle img = child.GetComponent<AUIToggle>();
if (img != null)
{
slotList.Add(img);
}
}
}
public override void OnEnable()
{
UpdateView();
}
private void UpdateView()
{
m_skills.Clear();
CECHostPlayer pHost = GetHostPlayer();
int i = 0;
int activeImgPicIndex = 1;
int passiveImgPicIndex = 1;
int positiveSkillNum = pHost.GetPositiveSkillNum();
int equipSkillNum = pHost.GetEquipSkillNum();
int passiveSkillNum = pHost.GetPassiveSkillNum();
for (i = 0; i < positiveSkillNum; i++)
{
var processSkill = pHost.GetPositiveSkillByIndex(i);
var processSkillID = processSkill.GetSkillID();
if (ptSkillSlotList.Count <= i)
{
var newSkillSlot = Instantiate(ptSkillSlotList[0], ptSkillContainer);
newSkillSlot.name = $"Item_{processSkillID}";
ptSkillSlotList.Add(newSkillSlot);
}
SetImage(processSkill, ptSkillSlotList[i]);
ptSkillSlotList[i].transform.GetChild(0).gameObject.SetActive(true);
ptSkillSlotList[i].SetSkillID(processSkillID);
m_skills.Add(processSkillID);
}
// for (i = 0; i < passiveSkillNum; i++)
// {
// if (psSkillSlotList.Count <= i)
// {
// psSkillSlotList.Add(Instantiate(psSkillSlotList[0], psSkillContainer));
// }
// psSkillSlotList[i].transform.GetChild(0).gameObject.SetActive(true);
// SetImage(pHost.GetPassiveSkillByIndex(i), psSkillSlotList[i]);
// m_skills.Add(pHost.GetPassiveSkillByIndex(i).GetSkillID());
// }
}
private void SetImage(CECSkill cECSkill, AUIToggle learnedSkillUI)
{
if(cECSkill == null)
{
BMLogger.LogError("CDlgSkillSubPool::SetImage cECSkill is null");
return;
}
BMLogger.Log($"CDlgSkillSubPool::SetImage SkillID={cECSkill.GetSkillID()} SkillName={cECSkill.GetName()} IconFile={cECSkill.GetIconFile()}");
GetGameUIMan().SetCover(learnedSkillUI, cECSkill.GetIconFile(), EC_GAMEUI_ICONS.ICONS_SKILL);
}
}
}