123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- using System.Collections.Generic;
- using UnityEngine;
- using DataTools;
- public class JobBoardBehaviour : MonoBehaviour
- {
- [Header("Data")]
- [SerializeField] private DataGigTemplates dataTemplates;
- [Header("Instant gig panel")]
- [SerializeField] private InstaGigs instaGigs;
- [Header("Job Cards")]
- [SerializeField] private List<JobCardManager> jobCards;
- [Header("Allowed gig types")]
- [SerializeField] private List<DataTools.GigType> allowedTypes;
-
- private void SetupJobBoard()
- {
- foreach(JobCardManager jobCard in jobCards)
- {
- setupJobCard(jobCard);
- }
- }
- private void setupJobCard(JobCardManager card)
- {
- bool done = false;
- while(!done)
- {
- DataTools.Gig gig = dataTemplates.atlas.GetRandomOfTypeOnLocation(location, allowedTypes[Random.Range(0, allowedTypes.Count)]);
- if(!names.Contains(gig.Description))
- {
- names.Add(gig.Description);
- card.AddGig(gig);
- done = true;
- }
- }
- }
- private void Start()
- {
- instaGigs = GameObject.FindObjectOfType<InstaGigs>();
- GameGlobal.Instance.OnLocationChanged += Reload;
- mainStoryGigs = new List<GigsBase>(FindObjectsOfType<GigsBase>());
- mainStoryGigs.RemoveAll(g => !g.IsMainStoryGig);
- }
- private void Reload(Location l)
- {
- needToReload = true;
- }
- private void OnEnable()
- {
- if(needToReload)
- {
- location = GameGlobal.Instance.Location;
- SetupJobBoard();
- needToReload = false;
- }
- }
- public void ClosePanel()
- {
- MenuOld.Instance.GoToMainPanel();
- }
- public void StartGig(DataTools.Gig gig, JobCardManager sender)
- {
- if (instaGigs != null)
- {
- instaGigs.GenerateGigs(gig);
- }
- BlockerManager.Instance.UnblockAllButtons(GameplayManager.instance.isFirstGigPassed);
- GameGlobal.Instance.PannigLocked = false;
- MenuOld.Instance.GoToMainPanel();
- //************************
- setupJobCard(sender);
- }
- private void Update()
- {
- foreach(JobCardManager jobcard in jobCards)
- {
- jobcard.UpdateButton(!mainStoryGigs.Exists(g => g.HasGigsRemaining) && !instaGigs.HasGigsRemaining);
- }
- }
- private string location = "";
- private bool needToReload = true;
- private List<GigsBase> mainStoryGigs;
- private List<string> names = new List<string>();
- }
|