PlayAreaOKState.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.EventSystems;
  5. public class PlayAreaOKState : AbstractPlayAreaState<SafetyAreaMono>
  6. {
  7. private PlayAreaStep playAreaStep;
  8. public override void OnStateEnter(object data)
  9. {
  10. if (playAreaStep == null)
  11. {
  12. playAreaStep = SafetyAreaManager.Instance.GetStep<PlayAreaStep>(SafetyAreaStepEnum.PlayArea);
  13. }
  14. reference.safetyPlaneMono.RegistPointerDownFillEvent();
  15. reference.safetyPlaneMono.RegistPointerUpFillEvent();
  16. ShowPlayAreaOKUI();
  17. reference.playAreaOKUI.OnRedrawAreaClick += ChangePrepareDrawPlayAreaState;
  18. reference.playAreaOKUI.OnBackClick += ChangePrepareDrawPlayAreaState;
  19. reference.playAreaOKUI.OnContinueClick += SwitchToConfirmPlayAreaStep;
  20. //FillIndices(null);
  21. reference.safetyPlaneMono.RegistPointerUpEvent(FillIndices);
  22. }
  23. public override void OnStateExit(object data)
  24. {
  25. reference.safetyPlaneMono.UnRegistPointerUpEvent(FillIndices);
  26. reference.playAreaOKUI.OnRedrawAreaClick -= ChangePrepareDrawPlayAreaState;
  27. reference.playAreaOKUI.OnBackClick -= ChangePrepareDrawPlayAreaState;
  28. reference.playAreaOKUI.OnContinueClick -= SwitchToConfirmPlayAreaStep;
  29. HidePlayAreaOKUI();
  30. //HidePlane();
  31. if (reference.safetyPlaneMono != null)
  32. {
  33. reference.safetyPlaneMono.UnRegistPointerDownFillEvent();
  34. reference.safetyPlaneMono.UnRegistPointerUpFillEvent();
  35. }
  36. }
  37. public override void OnStateBreathe()
  38. {
  39. }
  40. private void FillIndices(PointerEventData pointerEventData)
  41. {
  42. reference.safetyPlaneMono.FillIndices();
  43. }
  44. private void ChangePrepareDrawPlayAreaState()
  45. {
  46. reference.safetyPlaneMono.ClearAllMeshColor();
  47. playAreaStep.ChangePlayAreaState(PlayAreaStateEnum.WaitingDraw);
  48. }
  49. private void SwitchToConfirmPlayAreaStep()
  50. {
  51. playAreaStep.ChangePlayAreaState(PlayAreaStateEnum.ConfirmPlayArea);
  52. }
  53. private void ShowPlayAreaOKUI()
  54. {
  55. reference.playAreaOKUI.gameObject.SetActive(true);
  56. reference.playAreaOKUI.Init();
  57. }
  58. private void HidePlayAreaOKUI()
  59. {
  60. reference.playAreaOKUI.Release();
  61. reference.playAreaOKUI.gameObject.SetActive(false);
  62. }
  63. }