169 lines
6.5 KiB
C#
169 lines
6.5 KiB
C#
using BrewMonster.Assets.PerfectWorld.Scripts.UI.GamePlay;
|
|
using BrewMonster.UI;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using BrewMonster.Network;
|
|
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;
|
|
[SerializeField] private SkillSetUpComboWidget _skillSetUpComboWidget;
|
|
|
|
private AUIImagePicture _currentSelectSkill;
|
|
private SkillSlotWidget _currentSelectComboSlot;
|
|
|
|
public override void Awake()
|
|
{
|
|
base.Awake();
|
|
SetUp();
|
|
foreach (var skill in ptSkillSlotList)
|
|
{
|
|
if (skill is LearnedSkillUI skillUI)
|
|
{
|
|
skillUI.OnClickedSkill += OnClickedSkill;
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void OnEnable()
|
|
{
|
|
UpdateView();
|
|
_skillSetUpComboWidget.ShowSetUpContent(false);
|
|
_skillSetUpComboWidget.OnClickedSkillSlot += OnClickedSkillSlot;
|
|
_skillSetUpComboWidget.OnClickedAssignSkill += OnClickedAssignSkill;
|
|
_skillSetUpComboWidget.OnClickedConfirmCombo += OnClickedConfirmCombo;
|
|
}
|
|
|
|
public override void OnDisable()
|
|
{
|
|
base.OnDisable();
|
|
_skillSetUpComboWidget.OnClickedSkillSlot -= OnClickedSkillSlot;
|
|
_skillSetUpComboWidget.OnClickedAssignSkill -= OnClickedAssignSkill;
|
|
_skillSetUpComboWidget.OnClickedConfirmCombo -= OnClickedConfirmCombo;
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
foreach (var skill in ptSkillSlotList)
|
|
{
|
|
if (skill is LearnedSkillUI skillUI)
|
|
{
|
|
skillUI.OnClickedSkill -= OnClickedSkill;
|
|
}
|
|
}
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void OnClickedSkill(AUIImagePicture imagePicture)
|
|
{
|
|
_currentSelectSkill = imagePicture;
|
|
}
|
|
|
|
private void UpdateView()
|
|
{
|
|
m_skills.Clear();
|
|
|
|
CECHostPlayer pHost = GetHostPlayer();
|
|
int i = 0;
|
|
int positiveSkillNum = pHost.GetPositiveSkillNum();
|
|
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);
|
|
// EC_VIDEO_SETTING setting = EC_Game.GetConfigs().GetVideoSettings();
|
|
// var setting.comboSkill[((CECSCSkillGrp*)pSC)->GetGroupIndex()].nIcon + 1
|
|
// GetGameUIMan().SetCover(psSkillSlotList[i], "unknown", EC_GAMEUI_ICONS.ICONS_SKILL);
|
|
// // pCell->SetCover(GetGameUIMan()->m_pA2DSpriteIcons[CECGameUIMan::ICONS_SKILLGRP],
|
|
// // );
|
|
// 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()}");
|
|
var slot = GetGameUIMan().SetCover(learnedSkillUI, cECSkill.GetIconFile(), EC_GAMEUI_ICONS.ICONS_SKILL);
|
|
if (slot is AUIImagePicture picture)
|
|
{
|
|
picture.SetSkillId(cECSkill.GetSkillID());
|
|
}
|
|
}
|
|
private void OnClickedSkillSlot(SkillSlotWidget skillSlot)
|
|
{
|
|
_currentSelectComboSlot = skillSlot;
|
|
// _skillSetUpComboWidget.ShowSetUpContent(true);
|
|
// allow show edit to create
|
|
if (_skillSetUpComboWidget.IsEmptyComboSlot(skillSlot.GetSlotIndex))
|
|
{
|
|
_skillSetUpComboWidget.ShowSetUpContent(true);
|
|
}
|
|
}
|
|
|
|
private void OnClickedConfirmCombo()
|
|
{
|
|
_skillSetUpComboWidget.ShowCurrentCombos();
|
|
if (_currentSelectComboSlot != null &&
|
|
_skillSetUpComboWidget.CurrentComboSetting.comboSkill[_currentSelectComboSlot.GetSlotIndex].idSkill == null)
|
|
{
|
|
BMLogger.LogError("Null to set combo skill");
|
|
return;
|
|
}
|
|
EC_Game.GetConfigs().SetVideoSettings(_skillSetUpComboWidget.CurrentComboSetting);
|
|
CECUIManager.Instance.m_pDlgSkillSubOther.UpdateComboSkill();
|
|
EC_Game.GetGameRun().SaveConfigsToServer();
|
|
}
|
|
|
|
//assign skill from list in the left ui
|
|
private void OnClickedAssignSkill(SkillSlotWidget slotWidget)
|
|
{
|
|
if(_currentSelectSkill != null && _currentSelectSkill is LearnedSkillUI skillUI)
|
|
{
|
|
_skillSetUpComboWidget.SetSkillToCurrentCombo(slotWidget.GetSlotIndex, (short)skillUI.SkillId);
|
|
}
|
|
}
|
|
}
|
|
}
|