NoMapExistSafetyAreaSpecialState.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class NoMapExistSafetyAreaSpecialState : AbstractExistSafetyAreaSpecialState<SafetyAreaBase>
  5. {
  6. private const float OFFLINE_MAP_CALL_TIME_SPAN = 0.5f;
  7. private float timer = 0f;
  8. public override void OnStateBreathe()
  9. {
  10. //Debug.LogError("NoMapExistSafetyAreaSpecialState");
  11. reference.meshRenderer.enabled = false;
  12. if (SafetyAreaManager.Instance.isSettingSafetyArea || SafetyAreaManager.Instance.isDisableSafetyArea)
  13. {
  14. reference.outOfSafetyArea.SetActive(false);
  15. reference.nomapUI.SetActive(false);
  16. reference.slamLostUI.gameObject.SetActive(false);
  17. return;
  18. }
  19. reference.nomapUI.SetActive(true);
  20. timer += Time.deltaTime;
  21. if (timer >= OFFLINE_MAP_CALL_TIME_SPAN)
  22. {
  23. timer = 0f;
  24. int currentRelocState = API_GSXR_Slam.GSXR_Get_OfflineMapRelocState();
  25. if (currentRelocState != 0)
  26. {
  27. reference.ChangeState(ExistSafetyAreaEnum.Normal);
  28. return;
  29. }
  30. }
  31. }
  32. public override void OnStateEnter(object data)
  33. {
  34. SafetyAreaManager.Instance.ExitSafetyAreaInvoke();//OnEnterSafetyArea?.Invoke();
  35. SafetyAreaManager.Instance.OnDisableSafetyArea += OnDisableChange;
  36. if (!SafetyAreaManager.Instance.isDisableSafetyArea)
  37. {
  38. API_GSXR_Slam.GSXR_StartSeeThrough();
  39. }
  40. API_GSXR_Slam.GSXR_Add_SlamPauseCallback(OnSlamPause);
  41. }
  42. public override void OnStateExit(object data)
  43. {
  44. API_GSXR_Slam.GSXR_Remove_SlamPauseCallback(OnSlamPause);
  45. API_GSXR_Slam.GSXR_StopSeeThrough();
  46. reference.nomapUI.SetActive(false);
  47. SafetyAreaManager.Instance.OnDisableSafetyArea -= OnDisableChange;
  48. //SafetyAreaManager.Instance.EnterSafetyAreaInvoke();//OnExitSafetyArea?.Invoke();
  49. }
  50. private void OnSlamPause(bool isPause)
  51. {
  52. if (!isPause && !SafetyAreaManager.Instance.isDisableSafetyArea)
  53. {
  54. API_GSXR_Slam.GSXR_StartSeeThrough();
  55. }
  56. }
  57. private void OnDisableChange(bool isDisable)
  58. {
  59. if (!isDisable)
  60. {
  61. API_GSXR_Slam.GSXR_StartSeeThrough();
  62. }
  63. else
  64. {
  65. API_GSXR_Slam.GSXR_StopSeeThrough();
  66. }
  67. }
  68. }