- Turned multi job reward button click into a whole new content - Rift raids open up on multijob completion, allowing players to dive deep and take action into the rifts themselves
158 lines
5.4 KiB
C#
158 lines
5.4 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 GameObject jobsCountUIParent;
|
|
[SerializeField] private Button multiJobBonusClaimButton;
|
|
[SerializeField] private Button closeButton;
|
|
[Header("Events:")]
|
|
[SerializeField] private GameEvent onJobsListingUIClosed;
|
|
[SerializeField] private GameEvent onMultiJobBonusRetrievedEvent;
|
|
[SerializeField] private GameEvent_JobInstance OnMultiJobBonusRiftReadyToSpawn;
|
|
|
|
[Header("Listeners:")]
|
|
[SerializeField] private GameEventListener onJobsBoardInteracted;
|
|
[SerializeField] private GameEventListener onJobsBoardReleased;
|
|
[SerializeField] private GameEventListener_ZoneData onGameSceneLoaded;
|
|
[SerializeField] private GameEventListener onDifficultyChanged;
|
|
[SerializeField] private GameEventListener onAvailableJobsUpdated;
|
|
[SerializeField] private GameEventListener_JobInstance onJobCompleted;
|
|
[SerializeField] private GameEventListener onMultiJobBonusRetrieved;
|
|
[SerializeField] private GameEventListener_Int onHiddenMapDiscovered;
|
|
|
|
private List<JobListingButton> zoneButtons = new List<JobListingButton>();
|
|
private List<JobCountMark> jobsCount = new List<JobCountMark>();
|
|
|
|
JobRewardSettings jobRewardSettings;
|
|
|
|
private int jobsCompletedCount = 0;
|
|
|
|
HiddenMapButton hiddenMapButton;
|
|
|
|
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));
|
|
|
|
onJobCompleted.Response.AddListener(UpdateOnJobComplete);
|
|
|
|
onMultiJobBonusRetrieved.Response.AddListener(UpdateOnBonusRetrieved);
|
|
|
|
jobsCompletedCount = 0;
|
|
multiJobBonusClaimButton.interactable = false;
|
|
//multiJobBonusClaimButton.onClick.AddListener(() => onMultiJobBonusRetrievedEvent.Raise());
|
|
|
|
onHiddenMapDiscovered.Response.AddListener(UpdateHiddenMapButtons);
|
|
}
|
|
|
|
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);
|
|
}
|
|
|
|
UpdateHiddenMapButtons(0);
|
|
}
|
|
|
|
private void SetupButtons()
|
|
{
|
|
foreach (JobListingButton button in jobsListingUI.GetComponentsInChildren<JobListingButton>(true))
|
|
{
|
|
zoneButtons.Add(button);
|
|
}
|
|
|
|
foreach (JobCountMark jobCount in jobsCountUIParent.GetComponentsInChildren<JobCountMark>(true))
|
|
{
|
|
jobsCount.Add(jobCount);
|
|
jobCount.SetCheckMarkState(false);
|
|
}
|
|
}
|
|
|
|
private void UpdateHiddenMapButtons(int mapZone)
|
|
{
|
|
for (int i = 0; i < zoneButtons.Count; i++)
|
|
{
|
|
hiddenMapButton = zoneButtons[i].GetComponent<HiddenMapButton>();
|
|
|
|
if (hiddenMapButton == null) continue;
|
|
|
|
Debug.Log($"{hiddenMapButton.hiddenMapZone} unlocked? {PlayerDataHandler.Instance.HiddenMapUsed(PlayerDataHandler.Instance.currentPlayerName.Value, hiddenMapButton.hiddenMapZone)}");
|
|
hiddenMapButton.gameObject.SetActive(PlayerDataHandler.Instance.HiddenMapUsed(PlayerDataHandler.Instance.currentPlayerName.Value, hiddenMapButton.hiddenMapZone));
|
|
}
|
|
}
|
|
|
|
private void UpdateOnJobComplete(JobInstance jobCompleted)
|
|
{
|
|
jobsCompletedCount++;
|
|
if (jobsCompletedCount >= 3 && !jobCompleted.isBonusRiftJob)
|
|
{
|
|
//multiJobBonusClaimButton.interactable = true;
|
|
|
|
OnMultiJobBonusRiftReadyToSpawn.Raise(JobManager.Instance.GenerateBonusRiftInstance());
|
|
|
|
jobsCompletedCount = 0;
|
|
|
|
for (int i = 0; i < jobsCount.Count; i++)
|
|
{
|
|
jobsCount[i].SetCheckMarkState(true);
|
|
}
|
|
return;
|
|
}
|
|
for (int i = 0; i < jobsCompletedCount; i++)
|
|
{
|
|
jobsCount[i].SetCheckMarkState(true);
|
|
}
|
|
for (int i = jobsCompletedCount; i < jobsCount.Count; i++)
|
|
{
|
|
jobsCount[i].SetCheckMarkState(false);
|
|
}
|
|
multiJobBonusClaimButton.interactable = false;
|
|
}
|
|
|
|
private void UpdateOnBonusRetrieved()
|
|
{
|
|
for (int i = 0; i < jobsCount.Count; i++)
|
|
{
|
|
jobsCount[i].SetCheckMarkState(false);
|
|
}
|
|
jobsCompletedCount = 0;
|
|
}
|
|
|
|
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));
|
|
}
|
|
}
|
|
}
|