JobCardManager.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class JobCardManager : MonoBehaviour
  6. {
  7. [Serializable]
  8. public struct IconTypeSet
  9. {
  10. public DataTools.GigType type;
  11. public Sprite icon;
  12. }
  13. [Header("Gig attributes")]
  14. [SerializeField] private Text typeText;
  15. [SerializeField] private Text descriptionText;
  16. [SerializeField] private Image typeIcon;
  17. [Header("Requirements and reward")]
  18. [SerializeField] private Text hoursText;
  19. [SerializeField] private Text starsText;
  20. [SerializeField] private Text coinsText;
  21. [SerializeField] private Text experienceText;
  22. [Header("Icons Set")]
  23. [SerializeField] private List<IconTypeSet> icons;
  24. [Header("Job board")]
  25. [SerializeField] private JobBoardBehaviour parentJobBoard;
  26. private DataTools.Gig attachedGig;
  27. [Header("Accept Button")]
  28. [SerializeField] private Button acceptButton;
  29. public void OnButtonAcceptClick()
  30. {
  31. parentJobBoard.StartGig(attachedGig, this);
  32. }
  33. public void AddGig(DataTools.Gig gig)
  34. {
  35. attachedGig = gig;
  36. typeText.text = GigTypeRename(gig.Type);
  37. descriptionText.text = gig.Description;
  38. typeIcon.sprite = icons.Find(i => i.type == gig.Type).icon;
  39. hoursText.text = (gig.Duration / 60).ToString();
  40. starsText.text = gig.StarsNeeded.ToString();
  41. coinsText.text = gig.Currency.Dollars.ToString();
  42. experienceText.text = gig.Currency.Experience.ToString();
  43. }
  44. public string GigTypeRename(DataTools.GigType type)
  45. {
  46. switch(type)
  47. {
  48. case DataTools.GigType.FashionShow:
  49. return "Runway";
  50. case DataTools.GigType.Commerical:
  51. return "Film / TV Show";
  52. default:
  53. return type.ToString();
  54. }
  55. }
  56. public void UpdateButton(bool flag)
  57. {
  58. acceptButton.interactable = flag;
  59. }
  60. }