switch set, automatize more of the content without UI change
This commit is contained in:
55
Assets/UI/ChampionBaseUI.cs
Normal file
55
Assets/UI/ChampionBaseUI.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using Set.Data;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class ChampionBaseUI : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private Text _championNameText;
|
||||
|
||||
[SerializeField]
|
||||
private Toggle _championToggle;
|
||||
|
||||
private ChampionsEnum _championType;
|
||||
private bool _defaultSelected = false;
|
||||
|
||||
public ChampionsEnum ChampionType => _championType;
|
||||
public bool IsSelected => _championToggle != null ? _championToggle.isOn : false;
|
||||
|
||||
public void Initialize(
|
||||
ChampionsEnum championType,
|
||||
string championDisplayName,
|
||||
bool defaultSelected = false
|
||||
)
|
||||
{
|
||||
_championType = championType;
|
||||
_championNameText.text = championDisplayName;
|
||||
_defaultSelected = defaultSelected;
|
||||
|
||||
// Set default selection state
|
||||
if (_championToggle != null)
|
||||
_championToggle.isOn = defaultSelected;
|
||||
}
|
||||
|
||||
public void SetSelected(bool selected)
|
||||
{
|
||||
if (_championToggle != null)
|
||||
_championToggle.isOn = selected;
|
||||
}
|
||||
|
||||
public void ResetToDefault()
|
||||
{
|
||||
if (_championToggle != null)
|
||||
_championToggle.isOn = _defaultSelected;
|
||||
}
|
||||
|
||||
public void SetInteractable(bool interactable)
|
||||
{
|
||||
if (_championToggle != null)
|
||||
_championToggle.interactable = interactable;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/UI/ChampionBaseUI.cs.meta
Normal file
2
Assets/UI/ChampionBaseUI.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 320b859d2593db54f8f302651ac58a69
|
||||
16
Assets/UI/ChampionDisplayInfo.cs
Normal file
16
Assets/UI/ChampionDisplayInfo.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class ChampionDisplayInfo : MonoBehaviour
|
||||
{
|
||||
public string DisplayName { get; }
|
||||
public int Cost { get; }
|
||||
|
||||
public ChampionDisplayInfo(string displayName, int cost)
|
||||
{
|
||||
DisplayName = displayName;
|
||||
Cost = cost;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/UI/ChampionDisplayInfo.cs.meta
Normal file
2
Assets/UI/ChampionDisplayInfo.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: acd8848a11b96a9458077637bacec1fd
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,135 +1,96 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Set.Data;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
public class EmblemSelector : MonoBehaviour
|
||||
namespace UI
|
||||
{
|
||||
[SerializeField] private int _defaultEmblemCount = 0;
|
||||
[SerializeField]
|
||||
private TMP_InputField _arcanaEmblems;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_InputField _chronoEmblems;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_InputField _dragonEmblems;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_InputField _druidEmblems;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_InputField _eldrichtEmblems;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_InputField _faerieEmblems;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_InputField _frostEmblems;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_InputField _honeymancyEmblems;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_InputField _portalEmblems;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_InputField _pyroEmblems;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_InputField _sugarcraftEmblems;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_InputField _witchcraftEmblems;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_InputField _bastionEmblems;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_InputField _blasterEmblems;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_InputField _hunterEmblems;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_InputField _incantatorEmblems;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_InputField _mageEmblems;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_InputField _multistrikerEmblems;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_InputField _preserverEmblems;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_InputField _scholarEmblems;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_InputField _shapeshifterEmblems;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_InputField _vanguardEmblems;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_InputField _warriorEmblems;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start() { }
|
||||
|
||||
public Dictionary<int, int> GetEmblems()
|
||||
public class EmblemSelector : MonoBehaviour
|
||||
{
|
||||
Dictionary<int, int> emblems = new Dictionary<int, int>();
|
||||
emblems[(int)TraitsEnum.ARCANA] = int.Parse(_arcanaEmblems.text);
|
||||
emblems[(int)TraitsEnum.CHRONO] = int.Parse(_chronoEmblems.text);
|
||||
emblems[(int)TraitsEnum.DRAGON] = int.Parse(_dragonEmblems.text);
|
||||
emblems[(int)TraitsEnum.DRUID] = int.Parse(_druidEmblems.text);
|
||||
emblems[(int)TraitsEnum.ELDRICHT] = int.Parse(_eldrichtEmblems.text);
|
||||
emblems[(int)TraitsEnum.FAERIE] = int.Parse(_faerieEmblems.text);
|
||||
emblems[(int)TraitsEnum.FROST] = int.Parse(_frostEmblems.text);
|
||||
emblems[(int)TraitsEnum.HONEYMANCY] = int.Parse(_honeymancyEmblems.text);
|
||||
emblems[(int)TraitsEnum.PORTAL] = int.Parse(_portalEmblems.text);
|
||||
emblems[(int)TraitsEnum.PYRO] = int.Parse(_pyroEmblems.text);
|
||||
emblems[(int)TraitsEnum.SUGARCRAFT] = int.Parse(_sugarcraftEmblems.text);
|
||||
emblems[(int)TraitsEnum.WITCHCRAFT] = int.Parse(_witchcraftEmblems.text);
|
||||
emblems[(int)TraitsEnum.BASTION] = int.Parse(_bastionEmblems.text);
|
||||
emblems[(int)TraitsEnum.BLASTER] = int.Parse(_blasterEmblems.text);
|
||||
emblems[(int)TraitsEnum.HUNTER] = int.Parse(_hunterEmblems.text);
|
||||
emblems[(int)TraitsEnum.INCANTATOR] = int.Parse(_incantatorEmblems.text);
|
||||
emblems[(int)TraitsEnum.MAGE] = int.Parse(_mageEmblems.text);
|
||||
emblems[(int)TraitsEnum.MULTISTRIKER] = int.Parse(_multistrikerEmblems.text);
|
||||
emblems[(int)TraitsEnum.PRESERVER] = int.Parse(_preserverEmblems.text);
|
||||
emblems[(int)TraitsEnum.SCHOLAR] = int.Parse(_scholarEmblems.text);
|
||||
emblems[(int)TraitsEnum.SHAPESHIFTER] = int.Parse(_shapeshifterEmblems.text);
|
||||
emblems[(int)TraitsEnum.VANGUARD] = int.Parse(_vanguardEmblems.text);
|
||||
emblems[(int)TraitsEnum.WARRIOR] = int.Parse(_warriorEmblems.text);
|
||||
return emblems;
|
||||
}
|
||||
public void Reset()
|
||||
{
|
||||
_arcanaEmblems.text = _defaultEmblemCount.ToString();
|
||||
_chronoEmblems.text = _defaultEmblemCount.ToString();
|
||||
_dragonEmblems.text = _defaultEmblemCount.ToString();
|
||||
_druidEmblems.text = _defaultEmblemCount.ToString();
|
||||
_eldrichtEmblems.text = _defaultEmblemCount.ToString();
|
||||
_faerieEmblems.text = _defaultEmblemCount.ToString();
|
||||
_frostEmblems.text = _defaultEmblemCount.ToString();
|
||||
_honeymancyEmblems.text = _defaultEmblemCount.ToString();
|
||||
_portalEmblems.text = _defaultEmblemCount.ToString();
|
||||
_pyroEmblems.text = _defaultEmblemCount.ToString();
|
||||
_sugarcraftEmblems.text = _defaultEmblemCount.ToString();
|
||||
_witchcraftEmblems.text = _defaultEmblemCount.ToString();
|
||||
_bastionEmblems.text = _defaultEmblemCount.ToString();
|
||||
_blasterEmblems.text = _defaultEmblemCount.ToString();
|
||||
_hunterEmblems.text = _defaultEmblemCount.ToString();
|
||||
_incantatorEmblems.text = _defaultEmblemCount.ToString();
|
||||
_mageEmblems.text = _defaultEmblemCount.ToString();
|
||||
_multistrikerEmblems.text = _defaultEmblemCount.ToString();
|
||||
_preserverEmblems.text = _defaultEmblemCount.ToString();
|
||||
_scholarEmblems.text = _defaultEmblemCount.ToString();
|
||||
_shapeshifterEmblems.text = _defaultEmblemCount.ToString();
|
||||
_vanguardEmblems.text = _defaultEmblemCount.ToString();
|
||||
_warriorEmblems.text = _defaultEmblemCount.ToString();
|
||||
[Header("Configuration")]
|
||||
[SerializeField]
|
||||
private int _defaultEmblemCount = 0;
|
||||
|
||||
[SerializeField]
|
||||
private TraitDisplayInfo _emblemUIPrefab;
|
||||
|
||||
[Header("Layout")]
|
||||
[SerializeField]
|
||||
private Transform _traitsParent;
|
||||
|
||||
private Dictionary<TraitsEnum, TraitDisplayInfo> _emblemUIs =
|
||||
new Dictionary<TraitsEnum, TraitDisplayInfo>();
|
||||
|
||||
// Trait definitions with display names
|
||||
private readonly Dictionary<TraitsEnum, string> _traitDisplayInfo = new Dictionary<
|
||||
TraitsEnum,
|
||||
string
|
||||
>
|
||||
{
|
||||
{ TraitsEnum.BATTLEACADEMIA, "Battle Academia" },
|
||||
{ TraitsEnum.CRYSTALGAMBIT, "Crystal Gambit" },
|
||||
{ TraitsEnum.LUCHADOR, "Luchador" },
|
||||
{ TraitsEnum.MIGHTYMECH, "Mighty Mech" },
|
||||
{ TraitsEnum.MONSTERTRAINER, "Monster Trainer" },
|
||||
{ TraitsEnum.SOULFIGHTER, "Soul Fighter" },
|
||||
{ TraitsEnum.STARGUARDIAN, "Star Guardian" },
|
||||
{ TraitsEnum.SUPREMECELLS, "Supreme Cells" },
|
||||
{ TraitsEnum.THECREW, "The Crew" },
|
||||
{ TraitsEnum.WRAITH, "Wraith" },
|
||||
{ TraitsEnum.MENTOR, "Mentor" },
|
||||
{ TraitsEnum.PRODIGY, "Prodigy" },
|
||||
{ TraitsEnum.THECHAMP, "The Champ" },
|
||||
{ TraitsEnum.STANCEMASTER, "Stance Master" },
|
||||
{ TraitsEnum.ROGUECAPTAIN, "Rogue Captain" },
|
||||
{ TraitsEnum.BASTION, "Bastion" },
|
||||
{ TraitsEnum.DUELIST, "Duelist" },
|
||||
{ TraitsEnum.EDGELORD, "Edgelord" },
|
||||
{ TraitsEnum.EXECUTIONER, "Executioner" },
|
||||
{ TraitsEnum.HEAVYWEIGHT, "Heavyweight" },
|
||||
{ TraitsEnum.JUGGERNAUT, "Juggernaut" },
|
||||
{ TraitsEnum.PROTECTOR, "Protector" },
|
||||
{ TraitsEnum.SNIPER, "Sniper" },
|
||||
{ TraitsEnum.SORCERER, "Sorcerer" },
|
||||
{ TraitsEnum.STRATEGIST, "Strategist" },
|
||||
};
|
||||
|
||||
void Start()
|
||||
{
|
||||
CreateEmblemUIs();
|
||||
}
|
||||
|
||||
private void CreateEmblemUIs()
|
||||
{
|
||||
foreach (var kvp in _traitDisplayInfo)
|
||||
{
|
||||
var trait = kvp.Key;
|
||||
var traitName = kvp.Value;
|
||||
|
||||
TraitDisplayInfo emblemUI = Instantiate<TraitDisplayInfo>(
|
||||
_emblemUIPrefab,
|
||||
_traitsParent
|
||||
);
|
||||
emblemUI.Initialize(trait, traitName, _defaultEmblemCount);
|
||||
_emblemUIs.Add(trait, emblemUI);
|
||||
}
|
||||
}
|
||||
|
||||
public Dictionary<int, int> GetEmblems()
|
||||
{
|
||||
Dictionary<int, int> emblems = new Dictionary<int, int>();
|
||||
|
||||
foreach (var kvp in _emblemUIs)
|
||||
{
|
||||
var trait = kvp.Key;
|
||||
var emblemUI = kvp.Value;
|
||||
|
||||
int emblemCount = emblemUI.GetEmblemCount();
|
||||
emblems[(int)trait] = emblemCount;
|
||||
|
||||
}
|
||||
return emblems;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
35
Assets/UI/TraitDisplayInfo.cs
Normal file
35
Assets/UI/TraitDisplayInfo.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using Set.Data;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UI
|
||||
{
|
||||
public class TraitDisplayInfo : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private TMP_Text _traitName;
|
||||
|
||||
[SerializeField]
|
||||
private TMP_Text _traitEmblemCount;
|
||||
|
||||
public string DisplayName { get; }
|
||||
|
||||
public TraitsEnum Trait { get; private set; }
|
||||
|
||||
public void Initialize(TraitsEnum trait, string traitName, int traitCount)
|
||||
{
|
||||
_traitName.text = traitName;
|
||||
_traitEmblemCount.text = traitCount.ToString();
|
||||
Trait = trait;
|
||||
}
|
||||
|
||||
public int GetEmblemCount()
|
||||
{
|
||||
int count;
|
||||
int.TryParse(_traitEmblemCount.text, out count);
|
||||
if(count != 0)
|
||||
Debug.Log($"Trait {Trait} has count {count}");
|
||||
return count;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/UI/TraitDisplayInfo.cs.meta
Normal file
2
Assets/UI/TraitDisplayInfo.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8dd0be74169a51b439320d3c9d6dcf22
|
||||
Reference in New Issue
Block a user