61 lines
1.3 KiB
C#
61 lines
1.3 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class TournamentFisheryDropdown : MonoBehaviour
|
|
{
|
|
private Dropdown dropdown;
|
|
|
|
[HideInInspector]
|
|
public LevelsManager levelsManager;
|
|
|
|
public List<int> fisheryIds = new List<int>();
|
|
|
|
private void Start()
|
|
{
|
|
InitList();
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
InitList();
|
|
}
|
|
|
|
private void InitList()
|
|
{
|
|
if (!GlobalSettings.Instance || !GlobalSettings.Instance.levelsManager || !GlobalSettings.Instance.saveManager.isProfileLoaded)
|
|
{
|
|
return;
|
|
}
|
|
if (!levelsManager)
|
|
{
|
|
levelsManager = GlobalSettings.Instance.levelsManager;
|
|
}
|
|
dropdown = base.gameObject.GetComponent<Dropdown>();
|
|
dropdown.options.Clear();
|
|
dropdown.options.Capacity = 0;
|
|
fisheryIds.Clear();
|
|
for (int i = 0; i < levelsManager.fisheryDefinitions.Count; i++)
|
|
{
|
|
if (levelsManager.IsLevelAvailable(i))
|
|
{
|
|
dropdown.options.Add(new Dropdown.OptionData(Utilities.GetTranslation(levelsManager.fisheryDefinitions[i].name)));
|
|
fisheryIds.Add(i);
|
|
}
|
|
}
|
|
dropdown.value = 0;
|
|
dropdown.RefreshShownValue();
|
|
GlobalSettings.Instance.levelsManager.currentFishery = fisheryIds[dropdown.value];
|
|
}
|
|
|
|
public void UpdateValue()
|
|
{
|
|
GlobalSettings.Instance.levelsManager.currentFishery = fisheryIds[dropdown.value];
|
|
}
|
|
|
|
public void LanguageChanged()
|
|
{
|
|
InitList();
|
|
}
|
|
}
|