RiftMayhem/Assets/Scripts/UI/WorldJobsListingUI/WorldJobsListingUIController.cs
Pedro Gomes d12942bff4 World Jobs Listing Board interactable
Whole interactable world-board with different zones and jobs ready to be completed.

- party voting for job selection & scene swapping
- fully working scene change between inn and skellyard
- updated many systems with lots of new information
- bunch of new UIs to acomodate new job and scene swapping voting systems
2024-05-13 01:15:58 +01:00

57 lines
1.8 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class WorldJobsListingUIController : MonoBehaviour
{
[Header("Components:")]
[SerializeField] private GameObject jobsListingUI;
[SerializeField] private Button closeButton;
[Header("Events:")]
[SerializeField] private GameEvent onJobsListingUIClosed;
[Header("Listeners:")]
[SerializeField] private GameEventListener onJobsBoardInteracted;
[SerializeField] private GameEventListener onJobsBoardReleased;
[SerializeField] private GameEventListener_ZoneData onGameSceneLoaded;
private List<JobListingButton> zoneButtons = new List<JobListingButton>();
private void Awake()
{
onJobsBoardInteracted.Response.AddListener(() => ToggleUIPanel(true));
onJobsBoardReleased.Response.AddListener(() => ToggleUIPanel(false));
onGameSceneLoaded.Response.AddListener(DisableZoneButton);
foreach (JobListingButton button in jobsListingUI.GetComponentsInChildren<JobListingButton>(true))
{
zoneButtons.Add(button);
}
closeButton.onClick.AddListener(() => ToggleUIPanel(false));
}
private void ToggleUIPanel(bool visible)
{
jobsListingUI.SetActive(visible);
if(!visible)
onJobsListingUIClosed.Raise();
}
private void DisableZoneButton(ZoneData zoneData)
{
ZoneData buttonData;
for (int i = 0; i < zoneButtons.Count; i++)
{
buttonData = zoneButtons[i].GetZoneData();
if (buttonData == null) continue;
if (buttonData.levelName == zoneData.levelName)
zoneButtons[i].ToggleInteractable(false);
else
zoneButtons[i].ToggleInteractable(true);
}
}
}