71 lines
2.4 KiB
C#
71 lines
2.4 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Assets.Data;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
public class TraitSelectorManager : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private TMP_InputField _compositionSize;
|
|
|
|
[SerializeField]
|
|
private ChampionSelector _mandatorychampionSelector;
|
|
|
|
[SerializeField]
|
|
private ChampionSelector _acceptablechampionSelector;
|
|
|
|
[SerializeField]
|
|
private EmblemSelector _emblemSelector;
|
|
|
|
[SerializeField]
|
|
private int _traitThreshold = 7;
|
|
|
|
|
|
public void ListAllActivableCompo()
|
|
{
|
|
var emblemList = _emblemSelector.GetEmblems();
|
|
var mandatoryChampions = ChampionUtils.ToLong(_mandatorychampionSelector.GetSelectedChampions());
|
|
var acceptableChampions = ChampionUtils.ToLong(_acceptablechampionSelector.GetSelectedChampions());
|
|
int compositionSize = _compositionSize.text == "" ? 1 : int.Parse(_compositionSize.text);
|
|
|
|
Coroutine coroutine = StartCoroutine(ComputeCompositionAsync(mandatoryChampions, acceptableChampions, compositionSize, emblemList));
|
|
}
|
|
|
|
public IEnumerator<float> ComputeCompositionAsync(long mandatoryChampions, long acceptableChampions, int compositionSize, Dictionary<int, int> emblemList)
|
|
{
|
|
var compositions = TraitsMapping.GenerateCombinations(mandatoryChampions, acceptableChampions, compositionSize);
|
|
Debug.Log($"{compositions.Count} Compositions generated.");
|
|
yield return 0f;
|
|
|
|
foreach (var composition in compositions)
|
|
{
|
|
HandleCombination(composition, emblemList);
|
|
yield return 0f;
|
|
}
|
|
|
|
}
|
|
|
|
private void HandleCombination(long combination, Dictionary<int, int> emblemList)
|
|
{
|
|
var synergies = TraitsMapping.TraitCountInCompo(combination);
|
|
|
|
var synergiesWithEmblem = TraitsMapping.MergeEmblems(
|
|
synergies,
|
|
emblemList
|
|
);
|
|
var activeSynergies = TraitsMapping.FilterActiveTraits(synergiesWithEmblem);
|
|
|
|
if (TraitUtils.TraitCountFromInt(activeSynergies) >= _traitThreshold)
|
|
{
|
|
HashSet<ChampionsEnum> champions = ChampionUtils.FromLong(combination);
|
|
var s = TraitsMapping.CompositionToString(champions);
|
|
Debug.Log(s);
|
|
}
|
|
// else
|
|
// {
|
|
// //Debug.LogWarning("Combination not valid");
|
|
// }
|
|
}
|
|
}
|