ConfirmPlayAreaState.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using UnityEngine;
  7. public class ConfirmPlayAreaState : AbstractPlayAreaState<SafetyAreaMono>
  8. {
  9. public override void OnStateEnter(object data)
  10. {
  11. SafetyAreaManager safetyAreaManager = SafetyAreaManager.Instance;
  12. reference.confirmPlayAreaUI.gameObject.SetActive(true);
  13. //reference.safetyGreyCameraUI.gameObject.SetActive(true);
  14. reference.confirmPlayAreaUI.Init();
  15. reference.confirmPlayAreaUI.OnConfirmClick += ExitSafetyAreaProcess;
  16. reference.confirmPlayAreaUI.OnBackClick += OnConfirmPlayAreaCancel;
  17. reference.safetyPlaneMono.GenerateEdgeMesh((mesh, perimeter) =>
  18. {
  19. safetyAreaManager.CreatePlayArea(mesh, reference.safetyPlaneMono.GetColorArray(), perimeter, reference.safetyPlaneMono.transform.position);
  20. });
  21. reference.safetyPlaneMono.gameObject.SetActive(false);
  22. safetyAreaManager.playAreaMono.SetMaterial(reference.areaConfirmMat);
  23. }
  24. public override void OnStateExit(object data)
  25. {
  26. reference.confirmPlayAreaUI.OnConfirmClick -= ExitSafetyAreaProcess;
  27. reference.confirmPlayAreaUI.OnBackClick -= OnConfirmPlayAreaCancel;
  28. reference.confirmPlayAreaUI.Release();
  29. reference.confirmPlayAreaUI.gameObject.SetActive(false);
  30. //reference.safetyGreyCameraUI.gameObject.SetActive(false);
  31. if (reference.safetyPlaneMono != null)
  32. {
  33. reference.safetyPlaneMono.gameObject.SetActive(true);
  34. }
  35. }
  36. public override void OnStateBreathe()
  37. {
  38. }
  39. private void OnConfirmPlayAreaCancel()
  40. {
  41. SafetyAreaManager.Instance.DestroyPlayArea();
  42. SafetyAreaManager.Instance.ChangeStep(SafetyAreaStepEnum.PlayArea);
  43. }
  44. private void ExitSafetyAreaProcess()
  45. {
  46. SafetyAreaManager.Instance.playAreaMono.SetMaterial(reference.areaNormalMat);
  47. reference.DestroySafetyPlane();
  48. SafetyAreaManager.Instance.ExitSafeAreaStep();
  49. }
  50. }