PanelEnvironmentBehaviour.cs 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using System.Linq;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. using UnityEngine.Events;
  7. using WebTools.Environments;
  8. namespace WebTools.Environments.Behaviours
  9. {
  10. public class PanelEnvironmentBehaviour : MonoBehaviour
  11. {
  12. [Header("UI")]
  13. [SerializeField]
  14. private Text textCurrentLocation;
  15. [SerializeField]
  16. private Text textPanelPopUp;
  17. [SerializeField]
  18. private string textPopUpTravelto;
  19. [SerializeField]
  20. private GameObject panelPopUpEnvironment;
  21. [SerializeField]
  22. private GameObject panelMap;
  23. [Header("EVENTS")]
  24. [SerializeField]
  25. private UnityEvent OnTravelCompletes;
  26. [SerializeField]
  27. private UnityEvent OnClickMarkers;
  28. private void OnEnable()
  29. {
  30. EnableOrDisableMap(true);
  31. // EnableEvents();
  32. }
  33. private void OnDisable()
  34. {
  35. EnableOrDisableMap(false);
  36. // DisableEvents();
  37. }
  38. /* private void EnableEvents()
  39. {
  40. EnviromentTravelManagerBehaviour.OnMarkerTravelSuccess += OnTravelComplete;
  41. EnviromentTravelManagerBehaviour.OnCanTravelToSuccess += OnCanTravelTo;
  42. }
  43. private void DisableEvents()
  44. {
  45. EnviromentTravelManagerBehaviour.OnMarkerTravelSuccess -= OnTravelComplete;
  46. EnviromentTravelManagerBehaviour.OnCanTravelToSuccess -= OnCanTravelTo;
  47. }*/
  48. private void EnableOrDisableMap(bool active)
  49. {
  50. if (panelMap)
  51. {
  52. panelMap.SetActive(active);
  53. }
  54. }
  55. private void SetCurrentLocation(string id)
  56. {
  57. textCurrentLocation.text = id;
  58. }
  59. private void SetTravelToLocation(string id)
  60. {
  61. panelPopUpEnvironment.SetActive(true);
  62. textPanelPopUp.text = textPopUpTravelto + " " + id + "?";
  63. }
  64. /* private void OnCanTravelTo(OnlineMapsMarkerBase marker)
  65. {
  66. SetTravelToLocation(marker.id);
  67. OnClickMarkers.Invoke();
  68. }
  69. private void OnTravelComplete(OnlineMapsMarkerBase marker)
  70. {
  71. SetCurrentLocation(marker.id);
  72. OnTravelCompletes.Invoke();
  73. }*/
  74. }
  75. }