88 lines
3.2 KiB
C#
88 lines
3.2 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 CDlgSkillSubPool : AUIDialog
|
|
{
|
|
private readonly SortedSet<int> m_skills = new();
|
|
[SerializeField] private Transform ptSkillContainer;
|
|
[SerializeField] private Transform psSkillContainer;
|
|
[SerializeField] private List<AUIImagePicture> psSkillSlotList;
|
|
[SerializeField] private List<AUIImagePicture> ptSkillSlotList;
|
|
|
|
private void Awake()
|
|
{
|
|
SetUp();
|
|
}
|
|
|
|
private void SetUp()
|
|
{
|
|
LoadChildToList(ptSkillContainer, ptSkillSlotList);
|
|
LoadChildToList(psSkillContainer, psSkillSlotList);
|
|
}
|
|
private void LoadChildToList(Transform parentTF, List<AUIImagePicture> slotList)
|
|
{
|
|
foreach (Transform child in parentTF)
|
|
{
|
|
AUIImagePicture img = child.GetComponent<AUIImagePicture>();
|
|
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++)
|
|
{
|
|
if (ptSkillSlotList.Count <= i)
|
|
{
|
|
ptSkillSlotList.Add(Instantiate(ptSkillSlotList[0], ptSkillContainer));
|
|
}
|
|
ptSkillSlotList[i].transform.GetChild(0).gameObject.SetActive(true);
|
|
SetImage(pHost.GetPositiveSkillByIndex(i), ptSkillSlotList[i]);
|
|
m_skills.Add(pHost.GetPositiveSkillByIndex(i).GetSkillID());
|
|
}
|
|
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, AUIImagePicture 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);
|
|
}
|
|
}
|
|
}
|