switch set, automatize more of the content without UI change
This commit is contained in:
@@ -1,325 +1,246 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Set.Data;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ChampionSelector : MonoBehaviour
|
||||
namespace UI
|
||||
{
|
||||
[SerializeField] private bool _defaultSelection = false;
|
||||
[SerializeField]
|
||||
Toggle _ASHESelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _BLITZCRANKSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _ELISESelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _JAXSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _JAYCESelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _LILLIASelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _NOMSYSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _POPPYSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _SERAPHINESelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _SORAKASelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _TWITCHSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _WARWICKSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _ZIGGSSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _ZOESelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _AHRISelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _AKALISelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _CASSIOPEIASelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _GALIOSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _KASSADINSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _KOGMAWSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _NILAHSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _NUNUSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _RUMBLESelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _SHYVANASelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _SYNDRASelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _TRISTANASelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _ZILEANSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _BARDSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _EZREALSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _HECARIMSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _HWEISelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _JINXSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _KATARINASelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _MORDEKAISERSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _NEEKOSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _SHENSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _SWAINSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _VEIGARSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _VEXSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _WUKONGSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _FIORASelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _GWENSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _KALISTASelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _KARMASelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _NAMISelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _NASUSSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _OLAFSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _RAKANSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _RYZESelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _TAHMKENCHSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _TARICSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _VARUSSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _BRIARSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _CAMILLESelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _DIANASelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _MILLIOSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _MORGANASelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _NORRASelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _SMOLDERSelector;
|
||||
|
||||
[SerializeField]
|
||||
Toggle _XERATHSelector;
|
||||
|
||||
|
||||
public HashSet<ChampionsEnum> GetSelectedChampions()
|
||||
public class ChampionSelector : MonoBehaviour
|
||||
{
|
||||
var selectedChampions = new HashSet<ChampionsEnum>();
|
||||
[Header("Configuration")]
|
||||
[SerializeField]
|
||||
private bool _defaultSelection = false;
|
||||
|
||||
if (_ASHESelector.isOn) selectedChampions.Add(ChampionsEnum.ASHE);
|
||||
if (_BLITZCRANKSelector.isOn) selectedChampions.Add(ChampionsEnum.BLITZCRANK);
|
||||
if (_ELISESelector.isOn) selectedChampions.Add(ChampionsEnum.ELISE);
|
||||
if (_JAXSelector.isOn) selectedChampions.Add(ChampionsEnum.JAX);
|
||||
if (_JAYCESelector.isOn) selectedChampions.Add(ChampionsEnum.JAYCE);
|
||||
if (_LILLIASelector.isOn) selectedChampions.Add(ChampionsEnum.LILLIA);
|
||||
if (_NOMSYSelector.isOn) selectedChampions.Add(ChampionsEnum.NOMSY);
|
||||
if (_POPPYSelector.isOn) selectedChampions.Add(ChampionsEnum.POPPY);
|
||||
if (_SERAPHINESelector.isOn) selectedChampions.Add(ChampionsEnum.SERAPHINE);
|
||||
if (_SORAKASelector.isOn) selectedChampions.Add(ChampionsEnum.SORAKA);
|
||||
if (_TWITCHSelector.isOn) selectedChampions.Add(ChampionsEnum.TWITCH);
|
||||
if (_WARWICKSelector.isOn) selectedChampions.Add(ChampionsEnum.WARWICK);
|
||||
if (_ZIGGSSelector.isOn) selectedChampions.Add(ChampionsEnum.ZIGGS);
|
||||
if (_ZOESelector.isOn) selectedChampions.Add(ChampionsEnum.ZOE);
|
||||
if (_AHRISelector.isOn) selectedChampions.Add(ChampionsEnum.AHRI);
|
||||
if (_AKALISelector.isOn) selectedChampions.Add(ChampionsEnum.AKALI);
|
||||
if (_CASSIOPEIASelector.isOn) selectedChampions.Add(ChampionsEnum.CASSIOPEIA);
|
||||
if (_GALIOSelector.isOn) selectedChampions.Add(ChampionsEnum.GALIO);
|
||||
if (_KASSADINSelector.isOn) selectedChampions.Add(ChampionsEnum.KASSADIN);
|
||||
if (_KOGMAWSelector.isOn) selectedChampions.Add(ChampionsEnum.KOGMAW);
|
||||
if (_NILAHSelector.isOn) selectedChampions.Add(ChampionsEnum.NILAH);
|
||||
if (_NUNUSelector.isOn) selectedChampions.Add(ChampionsEnum.NUNU);
|
||||
if (_RUMBLESelector.isOn) selectedChampions.Add(ChampionsEnum.RUMBLE);
|
||||
if (_SHYVANASelector.isOn) selectedChampions.Add(ChampionsEnum.SHYVANA);
|
||||
if (_SYNDRASelector.isOn) selectedChampions.Add(ChampionsEnum.SYNDRA);
|
||||
if (_TRISTANASelector.isOn) selectedChampions.Add(ChampionsEnum.TRISTANA);
|
||||
if (_ZILEANSelector.isOn) selectedChampions.Add(ChampionsEnum.ZILEAN);
|
||||
if (_BARDSelector.isOn) selectedChampions.Add(ChampionsEnum.BARD);
|
||||
if (_EZREALSelector.isOn) selectedChampions.Add(ChampionsEnum.EZREAL);
|
||||
if (_HECARIMSelector.isOn) selectedChampions.Add(ChampionsEnum.HECARIM);
|
||||
if (_HWEISelector.isOn) selectedChampions.Add(ChampionsEnum.HWEI);
|
||||
if (_JINXSelector.isOn) selectedChampions.Add(ChampionsEnum.JINX);
|
||||
if (_KATARINASelector.isOn) selectedChampions.Add(ChampionsEnum.KATARINA);
|
||||
if (_MORDEKAISERSelector.isOn) selectedChampions.Add(ChampionsEnum.MORDEKAISER);
|
||||
if (_NEEKOSelector.isOn) selectedChampions.Add(ChampionsEnum.NEEKO);
|
||||
if (_SHENSelector.isOn) selectedChampions.Add(ChampionsEnum.SHEN);
|
||||
if (_SWAINSelector.isOn) selectedChampions.Add(ChampionsEnum.SWAIN);
|
||||
if (_VEIGARSelector.isOn) selectedChampions.Add(ChampionsEnum.VEIGAR);
|
||||
if (_VEXSelector.isOn) selectedChampions.Add(ChampionsEnum.VEX);
|
||||
if (_WUKONGSelector.isOn) selectedChampions.Add(ChampionsEnum.WUKONG);
|
||||
if (_FIORASelector.isOn) selectedChampions.Add(ChampionsEnum.FIORA);
|
||||
if (_GWENSelector.isOn) selectedChampions.Add(ChampionsEnum.GWEN);
|
||||
if (_KALISTASelector.isOn) selectedChampions.Add(ChampionsEnum.KALISTA);
|
||||
if (_KARMASelector.isOn) selectedChampions.Add(ChampionsEnum.KARMA);
|
||||
if (_NAMISelector.isOn) selectedChampions.Add(ChampionsEnum.NAMI);
|
||||
if (_NASUSSelector.isOn) selectedChampions.Add(ChampionsEnum.NASUS);
|
||||
if (_OLAFSelector.isOn) selectedChampions.Add(ChampionsEnum.OLAF);
|
||||
if (_RAKANSelector.isOn) selectedChampions.Add(ChampionsEnum.RAKAN);
|
||||
if (_RYZESelector.isOn) selectedChampions.Add(ChampionsEnum.RYZE);
|
||||
if (_TAHMKENCHSelector.isOn) selectedChampions.Add(ChampionsEnum.TAHMKENCH);
|
||||
if (_TARICSelector.isOn) selectedChampions.Add(ChampionsEnum.TARIC);
|
||||
if (_VARUSSelector.isOn) selectedChampions.Add(ChampionsEnum.VARUS);
|
||||
if (_BRIARSelector.isOn) selectedChampions.Add(ChampionsEnum.BRIAR);
|
||||
if (_CAMILLESelector.isOn) selectedChampions.Add(ChampionsEnum.CAMILLE);
|
||||
if (_DIANASelector.isOn) selectedChampions.Add(ChampionsEnum.DIANA);
|
||||
if (_MILLIOSelector.isOn) selectedChampions.Add(ChampionsEnum.MILLIO);
|
||||
if (_MORGANASelector.isOn) selectedChampions.Add(ChampionsEnum.MORGANA);
|
||||
if (_NORRASelector.isOn) selectedChampions.Add(ChampionsEnum.NORRA);
|
||||
if (_SMOLDERSelector.isOn) selectedChampions.Add(ChampionsEnum.SMOLDER);
|
||||
if (_XERATHSelector.isOn) selectedChampions.Add(ChampionsEnum.XERATH);
|
||||
[SerializeField]
|
||||
private GameObject _championUIPrefab;
|
||||
|
||||
return selectedChampions;
|
||||
}
|
||||
[Header("Layout")]
|
||||
[SerializeField]
|
||||
private Transform _cost1Parent;
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
SetTo(_defaultSelection);
|
||||
}
|
||||
[SerializeField]
|
||||
private Transform _cost2Parent;
|
||||
|
||||
public void SetTo(bool on)
|
||||
{
|
||||
_ASHESelector.isOn = on;
|
||||
_BLITZCRANKSelector.isOn = on;
|
||||
_ELISESelector.isOn = on;
|
||||
_JAXSelector.isOn = on;
|
||||
_JAYCESelector.isOn = on;
|
||||
_LILLIASelector.isOn = on;
|
||||
_NOMSYSelector.isOn = on;
|
||||
_POPPYSelector.isOn = on;
|
||||
_SERAPHINESelector.isOn = on;
|
||||
_SORAKASelector.isOn = on;
|
||||
_TWITCHSelector.isOn = on;
|
||||
_WARWICKSelector.isOn = on;
|
||||
_ZIGGSSelector.isOn = on;
|
||||
_ZOESelector.isOn = on;
|
||||
_AHRISelector.isOn = on;
|
||||
_AKALISelector.isOn = on;
|
||||
_CASSIOPEIASelector.isOn = on;
|
||||
_GALIOSelector.isOn = on;
|
||||
_KASSADINSelector.isOn = on;
|
||||
_KOGMAWSelector.isOn = on;
|
||||
_NILAHSelector.isOn = on;
|
||||
_NUNUSelector.isOn = on;
|
||||
_RUMBLESelector.isOn = on;
|
||||
_SHYVANASelector.isOn = on;
|
||||
_SYNDRASelector.isOn = on;
|
||||
_TRISTANASelector.isOn = on;
|
||||
_ZILEANSelector.isOn = on;
|
||||
_BARDSelector.isOn = on;
|
||||
_EZREALSelector.isOn = on;
|
||||
_HECARIMSelector.isOn = on;
|
||||
_HWEISelector.isOn = on;
|
||||
_JINXSelector.isOn = on;
|
||||
_KATARINASelector.isOn = on;
|
||||
_MORDEKAISERSelector.isOn = on;
|
||||
_NEEKOSelector.isOn = on;
|
||||
_SHENSelector.isOn = on;
|
||||
_SWAINSelector.isOn = on;
|
||||
_VEIGARSelector.isOn = on;
|
||||
_VEXSelector.isOn = on;
|
||||
_WUKONGSelector.isOn = on;
|
||||
_FIORASelector.isOn = on;
|
||||
_GWENSelector.isOn = on;
|
||||
_KALISTASelector.isOn = on;
|
||||
_KARMASelector.isOn = on;
|
||||
_NAMISelector.isOn = on;
|
||||
_NASUSSelector.isOn = on;
|
||||
_OLAFSelector.isOn = on;
|
||||
_RAKANSelector.isOn = on;
|
||||
_RYZESelector.isOn = on;
|
||||
_TAHMKENCHSelector.isOn = on;
|
||||
_TARICSelector.isOn = on;
|
||||
_VARUSSelector.isOn = on;
|
||||
_BRIARSelector.isOn = on;
|
||||
_CAMILLESelector.isOn = on;
|
||||
_DIANASelector.isOn = on;
|
||||
_MILLIOSelector.isOn = on;
|
||||
_MORGANASelector.isOn = on;
|
||||
_NORRASelector.isOn = on;
|
||||
_SMOLDERSelector.isOn = on;
|
||||
_XERATHSelector.isOn = on;
|
||||
[SerializeField]
|
||||
private Transform _cost3Parent;
|
||||
|
||||
[SerializeField]
|
||||
private Transform _cost4Parent;
|
||||
|
||||
[SerializeField]
|
||||
private Transform _cost5Parent;
|
||||
|
||||
[Header("Optional: Champion Icons")]
|
||||
[SerializeField]
|
||||
|
||||
private Dictionary<ChampionsEnum, ChampionBaseUI> _championUIs =
|
||||
new Dictionary<ChampionsEnum, ChampionBaseUI>();
|
||||
|
||||
|
||||
// Champion definitions with display names and costs
|
||||
private readonly Dictionary<ChampionsEnum, ChampionDisplayInfo> _championDisplayInfo =
|
||||
new Dictionary<ChampionsEnum, ChampionDisplayInfo>
|
||||
{
|
||||
// Cost 1 Champions
|
||||
{ ChampionsEnum.AATROX, new ChampionDisplayInfo("Aatrox", 1) },
|
||||
{ ChampionsEnum.EZREAL, new ChampionDisplayInfo("Ezreal", 1) },
|
||||
{ ChampionsEnum.GAREN, new ChampionDisplayInfo("Garen", 1) },
|
||||
{ ChampionsEnum.GNAR, new ChampionDisplayInfo("Gnar", 1) },
|
||||
{ ChampionsEnum.KALISTA, new ChampionDisplayInfo("Kalista", 1) },
|
||||
{ ChampionsEnum.KAYLE, new ChampionDisplayInfo("Kayle", 1) },
|
||||
{ ChampionsEnum.KENNEN, new ChampionDisplayInfo("Kennen", 1) },
|
||||
{ ChampionsEnum.LUCIAN, new ChampionDisplayInfo("Lucian", 1) },
|
||||
{ ChampionsEnum.MALPHITE, new ChampionDisplayInfo("Malphite", 1) },
|
||||
{ ChampionsEnum.NAAFIRI, new ChampionDisplayInfo("Naafiri", 1) },
|
||||
{ ChampionsEnum.RELL, new ChampionDisplayInfo("Rell", 1) },
|
||||
{ ChampionsEnum.SIVIR, new ChampionDisplayInfo("Sivir", 1) },
|
||||
{ ChampionsEnum.SYNDRA, new ChampionDisplayInfo("Syndra", 1) },
|
||||
{ ChampionsEnum.ZAC, new ChampionDisplayInfo("Zac", 1) },
|
||||
// Cost 2 Champions
|
||||
{ ChampionsEnum.DRMUNDO, new ChampionDisplayInfo("Dr. Mundo", 2) },
|
||||
{ ChampionsEnum.GANGPLANK, new ChampionDisplayInfo("Gangplank", 2) },
|
||||
{ ChampionsEnum.JANNA, new ChampionDisplayInfo("Janna", 2) },
|
||||
{ ChampionsEnum.JHIN, new ChampionDisplayInfo("Jhin", 2) },
|
||||
{ ChampionsEnum.KAISA, new ChampionDisplayInfo("Kai'Sa", 2) },
|
||||
{ ChampionsEnum.KATARINA, new ChampionDisplayInfo("Katarina", 2) },
|
||||
{ ChampionsEnum.KOBUKO, new ChampionDisplayInfo("Kobuko", 2) },
|
||||
{ ChampionsEnum.LUX, new ChampionDisplayInfo("Lux", 2) },
|
||||
{ ChampionsEnum.RAKAN, new ChampionDisplayInfo("Rakan", 2) },
|
||||
{ ChampionsEnum.SHEN, new ChampionDisplayInfo("Shen", 2) },
|
||||
{ ChampionsEnum.VI, new ChampionDisplayInfo("Vi", 2) },
|
||||
{ ChampionsEnum.XAYAH, new ChampionDisplayInfo("Xayah", 2) },
|
||||
{ ChampionsEnum.XINZHAO, new ChampionDisplayInfo("Xin Zhao", 2) },
|
||||
// Cost 3 Champions
|
||||
{ ChampionsEnum.AHRI, new ChampionDisplayInfo("Ahri", 3) },
|
||||
{ ChampionsEnum.CAITLYN, new ChampionDisplayInfo("Caitlyn", 3) },
|
||||
{ ChampionsEnum.DARIUS, new ChampionDisplayInfo("Darius", 3) },
|
||||
{ ChampionsEnum.JAYCE, new ChampionDisplayInfo("Jayce", 3) },
|
||||
{ ChampionsEnum.KOGMAW, new ChampionDisplayInfo("Kog'Maw", 3) },
|
||||
{ ChampionsEnum.LULU, new ChampionDisplayInfo("Lulu", 3) },
|
||||
{ ChampionsEnum.MALZAHAR, new ChampionDisplayInfo("Malzahar", 3) },
|
||||
{ ChampionsEnum.NEEKO, new ChampionDisplayInfo("Neeko", 3) },
|
||||
{ ChampionsEnum.RAMMUS, new ChampionDisplayInfo("Rammus", 3) },
|
||||
{ ChampionsEnum.SENNA, new ChampionDisplayInfo("Senna", 3) },
|
||||
{ ChampionsEnum.SMOLDER, new ChampionDisplayInfo("Smolder", 3) },
|
||||
{ ChampionsEnum.SWAIN, new ChampionDisplayInfo("Swain", 3) },
|
||||
{ ChampionsEnum.UDYR, new ChampionDisplayInfo("Udyr", 3) },
|
||||
{ ChampionsEnum.VIEGO, new ChampionDisplayInfo("Viego", 3) },
|
||||
{ ChampionsEnum.YASUO, new ChampionDisplayInfo("Yasuo", 3) },
|
||||
{ ChampionsEnum.ZIGGS, new ChampionDisplayInfo("Ziggs", 3) },
|
||||
// Cost 4 Champions
|
||||
{ ChampionsEnum.AKALI, new ChampionDisplayInfo("Akali", 4) },
|
||||
{ ChampionsEnum.ASHE, new ChampionDisplayInfo("Ashe", 4) },
|
||||
{ ChampionsEnum.JARVANIV, new ChampionDisplayInfo("Jarvan IV", 4) },
|
||||
{ ChampionsEnum.JINX, new ChampionDisplayInfo("Jinx", 4) },
|
||||
{ ChampionsEnum.KARMA, new ChampionDisplayInfo("Karma", 4) },
|
||||
{ ChampionsEnum.KSANTE, new ChampionDisplayInfo("K'Sante", 4) },
|
||||
{ ChampionsEnum.LEONA, new ChampionDisplayInfo("Leona", 4) },
|
||||
{ ChampionsEnum.POPPY, new ChampionDisplayInfo("Poppy", 4) },
|
||||
{ ChampionsEnum.RYZE, new ChampionDisplayInfo("Ryze", 4) },
|
||||
{ ChampionsEnum.SAMIRA, new ChampionDisplayInfo("Samira", 4) },
|
||||
{ ChampionsEnum.SETT, new ChampionDisplayInfo("Sett", 4) },
|
||||
{ ChampionsEnum.VOLIBEAR, new ChampionDisplayInfo("Volibear", 4) },
|
||||
{ ChampionsEnum.YUUMI, new ChampionDisplayInfo("Yuumi", 4) },
|
||||
// Cost 5 Champions
|
||||
{ ChampionsEnum.BRAUM, new ChampionDisplayInfo("Braum", 5) },
|
||||
{ ChampionsEnum.EKKO, new ChampionDisplayInfo("Ekko", 5) },
|
||||
{ ChampionsEnum.GWEN, new ChampionDisplayInfo("Gwen", 5) },
|
||||
{ ChampionsEnum.LEESIN, new ChampionDisplayInfo("Lee Sin", 5) },
|
||||
{ ChampionsEnum.SERAPHINE, new ChampionDisplayInfo("Seraphine", 5) },
|
||||
{ ChampionsEnum.TWISTEDFATE, new ChampionDisplayInfo("Twisted Fate", 5) },
|
||||
{ ChampionsEnum.VARUS, new ChampionDisplayInfo("Varus", 5) },
|
||||
};
|
||||
|
||||
[System.Serializable]
|
||||
public class ChampionIconData
|
||||
{
|
||||
public ChampionsEnum champion;
|
||||
public Sprite icon;
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
CreateChampionUIs();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void CreateChampionUIs()
|
||||
{
|
||||
if (_championUIPrefab == null)
|
||||
{
|
||||
Debug.LogError("Champion UI Prefab is not assigned!");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var kvp in _championDisplayInfo)
|
||||
{
|
||||
var champion = kvp.Key;
|
||||
var displayInfo = kvp.Value;
|
||||
|
||||
Transform parent = GetParentForCost(displayInfo.Cost);
|
||||
if (parent == null)
|
||||
continue;
|
||||
|
||||
GameObject championUI = Instantiate(_championUIPrefab, parent);
|
||||
ChampionBaseUI championBaseUI = championUI.GetComponent<ChampionBaseUI>();
|
||||
|
||||
if (championBaseUI != null)
|
||||
{
|
||||
championBaseUI.Initialize(champion, displayInfo.DisplayName, _defaultSelection);
|
||||
_championUIs[champion] = championBaseUI;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"ChampionBaseUI component not found on prefab for {champion}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Transform GetParentForCost(int cost)
|
||||
{
|
||||
return cost switch
|
||||
{
|
||||
1 => _cost1Parent,
|
||||
2 => _cost2Parent,
|
||||
3 => _cost3Parent,
|
||||
4 => _cost4Parent,
|
||||
5 => _cost5Parent,
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
public HashSet<Set.Data.ChampionsEnum> GetSelectedChampions()
|
||||
{
|
||||
var selectedChampions = new HashSet<Set.Data.ChampionsEnum>();
|
||||
|
||||
foreach (var kvp in _championUIs)
|
||||
{
|
||||
if (kvp.Value.IsSelected)
|
||||
{
|
||||
selectedChampions.Add(kvp.Key);
|
||||
}
|
||||
}
|
||||
|
||||
return selectedChampions;
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
ResetToDefault();
|
||||
}
|
||||
|
||||
public void SetTo(bool on)
|
||||
{
|
||||
if (on)
|
||||
SelectAll();
|
||||
else
|
||||
SelectNone();
|
||||
}
|
||||
|
||||
public void SetTo(Set.Data.ChampionsEnum championValue)
|
||||
{
|
||||
foreach (var kvp in _championUIs)
|
||||
{
|
||||
var champion = kvp.Key;
|
||||
var championUI = kvp.Value;
|
||||
|
||||
bool shouldBeSelected = (championValue & champion) == champion;
|
||||
championUI.SetSelected(shouldBeSelected);
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetToDefault()
|
||||
{
|
||||
foreach (var championUI in _championUIs.Values)
|
||||
{
|
||||
championUI.ResetToDefault();
|
||||
}
|
||||
}
|
||||
|
||||
public void SelectAll()
|
||||
{
|
||||
foreach (var championUI in _championUIs.Values)
|
||||
{
|
||||
championUI.SetSelected(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void SelectNone()
|
||||
{
|
||||
foreach (var championUI in _championUIs.Values)
|
||||
{
|
||||
championUI.SetSelected(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetInteractable(bool interactable)
|
||||
{
|
||||
foreach (var championUI in _championUIs.Values)
|
||||
{
|
||||
championUI.SetInteractable(interactable);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user