| 123456789101112131415161718192021222324252627282930313233 |
- using UnityEngine;
- using UnityEngine.UI;
- public class CharacterEntryUI : MonoBehaviour
- {
- public Dropdown weaponDropdown;
- public Button removeButton;
- private bool isPlayer;
- private System.Action<GameObject, bool> onRemove;
- private System.Action onChanged;
- public void Setup(bool isPlayer, System.Action<GameObject, bool> onRemove, System.Action onChanged)
- {
- this.isPlayer = isPlayer;
- this.onRemove = onRemove;
- this.onChanged = onChanged;
- removeButton.onClick.AddListener(() => onRemove(gameObject, isPlayer));
- weaponDropdown.ClearOptions();
- weaponDropdown.AddOptions(new System.Collections.Generic.List<string> { "Sword", "Bow" }); // TODO needs to be collected amongst available weapons
- weaponDropdown.onValueChanged.AddListener(_ => onChanged());
- }
- public CharacterSelection GetSelection()
- {
- return new CharacterSelection
- {
- characterName = isPlayer ? "Player" : "Enemy",
- weaponType = weaponDropdown.options[weaponDropdown.value].text
- };
- }
- }
|