- Boss after rift clearance - job completed event - job rewards awarded on completion
78 lines
2.5 KiB
C#
78 lines
2.5 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;
|
|
[SerializeField] private GameEventListener onDifficultyChanged;
|
|
[SerializeField] private GameEventListener onAvailableJobsUpdated;
|
|
|
|
private List<JobListingButton> zoneButtons = new List<JobListingButton>();
|
|
|
|
JobRewardSettings jobRewardSettings;
|
|
|
|
private void Awake()
|
|
{
|
|
onJobsBoardInteracted.Response.AddListener(() => ToggleUIPanel(true));
|
|
onJobsBoardReleased.Response.AddListener(() => ToggleUIPanel(false));
|
|
onGameSceneLoaded.Response.AddListener(DisableZoneButton);
|
|
//onDifficultyChanged.Response.AddListener(UpdateJobsOnButtons);
|
|
onAvailableJobsUpdated.Response.AddListener(UpdateJobsOnButtons);
|
|
|
|
SetupButtons();
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
private void SetupButtons()
|
|
{
|
|
foreach (JobListingButton button in jobsListingUI.GetComponentsInChildren<JobListingButton>(true))
|
|
{
|
|
zoneButtons.Add(button);
|
|
}
|
|
}
|
|
|
|
private void UpdateJobsOnButtons()
|
|
{
|
|
foreach (JobListingButton button in zoneButtons)
|
|
{
|
|
if (button.GetZoneData() == null) continue;
|
|
|
|
button.UpdateJobData(JobManager.Instance.availableJobs.Find(job => job.zoneName == button.GetZoneData().zoneName));
|
|
}
|
|
}
|
|
}
|